feat(main): Add base theme: This is the falcon theme out of the box.
This is falcon v3.1.2
This commit is contained in:
41
_dev/js/theme/utils/DynamicImportJqueryPlugin.js
Normal file
41
_dev/js/theme/utils/DynamicImportJqueryPlugin.js
Normal file
@ -0,0 +1,41 @@
|
||||
import $ from 'jquery';
|
||||
|
||||
class DynamicImportJqueryPlugin {
|
||||
constructor({
|
||||
jqueryPluginCover,
|
||||
importer,
|
||||
} = {}) {
|
||||
this.jqueryPluginCover = jqueryPluginCover;
|
||||
this.importer = importer;
|
||||
this.jqueryFuncCalled = [];
|
||||
|
||||
this.setJqueryPlugin();
|
||||
}
|
||||
|
||||
callJqueryAction() {
|
||||
for (const fncCall of this.jqueryFuncCalled) {
|
||||
fncCall.elem[this.jqueryPluginCover](fncCall.args);
|
||||
}
|
||||
}
|
||||
|
||||
fetchFiles() {
|
||||
this.importer.loadFiles(() => this.callJqueryAction());
|
||||
}
|
||||
|
||||
setJqueryPlugin() {
|
||||
const self = this;
|
||||
|
||||
/* eslint-disable func-names */
|
||||
$.fn[this.jqueryPluginCover] = function (args) {
|
||||
self.jqueryFuncCalled.push({
|
||||
elem: this,
|
||||
args,
|
||||
});
|
||||
self.fetchFiles();
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default DynamicImportJqueryPlugin;
|
||||
Reference in New Issue
Block a user