diff --git a/src/_h5ai/js/inc/core/entry.js b/src/_h5ai/js/inc/core/entry.js index b86bfd23..033970b3 100644 --- a/src/_h5ai/js/inc/core/entry.js +++ b/src/_h5ai/js/inc/core/entry.js @@ -1,5 +1,5 @@ -module.define('core/entry', [jQuery, 'core/parser', 'model/entry'], function ($, parser, Entry) { +modulejs.define('core/entry', ['jQuery', 'core/parser', 'model/entry'], function ($, parser, Entry) { var absHref = document.location.pathname.replace(/[^\/]*$/, ''); diff --git a/src/_h5ai/js/inc/core/event.js b/src/_h5ai/js/inc/core/event.js index f8e84334..81ce4284 100644 --- a/src/_h5ai/js/inc/core/event.js +++ b/src/_h5ai/js/inc/core/event.js @@ -1,5 +1,5 @@ -module.define('core/event', [amplify], function (amplify) { +modulejs.define('core/event', ['amplify'], function (amplify) { var sub = function (topic, callback) { diff --git a/src/_h5ai/js/inc/core/format.js b/src/_h5ai/js/inc/core/format.js index c2008664..4fbeba5a 100644 --- a/src/_h5ai/js/inc/core/format.js +++ b/src/_h5ai/js/inc/core/format.js @@ -1,5 +1,5 @@ -module.define('core/format', [moment], function (moment) { +modulejs.define('core/format', ['moment'], function (moment) { var reParseSize = /^\s*([\.\d]+)\s*([kmgt]?)b?\s*$/i, treshhold = 1000.0, diff --git a/src/_h5ai/js/inc/core/parser.js b/src/_h5ai/js/inc/core/parser.js index b5daacb5..0f06d463 100644 --- a/src/_h5ai/js/inc/core/parser.js +++ b/src/_h5ai/js/inc/core/parser.js @@ -1,11 +1,11 @@ -module.define('core/parser', [jQuery], function ($) { +modulejs.define('core/parser', ['jQuery'], function ($) { if ($('#data-apache-autoindex').length) { - return module.require('parser/apache-autoindex'); + return modulejs.require('parser/apache-autoindex'); } if ($('#data-generic-json').length) { - return module.require('parser/generic-json'); + return modulejs.require('parser/generic-json'); } return { diff --git a/src/_h5ai/js/inc/core/resource.js b/src/_h5ai/js/inc/core/resource.js index add1636a..17baed3c 100644 --- a/src/_h5ai/js/inc/core/resource.js +++ b/src/_h5ai/js/inc/core/resource.js @@ -1,5 +1,5 @@ -module.define('core/resource', ['core/settings'], function (settings) { +modulejs.define('core/resource', ['core/settings'], function (settings) { var api = function () { diff --git a/src/_h5ai/js/inc/core/settings.js b/src/_h5ai/js/inc/core/settings.js index e279cc2c..bbb74f32 100644 --- a/src/_h5ai/js/inc/core/settings.js +++ b/src/_h5ai/js/inc/core/settings.js @@ -1,5 +1,5 @@ -module.define('core/settings', [H5AI_CONFIG], function (config) { +modulejs.define('core/settings', ['H5AI_CONFIG'], function (config) { var defaults = { rootAbsHref: '/', @@ -12,7 +12,7 @@ module.define('core/settings', [H5AI_CONFIG], function (config) { }); -module.define('core/types', [H5AI_CONFIG], function (config) { +modulejs.define('core/types', ['H5AI_CONFIG'], function (config) { var reEndsWithSlash = /\/$/, reStartsWithDot = /^\./, @@ -61,7 +61,7 @@ module.define('core/types', [H5AI_CONFIG], function (config) { }); -module.define('core/langs', [H5AI_CONFIG], function (config) { +modulejs.define('core/langs', ['H5AI_CONFIG'], function (config) { var defaults = { lang: 'unknown', diff --git a/src/_h5ai/js/inc/core/store.js b/src/_h5ai/js/inc/core/store.js index 04d297b1..ca7f6715 100644 --- a/src/_h5ai/js/inc/core/store.js +++ b/src/_h5ai/js/inc/core/store.js @@ -1,5 +1,5 @@ -module.define('core/store', [amplify], function (amplify) { +modulejs.define('core/store', ['amplify'], function (amplify) { var put = function (key, value) { diff --git a/src/_h5ai/js/inc/ext/crumb.js b/src/_h5ai/js/inc/ext/crumb.js index d34dfb55..8622a546 100644 --- a/src/_h5ai/js/inc/ext/crumb.js +++ b/src/_h5ai/js/inc/ext/crumb.js @@ -1,5 +1,5 @@ -module.define('ext/crumb', [jQuery, 'core/settings', 'core/resource', 'core/entry'], function ($, allsettings, resource, entry) { +modulejs.define('ext/crumb', ['jQuery', 'core/settings', 'core/resource', 'core/entry'], function ($, allsettings, resource, entry) { var defaults = { enabled: false diff --git a/src/_h5ai/js/inc/ext/custom.js b/src/_h5ai/js/inc/ext/custom.js index 2154026d..dd5fce91 100644 --- a/src/_h5ai/js/inc/ext/custom.js +++ b/src/_h5ai/js/inc/ext/custom.js @@ -1,5 +1,5 @@ -module.define('ext/custom', [jQuery, 'core/settings'], function ($, allsettings) { +modulejs.define('ext/custom', ['jQuery', 'core/settings'], function ($, allsettings) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/download.js b/src/_h5ai/js/inc/ext/download.js index cc88cb1c..af007f37 100644 --- a/src/_h5ai/js/inc/ext/download.js +++ b/src/_h5ai/js/inc/ext/download.js @@ -1,5 +1,5 @@ -module.define('ext/download', [jQuery, 'core/settings', 'core/resource', 'core/event'], function ($, allsettings, resource, event) { +modulejs.define('ext/download', ['jQuery', 'core/settings', 'core/resource', 'core/event'], function ($, allsettings, resource, event) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/filter.js b/src/_h5ai/js/inc/ext/filter.js index 67762858..b0ce24cf 100644 --- a/src/_h5ai/js/inc/ext/filter.js +++ b/src/_h5ai/js/inc/ext/filter.js @@ -1,5 +1,5 @@ -module.define('ext/filter', [jQuery, 'core/settings', 'core/resource'], function ($, allsettings, resource) { +modulejs.define('ext/filter', ['jQuery', 'core/settings', 'core/resource'], function ($, allsettings, resource) { var defaults = { enabled: false diff --git a/src/_h5ai/js/inc/ext/folderstatus.js b/src/_h5ai/js/inc/ext/folderstatus.js index c4d95254..9d1326ad 100644 --- a/src/_h5ai/js/inc/ext/folderstatus.js +++ b/src/_h5ai/js/inc/ext/folderstatus.js @@ -1,5 +1,5 @@ -module.define('ext/folderstatus', [jQuery, 'core/settings'], function ($, allsettings) { +modulejs.define('ext/folderstatus', ['jQuery', 'core/settings'], function ($, allsettings) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/l10n.js b/src/_h5ai/js/inc/ext/l10n.js index 5598f41e..ca8ed7bd 100644 --- a/src/_h5ai/js/inc/ext/l10n.js +++ b/src/_h5ai/js/inc/ext/l10n.js @@ -1,5 +1,5 @@ -module.define('ext/l10n', [jQuery, 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event'], function ($, allsettings, langs, format, store, event) { +modulejs.define('ext/l10n', ['jQuery', 'core/settings', 'core/langs', 'core/format', 'core/store', 'core/event'], function ($, allsettings, langs, format, store, event) { var defaults = { enabled: true, diff --git a/src/_h5ai/js/inc/ext/link-hover-states.js b/src/_h5ai/js/inc/ext/link-hover-states.js index ea65755f..5b5db61e 100644 --- a/src/_h5ai/js/inc/ext/link-hover-states.js +++ b/src/_h5ai/js/inc/ext/link-hover-states.js @@ -1,5 +1,5 @@ -module.define('ext/link-hover-states', [jQuery, 'core/settings'], function ($, allsettings) { +modulejs.define('ext/link-hover-states', ['jQuery', 'core/settings'], function ($, allsettings) { var defaults = { enabled: false diff --git a/src/_h5ai/js/inc/ext/mode.js b/src/_h5ai/js/inc/ext/mode.js index 90cdf9ae..7253d9df 100644 --- a/src/_h5ai/js/inc/ext/mode.js +++ b/src/_h5ai/js/inc/ext/mode.js @@ -1,5 +1,5 @@ -module.define('ext/mode', [jQuery, 'core/settings', 'core/parser'], function ($, allsettings, parser) { +modulejs.define('ext/mode', ['jQuery', 'core/settings', 'core/parser'], function ($, allsettings, parser) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/preview-img.js b/src/_h5ai/js/inc/ext/preview-img.js index 6f601d2c..814abef2 100644 --- a/src/_h5ai/js/inc/ext/preview-img.js +++ b/src/_h5ai/js/inc/ext/preview-img.js @@ -1,5 +1,5 @@ -module.define('ext/preview-img', [jQuery, 'core/settings', 'core/resource', 'core/store', 'core/entry'], function ($, allsettings, resource, store, entry) { +modulejs.define('ext/preview-img', ['jQuery', 'core/settings', 'core/resource', 'core/store', 'core/entry'], function ($, allsettings, resource, store, entry) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/qrcode.js b/src/_h5ai/js/inc/ext/qrcode.js index 62b15304..c325009a 100644 --- a/src/_h5ai/js/inc/ext/qrcode.js +++ b/src/_h5ai/js/inc/ext/qrcode.js @@ -1,5 +1,5 @@ -module.define('ext/qrcode', [jQuery, 'core/settings', 'core/event'], function ($, allsettings, event) { +modulejs.define('ext/qrcode', ['jQuery', 'core/settings', 'core/event'], function ($, allsettings, event) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/select.js b/src/_h5ai/js/inc/ext/select.js index eb0ea1ba..c19d600c 100644 --- a/src/_h5ai/js/inc/ext/select.js +++ b/src/_h5ai/js/inc/ext/select.js @@ -1,5 +1,5 @@ -module.define('ext/select', [jQuery, 'core/settings', 'core/event'], function ($, allsettings, event) { +modulejs.define('ext/select', ['jQuery', 'core/settings', 'core/event'], function ($, allsettings, event) { var defaults = { enabled: false diff --git a/src/_h5ai/js/inc/ext/sort.js b/src/_h5ai/js/inc/ext/sort.js index c30efef1..9b12b0cd 100644 --- a/src/_h5ai/js/inc/ext/sort.js +++ b/src/_h5ai/js/inc/ext/sort.js @@ -1,5 +1,5 @@ -module.define('ext/sort', [jQuery, 'core/settings', 'core/resource', 'core/store'], function ($, allsettings, resource, store) { +modulejs.define('ext/sort', ['jQuery', 'core/settings', 'core/resource', 'core/store'], function ($, allsettings, resource, store) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/statusbar.js b/src/_h5ai/js/inc/ext/statusbar.js index e8d9b16c..6d985e44 100644 --- a/src/_h5ai/js/inc/ext/statusbar.js +++ b/src/_h5ai/js/inc/ext/statusbar.js @@ -1,5 +1,5 @@ -module.define('ext/statusbar', [jQuery, 'core/settings', 'core/format', 'core/event', 'core/entry'], function ($, allsettings, format, event, entry) { +modulejs.define('ext/statusbar', ['jQuery', 'core/settings', 'core/format', 'core/event', 'core/entry'], function ($, allsettings, format, event, entry) { var defaults = { enabled: false diff --git a/src/_h5ai/js/inc/ext/thumbnails.js b/src/_h5ai/js/inc/ext/thumbnails.js index 896e25e2..2dac49fb 100644 --- a/src/_h5ai/js/inc/ext/thumbnails.js +++ b/src/_h5ai/js/inc/ext/thumbnails.js @@ -1,5 +1,5 @@ -module.define('ext/thumbnails', [jQuery, 'core/settings', 'core/resource', 'core/entry'], function ($, allsettings, resource, entry) { +modulejs.define('ext/thumbnails', ['jQuery', 'core/settings', 'core/resource', 'core/entry'], function ($, allsettings, resource, entry) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/ext/title.js b/src/_h5ai/js/inc/ext/title.js index d49081f1..2a9097e1 100644 --- a/src/_h5ai/js/inc/ext/title.js +++ b/src/_h5ai/js/inc/ext/title.js @@ -1,5 +1,5 @@ -module.define('ext/title', [jQuery, 'core/settings', 'core/entry'], function ($, allsettings, entry) { +modulejs.define('ext/title', ['jQuery', 'core/settings', 'core/entry'], function ($, allsettings, entry) { var defaults = { enabled: false diff --git a/src/_h5ai/js/inc/ext/tree.js b/src/_h5ai/js/inc/ext/tree.js index 014dc0f2..3d2decc2 100644 --- a/src/_h5ai/js/inc/ext/tree.js +++ b/src/_h5ai/js/inc/ext/tree.js @@ -1,5 +1,5 @@ -module.define('ext/tree', [jQuery, 'core/settings', 'core/resource', 'core/event', 'core/entry', 'core/parser'], function ($, allsettings, resource, event, entry, parser) { +modulejs.define('ext/tree', ['jQuery', 'core/settings', 'core/resource', 'core/event', 'core/entry', 'core/parser'], function ($, allsettings, resource, event, entry, parser) { var defaults = { enabled: false, diff --git a/src/_h5ai/js/inc/h5ai-info.js b/src/_h5ai/js/inc/h5ai-info.js index 9ad9bd48..640fd3b5 100644 --- a/src/_h5ai/js/inc/h5ai-info.js +++ b/src/_h5ai/js/inc/h5ai-info.js @@ -1,5 +1,5 @@ -module.define('h5ai-info', [jQuery, 'core/resource'], function ($, resource) { +modulejs.define('h5ai-info', ['jQuery', 'core/resource'], function ($, resource) { var setCheckResult = function (id, result) { diff --git a/src/_h5ai/js/inc/h5ai-main.js b/src/_h5ai/js/inc/h5ai-main.js index 222d1f64..19003056 100644 --- a/src/_h5ai/js/inc/h5ai-main.js +++ b/src/_h5ai/js/inc/h5ai-main.js @@ -1,18 +1,19 @@ -module.define('h5ai-main', [jQuery, 'core/event', 'core/settings'], function ($, event, settings) { +modulejs.define('h5ai-main', ['jQuery', 'core/event', 'core/settings'], function ($, event, settings) { event.pub('beforeView'); - module.require('view/extended'); - module.require('view/viewmode'); - module.require('view/spacing'); + modulejs.require('view/extended'); + modulejs.require('view/viewmode'); + modulejs.require('view/spacing'); event.pub('beforeExt'); - _.each(module.getIds(/^ext\/.+/), function (id) { + // _.each(modulejs.getIds(/^ext\/.+/), function (id) { - module.require(id); - }); + // modulejs.require(id); + // }); + modulejs.require(/^ext\/.+/); event.pub('ready'); }); diff --git a/src/_h5ai/js/inc/lib/module.js b/src/_h5ai/js/inc/lib/module.js deleted file mode 100644 index 689d5271..00000000 --- a/src/_h5ai/js/inc/lib/module.js +++ /dev/null @@ -1,198 +0,0 @@ -/*! - * module.js - * author: Lars Jung - * license: MIT - */ - -(function (global, name) { - 'use strict'; - - var err = function (message) { - - throw name + ' exception: ' + message; - }; - - if (!_) { - err(name + ' depends on underscore'); - } - - var self = {}, - previous = global[name], - - noConflict = function () { - - if (global[name] === self) { - global[name] = previous; - } - return self; - }, - - definitions = {}, - modules = {}, - - findDepsUnsafe = function (ids) { - - var self = this; - var deps = []; - - if (_.isString(ids)) { - - var def = definitions[ids]; - if (def) { - _.each(def.deps, function (id) { - - deps = deps.concat(findDepsUnsafe(id)); - }); - deps.push(def.id); - } else { - deps.push(ids); - } - } else if (_.isArray(ids)) { - - _.each(ids, function (id) { - - deps = deps.concat(findDepsUnsafe(id)); - }); - } - - return _.uniq(deps); - }, - - findDeps = function (ids) { - - if (ids) { - try { - return findDepsUnsafe(ids); - } catch (e) { - err('cyclic dependencies for ids "' + ids + '"'); - } - } else { - var res = {}; - _.each(definitions, function (def, id) { - - res[id] = findDeps(id); - }); - return res; - } - }, - - log = function (showInvDeps) { - - var allDeps = findDeps(), - allInvDeps = {}, - out = ''; - - if (!showInvDeps) { - _.each(allDeps, function (deps, id) { - - deps.pop(); - out += (_.has(modules, id) ? '* ' : ' ') + id + ' -> [ ' + deps.join(', ') + ' ]\n'; - }); - } else { - _.each(definitions, function (def) { - - var invDeps = []; - _.each(allDeps, function (depIds, id) { - - if (_.indexOf(depIds, def.id) >= 0) { - invDeps.push(id); - } - }); - allInvDeps[def.id] = invDeps; - }); - - _.each(allInvDeps, function (invDeps, id) { - - invDeps.shift(); - out += (_.has(modules, id) ? '* ' : ' ') + id + ' <- [ ' + invDeps.join(', ') + ' ]\n'; - }); - } - - return out; - }, - - define = function (id, deps, fn) { - - if (_.isFunction(deps)) { - fn = deps; - deps = []; - } - if (!_.isString(id)) { - err('id must be a string "' + id + '"'); - } - if (!_.isArray(deps)) { - err('dependencies must be an array "' + deps + '"'); - } - if (!_.isFunction(fn)) { - err('constructor must be a function "' + fn + '"'); - } - if (definitions[id]) { - err('id already defined "' + id + '"'); - } - - definitions[id] = { - id: id, - deps: deps, - fn: fn - }; - }, - - getIds = function (regexp) { - - var ids = _.map(definitions, function (def) { - - return def.id; - }); - - if (!_.isRegExp(regexp)) { - return ids; - } - - return _.filter(ids, function (id) { - - return regexp.test(id); - }); - }, - - isDefined = function (id) { - - return _.isString(id) ? !!definitions[id] : !!id; - }, - - require = function (id) { - - if (!_.isString(id)) { - return id; - } - - if (_.has(modules, id)) { - return modules[id]; - } - - var def = definitions[id]; - if (!def) { - err('id not defined "' + id + '"'); - } - - var deps = _.map(def.deps, function (depId) { - - return require(depId); - }); - - var obj = def.fn.apply(this, deps); - modules[id] = obj; - return obj; - }; - - _.extend(self, { - noConflict: noConflict, - log: log, - define: define, - require: require, - getIds: getIds, - isDefined: isDefined - }); - - global[name] = self; - -}(this, 'module')); diff --git a/src/_h5ai/js/inc/lib/modulejs-0.1.js b/src/_h5ai/js/inc/lib/modulejs-0.1.js new file mode 100644 index 00000000..ff7dfd54 --- /dev/null +++ b/src/_h5ai/js/inc/lib/modulejs-0.1.js @@ -0,0 +1,168 @@ +/*! modulejs 0.1 - //larsjung.de/qrcode - MIT License */ + +(function (global, _, name) { + 'use strict'; + + + // throws error + var err = function (condition, code, message) { + + if (condition) { + if (console && console.error) { + console.error(name + ' error: [' + code + '] ' + message); + } + throw { + code: code, + msg: name + ' error: ' + message + }; + } + }; + + // make sure underscore is loaded + err(!_, 1, name + ' requires underscore'); + + + // ModuleJs + // ======== + var ModuleJs = function () { + + var self = this; + + // module definitions + self.definitions = {}; + + // module instances + self.instances = {}; + + // define + // ------ + // Defines a module. + self.define = function (id, deps, fn) { + + // sort arguments + if (_.isFunction(deps)) { + fn = deps; + deps = []; + } + // check arguments + err(!_.isString(id), 11, 'id must be a string "' + id + '"'); + err(self.definitions[id], 12, 'id already defined "' + id + '"'); + err(!_.isFunction(fn), 13, 'constructor for "' + id + '" must be a function "' + fn + '"'); + err(!_.isArray(deps), 14, 'dependencies for "' + id + '" must be an array "' + deps + '"'); + + // map definition + self.definitions[id] = { + id: id, + deps: deps, + fn: fn + }; + }; + + // predefined + // ---------- + // Registers a predefined object. + self.predefined = function (id, instance, check) { + + if (_.isFunction(check)) { + check = !!check(); + } + if (!_.isBoolean(check)) { + check = instance !== undefined; + } + err(!check, 21, 'check for predefined "' + id + '" failed'); + + self.define(id, [], function () { + + return instance; + }); + }; + + // Returns an instance for `id`, checked against require-`stack` for + // cyclic dependencies. + self._require = function (id, stack) { + + err(!_.isString(id), 31, 'id must be a string "' + id + '"'); + + if (_.has(self.instances, id)) { + return self.instances[id]; + } + + var def = self.definitions[id]; + err(!def, 32, 'id not defined "' + id + '"'); + + stack = (stack || []).slice(0); + stack.push(id); + var deps = _.map(def.deps, function (depId) { + + err(_.indexOf(stack, depId) >= 0, 33, 'cyclic dependencies: ' + stack + ' & ' + depId); + + return self._require(depId, stack); + }); + + var obj = def.fn.apply(global, deps); + self.instances[id] = obj; + return obj; + }; + + // require + // ------- + // Returns an instance for `id`. + self.require = function (arg) { + + if (_.isArray(arg)) { + + return _.map(arg, function (id) { + + return self._require(id); + }); + } + + if (_.isRegExp(arg)) { + + var res = {}; + _.each(_.keys(self.definitions), function (id) { + + if (arg.test(id)) { + res[id] = self._require(id); + } + }); + return res; + } + + return self._require(arg); + }; + + // Registers public API on the global object. + self.register = function (name) { + + var previous = global[name], + api = { + define: self.define, + predefined: self.predefined, + require: self.require, + noConflict: function () { + + if (global[name] === api) { + global[name] = previous; + } + return api; + } + }; + + global[name] = api; + }; + }; + + + var modulejs = new ModuleJs(); + modulejs.register(name); + + + // debugger + // -------- + var debugName = name.toUpperCase(); + if (_.isFunction(global[debugName])) { + global[debugName] = new global[debugName](modulejs); + } + +}(this, _, 'modulejs')); diff --git a/src/_h5ai/js/inc/lib/modulejs-debug-0.1.js b/src/_h5ai/js/inc/lib/modulejs-debug-0.1.js new file mode 100644 index 00000000..5f4f7b7c --- /dev/null +++ b/src/_h5ai/js/inc/lib/modulejs-debug-0.1.js @@ -0,0 +1,133 @@ +/*! modulejs-debug 0.1 - //larsjung.de/qrcode - MIT License */ + +(function (global, _, name) { + 'use strict'; + + + var Debugger = function (modulejs) { + + + var self = this; + + + self.modulejs = modulejs; + + + self.clear = function () { + + modulejs.definitions = {}; + modulejs.instances = {}; + }; + + + self.isDefined = function (id) { + + return _.isString(id) && !!modulejs.definitions[id]; + }; + + + self.ids = function (regexp) { + + var ids = _.map(modulejs.definitions, function (def) { + + return def.id; + }); + + if (!_.isRegExp(regexp)) { + return ids; + } + + return _.filter(ids, function (id) { + + return regexp.test(id); + }); + }; + + + var _deps = function (id, stack) { + + var deps = []; + + var def = modulejs.definitions[id]; + if (def) { + stack = (stack || []).slice(0); + stack.push(id); + _.each(def.deps, function (depId) { + + if (_.indexOf(stack, depId) >= 0) { + deps = deps.concat([false, def.id]); + return deps; + } + + deps = deps.concat(_deps(depId, stack)); + deps.push(depId); + }); + } + + return _.uniq(deps); + }; + + + self.deps = function (ids) { + + if (_.isString(ids)) { + + return _deps(ids); + } else if (_.isArray(ids)) { + + var deps = []; + _.each(ids, function (id) { + + deps = deps.concat(_deps(id)); + }); + return _.uniq(deps); + } + + var res = {}; + _.each(modulejs.definitions, function (def, id) { + + res[id] = _deps(id); + }); + return res; + }; + + + self.log = function (showInvDeps) { + + var allDeps = self.deps(), + allInvDeps = {}, + out = '\n'; + + if (!showInvDeps) { + _.each(allDeps, function (deps, id) { + + out += (_.has(modulejs.instances, id) ? '* ' : ' ') + id + ' -> [ ' + deps.join(', ') + ' ]\n'; + }); + } else { + _.each(modulejs.definitions, function (def) { + + var invDeps = []; + _.each(allDeps, function (depIds, id) { + + if (_.indexOf(depIds, def.id) >= 0) { + invDeps.push(id); + } + }); + allInvDeps[def.id] = invDeps; + }); + + _.each(allInvDeps, function (invDeps, id) { + + out += (_.has(modulejs.instances, id) ? '* ' : ' ') + id + ' <- [ ' + invDeps.join(', ') + ' ]\n'; + }); + } + + return out; + }; + }; + + + global[name.toUpperCase()] = Debugger; + + +}(this, _, 'modulejs')); diff --git a/src/_h5ai/js/inc/main.js b/src/_h5ai/js/inc/main.js index d59debb8..9c116a76 100644 --- a/src/_h5ai/js/inc/main.js +++ b/src/_h5ai/js/inc/main.js @@ -2,6 +2,12 @@ (function ($) { 'use strict'; + modulejs.predefined('jQuery', jQuery); + modulejs.predefined('amplify', amplify); + modulejs.predefined('moment', moment); + modulejs.predefined('H5AI_CONFIG', H5AI_CONFIG); + + // @include "core/entry.js" // @include "core/event.js" // @include "core/format.js" @@ -42,7 +48,7 @@ $(function () { - module.require($('body').attr('id')); + modulejs.require($('body').attr('id')); }); }(jQuery)); diff --git a/src/_h5ai/js/inc/model/entry.js b/src/_h5ai/js/inc/model/entry.js index 22052ee3..b6c2730e 100644 --- a/src/_h5ai/js/inc/model/entry.js +++ b/src/_h5ai/js/inc/model/entry.js @@ -1,5 +1,5 @@ -module.define('model/entry', [jQuery, 'core/types'], function ($, types) { +modulejs.define('model/entry', ['jQuery', 'core/types'], function ($, types) { var domain = document.domain, location = document.location.pathname.replace(/[^\/]*$/, ''), @@ -132,7 +132,14 @@ module.define('model/entry', [jQuery, 'core/types'], function ($, types) { return self; }, - folderstatus = module.isDefined('ext/folderstatus') ? module.require('ext/folderstatus') : {}, + // folderstatus = module.isDefined('ext/folderstatus') ? module.require('ext/folderstatus') : {}, + folderstatus = (function () { + + var id = 'ext/folderstatus', + res = modulejs.require(new RegExp('^' + id + '$')); + + return res.id ? res.id : {}; + }()), fetchStatus = function (absHref, callback) { diff --git a/src/_h5ai/js/inc/parser/apache-autoindex.js b/src/_h5ai/js/inc/parser/apache-autoindex.js index e0c244f2..caa1d71a 100644 --- a/src/_h5ai/js/inc/parser/apache-autoindex.js +++ b/src/_h5ai/js/inc/parser/apache-autoindex.js @@ -1,5 +1,5 @@ -module.define('parser/apache-autoindex', [jQuery, 'core/settings', 'core/format', 'model/entry'], function ($, settings, format, Entry) { +modulejs.define('parser/apache-autoindex', ['jQuery', 'core/settings', 'core/format', 'model/entry'], function ($, settings, format, Entry) { var parseTableRow = function (absHref, tr) { diff --git a/src/_h5ai/js/inc/parser/generic-json.js b/src/_h5ai/js/inc/parser/generic-json.js index 64157102..672377b5 100644 --- a/src/_h5ai/js/inc/parser/generic-json.js +++ b/src/_h5ai/js/inc/parser/generic-json.js @@ -1,5 +1,5 @@ -module.define('parser/generic-json', [jQuery, 'core/settings', 'model/entry'], function ($, settings, Entry) { +modulejs.define('parser/generic-json', ['jQuery', 'core/settings', 'model/entry'], function ($, settings, Entry) { var parser = { id: 'generic-json', diff --git a/src/_h5ai/js/inc/view/extended.js b/src/_h5ai/js/inc/view/extended.js index 04dba993..a1f29e37 100644 --- a/src/_h5ai/js/inc/view/extended.js +++ b/src/_h5ai/js/inc/view/extended.js @@ -1,5 +1,5 @@ -module.define('view/extended', [jQuery, 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/entry'], function ($, allsettings, resource, format, event, entry) { +modulejs.define('view/extended', ['jQuery', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/entry'], function ($, allsettings, resource, format, event, entry) { var defaults = { modes: ['details', 'icons'], diff --git a/src/_h5ai/js/inc/view/spacing.js b/src/_h5ai/js/inc/view/spacing.js index 77e37784..6055fa8c 100644 --- a/src/_h5ai/js/inc/view/spacing.js +++ b/src/_h5ai/js/inc/view/spacing.js @@ -1,5 +1,5 @@ -module.define('view/spacing', [jQuery, 'core/settings', 'core/event'], function ($, allsettings, event) { +modulejs.define('view/spacing', ['jQuery', 'core/settings', 'core/event'], function ($, allsettings, event) { var defaults = { maxWidth: 960, diff --git a/src/_h5ai/js/inc/view/viewmode.js b/src/_h5ai/js/inc/view/viewmode.js index c78ed480..a321acbb 100644 --- a/src/_h5ai/js/inc/view/viewmode.js +++ b/src/_h5ai/js/inc/view/viewmode.js @@ -1,5 +1,5 @@ -module.define('view/viewmode', [jQuery, 'core/settings', 'core/resource', 'core/store'], function ($, allsettings, resource, store) { +modulejs.define('view/viewmode', ['jQuery', 'core/settings', 'core/resource', 'core/store'], function ($, allsettings, resource, store) { var defaults = { modes: ['details', 'list', 'icons'], diff --git a/src/_h5ai/js/scripts.js b/src/_h5ai/js/scripts.js index 3e40e7e2..889b2ebe 100644 --- a/src/_h5ai/js/scripts.js +++ b/src/_h5ai/js/scripts.js @@ -10,7 +10,8 @@ // underscore libs // --------------- // @include "inc/lib/underscore-1.3.1.min.js" -// @include "inc/lib/module.js" +// @-include "inc/lib/modulejs-debug-0.1.js" +// @include "inc/lib/modulejs-0.1.js" // other libs // ----------