Squire.min.js 2.27 KB
Newer Older
1
define(function(){var a=Object.prototype.toString,b=function(b){return"[object Array]"===a.call(b)},c=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},d=function(a,b,c){var d={};if(null!==a)if(Array.prototype.forEach&&a.forEach===Array.prototype.forEach)a.forEach(b,c);else if(a.length===+a.length){for(var e=0,f=a.length;f>e;e++)if(b.call(c,a[e],e,a)===d)return}else for(var g in a)if(a.hasOwnProperty(g)&&b.call(c,a[g],g,a)===d)return},e=function(a){return requirejs.s.contexts[a]},f=function(a,b){return a.undef?a.undef(b):a.require.undef(b)},g=0,h=function(){var b=g++;return"context"+b},i=function(){this.mocks={},this._store=[],this.requiredCallbacks=[],this.configure.apply(this,arguments)};return i.prototype.onRequired=function(a){this.requiredCallbacks.push(a)},i.prototype.configure=function(a){var b={};if(this.id=h(),"undefined"==typeof a&&(a="_"),a=e(a),!a)throw new Error("This context has not been created!");d(a.config,function(a,c){"deps"!==c&&(b[c]=a)}),b.context=this.id,this.load=requirejs.config(b)},i.prototype.mock=function(a,b){return"object"==typeof a?d(a,function(a,b){this.mock(b,a)},this):this.mocks[a]=b,this},i.prototype.store=function(a){return a&&"string"==typeof a?this._store.push(a):a&&b(a)&&d(a,function(a){this.store(a)},this),this},i.prototype.require=function(a,b,f){var j,g="mocks",h=this;j=c(a,g),-1!==j&&a.splice(j,1),d(this.mocks,function(a,b){define(b,a)}),this.load(a,function(){var c={},f=Array.prototype.slice.call(arguments);-1!==j&&(d(h._store,function(a){c[a]=e(h.id).defined[a]}),f.splice(j,0,{mocks:h.mocks,store:c})),b.apply(null,f),d(h.requiredCallbacks,function(b){b.call(null,a,f)})},f)},i.prototype.clean=function(a){return a&&"string"==typeof a?(f(e(this.id),a),delete this.mocks[a]):a&&b(a)?d(a,function(a){this.clean(a)},this):d(this.mocks,function(a,b){this.clean(b)},this),this},i.prototype.remove=function(){var b=e(this.id);b&&(d(e(this.id).defined,function(a,c){f(b,c)},this),delete requirejs.s.contexts[this.id])},i.prototype.run=function(a,b){var c=this,d=function(d){c.require(a,function(){b.apply(null,arguments),d()})};return d.toString=function(){return b.toString()},d},i.Helpers={},i.Helpers.returns=function(a){return function(){return a}},i.Helpers.constructs=function(a){return function(){return function(){return a}}},i});