Commit bf2698d5 authored by Pascal Hartig's avatar Pascal Hartig

Flight: Upgrade to 1.1.1

parent 16adcca6
......@@ -4,16 +4,14 @@
// http://opensource.org/licenses/MIT
// ==========================================
"use strict";
define(
[
'./utils',
'./compose'
],
function (util, compose) {
function(compose) {
'use strict';
var advice = {
......@@ -25,7 +23,7 @@ define(
for (; i < l; i++) args[i + 1] = arguments[i];
return wrapped.apply(this, args);
}
};
},
before: function(base, before) {
......@@ -33,7 +31,7 @@ define(
return function composedBefore() {
beforeFn.apply(this, arguments);
return base.apply(this, arguments);
}
};
},
after: function(base, after) {
......@@ -42,7 +40,7 @@ define(
var res = (base.unbound || base).apply(this, arguments);
afterFn.apply(this, arguments);
return res;
}
};
},
// a mixin that allows other mixins to augment existing functions by adding additional
......@@ -53,10 +51,12 @@ define(
compose.unlockProperty(this, method, function() {
if (typeof this[method] == 'function') {
return this[method] = advice[m](this[method], fn);
this[method] = advice[m](this[method], fn);
} else {
return this[method] = fn;
this[method] = fn;
}
return this[method];
});
};
......
......@@ -4,8 +4,6 @@
// http://opensource.org/licenses/MIT
// ==========================================
"use strict";
define(
[
......@@ -19,10 +17,11 @@ define(
],
function(advice, utils, compose, withBase, registry, withLogging, debug) {
'use strict';
var functionNameRegEx = /function (.*?)\s?\(/;
//teardown for all instances of this constructor
// teardown for all instances of this constructor
function teardownAll() {
var componentInfo = registry.findComponentInfo(this);
......@@ -38,7 +37,7 @@ define(
} catch(e) {
console.log('unserializable data for event',type,':',data);
throw new Error(
["The event", type, "on component", this.toString(), "was triggered with non-serializable data"].join(" ")
['The event', type, 'on component', this.toString(), 'was triggered with non-serializable data'].join(' ')
);
}
}
......@@ -50,16 +49,15 @@ define(
for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
if (!selector) {
throw new Error("Component needs to be attachTo'd a jQuery object, native node or selector string");
throw new Error('Component needs to be attachTo\'d a jQuery object, native node or selector string');
}
var options = utils.merge.apply(utils, args);
var componentInfo = registry.findComponentInfo(this);
$(selector).each(function(i, node) {
var rawNode = node.jQuery ? node[0] : node;
var componentInfo = registry.findComponentInfo(this)
if (componentInfo && componentInfo.isAttachedTo(rawNode)) {
//already attached
if (componentInfo && componentInfo.isAttachedTo(node)) {
// already attached
return;
}
......@@ -73,7 +71,8 @@ define(
function define(/*mixins*/) {
// unpacking arguments by hand benchmarked faster
var l = arguments.length;
var mixins = new Array(l + 3); //add three for common mixins
// add three for common mixins
var mixins = new Array(l + 3);
for (var i = 0; i < l; i++) mixins[i] = arguments[i];
var Component = function() {};
......@@ -81,11 +80,11 @@ define(
Component.toString = Component.prototype.toString = function() {
var prettyPrintMixins = mixins.map(function(mixin) {
if (mixin.name == null) {
//function name property not supported by this browser, use regex
// function name property not supported by this browser, use regex
var m = mixin.toString().match(functionNameRegEx);
return (m && m[1]) ? m[1] : "";
return (m && m[1]) ? m[1] : '';
} else {
return (mixin.name != "withBase") ? mixin.name : "";
return (mixin.name != 'withBase') ? mixin.name : '';
}
}).filter(Boolean).join(', ');
return prettyPrintMixins;
......@@ -95,7 +94,7 @@ define(
Component.describe = Component.prototype.describe = Component.toString();
}
//'options' is optional hash to be merged with 'defaults' in the component definition
// 'options' is optional hash to be merged with 'defaults' in the component definition
Component.attachTo = attachTo;
Component.teardownAll = teardownAll;
......
......@@ -4,8 +4,6 @@
// http://opensource.org/licenses/MIT
// ==========================================
"use strict";
define(
[
......@@ -13,10 +11,11 @@ define(
'./debug'
],
function(util, debug) {
function(utils, debug) {
'use strict';
//enumerables are shims - getOwnPropertyDescriptor shim doesn't work
var canWriteProtect = debug.enabled && !util.isEnumerable(Object, 'getOwnPropertyDescriptor');
var canWriteProtect = debug.enabled && !utils.isEnumerable(Object, 'getOwnPropertyDescriptor');
//whitelist of unlockable property names
var dontLock = ['mixedIn'];
......
"use strict";
// ==========================================
// Copyright 2013 Twitter, Inc
// Licensed under The MIT License
// http://opensource.org/licenses/MIT
// ==========================================
define([], function() {
define(
var logFilter;
[],
function() {
'use strict';
//******************************************************************************************
// Search object model
//******************************************************************************************
function traverse(util, searchTerm, options) {
var options = options || {};
options = options || {};
var obj = options.obj || window;
var path = options.path || ((obj==window) ? "window" : "");
var path = options.path || ((obj==window) ? 'window' : '');
var props = Object.keys(obj);
props.forEach(function(prop) {
if ((tests[util] || util)(searchTerm, obj, prop)){
console.log([path, ".", prop].join(""), "->",["(", typeof obj[prop], ")"].join(""), obj[prop]);
console.log([path, '.', prop].join(''), '->', ['(', typeof obj[prop], ')'].join(''), obj[prop]);
}
if(Object.prototype.toString.call(obj[prop])=="[object Object]" && (obj[prop] != obj) && path.split(".").indexOf(prop) == -1) {
traverse(util, searchTerm, {obj: obj[prop], path: [path,prop].join(".")});
if (Object.prototype.toString.call(obj[prop]) == '[object Object]' && (obj[prop] != obj) && path.split('.').indexOf(prop) == -1) {
traverse(util, searchTerm, {obj: obj[prop], path: [path,prop].join('.')});
}
});
}
......@@ -27,24 +34,24 @@ define([], function() {
if (!expected || typeof searchTerm == expected) {
traverse(util, searchTerm, options);
} else {
console.error([searchTerm, 'must be', expected].join(' '))
console.error([searchTerm, 'must be', expected].join(' '));
}
}
var tests = {
'name': function(searchTerm, obj, prop) {return searchTerm == prop},
'nameContains': function(searchTerm, obj, prop) {return prop.indexOf(searchTerm)>-1},
'type': function(searchTerm, obj, prop) {return obj[prop] instanceof searchTerm},
'value': function(searchTerm, obj, prop) {return obj[prop] === searchTerm},
'valueCoerced': function(searchTerm, obj, prop) {return obj[prop] == searchTerm}
}
'name': function(searchTerm, obj, prop) {return searchTerm == prop;},
'nameContains': function(searchTerm, obj, prop) {return prop.indexOf(searchTerm) > -1;},
'type': function(searchTerm, obj, prop) {return obj[prop] instanceof searchTerm;},
'value': function(searchTerm, obj, prop) {return obj[prop] === searchTerm;},
'valueCoerced': function(searchTerm, obj, prop) {return obj[prop] == searchTerm;}
};
function byName(searchTerm, options) {search('name', 'string', searchTerm, options);};
function byNameContains(searchTerm, options) {search('nameContains', 'string', searchTerm, options);};
function byType(searchTerm, options) {search('type', 'function', searchTerm, options);};
function byValue(searchTerm, options) {search('value', null, searchTerm, options);};
function byValueCoerced(searchTerm, options) {search('valueCoerced', null, searchTerm, options);};
function custom(fn, options) {traverse(fn, null, options);};
function byName(searchTerm, options) {search('name', 'string', searchTerm, options);}
function byNameContains(searchTerm, options) {search('nameContains', 'string', searchTerm, options);}
function byType(searchTerm, options) {search('type', 'function', searchTerm, options);}
function byValue(searchTerm, options) {search('value', null, searchTerm, options);}
function byValueCoerced(searchTerm, options) {search('valueCoerced', null, searchTerm, options);}
function custom(fn, options) {traverse(fn, null, options);}
//******************************************************************************************
// Event logging
......@@ -98,7 +105,8 @@ define([], function() {
eventNames: (window.localStorage && localStorage.getItem('logFilter_eventNames')) || defaultEventNamesFilter,
actions: (window.localStorage && localStorage.getItem('logFilter_actions')) || defaultActionsFilter
};
//reconstitute arrays
// reconstitute arrays
Object.keys(result).forEach(function(k) {
var thisProp = result[k];
if (typeof thisProp == 'string' && thisProp !== ALL) {
......@@ -147,4 +155,3 @@ define([], function() {
};
}
);
......@@ -15,7 +15,8 @@ define(
'./utils'
],
function (advice, component, compose, logger, registry, utils) {
function(advice, component, compose, logger, registry, utils) {
'use strict';
return {
advice: advice,
......
......@@ -4,41 +4,38 @@
// http://opensource.org/licenses/MIT
// ==========================================
"use strict";
define(
[
'./compose',
'./utils'
],
function (compose, util) {
function(utils) {
'use strict';
var actionSymbols = {
on:'<-',
on: '<-',
trigger: '->',
off: 'x '
};
function elemToString(elem) {
var tagStr = elem.tagName ? elem.tagName.toLowerCase() : elem.toString();
var classStr = elem.className ? "." + (elem.className) : "";
var classStr = elem.className ? '.' + (elem.className) : '';
var result = tagStr + classStr;
return elem.tagName ? ['\'', '\''].join(result) : result;
}
function log(action, component, eventArgs) {
var name, elem, fn, fnName, logFilter, toRegExp, actionLoggable, nameLoggable;
var name, elem, fn, logFilter, toRegExp, actionLoggable, nameLoggable;
if (typeof eventArgs[eventArgs.length-1] == 'function') {
fn = eventArgs.pop();
fn = fn.unbound || fn; //use unbound version if any (better info)
fn = fn.unbound || fn; // use unbound version if any (better info)
}
if (typeof eventArgs[eventArgs.length - 1] == 'object') {
eventArgs.pop(); //trigger data arg - not logged right now
eventArgs.pop(); // trigger data arg - not logged right now
}
if (eventArgs.length == 2) {
......@@ -53,14 +50,14 @@ define(
logFilter = DEBUG.events.logFilter;
// no regex for you, actions...
actionLoggable = logFilter.actions=="all" || (logFilter.actions.indexOf(action) > -1);
actionLoggable = logFilter.actions == 'all' || (logFilter.actions.indexOf(action) > -1);
// event name filter allow wildcards or regex...
toRegExp = function(expr) {
return expr.test ? expr : new RegExp("^" + expr.replace(/\*/g, ".*") + "$");
return expr.test ? expr : new RegExp('^' + expr.replace(/\*/g, '.*') + '$');
};
nameLoggable =
logFilter.eventNames=="all" ||
logFilter.eventNames.some(function(e) {return toRegExp(e).test(name)});
logFilter.eventNames == 'all' ||
logFilter.eventNames.some(function(e) {return toRegExp(e).test(name);});
if (actionLoggable && nameLoggable) {
console.info(
......@@ -68,7 +65,7 @@ define(
action,
'[' + name + ']',
elemToString(elem),
component.constructor.describe.split(' ').slice(0,3).join(' ') //two mixins only
component.constructor.describe.split(' ').slice(0,3).join(' ') // two mixins only
);
}
}
......@@ -76,13 +73,13 @@ define(
function withLogging() {
this.before('trigger', function() {
log('trigger', this, util.toArray(arguments));
log('trigger', this, utils.toArray(arguments));
});
this.before('on', function() {
log('on', this, util.toArray(arguments));
log('on', this, utils.toArray(arguments));
});
this.before('off', function(eventArgs) {
log('off', this, util.toArray(arguments));
this.before('off', function() {
log('off', this, utils.toArray(arguments));
});
}
......
......@@ -4,15 +4,12 @@
// http://opensource.org/licenses/MIT
// ==========================================
"use strict";
define(
[
'./utils'
],
[],
function (util) {
function() {
'use strict';
function parseEventArgs(instance, args) {
var element, type, callback;
......@@ -71,7 +68,7 @@ define(
this.attachedTo.push(instance.node);
return instanceInfo;
}
};
this.removeInstance = function(instance) {
delete this.instances[instance.identity];
......@@ -82,11 +79,11 @@ define(
//if I hold no more instances remove me from registry
registry.removeComponentInfo(this);
}
}
};
this.isAttachedTo = function(node) {
return this.attachedTo.indexOf(node) > -1;
}
};
}
function InstanceInfo(instance) {
......@@ -104,7 +101,7 @@ define(
this.events.splice(i, 1);
}
}
}
};
}
this.addInstance = function(instance) {
......@@ -135,7 +132,7 @@ define(
this.removeComponentInfo = function(componentInfo) {
var index = this.components.indexOf(componentInfo);
(index > -1) && this.components.splice(index, 1);
(index > -1) && this.components.splice(index, 1);
};
this.findComponentInfo = function(which) {
......@@ -151,18 +148,18 @@ define(
};
this.findInstanceInfo = function(instance) {
return this.allInstances[instance.identity] || null;
return this.allInstances[instance.identity] || null;
};
this.findInstanceInfoByNode = function(node) {
var result = [];
Object.keys(this.allInstances).forEach(function(k) {
var thisInstanceInfo = this.allInstances[k];
if(thisInstanceInfo.instance.node === node) {
result.push(thisInstanceInfo);
}
}, this);
return result;
var result = [];
Object.keys(this.allInstances).forEach(function(k) {
var thisInstanceInfo = this.allInstances[k];
if (thisInstanceInfo.instance.node === node) {
result.push(thisInstanceInfo);
}
}, this);
return result;
};
this.on = function(componentOn) {
......@@ -183,7 +180,7 @@ define(
}
};
this.off = function(el, type, callback) {
this.off = function(/*el, type, callback*/) {
var event = parseEventArgs(this, arguments),
instance = registry.findInstanceInfo(this);
......@@ -199,8 +196,8 @@ define(
}
};
//debug tools may want to add advice to trigger
registry.trigger = new Function;
// debug tools may want to add advice to trigger
registry.trigger = function() {};
this.teardown = function() {
registry.removeInstance(this);
......@@ -215,7 +212,7 @@ define(
this.after('off', registry.off);
//debug tools may want to add advice to trigger
window.DEBUG && DEBUG.enabled && this.after('trigger', registry.trigger);
this.after('teardown', {obj:registry, fnName:'teardown'});
this.after('teardown', {obj: registry, fnName: 'teardown'});
};
}
......
......@@ -4,13 +4,12 @@
// http://opensource.org/licenses/MIT
// ==========================================
"use strict";
define(
[],
function () {
function() {
'use strict';
var arry = [];
var DEFAULT_INTERVAL = 100;
......@@ -92,14 +91,14 @@ define(
if (base) {
Object.keys(extra || {}).forEach(function(key) {
if (base[key] && protect) {
throw Error("utils.push attempted to overwrite '" + key + "' while running in protected mode");
throw new Error('utils.push attempted to overwrite "' + key + '" while running in protected mode');
}
if (typeof base[key] == "object" && typeof extra[key] == "object") {
//recurse
if (typeof base[key] == 'object' && typeof extra[key] == 'object') {
// recurse
this.push(base[key], extra[key]);
} else {
//no protect, so extra wins
// no protect, so extra wins
base[key] = extra[key];
}
}, this);
......@@ -112,9 +111,9 @@ define(
return Object.keys(obj).indexOf(property) > -1;
},
//build a function from other function(s)
//util.compose(a,b,c) -> a(b(c()));
//implementation lifted from underscore.js (c) 2009-2012 Jeremy Ashkenas
// build a function from other function(s)
// utils.compose(a,b,c) -> a(b(c()));
// implementation lifted from underscore.js (c) 2009-2012 Jeremy Ashkenas
compose: function() {
var funcs = arguments;
......
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* @license RequireJS 2.1.9 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
......@@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) {
var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.8',
version = '2.1.9',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/,
......@@ -22,7 +22,7 @@ var requirejs, require, define;
hasOwn = op.hasOwnProperty,
ap = Array.prototype,
apsp = ap.splice,
isBrowser = !!(typeof window !== 'undefined' && navigator && window.document),
isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
//PS3 indicates loaded and complete, but need to wait for complete
//specifically. Sequence is 'loading', 'loaded', execution,
......@@ -373,7 +373,6 @@ var requirejs, require, define;
function hasPathFallback(id) {
var pathConfig = getOwn(config.paths, id);
if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
removeScript(id);
//Pop off the first array value, since it failed, and
//retry
pathConfig.shift();
......@@ -1464,6 +1463,8 @@ var requirejs, require, define;
var map = makeModuleMap(id, relMap, true),
mod = getOwn(registry, id);
removeScript(id);
delete defined[id];
delete urlFetched[map.url];
delete undefEvents[id];
......@@ -1609,7 +1610,7 @@ var requirejs, require, define;
//Join the path parts together, then figure out if baseUrl is needed.
url = syms.join('/');
url += (ext || (/\?/.test(url) || skipExt ? '' : '.js'));
url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
}
......@@ -1918,7 +1919,7 @@ var requirejs, require, define;
}
//Look for a data-main script attribute, which could also adjust the baseUrl.
if (isBrowser) {
if (isBrowser && !cfg.skipDataMain) {
//Figure out baseUrl. Get it from the script tag with require.js in it.
eachReverse(scripts(), function (script) {
//Set the 'head' where we can append children by
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment