diff options
Diffstat (limited to 'public/assets/js/_dependency-control/require')
6 files changed, 1938 insertions, 0 deletions
diff --git a/public/assets/js/_dependency-control/require/AttributePlugin.js b/public/assets/js/_dependency-control/require/AttributePlugin.js new file mode 100644 index 0000000..d0568a2 --- /dev/null +++ b/public/assets/js/_dependency-control/require/AttributePlugin.js @@ -0,0 +1,138 @@ +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/public/assets/js/_dependency-control/require/Require.js b/public/assets/js/_dependency-control/require/Require.js new file mode 100644 index 0000000..f75558f --- /dev/null +++ b/public/assets/js/_dependency-control/require/Require.js @@ -0,0 +1,848 @@ +(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 += '///' + ' <reference path="' + state.url.split('?')[0] + '" />\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/public/assets/js/_dependency-control/require/plugins.attribute.js b/public/assets/js/_dependency-control/require/plugins.attribute.js new file mode 100644 index 0000000..05504d5 --- /dev/null +++ b/public/assets/js/_dependency-control/require/plugins.attribute.js @@ -0,0 +1,219 @@ +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/public/assets/js/_dependency-control/require/plugins.attribute.setup.js b/public/assets/js/_dependency-control/require/plugins.attribute.setup.js new file mode 100644 index 0000000..296b567 --- /dev/null +++ b/public/assets/js/_dependency-control/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 diff --git a/public/assets/js/_dependency-control/require/require.files.js b/public/assets/js/_dependency-control/require/require.files.js new file mode 100644 index 0000000..cd07254 --- /dev/null +++ b/public/assets/js/_dependency-control/require/require.files.js @@ -0,0 +1,147 @@ +var __requireFiles = __requireFiles || []; +var requireFiles = requireFiles || __requireFiles; +__requireFiles.push({ + + // CORE + //////////////////////////////////////////////////////////////////////////// + + // --- REQUIRE + "Require" : "/js/require/Require.js?v=1b5de85538a429f52c11da29b318571a", + "require.slim" : "/js/require/require.slim.js?v=bb1df68c3534777c6d087ccec1f1b719", + + // --- UTILITY, + "current-device" : "/lib/current-device.min.js?v=a99ea17bf310323f8a50186703519d41", + "nouislider" : "/lib/nouislider.min.js?v=2466096360ec47c99c24466e2da924a3", + + // NOTE: + // swiper may need to be loaded outside Require system; + // so the followinfg may be depricated + "swiper-bundle" : "/lib/swiper-bundle.min.js?v=659ad1f9e2b0d54d90d68caf359bb9fe", // old version + "swiper": "/lib/swiper/swiper-bundle.min.js", // new (latest) verstion + + + "wNumb" : "/lib/wNumb.min.js?v=1f80cfaf4e97858a1ff12021a0460cc8", + + // --- JQUERY + "jQuery" : "/js/jquery/jQuery.js?v=62865e1140f5241404dab7cb2f0c1820", + "jquery3" : "/js/jquery/jquery-3.6.2.js?v=a08f762982bd4fda9773775e5e8f158a", + + "crypto-js" : "https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js", + + // --- VALIDATION + "jquery.validate.unobtrusive" : "/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js?v=b8ce1b651fecf18f796c94235fb1baf9", + "additional-methods" : "/lib/jquery-validation/dist/additional-methods.js?v=7c842b9debce62b8458428a0a7254105", + "jquery-validation" : "/lib/jquery-validation/dist/jquery.validate.js?v=93dd3bd9e046170e83a05cb035164169", + "messages_el" : "/lib/jquery-validation/dist/localization/messages_el.js?v=dcb809e18731d8c48433baca9e9d2b63", + + // --- PLUGINS + "plugins" : "/js/Plugins/plugins.js?v=fc1f0a15c337f6c87713a38aff4263b5", + "plugins.setup" : "/js/Plugins/plugins.setup.js?v=2005e22f4ee49528c93d0ac5adcfc2ed", + "AttributePlugin" : "/js/require/AttributePlugin.js?v=3c8489196313ce9ebb16bd8cc4116af4", + "plugins.attribute" : "/js/require/plugins.attribute.js?v=09501f51d7c60123de8800c7ab92a792", + "plugins.attribute.setup" : "/js/require/plugins.attribute.setup.js?v=de5fad9325b5e150119091d6f81441ec", + + "emitter" : "/lib/emitter/dist/emitter.js?v=", + + // --- TYPEAHEAD + "typeahead" : "/js/Search/typeahead.jquery.js?v=2b6b170c60edbe84f6918494c33150b6" +}); + +var __requireFiles = __requireFiles || []; +var requireFiles = requireFiles || __requireFiles; +__requireFiles.push({ + // MIDDLEWARE, + ////////////////////////////////////////////////////////////////////////////, + + "dom" : "/js/Utils/dom.js?v=fbbcc0dc32d1bde92f2b89b77da74d6c", + "domHelper" : "/js/Utils/domHelper.js?v=d151145f4ecba4bc4611ba630617e23d", + + // --- THE PLUGINS + "markerClusterer": "/js/google_maps/markerclusterer_compiled.js?v=6", + "accordion" : "/js/Plugins/accordion.js?v=b4e153c6b93d97280a9e22ca49f95f53", + "miniCart" : "/js/Cart/miniCart.js?v=67998e1eaebddd615ba4088f65b1e2e9", + "productList" : "/js/Products/productList.js?v=fcc45cca20a14d80c0c5b3d67c19d2fb", + "localStorage" : "/js/Plugins/localStorage.js", + "filterStatus" : "/js/Filters/filterStatus.js?v=aa704bd052c18bf5ab5681458c296d76", + "filters" : "/js/Filters/filters.js?v=5974a377fab0dabd82f72814959784c8", + "filtersBar" : "/js/Filters/filtersBar.js?v=0d7bc82e840bf02cd8025f83a777d7c2", + "range" : "/js/Filters/range.js?v=54da1febf08e3d949f9ac4e4a58a7b61", + "ajaxForm" : "/js/Forms/ajaxForm.js?v=2495accedcca79bfaaf91112fc806211", + "clearinput" : "/js/Forms/clearinput.js?v=f952099c61d908ecfd20945ff3a65bb8", + "customValidators" : "/js/Forms/customValidators.js?v=9d1c6944ad2ae64f6a62a850615f46f5", + "password" : "/js/Forms/password.js?v=0800d4a64a18db0539353b3c164035a4", + "select" : "/js/Forms/select.js?v=fe30895e5b07dd055a01b3a59b6547d3", + "serialize" : "/js/Forms/serialize.js?v=c28cbc5b081877015757d132c5b35782", + "textarea" : "/js/Forms/textarea.js?v=f1642a563036a57c9624c192d87aa469", + "validateform" : "/js/Forms/validateform.js?v=985f6e79fafbcbec37e5e402ab15e028", + "lazyload" : "/js/Images/lazyload.js?v=89be6f6bb00069e9e6f44fd92d8411ad", + "modal" : "/js/Modals/modal.js?v=61dd71d2ba09315203bc8441bcc34bd6", + "breadcrumb" : "/js/Plugins/breadcrumb.js?v=bdaf9241d83ff5f65bbc0e5ed98cc9c4", + "copy" : "/js/Plugins/copy.js?v=d36c7349e15f8fde0e9ec1da3590f6fc", + "expand" : "/js/Plugins/expand.js?v=ef81bcd6e9aae73a2efc65824a898e17", + "expandText" : "/js/Plugins/expandText.js?v=b9fd83f7cd6745320da3dc306a01d56d", + "fileinput" : "/js/Plugins/fileinput.js?v=308a2b1236206fe9731663602a85dd9e", + "storesMap" : "/js/Plugins/storesMap.js?v=fc13d3766f9dd29edd545c5e0bae3be9 ", + "gallery" : "/js/Plugins/gallery.js?v=f416dfe714165f369357cd3b0072e1f8", + "infoPopup" : "/js/Plugins/infoPopup.js?v=7c6321b0e54f2e1ac3ea839601ab3a60", + "initialize" : "/js/Plugins/initialize.js?v=88bdc01af2fb2662cb0ebbd0331405d9", + "intersecting" : "/js/Plugins/intersecting.js?v=f512e809cee486f75547f2972f2d43f8", + "menu" : "/js/Plugins/menu.js?v=4f0519e4c94480e6ffe0e3ff42e440a0", + "quantity" : "/js/Plugins/quantity.js?v=20686640c790efc982398096c1ba3318", + "scrollShadowHor" : "/js/Plugins/scrollShadowHor.js?v=ef0011e4a4cae3e41f5a972da7c4f018", + "scrollShadowVert" : "/js/Plugins/scrollShadowVert.js?v=5cf4e39837dc5248f61c3b09cfc564ce", + "tabs" : "/js/Plugins/tabs.js?v=3eb292e962fe05e6b88fe6a67d499cfd", + "tabtoggle" : "/js/Plugins/tabtoggle.js?v=d0172c6b70d8a11987dd918371e6bbed", + "tooltip" : "/js/Plugins/tooltip.js?v=28db1f23b82105788276e1c131a255fb", + "productHeader" : "/js/Products/productHeader.js?v=76be9683b425619ba9a22d77d28094f8", + "productImageModal" : "/js/Products/productImageModal.js?v=8d4b7a7d53ec8ff7ed2f97fa056b9c57", + "productattr" : "/js/Products/productattr.js?v=4ea6e244aac56d6fdcb0c667efaf9467", + "productsSlider" : "/js/Sliders/productsSlider.js?v=e0f8e7383b33e767d6dd60a4a14e0702", + "slider" : "/js/Sliders/slider.js?v=69e22b18d920ebde775914f7aa27980a", + "Event" : "/js/Utils/Event.js?v=8fcacd0d87a348d4f94b28b148db09e8", + "EventUtils" : "/js/Utils/EventUtils.js?v=bd22544287a19d5706bfe73be7b94a97", + "apiready" : "/js/Utils/apiready.js?v=dae714af7b8790772fa5020ddeef2ee4", + "confirm" : "/js/Utils/confirm.js?v=64529e92fff00123fd7f9e84e506da30", + "debounce" : "/js/Utils/debounce.js?v=694137b20dea810855190c3a4bf4f90f", + "defineApi" : "/js/Utils/defineApi.js?v=26f753bd841f834492f0da934e2b1985", + "destroyevent" : "/js/Utils/destroyevent.js?v=44de7d3569a3e9ae237289b37b9d78cc", + "enabled" : "/js/Utils/enabled.js?v=e5da7f701cfbb9c543afd313bdfc7f4c", + "getApis" : "/js/Utils/getApis.js?v=775b9f26e7ceb75ea89e35d778366b94", + "throttle" : "/js/Utils/throttle.js?v=a9791e5d08a66c0d4d865d6402b570ec", + "whenAll" : "/js/Utils/whenAll.js?v=d97769699ea77dd77cf94ba277115fcc", + "wishlistbutton" : "/js/Wishlist/wishlistbutton.js?v=3a7ff545e51b1ecc0b8652df20f48983", + "tinySlider": "/js/Plugins/accordion.js?v=b4e153c6b93d97280a9e22ca49f95f53", + + + // MODALS + //////////////////////////////////////////////////////////////////////////// + "modal_handling" : "/js/Modals/modal_handling.js?v=0.7", + "delivery-options" : "/js/Modals/delivery_options.js?v=0.2", + "timeslot_selection" : "/js/Modals/timeslot_selection.js?v=0.2", + "timeslot_swiper" : "/js/Modals/timeslot_swiper.js?v=0.2", + "productSliderModal" : "/js/Modals/productSliderModal.js?v=0.1", + + // CUSTOM CODE pluginified + //////////////////////////////////////////////////////////////////////////// + + "nomades" : "/js/Utils/nomades.js?v=0.1", + + + "miniCartElement" : "/js/Cart/components/miniCartElement.js", + "minicart" : "/js/Cart/miniCart.js", + "productTile" : "/js/Products/components/productTile.js?v=8372ca26c2f2685ede00b97011c1e59e", + "categoryTile" : "/js/Products/components/categoryTile.js?v=daee0a1e62abc426b049febecf7c5b0e", + "basketProduct" : "/js/Basket/components/basketProduct.js", + "customers" : "/js/Customers/customers.js?v=4057b7d7bf81b6b8ad0cb1dfe0f98e83", + "suggestions" : "/js/Search/suggestions.js?v=cb9005bbf77c2279df411f296627a7a2", + "productDetails": "/js/Products/components/productDetails.js", + "emarket": "/js/emarket/emarket.js", + "productUtils": "/js/Products/productUtils.js", + "create_list": "/js/Customers/create_list.js", + "customersLists": "/js/Customers/customersLists.js", + "customerListElements": "/js/Customers/components/customerListElements.js", + "customerListTile": "/js/Products/components/customerListTile.js", + "productFilter" : "/js/Products/components/productFilter.js", + "basket": "/js/Basket/basket.js", + "forgot_password": "js/Customers/forgot_password.js?v=2" +});
\ No newline at end of file diff --git a/public/assets/js/_dependency-control/require/require.slim.js b/public/assets/js/_dependency-control/require/require.slim.js new file mode 100644 index 0000000..f42cea6 --- /dev/null +++ b/public/assets/js/_dependency-control/require/require.slim.js @@ -0,0 +1,492 @@ +(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 |
