Update modulejs.

This commit is contained in:
Lars Jung 2014-08-04 01:26:11 +02:00
parent c777a9f949
commit 80d0952d1f
3 changed files with 94 additions and 46 deletions

View file

@ -7,6 +7,7 @@
* removes True Type fonts
* outsources themes to [h5ai-themes](https://github.com/lrsjng/h5ai-themes)
* replaces `markdown` with [`marked`](https://github.com/chjj/marked)
* updates `modulejs` to 0.4.5
## v0.25.2 - *2014-07-01*
@ -44,13 +45,13 @@
* fixes QR code URI origin (issue [#287](https://github.com/lrsjng/h5ai/issues/287))
* replaces PHP backtick operator with `exec`
* removes server side file manipulation extensions `dropbox`, `delete` and `rename`
* updates H5BP to 4.3.0
* updates jQuery to 2.1.1
* updates json2.js to 2014-02-04
* updates markdown-js to 0.5.0
* updates Modernizr to 2.8.2
* updates Moment.js to 2.6.0
* updates Underscore.js to 1.6.0
* updates `H5BP` to 4.3.0
* updates `jQuery` to 2.1.1
* updates `json2.js` to 2014-02-04
* updates `markdown-js` to 0.5.0
* updates `Modernizr` to 2.8.2
* updates `Moment.js` to 2.6.0
* updates `Underscore.js` to 1.6.0
* language updates (`bg`, `ko`, `pt`, `sl`, `sv`, `zh-cn`)
@ -95,12 +96,12 @@
* now uses scalable images for the interface
* fixes filter (ignore parent folder, display of `no match`)
* lots of small fixes
* updates H5BP to 4.2.0
* updates jQuery to 2.0.3
* updates jQuery.mousewheel to 3.1.3
* updates Moment.js to 2.1.0
* updates markdown-js to 0.4.0-9c21acdf08
* updates json2.js to 2013-05-26
* updates `H5BP` to 4.2.0
* updates `jQuery` to 2.0.3
* updates `jQuery.mousewheel` to 3.1.3
* updates `Moment.js` to 2.1.0
* updates `markdown-js` to 0.4.0-9c21acdf08
* updates `json2.js` to 2013-05-26
* adds `uk` translation by Viktor Matveenko
* updates to `pl` translation by Mark

View file

@ -14,6 +14,7 @@ modulejs.define('view/ensure', ['$', 'config', 'core/event'], function ($, confi
if (
$(selr).text() !== sequence ||
$(sela).attr('href') !== url ||
$(sela).filter(isVisible).length !== 1 ||
$(selr).filter(isVisible).length !== 1 ||
$(selb).filter(isVisible).length !== 1

View file

@ -1,35 +1,53 @@
/*! modulejs 0.2 - //larsjung.de/modulejs - MIT License */
/*! modulejs 0.4.5 - //larsjung.de/modulejs/ - MIT License */
(function (global, name) {
'use strict';
// Helpers
// -------
// References.
var objProto = Object.prototype,
arrayForEach = Array.prototype.forEach,
isType = function (arg, type) {
return objProto.toString.call(arg) === '[object ' + type + ']';
},
isString = function (arg) {
// Returns a function that returns `true` if `arg` is of the correct `type`, otherwise `false`.
createIsTypeFn = function (type) {
return isType(arg, 'String');
},
isFunction = function (arg) {
return function (arg) {
return isType(arg, 'Function');
return objProto.toString.call(arg) === '[object ' + type + ']';
};
},
isArray = Array.isArray || function (arg) {
return isType(arg, 'Array');
},
// ### isString
// Returns `true` if argument is a string, otherwise `false`.
isString = createIsTypeFn('String'),
// ### isFunction
// Returns `true` if argument is a function, otherwise `false`.
isFunction = createIsTypeFn('Function'),
// ### isArray
// Returns `true` if argument is an array, otherwise `false`.
isArray = Array.isArray || createIsTypeFn('Array'),
// ### isObject
// Returns `true` if argument is an object, otherwise `false`.
isObject = function (arg) {
return arg === new Object(arg);
},
// ### has
// Short cut for `hasOwnProperty`.
has = function (arg, id) {
return objProto.hasOwnProperty.call(arg, id);
},
// ### each
// Iterates over all elements af an array or all own keys of an object.
each = function (obj, iterator, context) {
if (arrayForEach && obj.forEach === arrayForEach) {
@ -46,15 +64,21 @@
}
}
},
contains = function (array, item) {
// ### contains
// Returns `true` if array contains element, otherwise `false`.
contains = function (array, element) {
for (var i = 0, l = array.length; i < l; i += 1) {
if (array[i] === item) {
if (array[i] === element) {
return true;
}
}
return false;
},
// ### uniq
// Returns an new array containing no duplicates. Preserves first occurence and order.
uniq = function (array) {
var elements = {},
@ -70,57 +94,84 @@
return result;
},
// ### err
// Throws an error if `condition` is `true`.
err = function (condition, code, message) {
if (condition) {
throw {
// machine readable
code: code,
// human readable
msg: message,
// let it be helpful in consoles
toString: function () {
return name + ' error ' + code + ': ' + message;
}
};
}
},
// Private
// -------
// ### definitions
// Module definitions.
definitions = {},
// ### instances
// Module instances.
instances = {},
resolve = function (id, cold, stack) {
// ### resolve
// Resolves an `id` to an object, or if `onlyDepIds` is `true` only returns dependency-ids.
// `stack` is used internal to check for circular dependencies.
resolve = function (id, onlyDepIds, stack) {
// check arguments
err(!isString(id), 31, 'id must be a string "' + id + '"');
if (!cold && has(instances, id)) {
// if a module is required that was already created return that object
if (!onlyDepIds && has(instances, id)) {
return instances[id];
}
// check if `id` is defined
var def = definitions[id];
err(!def, 32, 'id not defined "' + id + '"');
// copy resolve stack and add this `id`
stack = (stack || []).slice(0);
stack.push(id);
// if onlyDepIds this will hold the dependency-ids, otherwise it will hold the dependency-objects
var deps = [];
each(def.deps, function (depId, idx) {
each(def.deps, function (depId) {
err(contains(stack, depId), 33, 'cyclic dependencies: ' + stack + ' & ' + depId);
// check for circular dependencies
err(contains(stack, depId), 33, 'circular dependencies: ' + stack + ' & ' + depId);
if (cold) {
deps = deps.concat(resolve(depId, cold, stack));
if (onlyDepIds) {
deps = deps.concat(resolve(depId, onlyDepIds, stack));
deps.push(depId);
} else {
deps[idx] = resolve(depId, cold, stack);
deps.push(resolve(depId, onlyDepIds, stack));
}
});
if (cold) {
// if `onlyDepIds` return only dependency-ids in right order
if (onlyDepIds) {
return uniq(deps);
}
// create, memorize and return object
var obj = def.fn.apply(global, deps);
instances[id] = obj;
return obj;
@ -128,8 +179,8 @@
// Public methods
// --------------
// Public
// ------
// ### define
// Defines a module for `id: String`, optional `deps: Array[String]`,
@ -222,13 +273,8 @@
define: define,
require: require,
state: state,
log: log
};
// Uncomment to run internal tests.
/*
if (global[name.toUpperCase()] === true) {
global[name.toUpperCase()] = {
log: log,
_private: {
isString: isString,
isFunction: isFunction,
isArray: isArray,
@ -241,7 +287,7 @@
definitions: definitions,
instances: instances,
resolve: resolve
};
} // */
}
};
}(this, 'modulejs'));