Skip to content

Commit

Permalink
We can't have nice things and bs3
Browse files Browse the repository at this point in the history
The `$(this).tab('show');` in `assets/frontpage/initFrontpage.js` was
broken, since `.tab` was not defined. `.tab` is a bootstrap3-extension
to jQuery https://getbootstrap.com/docs/3.4/javascript/#tabs. To make
that extension method available you need to rely on the side-effects
of `import 'bootstrap'`, which only applies it to the _global_ $/jQuery.

When you `import $ from 'jquery'`, that creates a local and specifically
non-global `$`. Generally speaking you would then immediately set your
`$` to be the global `$` by using `globalThis.jQuery = globalThis.$ =
$`. We import and thus define the global `$` from a `<script>`-element
in the base HTML template, and thus this causes a "conflict" between the
esm/esbuild `$` and the already imported one.

In particular `import 'bootstrap'` only applies the extensions to the
global one. Ideally we would just get rid of this use of global
variables (and jQuery as a whole). For now just give up on attempting to
use jQuery from npm, and go back to jQuery 2.X from the Django template.

The strange thing here is probably rather that there were imports in the
webpack setup, since it was actually threated as a global variable, thus
the imports previously did "nothing".
  • Loading branch information
henrikhorluck committed Oct 17, 2023
1 parent e427735 commit 812c7bb
Show file tree
Hide file tree
Showing 36 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion assets/article/archive/Article-archive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
/// import $ from 'jquery';
import ArticleArchiveWidget from './ArticleArchiveWidget';

let isLoadingNewContent = false; // Indicating if we are currently loading something
Expand Down
2 changes: 1 addition & 1 deletion assets/article/archive/ArticleArchiveWidget.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment';
import $ from 'jquery';
// import $ from 'jquery';
import { makeApiRequest } from 'common/utils';

function ArticleArchiveWidget() {
Expand Down
2 changes: 1 addition & 1 deletion assets/article/archive/TagCloud.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

$('div.tagcloud span').each(function tagCloud() {
const max = $('div.tagcloud').data('max_frequency');
Expand Down
2 changes: 1 addition & 1 deletion assets/article/details/articleRelated.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

const addRelatedArticles = (data) => {
let output = '';
Expand Down
2 changes: 1 addition & 1 deletion assets/authentication/login.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

export default () => {
// Setting focus on either username or password if errortext is presented
Expand Down
2 changes: 1 addition & 1 deletion assets/common/utils/alert.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

// Fadeout alerts if they have the data-dismiss property
export const timeOutAlerts = () => {
Expand Down
2 changes: 1 addition & 1 deletion assets/common/utils/dom.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import { template } from 'underscore';
import { cityFromZipCode } from './request';

Expand Down
2 changes: 1 addition & 1 deletion assets/common/utils/request.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import Cookies from 'js-cookie';

/**
Expand Down
2 changes: 1 addition & 1 deletion assets/core/init.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

const addAnimation = () => {
const svg = document.querySelectorAll('.mn-svg');
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/approval/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import { showStatusMessage } from 'common/utils';
import './less/approval.less';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/article/article.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment';
import jQuery from 'jquery';
// import jQuery from 'jquery';
import { ajax, showStatusMessage } from 'common/utils';
/**
* Created by myth on 10/18/15.
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/chunks/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import showdown from 'showdown';
import $ from 'jquery';
// import $ from 'jquery';

let sourceText = '';
let previousSourceText;
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/core/Gallery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import MicroEvent from 'common/utils/MicroEvent';
import { ajaxEnableCSRF, format, render } from 'common/utils';
import moment from 'moment';
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/core/GalleryCrop.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import Cropper from 'cropperjs';
import 'cropperjs/dist/cropper.css';
import { format, render } from 'common/utils';
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/core/GalleryUpload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import Dropzone from 'dropzone';
import 'dropzone/dist/dropzone.css';
import './less/dropzone.less';
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/core/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import 'common/datetimepicker';
import 'common/tablesorter';
import { ajaxEnableCSRF } from 'common/utils';
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/events/events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import { plainUserTypeahead } from 'common/typeahead';
import { ajax, showStatusMessage, toggleChecked } from 'common/utils';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/gallery/galleryDashboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import moment from 'moment';
import { ajax, showStatusMessage } from 'common/utils';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/groups/group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import { plainUserTypeahead } from 'common/typeahead';
import { ajax, showStatusMessage } from 'common/utils';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/inventory/Inventory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import { ajax, showStatusMessage, toggleChecked } from 'common/utils';
import './index.less';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/inventory/InventoryStats.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

const google = window.google;

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/marks/marks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';
import { plainUserTypeahead } from 'common/typeahead';
import { ajax, showStatusMessage } from 'common/utils';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/photoalbum/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Urls from 'common/utils/django_reverse';
import $ from 'jquery';
// import $ from 'jquery';
import { plainUserTypeahead } from 'common/typeahead';
import Cookies from 'js-cookie';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/posters/assignToJob.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import { setStatusMessage } from 'common/utils/';

const assignToJob = (orderId, row) => {
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/posters/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import assignToJob from './assignToJob';
import './less/posters.less';

Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/webshop/Webshop.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

const postDeleteForm = (url) => {
$(`<form method="POST" action="${url}">` +
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/webshop/WebshopGallery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jQuery from 'jquery';
// import jQuery from 'jquery';

const WebshopGallery = (function PrivateWebshopGallery($) {
const images = [];
Expand Down
2 changes: 1 addition & 1 deletion assets/dashboard/webshop/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import Webshop from './Webshop';
import WebshopGallery from './WebshopGallery';

Expand Down
2 changes: 1 addition & 1 deletion assets/events/archive/filters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Urls from 'common/utils/django_reverse';
import $ from 'jquery';
// import $ from 'jquery';

class Filters {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion assets/events/details/events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import Cookies from 'js-cookie';
import { makeApiRequest, showFlashMessage } from 'common/utils/';

Expand Down
2 changes: 1 addition & 1 deletion assets/feedback/answerRating.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import 'jquery-bar-rating';

export default () => {
Expand Down
2 changes: 1 addition & 1 deletion assets/feedback/feedbackResults.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import 'common/jqplot';
import { ajaxEnableCSRF, debouncedResize, setStatusMessage } from 'common/utils/';

Expand Down
2 changes: 1 addition & 1 deletion assets/frontpage/initFrontpage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// // import $ from 'jquery';

const TOP_OFFSET_ADJUST = 65;

Expand Down
2 changes: 1 addition & 1 deletion assets/profiles/dependent_fields.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';

export default () => {
$('#social-membership-application').hide();
Expand Down
2 changes: 1 addition & 1 deletion assets/profiles/profiles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import { ajaxEnableCSRF, setStatusMessage } from 'common/utils/';

ajaxEnableCSRF($);
Expand Down
2 changes: 1 addition & 1 deletion assets/profiles/userSearch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import $ from 'jquery';
// import $ from 'jquery';
import { userTypeahead } from 'common/typeahead';
import Spinner from 'spin.js';
import './less/typeahead.less';
Expand Down

0 comments on commit 812c7bb

Please sign in to comment.