diff --git a/app/assets/javascripts/discourse-loader.js b/app/assets/javascripts/discourse-loader.js index 3a86a00da13..6809670b937 100644 --- a/app/assets/javascripts/discourse-loader.js +++ b/app/assets/javascripts/discourse-loader.js @@ -1,18 +1,21 @@ var define, requirejs; (function() { - var MOVED_MODULES = { - "discourse/views/list/post-count-or-badges": "discourse/raw-views/list/post-count-or-badges", - "discourse/views/list/posts-count-column" : "discourse/raw-views/list/posts-count-column", - "discourse/views/list/visited-line" : "discourse/raw-views/list/visited-line", - "discourse/views/topic-list-header-column" : "discourse/raw-views/topic-list-header-column", - "discourse/views/topic-status" : "discourse/raw-views/topic-status" + "discourse/views/list/post-count-or-badges": + "discourse/raw-views/list/post-count-or-badges", + "discourse/views/list/posts-count-column": + "discourse/raw-views/list/posts-count-column", + "discourse/views/list/visited-line": + "discourse/raw-views/list/visited-line", + "discourse/views/topic-list-header-column": + "discourse/raw-views/topic-list-header-column", + "discourse/views/topic-status": "discourse/raw-views/topic-status" }; var _isArray; if (!Array.isArray) { - _isArray = function (x) { + _isArray = function(x) { return Object.prototype.toString.call(x) === "[object Array]"; }; } else { @@ -34,28 +37,34 @@ var define, requirejs; } function unsupportedModule(length) { - throw new Error("an unsupported module was defined, expected `define(name, deps, module)` instead got: `" + length + "` arguments to define`"); + throw new Error( + "an unsupported module was defined, expected `define(name, deps, module)` instead got: `" + + length + + "` arguments to define`" + ); } - var defaultDeps = ['require', 'exports', 'module']; + var defaultDeps = ["require", "exports", "module"]; function Module(name, deps, callback, exports) { - this.id = uuid++; - this.name = name; - this.deps = !deps.length && callback.length ? defaultDeps : deps; - this.exports = exports || { }; + this.id = uuid++; + this.name = name; + this.deps = !deps.length && callback.length ? defaultDeps : deps; + this.exports = exports || {}; this.callback = callback; - this.state = undefined; - this._require = undefined; + this.state = undefined; + this._require = undefined; } - Module.prototype.makeRequire = function() { var name = this.name; - return this._require || (this._require = function(dep) { - return requirejs(resolve(dep, name)); - }); + return ( + this._require || + (this._require = function(dep) { + return requirejs(resolve(dep, name)); + }) + ); }; define = function(name, deps, callback) { @@ -65,7 +74,7 @@ var define, requirejs; if (!_isArray(deps)) { callback = deps; - deps = []; + deps = []; } registry[name] = new Module(name, deps, callback); @@ -74,7 +83,7 @@ var define, requirejs; // we don't support all of AMD // define.amd = {}; // we will support petals... - define.petal = { }; + define.petal = {}; function Alias(path) { this.name = path; @@ -91,15 +100,15 @@ var define, requirejs; var dep; // TODO: new Module // TODO: seen refactor - var module = { }; + var module = {}; for (var i = 0, l = length; i < l; i++) { dep = deps[i]; - if (dep === 'exports') { + if (dep === "exports") { module.exports = reified[i] = rseen; - } else if (dep === 'require') { + } else if (dep === "require") { reified[i] = mod.makeRequire(); - } else if (dep === 'module') { + } else if (dep === "module") { mod.exports = rseen; module = reified[i] = mod; } else { @@ -114,28 +123,29 @@ var define, requirejs; } function requireFrom(name, origin) { - var mod = registry[name]; if (!mod) { var moved = MOVED_MODULES[name]; if (moved) { - console.warn("DEPRECATION: `" + name + "` was moved to `" + moved + "`"); // eslint-disable-line no-console + var msg = "DEPRECATION: `" + name + "` was moved to `" + moved + "`"; + console.warn(msg); // eslint-disable-line no-console } mod = registry[moved]; } if (!mod) { - throw new Error('Could not find module `' + name + '` imported from `' + origin + '`'); + throw new Error( + "Could not find module `" + name + "` imported from `" + origin + "`" + ); } return requirejs(name); } function missingModule(name) { - throw new Error('Could not find module ' + name); + throw new Error("Could not find module " + name); } requirejs = require = function(name) { - if (MOVED_MODULES[name]) { name = MOVED_MODULES[name]; } @@ -146,10 +156,11 @@ var define, requirejs; mod = registry[mod.callback.name]; } - if (!mod) { missingModule(name); } + if (!mod) { + missingModule(name); + } - if (mod.state !== FAILED && - seen.hasOwnProperty(name)) { + if (mod.state !== FAILED && seen.hasOwnProperty(name)) { return seen[name]; } @@ -157,17 +168,20 @@ var define, requirejs; var module; var loaded = false; - seen[name] = { }; // placeholder for run-time cycles + seen[name] = {}; // placeholder for run-time cycles - tryFinally(function() { - reified = reify(mod, name, seen[name]); - module = mod.callback.apply(this, reified.deps); - loaded = true; - }, function() { - if (!loaded) { - mod.state = FAILED; + tryFinally( + function() { + reified = reify(mod, name, seen[name]); + module = mod.callback.apply(this, reified.deps); + loaded = true; + }, + function() { + if (!loaded) { + mod.state = FAILED; + } } - }); + ); var obj; if (module === undefined && reified.module.exports) { @@ -176,10 +190,12 @@ var define, requirejs; obj = seen[name] = module; } - if (obj !== null && - (typeof obj === 'object' || typeof obj === 'function') && - obj['default'] === undefined) { - obj['default'] = obj; + if ( + obj !== null && + (typeof obj === "object" || typeof obj === "function") && + obj["default"] === undefined + ) { + obj["default"] = obj; } return (seen[name] = obj); @@ -187,26 +203,30 @@ var define, requirejs; window.requireModule = requirejs; function resolve(child, name) { - if (child.charAt(0) !== '.') { return child; } + if (child.charAt(0) !== ".") { + return child; + } - var parts = child.split('/'); - var nameParts = name.split('/'); + var parts = child.split("/"); + var nameParts = name.split("/"); var parentBase = nameParts.slice(0, -1); for (var i = 0, l = parts.length; i < l; i++) { var part = parts[i]; - if (part === '..') { + if (part === "..") { if (parentBase.length === 0) { - throw new Error('Cannot access parent module of root'); + throw new Error("Cannot access parent module of root"); } parentBase.pop(); - } else if (part === '.') { + } else if (part === ".") { continue; - } else { parentBase.push(part); } + } else { + parentBase.push(part); + } } - return parentBase.join('/'); + return parentBase.join("/"); } requirejs.entries = requirejs._eak_seen = registry;