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/require/AttributePlugin.js | 138 ---- html/content/lib/require/Require.js | 848 --------------------- html/content/lib/require/plugins.attribute.js | 219 ------ .../content/lib/require/plugins.attribute.setup.js | 94 --- html/content/lib/require/require.files.js | 75 -- html/content/lib/require/require.slim.js | 492 ------------ 6 files changed, 1866 deletions(-) delete mode 100644 html/content/lib/require/AttributePlugin.js delete mode 100644 html/content/lib/require/Require.js delete mode 100644 html/content/lib/require/plugins.attribute.js delete mode 100644 html/content/lib/require/plugins.attribute.setup.js delete mode 100644 html/content/lib/require/require.files.js delete mode 100644 html/content/lib/require/require.slim.js (limited to 'html/content/lib/require') diff --git a/html/content/lib/require/AttributePlugin.js b/html/content/lib/require/AttributePlugin.js deleted file mode 100644 index 79dc5af..0000000 --- a/html/content/lib/require/AttributePlugin.js +++ /dev/null @@ -1,138 +0,0 @@ -require('jQuery', function ($) { - - function debounce(func, wait, immediate) { - var timeout; - return function () { - var context = this, args = arguments; - var later = function () { - timeout = null; - if (!immediate) func.apply(context, args); - }; - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) func.apply(context, args); - }; - }; - - function init($element, pluginName, pluginConfiguration, callback) { - if (typeof (pluginName) === 'undefined') { - return; - } - - require([pluginName], function (plugin) { - if (typeof (plugin) === 'undefined') { - throw 'plugin ' + pluginName + ' is undefined'; - } - plugin($element, pluginConfiguration); - }); - } - - - var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/; - function parseOptions(data, element) { - if (data === "true") { - return true; - } - - if (data === "false") { - return false; - } - - if (data === "null") { - return null; - } - - // Only convert to a number if it doesn't change the string - if (data === +data + "") { - return +data; - } - - if (rbrace.test(data)) { - return tryParseJson(data, element); - } - - return data; - } - function tryParseJson(json, element) { - try { - return JSON.parse(json) - } - catch (err) { - console.warn(element, 'error during parsing of json', json, err); - return json; - } - } - - function attach($container) { - $container.find('*').addBack().each(function () { - var domNode = this; - var attributeNamePrefix = "data-plugin-"; - var plugins = []; - var initialized = domNode.initializedPlugins = (domNode.initializedPlugins || {}); - var $element = $(this); - for (var i = 0; i < domNode.attributes.length; i++) { - var attribute = domNode.attributes[i]; - - if (attribute.name.indexOf(attributeNamePrefix) != 0) { - continue; - } - if (initialized[attribute.name]) { - continue; - } - - var plugin = { name: attribute.name.substring(attributeNamePrefix.length), options: parseOptions(attribute.value, domNode) }; - init($element, plugin.name, plugin.options); - initialized[attribute.name] = true; - } - }); - } - $.fn.parseAttributePlugins = function () { - attach($(this)); - return $(this); - }; - var attachFn = debounce(function () { - attach($('body')); - }, 100); - - $(function () { - attachFn(); - }); - $('body').on('contentInjected', function (e) { - attachFn(); - }); - $.defineAttributePlugin = function (pluginName, dependencies, plugin) { - if (typeof (plugin) == 'undefined') { - plugin = dependencies; - dependencies = []; - } - define(pluginName, dependencies, function () { - var dependencyValues = arguments; - if (dependencies.length) { - return function ($element, options) { - var args = [$element, options]; - for (var i = 0; i < dependencyValues.length; i++) { - args.push(dependencyValues[i]); - } - - plugin.apply(this, args); - }; - } - return function ($element, options) { - - plugin($element, options); - }; - }); - }; - - $.fn.executePlugin = function (pluginName, pluginConfiguration, callback) { - return $(this).each(function () { - var $element = $(this); - init($element, pluginName, pluginConfiguration, function () { - if (typeof (callback) !== 'undefined') { - callback.apply($element, []); - } - }); - }); - }; -}); \ No newline at end of file diff --git a/html/content/lib/require/Require.js b/html/content/lib/require/Require.js deleted file mode 100644 index df3f536..0000000 --- a/html/content/lib/require/Require.js +++ /dev/null @@ -1,848 +0,0 @@ -(function (requireFiles) { - var require, _helpers; - if (typeof (window.require) != 'undefined') { - return; - } - - function isArraylike(obj) { - return Array.isArray(obj); - } - _helpers = { - isFunction: function (obj) { - return typeof (obj) == 'function'; - }, - isArray: isArraylike, - grep: function (elems, callback, inv) { - var retVal, - ret = [], - i = 0, - length = elems.length; - inv = !!inv; - - for (; i < length; i++) { - retVal = !!callback(elems[i], i); - if (inv !== retVal) { - ret.push(elems[i]); - } - } - - return ret; - }, - map: function (elems, callback, arg) { - var value, - i = 0, - length = elems.length, - isArray = isArraylike(elems), - ret = []; - - // Go through the array, translating each of the items to their - if (isArray) { - for (; i < length; i++) { - value = callback(elems[i], i, arg); - - if (value != null) { - ret[ret.length] = value; - } - } - - // Go through every key on the object, - } else { - for (i in elems) { - value = callback(elems[i], i, arg); - - if (value != null) { - ret[ret.length] = value; - } - } - } - - // Flatten any nested arrays - return [].concat(ret); - } - }; - - function configuration(versions, speculativeDependencies, modules) { - this.modules = modules || {}; - this.modulePaths = {}; - this.bundles = []; - this.bundlesByName = {}; - - for (var i = 0; i < versions.length; i++) { - var v = versions[i]; - for (var k in v) { - var moduleName = k; - var url = v[k]; - if (typeof (url) == 'object') { - this.modulePaths[moduleName] = url.Url; - var bundle = { - name: moduleName, - url: url.Url, - modules: url.Contents, - usages: [] - }; - - this.bundles.push(bundle); - this.bundlesByName[bundle.name] = bundle; - continue; - } - this.modulePaths[moduleName] = url; - - } - } - - this.getSpeculativeDependencies = function (moduleNames) { - var result = []; - if (!isArraylike(moduleNames)) { - result.push(moduleNames); - for (var i = 0; i < speculativeDependencies.length; i++) { - var deps = speculativeDependencies[i][moduleNames]; - if (deps) { - for (var j = 0; j < deps.length; j++) { - if (result.indexOf(deps[j]) == -1) - result.push(deps[j]); - } - } - } - } - else { - for (var i = 0; i < moduleNames.length; i++) { - var deps = this.getSpeculativeDependencies(moduleNames[i]); - for (var j = 0; j < deps.length; j++) { - if (result.indexOf(deps[j]) === -1) - result.push(deps[j]); - } - } - } - return result; - } - - - this.updateState = function (state, moduleDependencies, callback) { - var config = this; - state.moduleDependencies = moduleDependencies; - state.dependencies = _helpers.map(_helpers.grep( - moduleDependencies, - function (x) { - return x && x.indexOf('exports') == -1 && x.indexOf('require') == -1; - } - ), function (x) { - return config.getOrCreateState(x); - }); - state.loaded = true; - state.readyCallback = function () { - state.ready = true; - if (callback) { - state.object = invokeCallback(callback, state.moduleDependencies, state.name); - document.dispatchEvent(new CustomEvent("require.moduleLoaded", { detail: state })); - } - - }; - if (state.readyCheck) { - state.readyCheck(); - } - - - if (state.dependencies.length) { - for (var i = 0; i < state.dependencies.length; i++) { - state.dependencies[i].callbacks.push(function () { - if (state.readyCheck) { - state.readyCheck(); - } - }); - } - var dependendentModuleNames = _helpers.map(state.dependencies, function (x) { return x.name }); - - require( - dependendentModuleNames, - function () { - if (state.readyCheck) { - state.readyCheck(); - } - } - ); - } - } - - this.getOrCreateState = function (moduleName) { - var state = window.define.amd.getProp(moduleName); - if (!state) { - window.define.amd[moduleName] = state = this.createState(moduleName); - } - - return state; - } - this.createState = function (moduleName) { - var bundle = this.bundlesByName[moduleName]; - return { - isBundle: typeof (bundle) !== 'undefined', - url: this.modulePaths.getProp(this.modules[moduleName] || moduleName), - name: moduleName, - loaded: false, - callbacks: [], - ready: false, - dependencies: [], - doCallBacks: function () { - for (var i = 0; i < this.callbacks.length; i++) { - this.callbacks[i].apply(this, []); - } - this.callbacks = []; - }, - removeReadyDependencies: function () { - this.dependencies = _helpers.grep(this.dependencies, function (x) { return !x.ready; }); - }, - readyCheck: function () { - this.removeReadyDependencies(); - if (!this.dependencies.length && this.loaded) { - if (!this.ready) { - if (this.readyCallback) { - var rc = this.readyCallback; - rc.apply(this, []); - } - else { - this.ready = true; - } - this.doCallBacks(); - } - } - }, - hasUrl: function () { - if (!this.url) { - if (debug) - console.warn('could not resolve ' + moduleName + ' into a url'); - return false; - } - return true; - }, - callPending: function () { - this.pending = true; - if (bundle) { - for (var i = 0; i < bundle.modules.length; i++) { - var state = config.getOrCreateState(bundle.modules[i]); - state.callPending(); - } - } - }, - callDone: function () { - if (this.isBundle) { - - if (!this.loaded) { - define(this.name, [], function () { }); - if (!this.loaded) { - console.warn('should be loaded'); - } - for (var i = 0; i < bundle.modules.length; i++) { - var state = config.getOrCreateState(bundle.modules[i]); - state.callDone(); - } - } - return; - } - if (!this.loaded) { - completeDefine(this.name); - if (!this.loaded) { - console.warn('should be loaded'); - } - } - } - }; - } - this.bundle = function (moduleNames, noLoadedBias, ignoredBundles) { - var self = this; - - var scoredBundles = _helpers.map(_helpers.grep(this.bundles, function (x) { return typeof (ignoredBundles) === 'undefined' || ignoredBundles.indexOf(x.name) == -1; }), function (bundle) { - return { - bundle: bundle, - state: self.getOrCreateState(bundle.name), - hits: _helpers.grep(bundle.modules, function (f) { - return moduleNames.indexOf(f) >= 0; - }), - waste: _helpers.grep(bundle.modules, function (f) { - return moduleNames.indexOf(f) === -1; - }), - wasteAmount: function () { - if (noLoadedBias) { - return this.waste.length; - } - if (this.state.pending) { - return 0; - } - return this.waste.length; - }, - score: function () { - return this.hits.length - this.wasteAmount(); - } - } - }); - scoredBundles.sort(function (a, b) { - return (b.score()) - (a.score()); - }); - var matchingBundles = _helpers.grep(scoredBundles, function (x) { - if (noLoadedBias) { - return x.hits.length > 1; - } - if (x.state.pending) { - return x.hits.length > 0; - } - return x.hits.length > 1; - }); - if (!matchingBundles.length) { - if (debug) - console.log('no bundles available', moduleNames, scoredBundles); - return moduleNames; - } - - - var moduleStack = moduleNames.slice(); - var bundleStack = matchingBundles.slice(); - var candidates = matchingBundles.slice(); - var rewrittenModuleNames = []; - var usedBundles = []; - - var iteration = 0; - while (moduleStack.length > 0 && bundleStack.length > 0) { - iteration++; - var bundle = bundleStack.shift(); - var considerationState = { - hits: bundle.hits.length, - pending: bundle.state.pending, - noLoadedBias: noLoadedBias, - hitModules: bundle.hits.slice() - } - if (considerationState.pending && !considerationState.noLoadedBias) { - if (considerationState.hits === 0) { - if (debug) - console.log('skipping bundle', bundle, bundle.hits, moduleStack, moduleNames); - considerationState.rejected = true; - continue; - } - } - else { - if (considerationState.hits <= 1) { - if (debug) - console.log('skipping bundle because it is not pending and only has one hit', bundle, bundle.hits); - considerationState.rejected = true; - continue; - } - } - - bundle.bundle.usages.push({ - considerationState: considerationState, - moduleStack: moduleStack.slice(), - hits: bundle.hits.slice(), - hitCount: bundle.hits.length, - waste: bundle.waste.slice(), - wasteAmount: bundle.wasteAmount(), - wasPending: bundle.state.pending, - score: bundle.score(), - candidates: _helpers.map(candidates, function (bundle) { return { hits: bundle.hits.slice(), waste: bundle.waste, wasteAmount: bundle.wasteAmount(), wasPending: bundle.state.pending, score: bundle.score() }; }), remainingCandidates: _helpers.map(bundleStack, function (bundle) { return { hits: bundle.hits.slice(), waste: bundle.waste, wasteAmount: bundle.wasteAmount(), wasPending: bundle.state.pending, score: bundle.score() }; }) - }); - - for (var i = 0; i < bundle.hits.length; i++) { - var moduleName = bundle.hits[i]; - - var index = moduleStack.indexOf(moduleName); - moduleStack.splice(index, 1); - } - rewrittenModuleNames.push(bundle.bundle.name); - usedBundles.push(bundle); - - for (var i = 0; i < bundleStack.length; i++) { - (function (bundle) { - bundle.hits = _helpers.grep(bundle.hits, function (f) { - return (moduleStack.indexOf(f) >= 0); - }); - bundle.waste = _helpers.grep(bundle.bundle.modules, function (f) { - return bundle.hits.indexOf(f) == -1; - }); - })(bundleStack[i]); - } - bundleStack.sort(function (a, b) { - return (b.score()) - (a.score()); - }); - } - for (var i = 0; i < moduleStack.length; i++) { - rewrittenModuleNames.push(moduleStack[i]); - } - - if (!usedBundles.length) { - if (debug) - console.log('no bundles found', moduleNames, matchingBundles, moduleStack, bundleStack); - return moduleNames; - } - return rewrittenModuleNames; - } - - } - var debug = false; - var config = new configuration( - requireFiles || [], - [] - ); - - Object.defineProperty(Object.prototype, "getProp", { - value: function (prop) { - if (!prop || (typeof (prop) !== typeof ('') && !(prop instanceof String))) { - console.warn('invalid property access', prop, this); - return null; - } - var key, self = this; - for (key in self) { - if (key.toLowerCase() === prop.toLowerCase()) { - return self[key]; - } - } - }, - //this keeps jquery happy - enumerable: false - }); - - - - function invokeCallback(callback, moduleNames, exportsName) { - var callbackArguments = []; - var resultFactory = function (r) { return r; } - for (var i = 0; i < moduleNames.length; i++) { - switch (moduleNames[i]) { - case 'exports': - if (!window.exports) { - window.exports = {}; - } - var e = window.exports[exportsName]; - if (!e) { - e = window.exports[exportsName] = {}; - } - resultFactory = function () { return e; }; - callbackArguments.push(e); - break; - case 'require': - callbackArguments.push(require); - break; - default: - var state = config.getOrCreateState(moduleNames[i]); - callbackArguments.push(state.object); - } - - - - } - var result = callback.apply(window, callbackArguments); - return resultFactory(result); - } - - function taskCompletionChecker(callback, moduleNames) { - this.pendingStates = getPendingStates(moduleNames); - moduleNames = config.bundle(moduleNames); - var self = this; - - this.pendingModules = getPendingStates(moduleNames); - - function getPendingStates(moduleNames) { - var pendingStates = []; - for (var i = 0; i < moduleNames.length; i++) { - var script = moduleNames[i]; - var state = config.getOrCreateState(script); - if (!state.ready) { - state.callbacks.push(function () { - self.check(); - }); - pendingStates.push(state); - } - } - return pendingStates; - } - - this.check = function () { - if (this.finished) { - return true; - } - - this.pendingStates = _helpers.grep(this.pendingStates, function (x) { return !x.ready; }); - - if (!this.pendingStates.length) { - this.done(); - return true; - } else { - notDone(); - return false; - } - }; - this.done = function () { - this.finished = true; - var s = _helpers.map(moduleNames, function (x) { return config.getOrCreateState(x); }); - for (var i = 0; i < s.length; i++) { - var state = s[i]; - if (state.readyCheck) { - state.readyCheck(); - } - } - callback(); - if (debug) - console.log('done', moduleNames); - } - function notDone() { - if (debug) - console.log('not done', _helpers.grep(self.pendingStates, function (x) { return !x.ready; })); - } - - } - - - function getScriptCached (url, callback) { - var d = document, t = 'script', - o = d.createElement(t), - s = d.getElementsByTagName(t)[0]; - o.src = url; - o.defer = true; - if (callback) { - - o.addEventListener('load', function (e) { - if (debug) - console.log('loaded script', url, e); - callback(null, e); - }, false); - } else { - console.warn('loading script without callback', url); - } - - s.parentNode.insertBefore(o, s); - } - - window.require = require = function require (moduleNames, callback, log) { - if (typeof (moduleNames) === typeof ('') || moduleNames instanceof String) { - moduleNames = [moduleNames]; - } - callback = (function (callback, moduleNames) { - return function () { - invokeCallback(callback, moduleNames); - } - })(callback, moduleNames); - moduleNames = config.getSpeculativeDependencies(moduleNames); - var taskChecker = new taskCompletionChecker(callback, moduleNames); - if (taskChecker.check()) { - return; - } - - var pendingStates = _helpers.grep(taskChecker.pendingModules, function (x) { return x.hasUrl() && !x.pending }); - if (!pendingStates.length) { - return; - } - - for (var i = 0; i < pendingStates.length; i++) { - (function (state) { - if (state.loaded && !state.ready) { - state.callbacks.push(function () { - taskChecker.check(); - }); - } else { - state.callPending(); - getScriptCached(state.url, function () { - state.callDone(); - }); - } - })(pendingStates[i]); - } - - }; - - require.getScriptCached = getScriptCached; - - require.getStyleSheet = function (path, fn, scope) { - var head = document.getElementsByTagName('head')[0], // reference to document.head for appending/ removing link nodes - link = document.createElement('link'); // create the link node - link.setAttribute('href', path); - link.setAttribute('rel', 'stylesheet'); - link.setAttribute('type', 'text/css'); - - var sheet, cssRules; - // get the correct properties to check for depending on the browser - if ('sheet' in link) { - sheet = 'sheet'; cssRules = 'cssRules'; - } - else { - sheet = 'styleSheet'; cssRules = 'rules'; - } - - var interval_id = setInterval(function () { // start checking whether the style sheet has successfully loaded - try { - if (link[sheet] && link[sheet][cssRules].length) { // SUCCESS! our style sheet has loaded - clearInterval(interval_id); // clear the counters - clearTimeout(timeout_id); - fn.call(scope || window, true, link); // fire the callback with success == true - } - } catch (e) { } finally { } - }, 10), // how often to check if the stylesheet is loaded - timeout_id = setTimeout(function () { // start counting down till fail - clearInterval(interval_id); // clear the counters - clearTimeout(timeout_id); - head.removeChild(link); // since the style sheet didn't load, remove the link node from the DOM - fn.call(scope || window, false, link); // fire the callback with success == false - }, 15000); // how long to wait before failing - - head.appendChild(link); // insert the link node into the DOM and start loading the style sheet - - return link; // return the link node; - } - - require.resource = function (scripts, callback) { - function flattenArray(arr) { - if (!_helpers.isArray(arr)) { - return arr; - } - - return _helpers.map(arr, function (n) { - return flattenArray(n) - }); - } - scripts = flattenArray(scripts).reverse(); - if (typeof (scripts) == 'undefined') { - console.error('$.require called without scripts', arguments); - return; - } - function next() { - if (!scripts.length) { - callback(); - return; - } - - if (!window.loadedScripts) { - window.loadedScripts = []; - } - if (!window.loadingScriptCallbacks) { - window.loadingScriptCallbacks = {}; - } - - var script = scripts.pop(); - var css = script.indexOf('.css') != -1; - - var originalScript = script; - if (script.indexOf('~/') == 0) { - script = script.replace('~/', $siteRoot()); - } - - if (window.loadingScriptCallbacks[script]) { - window.loadingScriptCallbacks[script].push(function () { - next(); - }); - return; - } - - if (!css) { - if (document.querySelector('script[src="' + script + '"]') || window.loadedScripts.indexOf(script) != -1) { - next(); - return; - } - } else { - if (document.querySelector('link[href="' + script + '"]') || window.loadedScripts.indexOf(script) != -1) { - next(); - return; - } - } - - window.loadingScriptCallbacks[script] = [function () { - next(); - }]; - - function done() { - window.loadedScripts.push(script); - document.dispatchEvent(new CustomEvent("require.scriptLoaded", { detail: originalScript })); - for (var i = 0; i < window.loadingScriptCallbacks[script].length; i++) { - window.loadingScriptCallbacks[script][i](); - } - delete window.loadingScriptCallbacks[script]; - } - - if (css) { - require.getStyleSheet(script, function () { - done(); - }); - } - else { - require.getScriptCached(script, function () { - done(); - }); - } - } - next(); - }; - - _helpers.getOnce = function (options) { - if (!window.getOnceCallbacks) { - window.getOnceCallbacks = {}; - } - if (options.data) { - var s = _helpers.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]); - }; - _helpers.ajax(options); - } - - function getModuleName(url) { - var u = url; - u = u.substring(u.lastIndexOf('/') + 1); - u = u.substring(0, u.lastIndexOf('.')); - return u; - } - - function completeDefine(moduleName) { - if (typeof (window._pendingDefine) === 'undefined') { - define(moduleName, [], function () { }); - return; - } - var moduleDependencies = window._pendingDefine.moduleDependencies; - var callback = window._pendingDefine.callback; - delete window._pendingDefine; - var state = config.getOrCreateState(moduleName); - - config.updateState(state, moduleDependencies, callback); - } - - var amd = window.define && window.define.amd ? window.define.amd : {}; - - window.define = function (moduleName, moduleDependencies, callback) { - if (typeof (moduleName) === "string") { - if (_helpers.isFunction(moduleDependencies)) { - callback = moduleDependencies; - } - } else if (_helpers.isArray(moduleName)) { - callback = moduleDependencies; - moduleDependencies = moduleName; - moduleName = null; - } else if (_helpers.isFunction(moduleName)) { - callback = moduleName; - moduleDependencies = []; - moduleName = null; - } - if (debug) - console.log('define', moduleName, moduleDependencies); - - window._pendingDefine = { - moduleDependencies: moduleDependencies, - callback: callback - }; - // if (moduleName == null && document.currentScript){ - // try { - // moduleName = getModuleName(document.currentScript.src); - // if (moduleName.indexOf(".min") === moduleName.length - 4){ - // moduleName = moduleName.substring(0, moduleName.length - 4); - // } - // } catch (e) { - // console && console.warn("Could not resolve current script"); - // } - // - // } - if (moduleName != null) { - completeDefine(moduleName); - } - - - } - window.define.amd = amd; - - - function getFlatDependencies(moduleName) { - var state = window.define.amd[moduleName]; - var dependencies = []; - if (!state || !state.moduleDependencies) { - return dependencies; - } - for (var i = 0; i < state.moduleDependencies.length; i++) { - if (state.moduleDependencies[i].indexOf('/') != -1) { - continue; - } - dependencies.push(state.moduleDependencies[i]); - var deps = getFlatDependencies(state.moduleDependencies[i]); - for (var j = 0; j < deps.length; j++) { - if (dependencies.indexOf(deps[j]) === -1) - dependencies.push(deps[j]); - } - } - return dependencies; - } - - window.flatDependencies = function (moduleName, ignoredBundles) { - var r = {}; - for (var k in window.define.amd) { - if (k.indexOf('anonymous') === -1) { - var deps = getFlatDependencies(k); - if (deps.length) - r[k] = deps; - } - } - if (typeof (moduleName) != 'undefined') { - var deps = r[moduleName]; - if (typeof (deps) == 'undefined') { - console.warn('no dependencies for', moduleName, r); - return; - } - deps = deps.slice(); - deps.push(moduleName); - deps = config.bundle(deps, true, ignoredBundles); - var s = '\n'; - for (var i = 0; i < deps.length; i++) { - var state = config.getOrCreateState(deps[i]); - if (state.isBundle) { - continue; - } - if (state.url) - s += '///' + ' \n'; - } - console.log(s); - } - return r; - }; - window.pendingModules = function () { - var states = []; - for (var k in window.define.amd) { - states.push(window.define.amd[k]); - } - - return { - blocked: _helpers.grep(states, function (x) { - return (x.pending && !x.ready) || _helpers.grep(x.dependencies || [], function (d) { return !x.ready; }).length; - }), - missing: _helpers.grep(states, function (x) { - return !x.isBundle && !x.loaded; - }) - }; - } - window.explainBundle = function (name) { - var bundle = config.bundlesByName[name]; - if (!bundle) { - console.warn('no bundle named', name); - } - console.log(bundle.usages); - }; -})(window.__requireFiles); \ No newline at end of file diff --git a/html/content/lib/require/plugins.attribute.js b/html/content/lib/require/plugins.attribute.js deleted file mode 100644 index 2655e90..0000000 --- a/html/content/lib/require/plugins.attribute.js +++ /dev/null @@ -1,219 +0,0 @@ -define('plugins.attribute', ['plugins'], function (plugins) { - var _toInitialize = [], - _toCleanup = [], - _processed = new WeakSet(), - observer, - _api = {}, - _options = { - preconfigure: identity - }, - attributeNamePrefix = "data-plugin-"; - - function identity(x){return x;} - - function processNodes (added, removed) { - scheduleInitialization(added); - scheduleDisconnection(removed); - } - - function scheduleInitialization(nodes){ - if (!_toInitialize.length){ - window.setTimeout(process,50); - } - nodes.forEach(discoverPlugins); - } - - function scheduleDisconnection (nodes) { - if (!_toCleanup.length) { - window.setTimeout(processCleanup, 50); - } - _toCleanup = _toCleanup.concat(Array.prototype.slice.call(nodes)); - } - - function discoverPlugins (node){ - var attrs, attr, i; - if (!(node instanceof (HTMLElement))){ - return; - } - if (_processed.has(node)){ - return; - } - _processed.add(node); - attrs = node.attributes; - for (i = 0; i < node.attributes.length; i++) { - attr = attrs[i]; - if (attr.name.indexOf(attributeNamePrefix) === 0) { - _toInitialize.push({ node: node, name: attr.name.substring(attributeNamePrefix.length), options: attr.value }); - } - } - if (node.children) { - Array.prototype.forEach.call(node.children, discoverPlugins); - } - } - - function initializeIfNeeded (definition){ - var node = definition.node, - name = definition.name, - initialized = node.initializedPlugins = (node.initializedPlugins || {}), - result; - - if (!initialized[name]) { - result = initialize(node, name, parseOptions(definition.options, node)); - initialized[name] = true; - return result; - } - return Promise.resolve(true); - } - - function initialize(el, pluginName, pluginConfiguration) { - var ctx; - if (typeof (pluginName) === 'undefined') { - return Promise.resolve(true); - } - ctx = { element: el, plugin: pluginName, options: pluginConfiguration, configuration: {} }; - Promise.resolve(_options.preconfigure(ctx)) - .then(function (context) { - return plugins.pluginManager.register(context || ctx); - }); - } - - function debounce(func, wait, immediate) { - var timeout; - return function () { - var context = this, args = arguments; - var later = function () { - timeout = null; - if (!immediate) func.apply(context, args); - }; - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) func.apply(context, args); - }; - } - - var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/; - function parseOptions(data, element) { - if (data === "true") { - return true; - } - - if (data === "false") { - return false; - } - - if (data === "null") { - return null; - } - - // Only convert to a number if it doesn't change the string - if (data === +data + "") { - return +data; - } - - if (rbrace.test(data)) { - return tryParseJson(data, element); - } - - return data; - } - function tryParseJson(json, element) { - try { - return JSON.parse(json) - } catch (err) { - console.warn(element, 'error during parsing of json', json, err); - return json; - } - } - - function detect(node){ - if (!observer){ - observer = new MutationObserver(function (mutations, obs) { - mutations.forEach(function (mutation, index) { - if (mutation.type === 'childList'){ - processNodes(mutation.addedNodes, mutation.removedNodes); - } - }); - }); - observer.observe(node, { childList: true, subtree: true }); - } - } - - function attach(container) { - plugins.emit("plugins:initializing", container); - discoverPlugins(container); - return Promise.all(process()).then(function () { - plugins.emit("plugins:loaded", container); - }); - } - - var attachFn = debounce(function () { - attach(document.querySelector("body")); - detect(document); - }, 100); - - function processCleanup(){ - if (_toCleanup.length){ - plugins.destroy(_toCleanup, 2000); - _toCleanup = []; - } - } - - function process() { - var results = []; - if (_toInitialize.length){ - _toInitialize.reduce(function (acc, definition) { - acc.push(initializeIfNeeded(definition)); - return acc; - }, results); - _toInitialize = []; - } - return results; - } - function documentLoad () { - return new Promise((resolve) => { - if (window.document.readyState === "complete") { - resolve(true); - } - window.addEventListener("load", function () { - window.setTimeout(function () { - resolve(true); - }, 1); - }); - }); - } - _api.execute = initialize; - _api.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); - }; - }); - }; - - _api.parse = function (elm) { - attach(elm); - }; - - _api.initialize = function (options) { - Object.keys(options).forEach(function (key) { - _options[key] = options[key]; - }); - return documentLoad().then(function () { - attachFn(); - }); - }; - return _api; -}); \ No newline at end of file diff --git a/html/content/lib/require/plugins.attribute.setup.js b/html/content/lib/require/plugins.attribute.setup.js deleted file mode 100644 index d54702f..0000000 --- a/html/content/lib/require/plugins.attribute.setup.js +++ /dev/null @@ -1,94 +0,0 @@ -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 diff --git a/html/content/lib/require/require.files.js b/html/content/lib/require/require.files.js deleted file mode 100644 index 39411b4..0000000 --- a/html/content/lib/require/require.files.js +++ /dev/null @@ -1,75 +0,0 @@ -var __requireFiles = __requireFiles || []; -var requireFiles = requireFiles || __requireFiles; -__requireFiles.push({ - "current-device":"/content/lib/current-device.min.js?v=096tp8sA1flVNMZBwPoP9K2Tzmxz1ndFAJMBmIkRe74", - "nouislider":"/content/lib/nouislider.min.js?v=BosoP-FisSNAh-HJ0W_chCpLZzoRhNvCnEJZxdFfRlU", - "swiper-bundle":"/content/lib/swiper-bundle.min.js?v=jR6rtRm0QB_PJtfzrMmFGVc49W6kAvPXVXchhZ2fEAo", - "wNumb":"/content/lib/wNumb.min.js?v=DkHIFUKQfqQ7jA6GnWR9ZyB4Jb-j-dOuY12vnYq8xjk", - "jquery.validate.unobtrusive":"/content/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js?v=qbS02vMHZxdLNYKUtLPSYaSHXj1_ZwH1fv9f3XAY0LU", - "plugins":"/content/lib/plugins/plugins.js?v=1kuxt4BqDtans-_5mu6A_E_QYJvsIoFc6n5XdndkvUI", - "plugins.setup":"/content/lib/plugins/plugins.setup.js?v=2-ZX4vnoYFwgm2QEeB89HSwpAey3V1Ug4EJCZw4ugZA", - "AttributePlugin":"/content/lib/require/AttributePlugin.js?v=CCh7V1HmANFpjh2y4sgVnwrl3oFNTGNmy6S5mUvXQPA", - "Require":"/content/lib/require/Require.js?v=TWCkmZbosBmKiKTdfngt8QCYgF9cBXEwpxUe4d3Hhrk", - "plugins.attribute":"/content/lib/require/plugins.attribute.js?v=4JphFZZtatHuS490kLgPDzroPD6Rrnt9UmC4qdCGLe8", - "plugins.attribute.setup":"/content/lib/require/plugins.attribute.setup.js?v=3DGSCle33ssBGOzj9ZhOCsEU6wXUf33PEnimBk1TShY", - "require.slim":"/content/lib/require/require.slim.js?v=zLGFdrsM1hFINnsunio6FYBrORnhN8cSz9reyDJWt3c", - "emitter":"/content/lib/emitter/dist/emitter.js?v=JfMLEusELKwD-9HlKeB-n9XRcOP12GFphdjxb4erbc4", - "additional-methods":"/content/lib/jquery-validation/dist/additional-methods.js?v=qLDpf9Urms7R6rnASrjHz38WdQfOvSOmTgLDfzQSzIQ", - "jquery.validate":"/content/lib/jquery-validation/dist/jquery.validate.js?v=27gs04nyeNuL9zc_GLQLjdbZqhNGvH-xIYgnYVPIawE", - "jquery":"/content/lib/jquery/dist/jquery.js?v=oo12yYOwbYfrLG1t6v9-HU-vMvEnlKkr1eIcdUwG7Zs" - }); -var __requireFiles = __requireFiles || []; -var requireFiles = requireFiles || __requireFiles; -__requireFiles.push({ - "miniCart":"/content/js/Cart/miniCart.js?v=NAQwfLcu6Sf7HbjEPNWOFAtE7AxjWrqwnA1sQ1vNPQU", - "filterStatus":"/content/js/Filters/filterStatus.js?v=NINyEYPF_Rh_vgRaM9JfpxvXbM4YAQDjiXbNGbpTgl4", - "filters":"/content/js/Filters/filters.js?v=WhLxxmKv7IP_2hiwS7yYyDagrUGSsxa5aScn4WQUrBE", - "filtersBar":"/content/js/Filters/filtersBar.js?v=0NJbemmO6BiXsNTAyxsAPEOndfOyCnL80vywjGcnLbk", - "range":"/content/js/Filters/range.js?v=ufY-O6OpXmI18fgi4JUn-avuLmFsmvaI3QzIgcSOubg", - "ajaxForm":"/content/js/Forms/ajaxForm.js?v=5KkDlJti0D1KlgBoM0YbOtoQPEGNpV3IF1kCzhwIXz0", - "clearinput":"/content/js/Forms/clearinput.js?v=xR5FM8GWMJ9ZNbmyDEfMWlw3KOSLE8lnFws0WUbVuew", - "customValidators":"/content/js/Forms/customValidators.js?v=Uev1J0gLWgcWczzNrO9ik0aMe_y3_WUZxZheLjHUCJY", - "password":"/content/js/Forms/password.js?v=_W2pB5hK_oYxOPVywKvq846HBgoMmEk0OcN2wuWdojk", - "select":"/content/js/Forms/select.js?v=bOZmTKLXM6i3lxxVjdVPGeDcwlMwOIhkLIo6bKpDc_w", - "serialize":"/content/js/Forms/serialize.js?v=xdAdpNzP5-LJXKo-KIF4e_EtBrjmUflSQpDC_Xm9nDQ", - "textarea":"/content/js/Forms/textarea.js?v=8FE7InEGwIF7wQirDY95OnqytEgswNV1X9GyOB4NYjw", - "validateform":"/content/js/Forms/validateform.js?v=4Uo1j3-6ANE51bw4axoXpsaTpP_PdH4aroCPtueEf10", - "lazyload":"/content/js/Images/lazyload.js?v=Tevv7UFu5RCTe_5dXITjrL-X306QhUVY8USQ2qdvMCg", - "modal":"/content/js/Modals/modal.js?v=i1ztg22j1qlFf0PdDhy3_lmPC79dYeoc-vwpUO6dwFk", - "accordion":"/content/js/Plugins/accordion.js?v=N8bjJ_y261I525ALvP252flG2_tlRXhP4BuFzMffZn0", - "breadcrumb":"/content/js/Plugins/breadcrumb.js?v=q50nGXMTM6bTGo4fwSCrbNv9cO1EyVlbSQZLS57we2U", - "copy":"/content/js/Plugins/copy.js?v=GUdiN6wYUuTni_xy4C5-Y3ttcDCLf4JRcQsSNnKDYN4", - "expand":"/content/js/Plugins/expand.js?v=qHphz7KKs2D7y25f52dD7PcI84kx63QOfhfSVvX-XkQ", - "expandText":"/content/js/Plugins/expandText.js?v=DP8rxJgIrIjcx4eyQLYrWZINHKxLL2T33pM2Krjgh1Y", - "fileinput":"/content/js/Plugins/fileinput.js?v=xJ9LpDrXpMrNIr7e5g6-uM7o3W_Vqb08p85OtbWB9TQ", - "gallery":"/content/js/Plugins/gallery.js?v=4AF5XF1BGzYhPkDq7LYo2zi8Al_8-IW40OwJi-BFhaI", - "infoPopup":"/content/js/Plugins/infoPopup.js?v=fDx3vhIn-kuaYRE8wT2mSD_Dew0Au5SBIojSa7p4x_o", - "initialize":"/content/js/Plugins/initialize.js?v=UnQ6ntGkuv-fuLslfpZswizS_tyFAgKt81kRm4mwgp4", - "intersecting":"/content/js/Plugins/intersecting.js?v=M8-IufWuJcN4ieNOx4CoGmSQLg9VsJagq2ExkeKRN_s", - "menu":"/content/js/Plugins/menu.js?v=I-0Mf0F5blwsgQBhozIiEcwuZ2eWUhfMmeoVY7COltk", - "quantity":"/content/js/Plugins/quantity.js?v=Cn4hP0hCMxNAVHB1dJWoZQJ5dx_tF4IcUCzChlzolVI", - "scrollShadowHor":"/content/js/Plugins/scrollShadowHor.js?v=FKpT35YA0aLYHDpCN2F6LgpjUmp-qnBL8zPh59964vE", - "scrollShadowVert":"/content/js/Plugins/scrollShadowVert.js?v=Q4bTjrAJQTDA7JRtRBhDr-G1ctGWoYq2939Us3LQnVU", - "tabs":"/content/js/Plugins/tabs.js?v=KI-tunHCALdnsQ8fRZJHQcKDajeWmYLk4l_oTnGR9Cc", - "tabtoggle":"/content/js/Plugins/tabtoggle.js?v=DxCpnsj3S30L0TqOpQlgAzfsl6XzX47urPc2N2CI48M", - "tooltip":"/content/js/Plugins/tooltip.js?v=GPblodrvTED0xmpfh5SHMTXWqTzxIYk5TjCn9zzczpE", - "productHeader":"/content/js/Products/productHeader.js?v=Mz4iHCTD4LtLbbCnGyK876afWemBTFqXRqT7gRRM58o", - "productImageModal":"/content/js/Products/productImageModal.js?v=2NWHbRifiLsw4bdxWA-7cF-JCsKYR7L5r40KDUVHU0A", - "productattr":"/content/js/Products/productattr.js?v=9duxJ3vfguUO6yNHBxHToNeXKHBiA0BpZ6-4QK0miII", - "productsSlider":"/content/js/Sliders/productsSlider.js?v=7hK8iURSBpAV5D5SCQCk8NDrQGMTrLUgwGCTRvHaX9g", - "slider":"/content/js/Sliders/slider.js?v=BZ0Rfwkii22n7dtXdkVmUMwLxsvKfm6aN5NurFxRLdk", - "Event":"/content/js/Utils/Event.js?v=VArVfCyoOniGaU_Igps9HceZ3q1C0BpgxLds3Pg3EJw", - "EventUtils":"/content/js/Utils/EventUtils.js?v=6ErWF0jVPywXQxPxD863OMWe-UwJ4NQti2JBptjwBjM", - "apiready":"/content/js/Utils/apiready.js?v=QVUv8kcn5ndUjJGcYazA8LOCg_wgs4BIB5PrG9B_Mes", - "confirm":"/content/js/Utils/confirm.js?v=VKI6nRKgEy3tpB3FmTKUSevxayIpx_wb1Sin7aEzHEY", - "debounce":"/content/js/Utils/debounce.js?v=Hd9VEeQCq054OT5Nrq-OvVAaas2oPaJNFdsmFVBd-Uw", - "defineApi":"/content/js/Utils/defineApi.js?v=B4Tw5xpdyS2FVNsOBNRH07sO9m-x8mdDuHKHtqZ8Sao", - "destroyevent":"/content/js/Utils/destroyevent.js?v=7Ud2i-pnCLToajrNN1CF4G0k52aNG4TlGe1wyLkV-7c", - "dom":"/content/js/Utils/dom.js?v=VtqomPcfZ01YPCD64c0IV2U8OPxADqVK3F_29h1OsYU", - "domHelper":"/content/js/Utils/domHelper.js?v=wqdci9fduQKQWLHC_JSQXBFwXWEsL1m_Nt2KXz7XGgU", - "enabled":"/content/js/Utils/enabled.js?v=0ObFojv-3gCSSGDZgHAMudy1jnN2to3qk6nUfsubHaw", - "getApis":"/content/js/Utils/getApis.js?v=zv0n-Zg7qAbJoeZRUCAyJ7-ShabJ4K52YWZ6lC3gVaI", - "throttle":"/content/js/Utils/throttle.js?v=HIngurOziuO88riQvw6o4GcCNConri31sxBgVysiUaM", - "whenAll":"/content/js/Utils/whenAll.js?v=IIG8ZjyvbIBgPVCxvOq3lnOZrfSq6LZa8c8rEi5Lf2w", - "wishlistbutton":"/content/js/Wishlist/wishlistbutton.js?v=CeonyCMb0e1YxmqfbV3jfMkwANbgIPNajATJSjz_eeM" - }); \ No newline at end of file diff --git a/html/content/lib/require/require.slim.js b/html/content/lib/require/require.slim.js deleted file mode 100644 index b7e49c1..0000000 --- a/html/content/lib/require/require.slim.js +++ /dev/null @@ -1,492 +0,0 @@ -(function (requireFiles) { - var require, _helpers = { - isFunction: function (obj) { - return typeof (obj) == 'function'; - }, - isArray: isArraylike - }; - if (typeof (window.require) != 'undefined') { - return; - } - - function isArraylike(obj) { - return Array.isArray(obj); - } - - function ModulesConfiguration(versions, modules) { - this.modules = modules || {}; - this.modulePaths = {}; - - for (var i = 0; i < versions.length; i++) { - var v = versions[i]; - for (var k in v) { - var moduleName = k; - var url = v[k]; - if (typeof (url) == 'object') { - this.modulePaths[moduleName] = url.Url; - continue; - } - this.modulePaths[moduleName] = url; - } - } - this.updateState = function (state, moduleDependencies, callback) { - var config = this, i = 0; - if (!Array.isArray(moduleDependencies)) { - moduleDependencies = [moduleDependencies]; - } - state.moduleDependencies = moduleDependencies; - state.dependencies = moduleDependencies.filter(function (x) { - return x && x.indexOf('exports') === -1 && x.indexOf('require') === -1; - }).map(function (x) { - return config.getOrCreateState(x); - }); - state.loaded = true; - state.readyCallback = function () { - state.ready = true; - if (callback && typeof callback === 'function') { - state.object = invokeCallback(callback, state.moduleDependencies, state.name); - document.dispatchEvent(new CustomEvent("require.moduleLoaded", { detail: state })); - } - }; - - state.readyCheck && state.readyCheck(); - if (state.dependencies.length) { - for (; i < state.dependencies.length; i++) { - state.dependencies[i].callbacks.push(function () { - state.readyCheck && state.readyCheck(); - }); - } - require( - state.dependencies.map(function (x) { return x.name }), - function () { - state.readyCheck && state.readyCheck(); - } - ); - } - } - - this.getOrCreateState = function (moduleName, ignoreWarnings) { - var state = window.define.amd.getProp(moduleName); - if (!state) { - window.define.amd[moduleName] = state = this.createState(moduleName, ignoreWarnings); - } - - return state; - } - this.createState = function (moduleName, ignoreWarnings) { - var url = this.modulePaths.getProp(this.modules[moduleName] || moduleName); - if (!url && !ignoreWarnings) { - console.warn( - "%c Module '%s' path is not present. Define it using the global '__requireFiles' variable", - [ 'background: orange', 'color: black', 'display: block', 'text-align: center', 'font-size: 14px', 'font-weight: 600'].join(';'), - moduleName - ); - } - return { - url: this.modulePaths.getProp(this.modules[moduleName] || moduleName), - name: moduleName, - loaded: false, - callbacks: [], - ready: false, - dependencies: [], - doCallBacks: function () { - for (var i = 0; i < this.callbacks.length; i++) { - this.callbacks[i].apply(this, []); - } - this.callbacks = []; - }, - removeReadyDependencies: function () { - this.dependencies = this.dependencies.filter(function (x) { return !x.ready; }); - }, - readyCheck: function () { - this.removeReadyDependencies(); - if (!this.dependencies.length && this.loaded) { - if (!this.ready) { - if (this.readyCallback) { - this.readyCallback.apply(this, []); - } else { - this.ready = true; - } - this.doCallBacks(); - } - } - }, - hasUrl: function () { - if (!this.url) { - return false; - } - return true; - }, - callPending: function () { - this.pending = true; - }, - callDone: function () { - if (!this.loaded) { - completeDefine(this.name); - if (!this.loaded) { - console.warn('should be loaded'); - } - } - } - }; - } - } - - var debug = false; - var config = new ModulesConfiguration( - requireFiles || [] - ); - - Object.defineProperty(Object.prototype, "getProp", { - value: function (prop) { - if (!prop || (typeof (prop) !== typeof ('') && !(prop instanceof String))) { - console.warn('invalid property access', prop, this); - return null; - } - var key, self = this; - for (key in self) { - if (key.toLowerCase() === prop.toLowerCase()) { - return self[key]; - } - } - }, - //this keeps jquery happy - enumerable: false - }); - - - - function invokeCallback(callback, moduleNames, exportsName) { - var callbackArguments = [], - resultFactory = function (r) { return r; }, - e, i = 0, state, result; - for (; i < moduleNames.length; i++) { - switch (moduleNames[i]) { - case 'exports': - if (!window.exports) { - window.exports = {}; - } - e = window.exports[exportsName]; - if (!e) { - e = window.exports[exportsName] = {}; - } - resultFactory = function () { return e; }; - callbackArguments.push(e); - break; - case 'require': - callbackArguments.push(require); - break; - default: - state = config.getOrCreateState(moduleNames[i]); - callbackArguments.push(state.object); - } - } - result = callback.apply(window, callbackArguments); - return resultFactory(result); - } - - function TaskWatcher(callback, moduleNames) { - var self = this; - //moduleNames = config.bundle(moduleNames); - this.pendingModules = getPendingStates(moduleNames); - this.check = function () { - if (this.finished) { - return true; - } - if (!this.pendingModules.filter(function (x) { return !x.ready; }).length) { - this.done(); - return true; - } - return false; - }; - this.done = function () { - var s = moduleNames.map(function (x) { return config.getOrCreateState(x); }), - i = 0, - state; - this.finished = true; - for (; i < s.length; i++) { - state = s[i]; - state.readyCheck && state.readyCheck(); - } - callback(); - if (debug) { - console.debug('done', moduleNames); - } - } - - function getPendingStates(moduleNames) { - var pendingStates = [], script, state, i = 0; - for (; i < moduleNames.length; i++) { - script = moduleNames[i]; - state = config.getOrCreateState(script); - if (!state.ready) { - state.callbacks.push(function () { - self.check(); - }); - pendingStates.push(state); - } - } - return pendingStates; - } - } - - - function getScriptCached (url, callback) { - var d = document, t = 'script', - o = d.createElement(t), - s = d.getElementsByTagName(t)[0]; - o.src = url; - o.defer = true; - if (callback) { - o.addEventListener('load', function (e) { - if (debug) { - console.debug('loaded script', url, e); - } - callback(null, e); - }, false); - } else { - console.warn('loading script without callback', url); - } - - s.parentNode.insertBefore(o, s); - } - - window.require = require = function require (moduleNames, callback) { - var i = 0, watcher, pendingStates; - if (typeof (moduleNames) === typeof ('') || moduleNames instanceof String) { - moduleNames = [moduleNames]; - } - callback = (function (cb, moduleNames) { - return function () { - invokeCallback(cb, moduleNames); - } - })(callback, moduleNames); - watcher = new TaskWatcher(callback, moduleNames); - if (watcher.check()) { - return; - } - - pendingStates = watcher.pendingModules.filter(function (x) { return x.hasUrl() && !x.pending }); - if (!pendingStates.length) { - return; - } - - for (; i < pendingStates.length; i++) { - fetchIfNeeded(pendingStates[i]); - } - - function fetchIfNeeded(state){ - if (state.loaded && !state.ready) { - state.callbacks.push(function () { - watcher.check(); - }); - } else { - state.callPending(); - getScriptCached(state.url, function () { - state.callDone(); - }); - } - } - - }; - - require.getScriptCached = getScriptCached; - - require.getStyleSheet = function getStyleSheet(path, fn, scope) { - var head = document.getElementsByTagName('head')[0], // reference to document.head for appending/ removing link nodes - link = document.createElement('link'); // create the link node - link.setAttribute('href', path); - link.setAttribute('rel', 'stylesheet'); - link.setAttribute('type', 'text/css'); - - var sheet, cssRules; - // get the correct properties to check for depending on the browser - if ('sheet' in link) { - sheet = 'sheet'; cssRules = 'cssRules'; - } else { - sheet = 'styleSheet'; cssRules = 'rules'; - } - - var interval_id = setInterval(function () { // start checking whether the style sheet has successfully loaded - try { - if (link[sheet] && link[sheet][cssRules].length) { // SUCCESS! our style sheet has loaded - clearInterval(interval_id); // clear the counters - clearTimeout(timeout_id); - fn.call(scope || window, true, link); // fire the callback with success == true - } - } catch (e) { } finally { } - }, 10), // how often to check if the stylesheet is loaded - timeout_id = setTimeout(function () { // start counting down till fail - clearInterval(interval_id); // clear the counters - clearTimeout(timeout_id); - head.removeChild(link); // since the style sheet didn't load, remove the link node from the DOM - fn.call(scope || window, false, link); // fire the callback with success == false - }, 15000); // how long to wait before failing - - head.appendChild(link); // insert the link node into the DOM and start loading the style sheet - - return link; // return the link node; - } - - require.resource = function (scripts, callback) { - if (!_helpers.isArray(scripts)) { - scripts = [scripts]; - } - function flattenArray(arr) { - if (!_helpers.isArray(arr)) { - return arr; - } - - return arr.map(function (n) { - return flattenArray(n) - }); - } - scripts = flattenArray(scripts).reverse(); - if (typeof (scripts) == 'undefined') { - console.error('require.resource called without scripts', arguments); - return; - } - function next() { - if (!scripts.length) { - callback && callback(); - return; - } - - if (!_helpers.loadedScripts) { - _helpers.loadedScripts = []; - } - if (!_helpers.loadingScriptCallbacks) { - _helpers.loadingScriptCallbacks = {}; - } - - var script = scripts.pop(); - var css = script.indexOf('.css') !== -1; - - var originalScript = script; - if (script.indexOf('~/') === 0) { - script = script.replace('~/', $siteRoot()); - } - - if (_helpers.loadingScriptCallbacks[script]) { - _helpers.loadingScriptCallbacks[script].push(function () { - next(); - }); - return; - } - - if (!css) { - if (document.querySelector('script[src="' + script + '"]') || _helpers.loadedScripts.indexOf(script) !== -1) { - next(); - return; - } - } else { - if (document.querySelector('link[href="' + script + '"]') || _helpers.loadedScripts.indexOf(script) !== -1) { - next(); - return; - } - } - - _helpers.loadingScriptCallbacks[script] = [function () { - next(); - }]; - - function done() { - _helpers.loadedScripts.push(script); - document.dispatchEvent(new CustomEvent("require.scriptLoaded", { detail: originalScript })); - for (var i = 0; i < _helpers.loadingScriptCallbacks[script].length; i++) { - _helpers.loadingScriptCallbacks[script][i](); - } - delete _helpers.loadingScriptCallbacks[script]; - } - - if (css) { - require.getStyleSheet(script, function () { - done(); - }); - } - else { - require.getScriptCached(script, function () { - done(); - }); - } - } - next(); - }; - - function getModuleName(url) { - var u = url; - u = u.substring(u.lastIndexOf('/') + 1); - u = u.substring(0, u.lastIndexOf('.')); - return u; - } - - function completeDefine(moduleName) { - if (typeof (_helpers._pendingDefinition) === 'undefined') { - define(moduleName, [], function () { }); - return; - } - var moduleDependencies = _helpers._pendingDefinition.moduleDependencies; - var callback = _helpers._pendingDefinition.callback; - delete _helpers._pendingDefinition; - var state = config.getOrCreateState(moduleName, true); - config.updateState(state, moduleDependencies, callback); - } - - window.define = function (moduleName, moduleDependencies, callback) { - if (typeof (moduleName) === "string") { - if (_helpers.isFunction(moduleDependencies)) { - callback = moduleDependencies; - moduleDependencies = []; - } - } else if (_helpers.isArray(moduleName)) { - callback = moduleDependencies; - moduleDependencies = moduleName; - moduleName = null; - } else if (_helpers.isFunction(moduleName)) { - callback = moduleName; - moduleDependencies = []; - moduleName = null; - } - if (debug) - console.log('define', moduleName, moduleDependencies); - - _helpers._pendingDefinition = { - moduleDependencies: moduleDependencies, - callback: callback - }; - // if (moduleName == null && document.currentScript){ - // try { - // moduleName = getModuleName(document.currentScript.src); - // if (moduleName.indexOf(".min") === moduleName.length - 4){ - // moduleName = moduleName.substring(0, moduleName.length - 4); - // } - // } catch (e) { - // console && console.warn("Could not resolve current script"); - // } - // - // } - if (moduleName != null) { - completeDefine(moduleName); - } - - - } - window.define.amd = window.define && window.define.amd ? window.define.amd : {}; - - window.define.pendingModules = function () { - var states = []; - for (var k in window.define.amd) { - states.push(window.define.amd[k]); - } - - return { - blocked: states.filter(function (x) { - return (x.pending && !x.ready) || - (x.dependencies || []).filter(function (d) { return !d.ready; }).length; - }), - missing: states.filter(function (x) { - return !x.loaded; - }) - }; - } -})(window.__requireFiles); \ No newline at end of file -- cgit v1.2.3