summaryrefslogtreecommitdiff
path: root/html/assets/js/require/plugins.attribute.setup.js
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 23:57:48 +0200
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 23:57:48 +0200
commit7aa203150fc1a2ec79c681c13f0d486d531746eb (patch)
treef09ba9f69ccd434e9c7fdeb41807fc8008784d8a /html/assets/js/require/plugins.attribute.setup.js
parent221af3a2e035bd6689294509feb52f286d3bd5be (diff)
downloadclassroom-7aa203150fc1a2ec79c681c13f0d486d531746eb.tar.gz
classroom-7aa203150fc1a2ec79c681c13f0d486d531746eb.tar.bz2
classroom-7aa203150fc1a2ec79c681c13f0d486d531746eb.zip
error pages; js system to support back/front-end
Diffstat (limited to 'html/assets/js/require/plugins.attribute.setup.js')
-rw-r--r--html/assets/js/require/plugins.attribute.setup.js94
1 files changed, 94 insertions, 0 deletions
diff --git a/html/assets/js/require/plugins.attribute.setup.js b/html/assets/js/require/plugins.attribute.setup.js
new file mode 100644
index 0000000..296b567
--- /dev/null
+++ b/html/assets/js/require/plugins.attribute.setup.js
@@ -0,0 +1,94 @@
+define('plugins.attribute.setup', ['plugins.attribute'], function (attributePlugins) {
+ var $ = window.jQuery, _done = false;
+ if ($) {
+ $ = window.jQuery;
+ $.defineAttributePlugin = function (pluginName, dependencies, plugin) {
+ return attributePlugins.define(pluginName, dependencies, plugin, function (fn, args, context){
+ args[0] = $(args[0]);
+ return fn.apply(context, args);
+ });
+ }
+
+ $.fn.parseAttributePlugins = function () {
+ attributePlugins.parse(this);
+ return $(this);
+ };
+
+ $.fn.executePlugin = function (pluginName, pluginConfiguration, callback) {
+ return $(this).each(function () {
+ var $element = $(this);
+ return attributePlugins.execute(this, 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: $ };
+ }
+
+ window.$$plugins = attributePlugins;
+ return function () {
+ if (_done) {
+ return;
+ }
+ _done = true;
+ attributePlugins.initialize({
+ preconfigure: function (ctx) {
+ //This is the way to configure/extend all plugin instances.
+ //The 'configuration' object will be available to all plugins by invoking this.configuration
+ //You can return a promise like an xhr request or other async operations
+ //that should be resolved using the value of ctx parameter.
+ let loggingConfigString = localStorage.getItem("plugins.configuration.logging");
+ ctx.configuration.logging = (loggingConfigString && JSON.parse(loggingConfigString)) || {};
+ }
+ });
+ }
+});
+require(['plugins.attribute.setup'], function (setup) {
+ setup();
+}); \ No newline at end of file