From 7aa203150fc1a2ec79c681c13f0d486d531746eb Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sun, 12 Mar 2023 23:57:48 +0200 Subject: error pages; js system to support back/front-end --- html/content/lib/plugins/plugins.setup.js | 178 ------------------------------ 1 file changed, 178 deletions(-) delete mode 100644 html/content/lib/plugins/plugins.setup.js (limited to 'html/content/lib/plugins/plugins.setup.js') diff --git a/html/content/lib/plugins/plugins.setup.js b/html/content/lib/plugins/plugins.setup.js deleted file mode 100644 index d756142..0000000 --- a/html/content/lib/plugins/plugins.setup.js +++ /dev/null @@ -1,178 +0,0 @@ -define('plugins.setup', ['plugins'], function (plugins) { - var system = plugins.setup({ - //the global attribute name prefix that hints the system - //for a given plugin in a node - attributeNamePrefix: "data-plugin", - //This is a way to configure/extend all plugin instances. - //The 'configuration' object will be available to all plugins - //using the 'this.configuration' - //You can return a promise (wrapping an xhr request or other async operations) - preconfigure: function (ctx) { - //ctx.configuration.someProperty = someValue; - }, - //the time (in seconds) that the system will wait before - //it destroys a disconnected plugin. Default value is 10 - idleTimeout: 10, - //the time (in seconds) that the system will wait before - //it starts processing discovered plugins. Default value is 10 - processInterval: 10, - //the time (in seconds) that the system will wait before - //it triggers a cleanup cycle. Default value is 10 - clearInterval: 10, - //the attribute that hints the system to lazy load a node's plugins - lazyLoadAttribute: 'plugins-lazy', - //the margin of the IntersectionObserver - //that detects when a lazy plugin should be registered - lazyLoadRootMargin: '0px 0px 200px 0px', - //the attribute that hints the system to ignore a node from - //the plugin discovery phase - ignoreAttribute: 'plugins-ignore', - //predicate function to filter out a node from - //the plugin discovery phase - filter: function (node) { - //ignore nodes with the v-plugin directive. Plugins will be initialized by the directive itself. - //return node.getAttribute("v-plugin") === null; - return true; - }, - //false if the automatic discovery of plugins is not desired - observeDocument: true, - // shouldLazyLoad: function (node, pluginOptions, lazyLoadAttributeName) { - // return true; - // } - }), - $ = window.jQuery, - $$plugins = {}; - - system.use(function (context) { - //system.moduleLoader.basePath = '/src/plugins/'; - context.onCreate(function (instance) { - if (instance.application.debug) { - console.log(instance.definition.type, 'plugin instance created', instance.definition); - } - if (instance.application.debug) { - instance.onDisconnect(logger("Disconnected")); - instance.onConnect(logger("Connected")); - instance.onDestroy(logger("Destroyed")); - } - - function logger (msg){ - return function (instance) { - console.log(msg, instance.definition); - } - } - }); - context.moduleLoader = { - load: function (pluginType, element) { - return new Promise(function (resolve) { - window.require(pluginType, resolve); - }); - } - } - $$plugins.execute = context.processor.initialize; - $$plugins.parse = context.processor.process; - $$plugins.define = function (pluginName, dependencies, plugin, invoke) { - invoke = invoke || function (fn, args, context) { - return fn.apply(context, args); - } - if (typeof (plugin) == 'undefined') { - plugin = dependencies; - dependencies = []; - } - define(pluginName, dependencies, function () { - var dependencyValues = arguments; - return function (element, options) { - var args = [element, options], i; - for (i = 0; i < dependencyValues.length; i++) { - args.push(dependencyValues[i]); - } - return invoke(plugin, args, this); - }; - }); - }; - }); - - if ($) { - $ = window.jQuery; - $.defineAttributePlugin = function (pluginName, dependencies, plugin) { - return $$plugins.define(pluginName, dependencies, plugin, function (fn, args, context){ - args[0] = $(args[0]); - return fn.apply(context, args); - }); - } - - $.fn.parseAttributePlugins = function () { - return $(this).each(function () { - $$plugins.parse([this]); - }); - }; - - $.fn.executePlugin = function (pluginName, pluginConfiguration, callback) { - return $(this).each(function () { - var $element = $(this); - return $$plugins.execute(this, pluginName, pluginName, pluginConfiguration).then(function (resolved) { - if (typeof (callback) !== 'undefined') { - return callback.apply($element, [resolved]); - } - }); - }); - }; - - $.getOnce = function (options) { - if (!window.getOnceCallbacks) { - window.getOnceCallbacks = {}; - } - if (options.data) { - var s = $.param(options.data, options.traditional); - if (options.url.indexOf('?') == -1) { - options.url += '?' + s; - } - else { - options.url += '&' + s; - } - delete options.data; - } - if (window.getOnceCallbacks[options.url]) { - window.getOnceCallbacks[options.url].push({ - success: options.success, - error: options.error - }); - return; - } - - window.getOnceCallbacks[options.url] = [{ - success: options.success, - error: options.error - }]; - function done(m, a) { - var callbacks = window.getOnceCallbacks[options.url]; - for (var i = 0; i < callbacks.length; i++) { - callbacks[i][m].apply(this, a); - } - delete window.getOnceCallbacks[options.url]; - } - - options.success = function () { - done.apply(this, ['success', arguments]); - - }; - options.error = function () { - done.apply(this, ['error', arguments]); - }; - $.ajax(options); - } - window.define.amd["jQuery"] = window.define.amd["jquery"] = { loaded: true, ready: true, object: $ }; - } - - if (window.Vue) { - window.define.amd["Vue"] = { loaded: true, ready: true, object: window.Vue }; - } - - window.$$plugins = $$plugins; - return system.initialize; -}); -require(['plugins.setup'], function (initialize) { - var pluginsSystem = initialize(); - pluginsSystem.application.debug = false; - window.define.amd["plugins.system"] = { loaded: true, ready: true, object: pluginsSystem }; - window.define.amd["application"] = { loaded: true, ready: true, object: pluginsSystem.application }; -}); \ No newline at end of file -- cgit v1.2.3