flight-for-rails 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62d2d612ed97ecfdeb034b7d5f0db1e5f38ed45b
4
+ data.tar.gz: 38d9f9c9577dc55699f0b13b08a58ba7bddcc3b0
5
+ SHA512:
6
+ metadata.gz: 0ba2b132add231cf69518cfd888d68a2f8332d2c7e780670db8db5764d1d977659451b7ece80fa8f7901b4080dfd0031d9f8ba05e0bc9828c76592071aa5d7f2
7
+ data.tar.gz: 46f47abf0860fac97700018a919dfa9aa996fcf4dde4e791136b80d8e340adb9b95a4c9f8d692e2d1d46a04f4b2c8d5b4e62841320f55f37be9fe4708dbb018c
data/README.md CHANGED
@@ -16,7 +16,7 @@ This gem vendors Flight files and dependecies for Rails assets pipeline.
16
16
  First add the following lines to your application `Gemfile`:
17
17
 
18
18
  ``` ruby
19
- gem 'flight-for-rails', '~> 1.0.0'
19
+ gem 'flight-for-rails', '~> 1.1.0'
20
20
  ```
21
21
 
22
22
  Then run `bundle install` to update your's gems bundle.
@@ -1,3 +1,3 @@
1
1
  module FlightForRails
2
- VERSION = '1.0.9'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -1,8 +1,1021 @@
1
- (function(context){var factories={},loaded={};var isArray=Array.isArray||function(obj){return obj.constructor==Array};var map=Array.map||function(arr,fn,scope){for(var i=0,len=arr.length,result=[];i<len;i++){result.push(fn.call(scope,arr[i]))}return result};function define(){var args=Array.prototype.slice.call(arguments),dependencies=[],id,factory;if(typeof args[0]=="string"){id=args.shift()}if(isArray(args[0])){dependencies=args.shift()}factory=args.shift();factories[id]=[dependencies,factory]}function require(id){function resolve(dep){var relativeParts=id.split("/"),depParts=dep.split("/"),relative=false;relativeParts.pop();while(depParts[0]==".."&&relativeParts.length){relativeParts.pop();depParts.shift();relative=true}if(depParts[0]=="."){depParts.shift();relative=true}if(relative){depParts=relativeParts.concat(depParts)}return depParts.join("/")}var unresolved,factory,dependencies;if(typeof loaded[id]=="undefined"){unresolved=factories[id];if(unresolved){dependencies=unresolved[0];factory=unresolved[1];loaded[id]=factory.apply(undefined,map(dependencies,function(id){return require(resolve(id))}))}}return loaded[id]};define("lib/utils",[],function(){var a=[],b=100,c={isDomObj:function(a){return!!a.nodeType||a===window},toArray:function(b,c){return a.slice.call(b,c)},merge:function(){var a=arguments.length,b=0,c=new Array(a+1);for(;b<a;b++)c[b+1]=arguments[b];return a===0?{}:(c[0]={},c[c.length-1]===!0&&(c.pop(),c.unshift(!0)),$.extend.apply(undefined,c))},push:function(a,b,c){return a&&Object.keys(b||{}).forEach(function(d){if(a[d]&&c)throw Error("utils.push attempted to overwrite '"+d+"' while running in protected mode");typeof a[d]=="object"&&typeof b[d]=="object"?this.push(a[d],b[d]):a[d]=b[d]},this),a},isEnumerable:function(a,b){return Object.keys(a).indexOf(b)>-1},compose:function(){var a=arguments;return function(){var b=arguments;for(var c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},uniqueArray:function(a){var b={},c=[];for(var d=0,e=a.length;d<e;++d){if(b.hasOwnProperty(a[d]))continue;c.push(a[d]),b[a[d]]=1}return c},debounce:function(a,c,d){typeof c!="number"&&(c=b);var e,f;return function(){var b=this,g=arguments,h=function(){e=null,d||(f=a.apply(b,g))},i=d&&!e;return clearTimeout(e),e=setTimeout(h,c),i&&(f=a.apply(b,g)),f}},throttle:function(a,c){typeof c!="number"&&(c=b);var d,e,f,g,h,i,j=this.debounce(function(){h=g=!1},c);return function(){d=this,e=arguments;var b=function(){f=null,h&&(i=a.apply(d,e)),j()};return f||(f=setTimeout(b,c)),g?h=!0:(g=!0,i=a.apply(d,e)),j(),i}},countThen:function(a,b){return function(){if(!--a)return b.apply(this,arguments)}},delegate:function(a){return function(b,c){var d=$(b.target),e;Object.keys(a).forEach(function(f){if((e=d.closest(f)).length)return c=c||{},c.el=e[0],a[f].apply(this,[b,c])},this)}}};return c})
2
- define("lib/registry",["./utils"],function(a){function b(a,b){var c,d,e,f=b.length;return typeof b[f-1]=="function"&&(f-=1,e=b[f]),typeof b[f-1]=="object"&&(f-=1),f==2?(c=b[0],d=b[1]):(c=a.node,d=b[0]),{element:c,type:d,callback:e}}function c(a,b){return a.element==b.element&&a.type==b.type&&(b.callback==null||a.callback==b.callback)}function d(){function d(b){this.component=b,this.attachedTo=[],this.instances={},this.addInstance=function(a){var b=new e(a);return this.instances[a.identity]=b,this.attachedTo.push(a.node),b},this.removeInstance=function(b){delete this.instances[b.identity];var c=this.attachedTo.indexOf(b.node);c>-1&&this.attachedTo.splice(c,1),Object.keys(this.instances).length||a.removeComponentInfo(this)},this.isAttachedTo=function(a){return this.attachedTo.indexOf(a)>-1}}function e(b){this.instance=b,this.events=[],this.addBind=function(b){this.events.push(b),a.events.push(b)},this.removeBind=function(a){for(var b=0,d;d=this.events[b];b++)c(d,a)&&this.events.splice(b,1)}}var a=this;(this.reset=function(){this.components=[],this.allInstances={},this.events=[]}).call(this),this.addInstance=function(a){var b=this.findComponentInfo(a);b||(b=new d(a.constructor),this.components.push(b));var c=b.addInstance(a);return this.allInstances[a.identity]=c,b},this.removeInstance=function(a){var b,c=this.findInstanceInfo(a),d=this.findComponentInfo(a);d&&d.removeInstance(a),delete this.allInstances[a.identity]},this.removeComponentInfo=function(a){var b=this.components.indexOf(a);b>-1&&this.components.splice(b,1)},this.findComponentInfo=function(a){var b=a.attachTo?a:a.constructor;for(var c=0,d;d=this.components[c];c++)if(d.component===b)return d;return null},this.findInstanceInfo=function(a){return this.allInstances[a.identity]||null},this.findInstanceInfoByNode=function(a){var b=[];return Object.keys(this.allInstances).forEach(function(c){var d=this.allInstances[c];d.instance.node===a&&b.push(d)},this),b},this.on=function(c){var d=a.findInstanceInfo(this),e,f=arguments.length,g=1,h=new Array(f-1);for(;g<f;g++)h[g-1]=arguments[g];if(d){e=c.apply(null,h),e&&(h[h.length-1]=e);var i=b(this,h);d.addBind(i)}},this.off=function(d,e,f){var g=b(this,arguments),h=a.findInstanceInfo(this);h&&h.removeBind(g);for(var i=0,j;j=a.events[i];i++)c(j,g)&&a.events.splice(i,1)},a.trigger=new Function,this.teardown=function(){a.removeInstance(this)},this.withRegistration=function(){this.before("initialize",function(){a.addInstance(this)}),this.around("on",a.on),this.after("off",a.off),window.DEBUG&&DEBUG.enabled&&this.after("trigger",a.trigger),this.after("teardown",{obj:a,fnName:"teardown"})}}return new d})
3
- define("tools/debug/debug",["../../lib/registry","../../lib/utils"],function(a,b){function d(a,b,c){var c=c||{},e=c.obj||window,g=c.path||(e==window?"window":""),h=Object.keys(e);h.forEach(function(c){(f[a]||a)(b,e,c)&&console.log([g,".",c].join(""),"->",["(",typeof e[c],")"].join(""),e[c]),Object.prototype.toString.call(e[c])=="[object Object]"&&e[c]!=e&&g.split(".").indexOf(c)==-1&&d(a,b,{obj:e[c],path:[g,c].join(".")})})}function e(a,b,c,e){!b||typeof c==b?d(a,c,e):console.error([c,"must be",b].join(" "))}function g(a,b){e("name","string",a,b)}function h(a,b){e("nameContains","string",a,b)}function i(a,b){e("type","function",a,b)}function j(a,b){e("value",null,a,b)}function k(a,b){e("valueCoerced",null,a,b)}function l(a,b){d(a,null,b)}function p(){var a=[].slice.call(arguments);c.eventNames.length||(c.eventNames=m),c.actions=a.length?a:m,t()}function q(){var a=[].slice.call(arguments);c.actions.length||(c.actions=m),c.eventNames=a.length?a:m,t()}function r(){c.actions=[],c.eventNames=[],t()}function s(){c.actions=m,c.eventNames=m,t()}function t(){window.localStorage&&(localStorage.setItem("logFilter_eventNames",c.eventNames),localStorage.setItem("logFilter_actions",c.actions))}function u(){var a={eventNames:window.localStorage&&localStorage.getItem("logFilter_eventNames")||n,actions:window.localStorage&&localStorage.getItem("logFilter_actions")||o};return Object.keys(a).forEach(function(b){var c=a[b];typeof c=="string"&&c!==m&&(a[b]=c.split(","))}),a}var c,f={name:function(a,b,c){return a==c},nameContains:function(a,b,c){return c.indexOf(a)>-1},type:function(a,b,c){return b[c]instanceof a},value:function(a,b,c){return b[c]===a},valueCoerced:function(a,b,c){return b[c]==a}},m="all",n=[],o=[],c=u();return{enable:function(a){this.enabled=!!a,a&&window.console&&(console.info("Booting in DEBUG mode"),console.info("You can configure event logging with DEBUG.events.logAll()/logNone()/logByName()/logByAction()")),window.DEBUG=this},find:{byName:g,byNameContains:h,byType:i,byValue:j,byValueCoerced:k,custom:l},events:{logFilter:c,logByAction:p,logByName:q,logAll:s,logNone:r}}})
4
- define("lib/compose",["./utils","../tools/debug/debug"],function(a,b){function f(a,b){if(!c)return;var e=Object.create(null);Object.keys(a).forEach(function(c){if(d.indexOf(c)<0){var f=Object.getOwnPropertyDescriptor(a,c);f.writable=b,e[c]=f}}),Object.defineProperties(a,e)}function g(a,b,d){var e;if(!c||!a.hasOwnProperty(b)){d.call(a);return}e=Object.getOwnPropertyDescriptor(a,b).writable,Object.defineProperty(a,b,{writable:!0}),d.call(a),Object.defineProperty(a,b,{writable:e})}function h(a,b){a.mixedIn=a.hasOwnProperty("mixedIn")?a.mixedIn:[],b.forEach(function(b){a.mixedIn.indexOf(b)==-1&&(f(a,!1),b.call(a),a.mixedIn.push(b))}),f(a,!0)}var c=b.enabled&&!a.isEnumerable(Object,"getOwnPropertyDescriptor"),d=["mixedIn"];if(c)try{Object.getOwnPropertyDescriptor(Object,"keys")}catch(e){c=!1}return{mixin:h,unlockProperty:g}})
5
- define("lib/advice",["./utils","./compose"],function(a,b){var c={around:function(a,b){return function(){var d=0,e=arguments.length,f=new Array(e+1);f[0]=a.bind(this);for(;d<e;d++)f[d+1]=arguments[d];return b.apply(this,f)}},before:function(a,b){var c=typeof b=="function"?b:b.obj[b.fnName];return function(){return c.apply(this,arguments),a.apply(this,arguments)}},after:function(a,b){var c=typeof b=="function"?b:b.obj[b.fnName];return function(){var d=(a.unbound||a).apply(this,arguments);return c.apply(this,arguments),d}},withAdvice:function(){["before","after","around"].forEach(function(a){this[a]=function(d,e){b.unlockProperty(this,d,function(){return typeof this[d]=="function"?this[d]=c[a](this[d],e):this[d]=e})}},this)}};return c})
6
- define("lib/logger",["./compose","./utils"],function(a,b){function d(a){var b=a.tagName?a.tagName.toLowerCase():a.toString(),c=a.className?"."+a.className:"",d=b+c;return a.tagName?["'","'"].join(d):d}function e(a,b,e){var f,g,h,i,j,k,l,m;typeof e[e.length-1]=="function"&&(h=e.pop(),h=h.unbound||h),typeof e[e.length-1]=="object"&&e.pop(),e.length==2?(g=e[0],f=e[1]):(g=b.$node[0],f=e[0]),window.DEBUG&&window.DEBUG.enabled&&(j=DEBUG.events.logFilter,l=j.actions=="all"||j.actions.indexOf(a)>-1,k=function(a){return a.test?a:new RegExp("^"+a.replace(/\*/g,".*")+"$")},m=j.eventNames=="all"||j.eventNames.some(function(a){return k(a).test(f)}),l&&m&&console.info(c[a],a,"["+f+"]",d(g),b.constructor.describe.split(" ").slice(0,3).join(" ")))}function f(){this.before("trigger",function(){e("trigger",this,b.toArray(arguments))}),this.before("on",function(){e("on",this,b.toArray(arguments))}),this.before("off",function(a){e("off",this,b.toArray(arguments))})}var c={on:"<-",trigger:"->",off:"x "};return f})
7
- define("lib/component",["./advice","./utils","./compose","./registry","./logger","../tools/debug/debug"],function(a,b,c,d,e,f){function i(a){a.events.slice().forEach(function(a){var b=[a.type];a.element&&b.unshift(a.element),typeof a.callback=="function"&&b.push(a.callback),this.off.apply(this,b)},a.instance)}function j(){i(d.findInstanceInfo(this))}function k(){var a=d.findComponentInfo(this);a&&Object.keys(a.instances).forEach(function(b){var c=a.instances[b];c.instance.teardown()})}function l(a,b){try{window.postMessage(b,"*")}catch(c){throw console.log("unserializable data for event",a,":",b),new Error(["The event",a,"on component",this.toString(),"was triggered with non-serializable data"].join(" "))}}function m(){this.trigger=function(){var a,b,c,d,e,g=arguments.length-1,h=arguments[g];return typeof h!="string"&&(!h||!h.defaultBehavior)&&(g--,c=h),g==1?(a=$(arguments[0]),d=arguments[1]):(a=this.$node,d=arguments[0]),d.defaultBehavior&&(e=d.defaultBehavior,d=$.Event(d.type)),b=d.type||d,f.enabled&&window.postMessage&&l.call(this,b,c),typeof this.attr.eventData=="object"&&(c=$.extend(!0,{},this.attr.eventData,c)),a.trigger(d||b,c),e&&!d.isDefaultPrevented()&&(this[e]||e).call(this),a},this.on=function(){var a,c,d,e,f=arguments.length-1,g=arguments[f];typeof g=="object"?e=b.delegate(this.resolveDelegateRules(g)):e=g,f==2?(a=$(arguments[0]),c=arguments[1]):(a=this.$node,c=arguments[0]);if(typeof e!="function"&&typeof e!="object")throw new Error("Unable to bind to '"+c+"' because the given callback is not a function or an object");return d=e.bind(this),d.target=e,e.guid&&(d.guid=e.guid),a.on(c,d),e.guid=d.guid,d},this.off=function(){var a,b,c,d=arguments.length-1;return typeof arguments[d]=="function"&&(c=arguments[d],d-=1),d==1?(a=$(arguments[0]),b=arguments[1]):(a=this.$node,b=arguments[0]),a.off(b,c)},this.resolveDelegateRules=function(a){var b={};return Object.keys(a).forEach(function(c){if(!c in this.attr)throw new Error('Component "'+this.toString()+'" wants to listen on "'+c+'" but no such attribute was defined.');b[this.attr[c]]=a[c]},this),b},this.defaultAttrs=function(a){b.push(this.defaults,a,!0)||(this.defaults=a)},this.select=function(a){return this.$node.find(this.attr[a])},this.initialize=$.noop,this.teardown=j}function n(a){var c=arguments.length,e=new Array(c-1);for(var f=1;f<c;f++)e[f-1]=arguments[f];if(!a)throw new Error("Component needs to be attachTo'd a jQuery object, native node or selector string");var g=b.merge.apply(b,e);$(a).each(function(a,b){var c=b.jQuery?b[0]:b,e=d.findComponentInfo(this);if(e&&e.isAttachedTo(c))return;new this(b,g)}.bind(this))}function o(){function l(a,b){b=b||{},this.identity=h++;if(!a)throw new Error("Component needs a node");a.jquery?(this.node=a[0],this.$node=a):(this.node=a,this.$node=$(a)),this.toString=l.toString,f.enabled&&(this.describe=this.toString());var c=Object.create(b);for(var d in this.defaults)b.hasOwnProperty(d)||(c[d]=this.defaults[d]);this.attr=c,Object.keys(this.defaults||{}).forEach(function(a){if(this.defaults[a]===null&&this.attr[a]===null)throw new Error('Required attribute "'+a+'" not specified in attachTo for component "'+this.toString()+'".')},this),this.initialize.call(this,b)}var b=arguments.length,i=new Array(b+3);for(var j=0;j<b;j++)i[j]=arguments[j];return l.toString=function(){var a=i.map(function(a){if(a.name==null){var b=a.toString().match(g);return b&&b[1]?b[1]:""}return a.name!="withBaseComponent"?a.name:""}).filter(Boolean).join(", ");return a},f.enabled&&(l.describe=l.toString()),l.attachTo=n,l.teardownAll=k,f.enabled&&i.unshift(e),i.unshift(m,a.withAdvice,d.withRegistration),c.mixin(l.prototype,i),l}var g=/function (.*?)\s?\(/,h=0;return o.teardownAll=function(){d.components.slice().forEach(function(a){a.component.teardownAll()}),d.reset()},o})
8
- define("lib/index",["./advice","./component","./compose","./logger","./registry","./utils"],function(a,b,c,d,e,f){return{advice:a,component:b,compose:c,logger:d,registry:e,utils:f}});context.flight=require("lib/index")})(this);
1
+ /*! Flight v1.1.0 | (c) Twitter, Inc. | MIT License */
2
+ (function(context) {
3
+ var factories = {}, loaded = {};
4
+ var isArray = Array.isArray || function(obj) {
5
+ return obj.constructor == Array;
6
+ };
7
+
8
+ var map = Array.map || function(arr, fn, scope) {
9
+ for (var i = 0, len = arr.length, result = []; i < len; i++) {
10
+ result.push(fn.call(scope, arr[i]));
11
+ }
12
+ return result;
13
+ };
14
+
15
+ function define() {
16
+ var args = Array.prototype.slice.call(arguments), dependencies = [], id, factory;
17
+ if (typeof args[0] == 'string') {
18
+ id = args.shift();
19
+ }
20
+ if (isArray(args[0])) {
21
+ dependencies = args.shift();
22
+ }
23
+ factory = args.shift();
24
+ factories[id] = [dependencies, factory];
25
+ }
26
+
27
+ function require(id) {
28
+ function resolve(dep) {
29
+ var relativeParts = id.split('/'), depParts = dep.split('/'), relative = false;
30
+ relativeParts.pop();
31
+ while (depParts[0] == '..' && relativeParts.length) {
32
+ relativeParts.pop();
33
+ depParts.shift();
34
+ relative = true;
35
+ }
36
+ if (depParts[0] == '.') {
37
+ depParts.shift();
38
+ relative = true;
39
+ }
40
+ if (relative) {
41
+ depParts = relativeParts.concat(depParts);
42
+ }
43
+ return depParts.join('/');
44
+ }
45
+
46
+ var unresolved, factory, dependencies;
47
+ if (typeof loaded[id] == 'undefined') {
48
+ unresolved = factories[id];
49
+ if (unresolved) {
50
+ dependencies = unresolved[0];
51
+ factory = unresolved[1];
52
+ loaded[id] = factory.apply(undefined, map(dependencies, function(id) {
53
+ return require(resolve(id));
54
+ }));
55
+ }
56
+ }
57
+
58
+ return loaded[id];
59
+ }
60
+
61
+ // ==========================================
62
+ // Copyright 2013 Twitter, Inc
63
+ // Licensed under The MIT License
64
+ // http://opensource.org/licenses/MIT
65
+ // ==========================================
66
+ define('lib/utils', [], function () {
67
+ var arry = [];
68
+ var DEFAULT_INTERVAL = 100;
69
+ var utils = {
70
+ isDomObj: function (obj) {
71
+ return !!(obj.nodeType || obj === window);
72
+ },
73
+ toArray: function (obj, from) {
74
+ return arry.slice.call(obj, from);
75
+ },
76
+ merge: function () {
77
+ // unpacking arguments by hand benchmarked faster
78
+ var l = arguments.length, i = 0, args = new Array(l + 1);
79
+ for (; i < l; i++)
80
+ args[i + 1] = arguments[i];
81
+ if (l === 0) {
82
+ return {};
83
+ }
84
+ //start with empty object so a copy is created
85
+ args[0] = {};
86
+ if (args[args.length - 1] === true) {
87
+ //jquery extend requires deep copy as first arg
88
+ args.pop();
89
+ args.unshift(true);
90
+ }
91
+ return $.extend.apply(undefined, args);
92
+ },
93
+ push: function (base, extra, protect) {
94
+ if (base) {
95
+ Object.keys(extra || {}).forEach(function (key) {
96
+ if (base[key] && protect) {
97
+ throw Error('utils.push attempted to overwrite \'' + key + '\' while running in protected mode');
98
+ }
99
+ if (typeof base[key] == 'object' && typeof extra[key] == 'object') {
100
+ //recurse
101
+ this.push(base[key], extra[key]);
102
+ } else {
103
+ //no protect, so extra wins
104
+ base[key] = extra[key];
105
+ }
106
+ }, this);
107
+ }
108
+ return base;
109
+ },
110
+ isEnumerable: function (obj, property) {
111
+ return Object.keys(obj).indexOf(property) > -1;
112
+ },
113
+ compose: function () {
114
+ var funcs = arguments;
115
+ return function () {
116
+ var args = arguments;
117
+ for (var i = funcs.length - 1; i >= 0; i--) {
118
+ args = [funcs[i].apply(this, args)];
119
+ }
120
+ return args[0];
121
+ };
122
+ },
123
+ uniqueArray: function (array) {
124
+ var u = {}, a = [];
125
+ for (var i = 0, l = array.length; i < l; ++i) {
126
+ if (u.hasOwnProperty(array[i])) {
127
+ continue;
128
+ }
129
+ a.push(array[i]);
130
+ u[array[i]] = 1;
131
+ }
132
+ return a;
133
+ },
134
+ debounce: function (func, wait, immediate) {
135
+ if (typeof wait != 'number') {
136
+ wait = DEFAULT_INTERVAL;
137
+ }
138
+ var timeout, result;
139
+ return function () {
140
+ var context = this, args = arguments;
141
+ var later = function () {
142
+ timeout = null;
143
+ if (!immediate) {
144
+ result = func.apply(context, args);
145
+ }
146
+ };
147
+ var callNow = immediate && !timeout;
148
+ clearTimeout(timeout);
149
+ timeout = setTimeout(later, wait);
150
+ if (callNow) {
151
+ result = func.apply(context, args);
152
+ }
153
+ return result;
154
+ };
155
+ },
156
+ throttle: function (func, wait) {
157
+ if (typeof wait != 'number') {
158
+ wait = DEFAULT_INTERVAL;
159
+ }
160
+ var context, args, timeout, throttling, more, result;
161
+ var whenDone = this.debounce(function () {
162
+ more = throttling = false;
163
+ }, wait);
164
+ return function () {
165
+ context = this;
166
+ args = arguments;
167
+ var later = function () {
168
+ timeout = null;
169
+ if (more) {
170
+ result = func.apply(context, args);
171
+ }
172
+ whenDone();
173
+ };
174
+ if (!timeout) {
175
+ timeout = setTimeout(later, wait);
176
+ }
177
+ if (throttling) {
178
+ more = true;
179
+ } else {
180
+ throttling = true;
181
+ result = func.apply(context, args);
182
+ }
183
+ whenDone();
184
+ return result;
185
+ };
186
+ },
187
+ countThen: function (num, base) {
188
+ return function () {
189
+ if (!--num) {
190
+ return base.apply(this, arguments);
191
+ }
192
+ };
193
+ },
194
+ delegate: function (rules) {
195
+ return function (e, data) {
196
+ var target = $(e.target), parent;
197
+ Object.keys(rules).forEach(function (selector) {
198
+ if ((parent = target.closest(selector)).length) {
199
+ data = data || {};
200
+ data.el = parent[0];
201
+ return rules[selector].apply(this, [
202
+ e,
203
+ data
204
+ ]);
205
+ }
206
+ }, this);
207
+ };
208
+ }
209
+ };
210
+ return utils;
211
+ });
212
+ define('lib/debug', [], function () {
213
+ var logFilter;
214
+ //******************************************************************************************
215
+ // Search object model
216
+ //******************************************************************************************
217
+ function traverse(util, searchTerm, options) {
218
+ var options = options || {};
219
+ var obj = options.obj || window;
220
+ var path = options.path || (obj == window ? 'window' : '');
221
+ var props = Object.keys(obj);
222
+ props.forEach(function (prop) {
223
+ if ((tests[util] || util)(searchTerm, obj, prop)) {
224
+ console.log([
225
+ path,
226
+ '.',
227
+ prop
228
+ ].join(''), '->', [
229
+ '(',
230
+ typeof obj[prop],
231
+ ')'
232
+ ].join(''), obj[prop]);
233
+ }
234
+ if (Object.prototype.toString.call(obj[prop]) == '[object Object]' && obj[prop] != obj && path.split('.').indexOf(prop) == -1) {
235
+ traverse(util, searchTerm, {
236
+ obj: obj[prop],
237
+ path: [
238
+ path,
239
+ prop
240
+ ].join('.')
241
+ });
242
+ }
243
+ });
244
+ }
245
+ function search(util, expected, searchTerm, options) {
246
+ if (!expected || typeof searchTerm == expected) {
247
+ traverse(util, searchTerm, options);
248
+ } else {
249
+ console.error([
250
+ searchTerm,
251
+ 'must be',
252
+ expected
253
+ ].join(' '));
254
+ }
255
+ }
256
+ var tests = {
257
+ 'name': function (searchTerm, obj, prop) {
258
+ return searchTerm == prop;
259
+ },
260
+ 'nameContains': function (searchTerm, obj, prop) {
261
+ return prop.indexOf(searchTerm) > -1;
262
+ },
263
+ 'type': function (searchTerm, obj, prop) {
264
+ return obj[prop] instanceof searchTerm;
265
+ },
266
+ 'value': function (searchTerm, obj, prop) {
267
+ return obj[prop] === searchTerm;
268
+ },
269
+ 'valueCoerced': function (searchTerm, obj, prop) {
270
+ return obj[prop] == searchTerm;
271
+ }
272
+ };
273
+ function byName(searchTerm, options) {
274
+ search('name', 'string', searchTerm, options);
275
+ }
276
+ ;
277
+ function byNameContains(searchTerm, options) {
278
+ search('nameContains', 'string', searchTerm, options);
279
+ }
280
+ ;
281
+ function byType(searchTerm, options) {
282
+ search('type', 'function', searchTerm, options);
283
+ }
284
+ ;
285
+ function byValue(searchTerm, options) {
286
+ search('value', null, searchTerm, options);
287
+ }
288
+ ;
289
+ function byValueCoerced(searchTerm, options) {
290
+ search('valueCoerced', null, searchTerm, options);
291
+ }
292
+ ;
293
+ function custom(fn, options) {
294
+ traverse(fn, null, options);
295
+ }
296
+ ;
297
+ //******************************************************************************************
298
+ // Event logging
299
+ //******************************************************************************************
300
+ var ALL = 'all';
301
+ //no filter
302
+ //no logging by default
303
+ var defaultEventNamesFilter = [];
304
+ var defaultActionsFilter = [];
305
+ var logFilter = retrieveLogFilter();
306
+ function filterEventLogsByAction() {
307
+ var actions = [].slice.call(arguments);
308
+ logFilter.eventNames.length || (logFilter.eventNames = ALL);
309
+ logFilter.actions = actions.length ? actions : ALL;
310
+ saveLogFilter();
311
+ }
312
+ function filterEventLogsByName() {
313
+ var eventNames = [].slice.call(arguments);
314
+ logFilter.actions.length || (logFilter.actions = ALL);
315
+ logFilter.eventNames = eventNames.length ? eventNames : ALL;
316
+ saveLogFilter();
317
+ }
318
+ function hideAllEventLogs() {
319
+ logFilter.actions = [];
320
+ logFilter.eventNames = [];
321
+ saveLogFilter();
322
+ }
323
+ function showAllEventLogs() {
324
+ logFilter.actions = ALL;
325
+ logFilter.eventNames = ALL;
326
+ saveLogFilter();
327
+ }
328
+ function saveLogFilter() {
329
+ if (window.localStorage) {
330
+ localStorage.setItem('logFilter_eventNames', logFilter.eventNames);
331
+ localStorage.setItem('logFilter_actions', logFilter.actions);
332
+ }
333
+ }
334
+ function retrieveLogFilter() {
335
+ var result = {
336
+ eventNames: window.localStorage && localStorage.getItem('logFilter_eventNames') || defaultEventNamesFilter,
337
+ actions: window.localStorage && localStorage.getItem('logFilter_actions') || defaultActionsFilter
338
+ };
339
+ //reconstitute arrays
340
+ Object.keys(result).forEach(function (k) {
341
+ var thisProp = result[k];
342
+ if (typeof thisProp == 'string' && thisProp !== ALL) {
343
+ result[k] = thisProp.split(',');
344
+ }
345
+ });
346
+ return result;
347
+ }
348
+ return {
349
+ enable: function (enable) {
350
+ this.enabled = !!enable;
351
+ if (enable && window.console) {
352
+ console.info('Booting in DEBUG mode');
353
+ console.info('You can configure event logging with DEBUG.events.logAll()/logNone()/logByName()/logByAction()');
354
+ }
355
+ window.DEBUG = this;
356
+ },
357
+ find: {
358
+ byName: byName,
359
+ byNameContains: byNameContains,
360
+ byType: byType,
361
+ byValue: byValue,
362
+ byValueCoerced: byValueCoerced,
363
+ custom: custom
364
+ },
365
+ events: {
366
+ logFilter: logFilter,
367
+ logByAction: filterEventLogsByAction,
368
+ logByName: filterEventLogsByName,
369
+ logAll: showAllEventLogs,
370
+ logNone: hideAllEventLogs
371
+ }
372
+ };
373
+ });
374
+ // ==========================================
375
+ // Copyright 2013 Twitter, Inc
376
+ // Licensed under The MIT License
377
+ // http://opensource.org/licenses/MIT
378
+ // ==========================================
379
+ define('lib/compose', [
380
+ './utils',
381
+ './debug'
382
+ ], function (util, debug) {
383
+ //enumerables are shims - getOwnPropertyDescriptor shim doesn't work
384
+ var canWriteProtect = debug.enabled && !util.isEnumerable(Object, 'getOwnPropertyDescriptor');
385
+ //whitelist of unlockable property names
386
+ var dontLock = ['mixedIn'];
387
+ if (canWriteProtect) {
388
+ //IE8 getOwnPropertyDescriptor is built-in but throws exeption on non DOM objects
389
+ try {
390
+ Object.getOwnPropertyDescriptor(Object, 'keys');
391
+ } catch (e) {
392
+ canWriteProtect = false;
393
+ }
394
+ }
395
+ function setPropertyWritability(obj, isWritable) {
396
+ if (!canWriteProtect) {
397
+ return;
398
+ }
399
+ var props = Object.create(null);
400
+ Object.keys(obj).forEach(function (key) {
401
+ if (dontLock.indexOf(key) < 0) {
402
+ var desc = Object.getOwnPropertyDescriptor(obj, key);
403
+ desc.writable = isWritable;
404
+ props[key] = desc;
405
+ }
406
+ });
407
+ Object.defineProperties(obj, props);
408
+ }
409
+ function unlockProperty(obj, prop, op) {
410
+ var writable;
411
+ if (!canWriteProtect || !obj.hasOwnProperty(prop)) {
412
+ op.call(obj);
413
+ return;
414
+ }
415
+ writable = Object.getOwnPropertyDescriptor(obj, prop).writable;
416
+ Object.defineProperty(obj, prop, { writable: true });
417
+ op.call(obj);
418
+ Object.defineProperty(obj, prop, { writable: writable });
419
+ }
420
+ function mixin(base, mixins) {
421
+ base.mixedIn = base.hasOwnProperty('mixedIn') ? base.mixedIn : [];
422
+ mixins.forEach(function (mixin) {
423
+ if (base.mixedIn.indexOf(mixin) == -1) {
424
+ setPropertyWritability(base, false);
425
+ mixin.call(base);
426
+ base.mixedIn.push(mixin);
427
+ }
428
+ });
429
+ setPropertyWritability(base, true);
430
+ }
431
+ return {
432
+ mixin: mixin,
433
+ unlockProperty: unlockProperty
434
+ };
435
+ });
436
+ // ==========================================
437
+ // Copyright 2013 Twitter, Inc
438
+ // Licensed under The MIT License
439
+ // http://opensource.org/licenses/MIT
440
+ // ==========================================
441
+ define('lib/advice', [
442
+ './utils',
443
+ './compose'
444
+ ], function (util, compose) {
445
+ var advice = {
446
+ around: function (base, wrapped) {
447
+ return function composedAround() {
448
+ // unpacking arguments by hand benchmarked faster
449
+ var i = 0, l = arguments.length, args = new Array(l + 1);
450
+ args[0] = base.bind(this);
451
+ for (; i < l; i++)
452
+ args[i + 1] = arguments[i];
453
+ return wrapped.apply(this, args);
454
+ };
455
+ },
456
+ before: function (base, before) {
457
+ var beforeFn = typeof before == 'function' ? before : before.obj[before.fnName];
458
+ return function composedBefore() {
459
+ beforeFn.apply(this, arguments);
460
+ return base.apply(this, arguments);
461
+ };
462
+ },
463
+ after: function (base, after) {
464
+ var afterFn = typeof after == 'function' ? after : after.obj[after.fnName];
465
+ return function composedAfter() {
466
+ var res = (base.unbound || base).apply(this, arguments);
467
+ afterFn.apply(this, arguments);
468
+ return res;
469
+ };
470
+ },
471
+ withAdvice: function () {
472
+ [
473
+ 'before',
474
+ 'after',
475
+ 'around'
476
+ ].forEach(function (m) {
477
+ this[m] = function (method, fn) {
478
+ compose.unlockProperty(this, method, function () {
479
+ if (typeof this[method] == 'function') {
480
+ return this[method] = advice[m](this[method], fn);
481
+ } else {
482
+ return this[method] = fn;
483
+ }
484
+ });
485
+ };
486
+ }, this);
487
+ }
488
+ };
489
+ return advice;
490
+ });
491
+ // ==========================================
492
+ // Copyright 2013 Twitter, Inc
493
+ // Licensed under The MIT License
494
+ // http://opensource.org/licenses/MIT
495
+ // ==========================================
496
+ define('lib/registry', ['./utils'], function (util) {
497
+ function parseEventArgs(instance, args) {
498
+ var element, type, callback;
499
+ var end = args.length;
500
+ if (typeof args[end - 1] === 'function') {
501
+ end -= 1;
502
+ callback = args[end];
503
+ }
504
+ if (typeof args[end - 1] === 'object') {
505
+ end -= 1;
506
+ }
507
+ if (end == 2) {
508
+ element = args[0];
509
+ type = args[1];
510
+ } else {
511
+ element = instance.node;
512
+ type = args[0];
513
+ }
514
+ return {
515
+ element: element,
516
+ type: type,
517
+ callback: callback
518
+ };
519
+ }
520
+ function matchEvent(a, b) {
521
+ return a.element == b.element && a.type == b.type && (b.callback == null || a.callback == b.callback);
522
+ }
523
+ function Registry() {
524
+ var registry = this;
525
+ (this.reset = function () {
526
+ this.components = [];
527
+ this.allInstances = {};
528
+ this.events = [];
529
+ }).call(this);
530
+ function ComponentInfo(component) {
531
+ this.component = component;
532
+ this.attachedTo = [];
533
+ this.instances = {};
534
+ this.addInstance = function (instance) {
535
+ var instanceInfo = new InstanceInfo(instance);
536
+ this.instances[instance.identity] = instanceInfo;
537
+ this.attachedTo.push(instance.node);
538
+ return instanceInfo;
539
+ };
540
+ this.removeInstance = function (instance) {
541
+ delete this.instances[instance.identity];
542
+ var indexOfNode = this.attachedTo.indexOf(instance.node);
543
+ indexOfNode > -1 && this.attachedTo.splice(indexOfNode, 1);
544
+ if (!Object.keys(this.instances).length) {
545
+ //if I hold no more instances remove me from registry
546
+ registry.removeComponentInfo(this);
547
+ }
548
+ };
549
+ this.isAttachedTo = function (node) {
550
+ return this.attachedTo.indexOf(node) > -1;
551
+ };
552
+ }
553
+ function InstanceInfo(instance) {
554
+ this.instance = instance;
555
+ this.events = [];
556
+ this.addBind = function (event) {
557
+ this.events.push(event);
558
+ registry.events.push(event);
559
+ };
560
+ this.removeBind = function (event) {
561
+ for (var i = 0, e; e = this.events[i]; i++) {
562
+ if (matchEvent(e, event)) {
563
+ this.events.splice(i, 1);
564
+ }
565
+ }
566
+ };
567
+ }
568
+ this.addInstance = function (instance) {
569
+ var component = this.findComponentInfo(instance);
570
+ if (!component) {
571
+ component = new ComponentInfo(instance.constructor);
572
+ this.components.push(component);
573
+ }
574
+ var inst = component.addInstance(instance);
575
+ this.allInstances[instance.identity] = inst;
576
+ return component;
577
+ };
578
+ this.removeInstance = function (instance) {
579
+ var index, instInfo = this.findInstanceInfo(instance);
580
+ //remove from component info
581
+ var componentInfo = this.findComponentInfo(instance);
582
+ componentInfo && componentInfo.removeInstance(instance);
583
+ //remove from registry
584
+ delete this.allInstances[instance.identity];
585
+ };
586
+ this.removeComponentInfo = function (componentInfo) {
587
+ var index = this.components.indexOf(componentInfo);
588
+ index > -1 && this.components.splice(index, 1);
589
+ };
590
+ this.findComponentInfo = function (which) {
591
+ var component = which.attachTo ? which : which.constructor;
592
+ for (var i = 0, c; c = this.components[i]; i++) {
593
+ if (c.component === component) {
594
+ return c;
595
+ }
596
+ }
597
+ return null;
598
+ };
599
+ this.findInstanceInfo = function (instance) {
600
+ return this.allInstances[instance.identity] || null;
601
+ };
602
+ this.findInstanceInfoByNode = function (node) {
603
+ var result = [];
604
+ Object.keys(this.allInstances).forEach(function (k) {
605
+ var thisInstanceInfo = this.allInstances[k];
606
+ if (thisInstanceInfo.instance.node === node) {
607
+ result.push(thisInstanceInfo);
608
+ }
609
+ }, this);
610
+ return result;
611
+ };
612
+ this.on = function (componentOn) {
613
+ var instance = registry.findInstanceInfo(this), boundCallback;
614
+ // unpacking arguments by hand benchmarked faster
615
+ var l = arguments.length, i = 1;
616
+ var otherArgs = new Array(l - 1);
617
+ for (; i < l; i++)
618
+ otherArgs[i - 1] = arguments[i];
619
+ if (instance) {
620
+ boundCallback = componentOn.apply(null, otherArgs);
621
+ if (boundCallback) {
622
+ otherArgs[otherArgs.length - 1] = boundCallback;
623
+ }
624
+ var event = parseEventArgs(this, otherArgs);
625
+ instance.addBind(event);
626
+ }
627
+ };
628
+ this.off = function (el, type, callback) {
629
+ var event = parseEventArgs(this, arguments), instance = registry.findInstanceInfo(this);
630
+ if (instance) {
631
+ instance.removeBind(event);
632
+ }
633
+ //remove from global event registry
634
+ for (var i = 0, e; e = registry.events[i]; i++) {
635
+ if (matchEvent(e, event)) {
636
+ registry.events.splice(i, 1);
637
+ }
638
+ }
639
+ };
640
+ //debug tools may want to add advice to trigger
641
+ registry.trigger = new Function();
642
+ this.teardown = function () {
643
+ registry.removeInstance(this);
644
+ };
645
+ this.withRegistration = function () {
646
+ this.after('initialize', function () {
647
+ registry.addInstance(this);
648
+ });
649
+ this.around('on', registry.on);
650
+ this.after('off', registry.off);
651
+ //debug tools may want to add advice to trigger
652
+ window.DEBUG && DEBUG.enabled && this.after('trigger', registry.trigger);
653
+ this.after('teardown', {
654
+ obj: registry,
655
+ fnName: 'teardown'
656
+ });
657
+ };
658
+ }
659
+ return new Registry();
660
+ });
661
+ define('lib/base', [
662
+ './utils',
663
+ './registry',
664
+ './debug'
665
+ ], function (utils, registry, debug) {
666
+ //common mixin allocates basic functionality - used by all component prototypes
667
+ //callback context is bound to component
668
+ var componentId = 0;
669
+ function teardownInstance(instanceInfo) {
670
+ instanceInfo.events.slice().forEach(function (event) {
671
+ var args = [event.type];
672
+ event.element && args.unshift(event.element);
673
+ typeof event.callback == 'function' && args.push(event.callback);
674
+ this.off.apply(this, args);
675
+ }, instanceInfo.instance);
676
+ }
677
+ function checkSerializable(type, data) {
678
+ try {
679
+ window.postMessage(data, '*');
680
+ } catch (e) {
681
+ console.log('unserializable data for event', type, ':', data);
682
+ throw new Error([
683
+ 'The event',
684
+ type,
685
+ 'on component',
686
+ this.toString(),
687
+ 'was triggered with non-serializable data'
688
+ ].join(' '));
689
+ }
690
+ }
691
+ function withBase() {
692
+ // delegate trigger, bind and unbind to an element
693
+ // if $element not supplied, use component's node
694
+ // other arguments are passed on
695
+ // event can be either a string specifying the type
696
+ // of the event, or a hash specifying both the type
697
+ // and a default function to be called.
698
+ this.trigger = function () {
699
+ var $element, type, data, event, defaultFn;
700
+ var lastIndex = arguments.length - 1, lastArg = arguments[lastIndex];
701
+ if (typeof lastArg != 'string' && !(lastArg && lastArg.defaultBehavior)) {
702
+ lastIndex--;
703
+ data = lastArg;
704
+ }
705
+ if (lastIndex == 1) {
706
+ $element = $(arguments[0]);
707
+ event = arguments[1];
708
+ } else {
709
+ $element = this.$node;
710
+ event = arguments[0];
711
+ }
712
+ if (event.defaultBehavior) {
713
+ defaultFn = event.defaultBehavior;
714
+ event = $.Event(event.type);
715
+ }
716
+ type = event.type || event;
717
+ if (debug.enabled && window.postMessage) {
718
+ checkSerializable.call(this, type, data);
719
+ }
720
+ if (typeof this.attr.eventData === 'object') {
721
+ data = $.extend(true, {}, this.attr.eventData, data);
722
+ }
723
+ $element.trigger(event || type, data);
724
+ if (defaultFn && !event.isDefaultPrevented()) {
725
+ (this[defaultFn] || defaultFn).call(this);
726
+ }
727
+ return $element;
728
+ };
729
+ this.on = function () {
730
+ var $element, type, callback, originalCb;
731
+ var lastIndex = arguments.length - 1, origin = arguments[lastIndex];
732
+ if (typeof origin == 'object') {
733
+ //delegate callback
734
+ originalCb = utils.delegate(this.resolveDelegateRules(origin));
735
+ } else {
736
+ originalCb = origin;
737
+ }
738
+ if (lastIndex == 2) {
739
+ $element = $(arguments[0]);
740
+ type = arguments[1];
741
+ } else {
742
+ $element = this.$node;
743
+ type = arguments[0];
744
+ }
745
+ if (typeof originalCb != 'function' && typeof originalCb != 'object') {
746
+ throw new Error('Unable to bind to \'' + type + '\' because the given callback is not a function or an object');
747
+ }
748
+ callback = originalCb.bind(this);
749
+ callback.target = originalCb;
750
+ // if the original callback is already branded by jQuery's guid, copy it to the context-bound version
751
+ if (originalCb.guid) {
752
+ callback.guid = originalCb.guid;
753
+ }
754
+ $element.on(type, callback);
755
+ // get jquery's guid from our bound fn, so unbinding will work
756
+ originalCb.guid = callback.guid;
757
+ return callback;
758
+ };
759
+ this.off = function () {
760
+ var $element, type, callback;
761
+ var lastIndex = arguments.length - 1;
762
+ if (typeof arguments[lastIndex] == 'function') {
763
+ callback = arguments[lastIndex];
764
+ lastIndex -= 1;
765
+ }
766
+ if (lastIndex == 1) {
767
+ $element = $(arguments[0]);
768
+ type = arguments[1];
769
+ } else {
770
+ $element = this.$node;
771
+ type = arguments[0];
772
+ }
773
+ return $element.off(type, callback);
774
+ };
775
+ this.resolveDelegateRules = function (ruleInfo) {
776
+ var rules = {};
777
+ Object.keys(ruleInfo).forEach(function (r) {
778
+ if (!(r in this.attr)) {
779
+ throw new Error('Component "' + this.toString() + '" wants to listen on "' + r + '" but no such attribute was defined.');
780
+ }
781
+ rules[this.attr[r]] = ruleInfo[r];
782
+ }, this);
783
+ return rules;
784
+ };
785
+ this.defaultAttrs = function (defaults) {
786
+ utils.push(this.defaults, defaults, true) || (this.defaults = defaults);
787
+ };
788
+ this.select = function (attributeKey) {
789
+ return this.$node.find(this.attr[attributeKey]);
790
+ };
791
+ this.initialize = function (node, attrs) {
792
+ attrs = attrs || {};
793
+ this.identity = componentId++;
794
+ if (!node) {
795
+ throw new Error('Component needs a node');
796
+ }
797
+ if (node.jquery) {
798
+ this.node = node[0];
799
+ this.$node = node;
800
+ } else {
801
+ this.node = node;
802
+ this.$node = $(node);
803
+ }
804
+ //merge defaults with supplied options
805
+ //put options in attr.__proto__ to avoid merge overhead
806
+ var attr = Object.create(attrs);
807
+ for (var key in this.defaults) {
808
+ if (!attrs.hasOwnProperty(key)) {
809
+ attr[key] = this.defaults[key];
810
+ }
811
+ }
812
+ this.attr = attr;
813
+ Object.keys(this.defaults || {}).forEach(function (key) {
814
+ if (this.defaults[key] === null && this.attr[key] === null) {
815
+ throw new Error('Required attribute "' + key + '" not specified in attachTo for component "' + this.toString() + '".');
816
+ }
817
+ }, this);
818
+ return this;
819
+ };
820
+ this.teardown = function () {
821
+ teardownInstance(registry.findInstanceInfo(this));
822
+ };
823
+ }
824
+ return withBase;
825
+ });
826
+ // ==========================================
827
+ // Copyright 2013 Twitter, Inc
828
+ // Licensed under The MIT License
829
+ // http://opensource.org/licenses/MIT
830
+ // ==========================================
831
+ define('lib/logger', [
832
+ './compose',
833
+ './utils'
834
+ ], function (compose, util) {
835
+ var actionSymbols = {
836
+ on: '<-',
837
+ trigger: '->',
838
+ off: 'x '
839
+ };
840
+ function elemToString(elem) {
841
+ var tagStr = elem.tagName ? elem.tagName.toLowerCase() : elem.toString();
842
+ var classStr = elem.className ? '.' + elem.className : '';
843
+ var result = tagStr + classStr;
844
+ return elem.tagName ? [
845
+ '\'',
846
+ '\''
847
+ ].join(result) : result;
848
+ }
849
+ function log(action, component, eventArgs) {
850
+ var name, elem, fn, fnName, logFilter, toRegExp, actionLoggable, nameLoggable;
851
+ if (typeof eventArgs[eventArgs.length - 1] == 'function') {
852
+ fn = eventArgs.pop();
853
+ fn = fn.unbound || fn; //use unbound version if any (better info)
854
+ }
855
+ if (typeof eventArgs[eventArgs.length - 1] == 'object') {
856
+ eventArgs.pop(); //trigger data arg - not logged right now
857
+ }
858
+ if (eventArgs.length == 2) {
859
+ elem = eventArgs[0];
860
+ name = eventArgs[1];
861
+ } else {
862
+ elem = component.$node[0];
863
+ name = eventArgs[0];
864
+ }
865
+ if (window.DEBUG && window.DEBUG.enabled) {
866
+ logFilter = DEBUG.events.logFilter;
867
+ // no regex for you, actions...
868
+ actionLoggable = logFilter.actions == 'all' || logFilter.actions.indexOf(action) > -1;
869
+ // event name filter allow wildcards or regex...
870
+ toRegExp = function (expr) {
871
+ return expr.test ? expr : new RegExp('^' + expr.replace(/\*/g, '.*') + '$');
872
+ };
873
+ nameLoggable = logFilter.eventNames == 'all' || logFilter.eventNames.some(function (e) {
874
+ return toRegExp(e).test(name);
875
+ });
876
+ if (actionLoggable && nameLoggable) {
877
+ console.info(actionSymbols[action], action, '[' + name + ']', elemToString(elem), component.constructor.describe.split(' ').slice(0, 3).join(' '));
878
+ }
879
+ }
880
+ }
881
+ function withLogging() {
882
+ this.before('trigger', function () {
883
+ log('trigger', this, util.toArray(arguments));
884
+ });
885
+ this.before('on', function () {
886
+ log('on', this, util.toArray(arguments));
887
+ });
888
+ this.before('off', function (eventArgs) {
889
+ log('off', this, util.toArray(arguments));
890
+ });
891
+ }
892
+ return withLogging;
893
+ });
894
+ // ==========================================
895
+ // Copyright 2013 Twitter, Inc
896
+ // Licensed under The MIT License
897
+ // http://opensource.org/licenses/MIT
898
+ // ==========================================
899
+ define('lib/component', [
900
+ './advice',
901
+ './utils',
902
+ './compose',
903
+ './base',
904
+ './registry',
905
+ './logger',
906
+ './debug'
907
+ ], function (advice, utils, compose, withBase, registry, withLogging, debug) {
908
+ var functionNameRegEx = /function (.*?)\s?\(/;
909
+ //teardown for all instances of this constructor
910
+ function teardownAll() {
911
+ var componentInfo = registry.findComponentInfo(this);
912
+ componentInfo && Object.keys(componentInfo.instances).forEach(function (k) {
913
+ var info = componentInfo.instances[k];
914
+ info.instance.teardown();
915
+ });
916
+ }
917
+ function checkSerializable(type, data) {
918
+ try {
919
+ window.postMessage(data, '*');
920
+ } catch (e) {
921
+ console.log('unserializable data for event', type, ':', data);
922
+ throw new Error([
923
+ 'The event',
924
+ type,
925
+ 'on component',
926
+ this.toString(),
927
+ 'was triggered with non-serializable data'
928
+ ].join(' '));
929
+ }
930
+ }
931
+ function attachTo(selector) {
932
+ // unpacking arguments by hand benchmarked faster
933
+ var l = arguments.length;
934
+ var args = new Array(l - 1);
935
+ for (var i = 1; i < l; i++)
936
+ args[i - 1] = arguments[i];
937
+ if (!selector) {
938
+ throw new Error('Component needs to be attachTo\'d a jQuery object, native node or selector string');
939
+ }
940
+ var options = utils.merge.apply(utils, args);
941
+ $(selector).each(function (i, node) {
942
+ var rawNode = node.jQuery ? node[0] : node;
943
+ var componentInfo = registry.findComponentInfo(this);
944
+ if (componentInfo && componentInfo.isAttachedTo(rawNode)) {
945
+ //already attached
946
+ return;
947
+ }
948
+ new this().initialize(node, options);
949
+ }.bind(this));
950
+ }
951
+ // define the constructor for a custom component type
952
+ // takes an unlimited number of mixin functions as arguments
953
+ // typical api call with 3 mixins: define(timeline, withTweetCapability, withScrollCapability);
954
+ function define() {
955
+ // unpacking arguments by hand benchmarked faster
956
+ var l = arguments.length;
957
+ var mixins = new Array(l + 3);
958
+ //add three for common mixins
959
+ for (var i = 0; i < l; i++)
960
+ mixins[i] = arguments[i];
961
+ var Component = function () {
962
+ };
963
+ Component.toString = Component.prototype.toString = function () {
964
+ var prettyPrintMixins = mixins.map(function (mixin) {
965
+ if (mixin.name == null) {
966
+ //function name property not supported by this browser, use regex
967
+ var m = mixin.toString().match(functionNameRegEx);
968
+ return m && m[1] ? m[1] : '';
969
+ } else {
970
+ return mixin.name != 'withBase' ? mixin.name : '';
971
+ }
972
+ }).filter(Boolean).join(', ');
973
+ return prettyPrintMixins;
974
+ };
975
+ if (debug.enabled) {
976
+ Component.describe = Component.prototype.describe = Component.toString();
977
+ }
978
+ //'options' is optional hash to be merged with 'defaults' in the component definition
979
+ Component.attachTo = attachTo;
980
+ Component.teardownAll = teardownAll;
981
+ // prepend common mixins to supplied list, then mixin all flavors
982
+ if (debug.enabled) {
983
+ mixins.unshift(withLogging);
984
+ }
985
+ mixins.unshift(withBase, advice.withAdvice, registry.withRegistration);
986
+ compose.mixin(Component.prototype, mixins);
987
+ return Component;
988
+ }
989
+ define.teardownAll = function () {
990
+ registry.components.slice().forEach(function (c) {
991
+ c.component.teardownAll();
992
+ });
993
+ registry.reset();
994
+ };
995
+ return define;
996
+ });
997
+ // ==========================================
998
+ // Copyright 2013 Twitter, Inc
999
+ // Licensed under The MIT License
1000
+ // http://opensource.org/licenses/MIT
1001
+ // ==========================================
1002
+ define('lib/index', [
1003
+ './advice',
1004
+ './component',
1005
+ './compose',
1006
+ './logger',
1007
+ './registry',
1008
+ './utils'
1009
+ ], function (advice, component, compose, logger, registry, utils) {
1010
+ return {
1011
+ advice: advice,
1012
+ component: component,
1013
+ compose: compose,
1014
+ logger: logger,
1015
+ registry: registry,
1016
+ utils: utils
1017
+ };
1018
+ });
1019
+
1020
+ context.flight = require('lib/index');
1021
+ }(this));
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flight-for-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sergey Rezvanov
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-19 00:00:00.000000000 Z
11
+ date: 2013-08-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.1.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.1.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: jquery-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.1.4
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.1.4
46
41
  description: Flight javascript framework for Rails assets pipeline
@@ -64,26 +59,25 @@ files:
64
59
  homepage: https://github.com/rezwyi/flight-for-rails
65
60
  licenses:
66
61
  - MIT
62
+ metadata: {}
67
63
  post_install_message:
68
64
  rdoc_options: []
69
65
  require_paths:
70
66
  - lib
71
67
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
68
  requirements:
74
- - - ! '>='
69
+ - - '>='
75
70
  - !ruby/object:Gem::Version
76
71
  version: '0'
77
72
  required_rubygems_version: !ruby/object:Gem::Requirement
78
- none: false
79
73
  requirements:
80
- - - ! '>='
74
+ - - '>='
81
75
  - !ruby/object:Gem::Version
82
76
  version: '0'
83
77
  requirements: []
84
78
  rubyforge_project:
85
- rubygems_version: 1.8.25
79
+ rubygems_version: 2.0.3
86
80
  signing_key:
87
- specification_version: 3
81
+ specification_version: 4
88
82
  summary: Flight javascript framework for Rails assets pipeline
89
83
  test_files: []