-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflight.min.js
2 lines (2 loc) · 15.4 KB
/
flight.min.js
1
2
/*! Flight v1.2.0 | (c) Twitter, Inc. | MIT License */
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):"object"==typeof exports?exports.flight=n():t.flight=n()}(this,function(){return function(t){function n(o){if(e[o])return e[o].exports;var i=e[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){var o,i;o=[e(1),e(2),e(3),e(4),e(5),e(6)],i=function(t,n,e,o,i,r){"use strict";return{advice:t,component:n,compose:e,logger:o,registry:i,utils:r}}.apply(null,o),!(void 0!==i&&(t.exports=i))},function(t,n,e){var o,i;o=[e(3),e(6)],i=function(t,n){"use strict";var e={around:function(t,n){return function(){var e=0,o=arguments.length,i=new Array(o+1);for(i[0]=t.bind(this);o>e;e++)i[e+1]=arguments[e];return n.apply(this,i)}},before:function(t,n){var e="function"==typeof n?n:n.obj[n.fnName];return function(){return e.apply(this,arguments),t.apply(this,arguments)}},after:function(t,n){var e="function"==typeof n?n:n.obj[n.fnName];return function(){var n=(t.unbound||t).apply(this,arguments);return e.apply(this,arguments),n}},withAdvice:function(){["before","after","around"].forEach(function(t){this[t]=function(o,i){n.mutateProperty(this,o,function(){return this[o]="function"==typeof this[o]?e[t](this[o],i):i,this[o]})}},this)}};return e}.apply(null,o),!(void 0!==i&&(t.exports=i))},function(t,n,e){var o,i;o=[e(1),e(6),e(3),e(7),e(5),e(4),e(8)],i=function(t,n,e,o,i,r,s){"use strict";function a(){var t=i.findComponentInfo(this);t&&Object.keys(t.instances).forEach(function(n){var e=t.instances[n];e&&e.instance&&e.instance.teardown()})}function u(t){for(var e=arguments.length,o=new Array(e-1),r=1;e>r;r++)o[r-1]=arguments[r];if(!t)throw new Error("Component needs to be attachTo'd a jQuery object, native node or selector string");var s=n.merge.apply(n,o),a=i.findComponentInfo(this);$(t).each(function(t,n){a&&a.isAttachedTo(n)||(new this).initialize(n,s)}.bind(this))}function c(){var t=this.mixedIn||this.prototype.mixedIn||[];return t.map(function(t){if(null==t.name){var n=t.toString().match(l);return n&&n[1]?n[1]:""}return"withBase"!=t.name?t.name:""}).filter(Boolean).join(", ")}function f(){for(var l=arguments.length,h=new Array(l),p=0;l>p;p++)h[p]=arguments[p];var d=function(){};return d.toString=d.prototype.toString=c,s.enabled&&(d.describe=d.prototype.describe=d.toString()),d.attachTo=u,d.mixin=function(){var t=f(),o=Object.create(d.prototype);return o.mixedIn=[].concat(d.prototype.mixedIn),o.defaults=n.merge(d.prototype.defaults),o.attrDef=d.prototype.attrDef,e.mixin(o,arguments),t.prototype=o,t.prototype.constructor=t,t},d.teardownAll=a,s.enabled&&h.unshift(r),h.unshift(o,t.withAdvice,i.withRegistration),e.mixin(d.prototype,h),d}var l=/function (.*?)\s?\(/;return f.teardownAll=function(){i.components.slice().forEach(function(t){t.component.teardownAll()}),i.reset()},f}.apply(null,o),!(void 0!==i&&(t.exports=i))},function(t,n,e){var o,i;o=[e(6)],i=function(t){"use strict";function n(n,e){Object.create(null);Object.keys(n).forEach(function(i){o.indexOf(i)<0&&t.propertyWritability(n,i,e)})}function e(t,e){t.mixedIn=t.hasOwnProperty("mixedIn")?t.mixedIn:[];for(var o=0;o<e.length;o++)-1==t.mixedIn.indexOf(e[o])&&(n(t,!1),e[o].call(t),t.mixedIn.push(e[o]));n(t,!0)}var o=["mixedIn"];return{mixin:e}}.apply(null,o),!(void 0!==i&&(t.exports=i))},function(t,n,e){var o,i;o=[e(6)],i=function(t){"use strict";function n(t){var n=t.tagName?t.tagName.toLowerCase():t.toString(),e=t.className?"."+t.className:"",o=n+e;return t.tagName?["'","'"].join(o):o}function e(t,e,o){if(window.DEBUG&&window.DEBUG.enabled){var r,s,a,u,c,f,l,h,p,d;"function"==typeof o[o.length-1]&&(u=o.pop(),u=u.unbound||u),1==o.length?(a=e.$node[0],s=o[0]):2!=o.length||"object"!=typeof o[1]||o[1].type?(a=o[0],s=o[1],"trigger"==t&&(c=o[2])):(a=e.$node[0],s=o[0],"trigger"==t&&(c=o[1])),r="object"==typeof s?s.type:s,f=DEBUG.events.logFilter,h="all"==f.actions||f.actions.indexOf(t)>-1,l=function(t){return t.test?t:new RegExp("^"+t.replace(/\*/g,".*")+"$")},p="all"==f.eventNames||f.eventNames.some(function(t){return l(t).test(r)}),h&&p&&(d=[i[t],t,"["+r+"]"],c&&d.push(c),d.push(n(a)),d.push(e.constructor.describe.split(" ").slice(0,3).join(" ")),console.groupCollapsed&&"trigger"==t&&console.groupCollapsed(t,r),console.info.apply(console,d))}}function o(){this.before("trigger",function(){e("trigger",this,t.toArray(arguments))}),console.groupCollapsed&&this.after("trigger",function(){console.groupEnd()}),this.before("on",function(){e("on",this,t.toArray(arguments))}),this.before("off",function(){e("off",this,t.toArray(arguments))})}var i={on:"<-",trigger:"->",off:"x "};return o}.apply(null,o),!(void 0!==i&&(t.exports=i))},function(t){var n,e;n=[],e=function(){"use strict";function t(t,n){var e,o,i,r=n.length;return"function"==typeof n[r-1]&&(r-=1,i=n[r]),"object"==typeof n[r-1]&&(r-=1),2==r?(e=n[0],o=n[1]):(e=t.node,o=n[0]),{element:e,type:o,callback:i}}function n(t,n){return t.element==n.element&&t.type==n.type&&(null==n.callback||t.callback==n.callback)}function e(){function e(t){this.component=t,this.attachedTo=[],this.instances={},this.addInstance=function(t){var n=new o(t);return this.instances[t.identity]=n,this.attachedTo.push(t.node),n},this.removeInstance=function(t){delete this.instances[t.identity];var n=this.attachedTo.indexOf(t.node);n>-1&&this.attachedTo.splice(n,1),Object.keys(this.instances).length||i.removeComponentInfo(this)},this.isAttachedTo=function(t){return this.attachedTo.indexOf(t)>-1}}function o(t){this.instance=t,this.events=[],this.addBind=function(t){this.events.push(t),i.events.push(t)},this.removeBind=function(t){for(var e,o=0;e=this.events[o];o++)n(e,t)&&this.events.splice(o,1)}}var i=this;(this.reset=function(){this.components=[],this.allInstances={},this.events=[]}).call(this),this.addInstance=function(t){var n=this.findComponentInfo(t);n||(n=new e(t.constructor),this.components.push(n));var o=n.addInstance(t);return this.allInstances[t.identity]=o,n},this.removeInstance=function(t){var n=(this.findInstanceInfo(t),this.findComponentInfo(t));n&&n.removeInstance(t),delete this.allInstances[t.identity]},this.removeComponentInfo=function(t){var n=this.components.indexOf(t);n>-1&&this.components.splice(n,1)},this.findComponentInfo=function(t){for(var n,e=t.attachTo?t:t.constructor,o=0;n=this.components[o];o++)if(n.component===e)return n;return null},this.findInstanceInfo=function(t){return this.allInstances[t.identity]||null},this.getBoundEventNames=function(t){return this.findInstanceInfo(t).events.map(function(t){return t.type})},this.findInstanceInfoByNode=function(t){var n=[];return Object.keys(this.allInstances).forEach(function(e){var o=this.allInstances[e];o.instance.node===t&&n.push(o)},this),n},this.on=function(n){for(var e,o=i.findInstanceInfo(this),r=arguments.length,s=1,a=new Array(r-1);r>s;s++)a[s-1]=arguments[s];if(o){e=n.apply(null,a),e&&(a[a.length-1]=e);var u=t(this,a);o.addBind(u)}},this.off=function(){var e=t(this,arguments),o=i.findInstanceInfo(this);o&&o.removeBind(e);for(var r,s=0;r=i.events[s];s++)n(r,e)&&i.events.splice(s,1)},i.trigger=function(){},this.teardown=function(){i.removeInstance(this)},this.withRegistration=function(){this.after("initialize",function(){i.addInstance(this)}),this.around("on",i.on),this.after("off",i.off),window.DEBUG&&(!1).enabled&&this.after("trigger",i.trigger),this.after("teardown",{obj:i,fnName:"teardown"})}}return new e}.apply(null,n),!(void 0!==e&&(t.exports=e))},function(t,n,e){var o,i;o=[e(8)],i=function(t){"use strict";function n(){var n=t.enabled&&!i.isEnumerable(Object,"getOwnPropertyDescriptor");if(n)try{Object.getOwnPropertyDescriptor(Object,"keys")}catch(e){return!1}return n}var e=[],o=100,i={isDomObj:function(t){return!(!t.nodeType&&t!==window)},toArray:function(t,n){return e.slice.call(t,n)},merge:function(){var t=arguments.length,n=new Array(t+1);if(0===t)return{};for(var e=0;t>e;e++)n[e+1]=arguments[e];return n[0]={},n[n.length-1]===!0&&(n.pop(),n.unshift(!0)),$.extend.apply(void 0,n)},push:function(t,n,e){return t&&Object.keys(n||{}).forEach(function(o){if(t[o]&&e)throw new Error('utils.push attempted to overwrite "'+o+'" while running in protected mode');"object"==typeof t[o]&&"object"==typeof n[o]?this.push(t[o],n[o]):t[o]=n[o]},this),t},isEnumerable:function(t,n){return Object.keys(t).indexOf(n)>-1},compose:function(){var t=arguments;return function(){for(var n=arguments,e=t.length-1;e>=0;e--)n=[t[e].apply(this,n)];return n[0]}},uniqueArray:function(t){for(var n={},e=[],o=0,i=t.length;i>o;++o)n.hasOwnProperty(t[o])||(e.push(t[o]),n[t[o]]=1);return e},debounce:function(t,n,e){"number"!=typeof n&&(n=o);var i,r;return function(){var o=this,s=arguments,a=function(){i=null,e||(r=t.apply(o,s))},u=e&&!i;return clearTimeout(i),i=setTimeout(a,n),u&&(r=t.apply(o,s)),r}},throttle:function(t,n){"number"!=typeof n&&(n=o);var e,i,r,s,a,u,c=this.debounce(function(){a=s=!1},n);return function(){e=this,i=arguments;var o=function(){r=null,a&&(u=t.apply(e,i)),c()};return r||(r=setTimeout(o,n)),s?a=!0:(s=!0,u=t.apply(e,i)),c(),u}},countThen:function(t,n){return function(){return--t?void 0:n.apply(this,arguments)}},delegate:function(t){return function(n,e){var o,i=$(n.target);Object.keys(t).forEach(function(r){return!n.isPropagationStopped()&&(o=i.closest(r)).length?(e=e||{},e.el=o[0],t[r].apply(this,[n,e])):void 0},this)}},once:function(t){var n,e;return function(){return n?e:(n=!0,e=t.apply(this,arguments))}},propertyWritability:function(t,e,o){n()&&t.hasOwnProperty(e)&&Object.defineProperty(t,e,{writable:o})},mutateProperty:function(t,e,o){var i;return n()&&t.hasOwnProperty(e)?(i=Object.getOwnPropertyDescriptor(t,e).writable,Object.defineProperty(t,e,{writable:!0}),o.call(t),void Object.defineProperty(t,e,{writable:i})):void o.call(t)}};return i}.apply(null,o),!(void 0!==i&&(t.exports=i))},function(t,n,e){var o,i;o=[e(6),e(5),e(8)],i=function(t,n,e){"use strict";function o(t){t.events.slice().forEach(function(t){var n=[t.type];t.element&&n.unshift(t.element),"function"==typeof t.callback&&n.push(t.callback),this.off.apply(this,n)},t.instance)}function i(t,n){try{window.postMessage(n,"*")}catch(e){throw console.log("unserializable data for event",t,":",n),new Error(["The event",t,"on component",this.toString(),"was triggered with non-serializable data"].join(" "))}}function r(t){var n,o=[];if(this.attr=new this.attrDef,e.enabled&&window.console){for(var i in this.attrDef.prototype)o.push(i);n=Object.keys(t);for(var r=n.length-1;r>=0;r--)if(-1==o.indexOf(n[r])){console.warn('Passed unused attributes including "'+n[r]+'" to component "'+this.toString()+'".');break}}for(var i in this.attrDef.prototype)if("undefined"==typeof t[i]){if(null==this.attr[i])throw new Error('Required attribute "'+i+'" not specified in attachTo for component "'+this.toString()+'".')}else this.attr[i]=t[i]}function s(t){var n=Object.create(t);for(var e in this.defaults)t.hasOwnProperty(e)||(n[e]=this.defaults[e]);this.attr=n,Object.keys(this.defaults||{}).forEach(function(t){if(null===this.defaults[t]&&null===this.attr[t])throw new Error('Required attribute "'+t+'" not specified in attachTo for component "'+this.toString()+'".')},this)}function a(t){return function(n,e){$(n.target).trigger(t,e)}}function u(){this.trigger=function(){var t,n,o,r,s,a=arguments.length-1,u=arguments[a];return"string"==typeof u||u&&u.defaultBehavior||(a--,o=u),1==a?(t=$(arguments[0]),r=arguments[1]):(t=this.$node,r=arguments[0]),r.defaultBehavior&&(s=r.defaultBehavior,r=$.Event(r.type)),n=r.type||r,e.enabled&&window.postMessage&&i.call(this,n,o),"object"==typeof this.attr.eventData&&(o=$.extend(!0,{},this.attr.eventData,o)),t.trigger(r||n,o),s&&!r.isDefaultPrevented()&&(this[s]||s).call(this),t},this.on=function(){var n,e,o,i,r=arguments.length-1,s=arguments[r];if(i="object"==typeof s?t.delegate(this.resolveDelegateRules(s)):"string"==typeof s?a(s):s,2==r?(n=$(arguments[0]),e=arguments[1]):(n=this.$node,e=arguments[0]),"function"!=typeof i&&"object"!=typeof i)throw new Error('Unable to bind to "'+e+'" because the given callback is not a function or an object');return o=i.bind(this),o.target=i,o.context=this,n.on(e,o),i.bound||(i.bound=[]),i.bound.push(o),o},this.off=function(){var t,n,e,o=arguments.length-1;if("function"==typeof arguments[o]&&(e=arguments[o],o-=1),1==o?(t=$(arguments[0]),n=arguments[1]):(t=this.$node,n=arguments[0]),e){var i=e.target?e.target.bound:e.bound||[];i&&i.some(function(t,n,o){return t.context&&this.identity==t.context.identity?(o.splice(n,1),e=t,!0):void 0},this)}return t.off(n,e)},this.resolveDelegateRules=function(t){var n={};return Object.keys(t).forEach(function(e){if(!(e in this.attr))throw new Error('Component "'+this.toString()+'" wants to listen on "'+e+'" but no such attribute was defined.');n[this.attr[e]]="string"==typeof t[e]?a(t[e]):t[e]},this),n},this.select=function(t){return this.$node.find(this.attr[t])},this.attributes=function(t){var n=function(){};this.attrDef&&(n.prototype=new this.attrDef);for(var e in t)n.prototype[e]=t[e];this.attrDef=n},this.defaultAttrs=function(n){t.push(this.defaults,n,!0)||(this.defaults=n)},this.initialize=function(t,n){if(n=n||{},this.identity||(this.identity=c++),!t)throw new Error("Component needs a node");return t.jquery?(this.node=t[0],this.$node=t):(this.node=t,this.$node=$(t)),this.attrDef?r.call(this,n):s.call(this,n),this},this.teardown=function(){o(n.findInstanceInfo(this))}}var c=0;return u}.apply(null,o),!(void 0!==i&&(t.exports=i))},function(t){var n,e;n=[],e=function(){"use strict";function t(n,e,o){o=o||{};var i=o.obj||window,r=o.path||(i==window?"window":""),s=Object.keys(i);s.forEach(function(o){(d[n]||n)(e,i,o)&&console.log([r,".",o].join(""),"->",["(",typeof i[o],")"].join(""),i[o]),"[object Object]"==Object.prototype.toString.call(i[o])&&i[o]!=i&&-1==r.split(".").indexOf(o)&&t(n,e,{obj:i[o],path:[r,o].join(".")})})}function n(n,e,o,i){e&&typeof o!=e?console.error([o,"must be",e].join(" ")):t(n,o,i)}function e(t,e){n("name","string",t,e)}function o(t,e){n("nameContains","string",t,e)}function i(t,e){n("type","function",t,e)}function r(t,e){n("value",null,t,e)}function s(t,e){n("valueCoerced",null,t,e)}function a(n,e){t(n,null,e)}function u(){var t=[].slice.call(arguments);m.eventNames.length||(m.eventNames=g),m.actions=t.length?t:g,h()}function c(){var t=[].slice.call(arguments);m.actions.length||(m.actions=g),m.eventNames=t.length?t:g,h()}function f(){m.actions=[],m.eventNames=[],h()}function l(){m.actions=g,m.eventNames=g,h()}function h(){try{window.localStorage&&(localStorage.setItem("logFilter_eventNames",m.eventNames),localStorage.setItem("logFilter_actions",m.actions))}catch(t){}}function p(){var t,n;try{t=window.localStorage&&localStorage.getItem("logFilter_eventNames"),n=window.localStorage&&localStorage.getItem("logFilter_actions")}catch(e){return}t&&(m.eventNames=t),n&&(m.actions=n),Object.keys(m).forEach(function(t){var n=m[t];"string"==typeof n&&n!==g&&(m[t]=n?n.split(","):[])})}var d={name:function(t,n,e){return t==e},nameContains:function(t,n,e){return e.indexOf(t)>-1},type:function(t,n,e){return n[e]instanceof t},value:function(t,n,e){return n[e]===t},valueCoerced:function(t,n,e){return n[e]==t}},g="all",m={eventNames:[],actions:[]};return{enable:function(t){this.enabled=!!t,t&&window.console&&(console.info("Booting in DEBUG mode"),console.info("You can configure event logging with DEBUG.events.logAll()/logNone()/logByName()/logByAction()")),p(),window.DEBUG=this},find:{byName:e,byNameContains:o,byType:i,byValue:r,byValueCoerced:s,custom:a},events:{logFilter:m,logByAction:u,logByName:c,logAll:l,logNone:f}}}.apply(null,n),!(void 0!==e&&(t.exports=e))}])});