(function(c,b,d){var a=/\s+/;d.unwhite=function(e){e=e&&d.trim(e);return e.length?e.split(a):[];};d.eventProxy=function(g,f){var e=d.proxy.apply(null,arguments);return function(){return e.apply(null,Array.prototype.slice.call(arguments,1));};};d.bindable=function(f,e){if(!(f instanceof Object)){e=f;f={};}f=d.isFunction(f)?f.prototype:f;d.each(["bind","one","unbind"],function(g,h){f[h]=function(j,k,i){d(this)[h](j,k,i);return this;};});f.trigger=function(h,j){var i=new d.Event(h),g=new d.Event(i);i.preventDefault();g.type="*";if(i.type!==g.type){d.event.trigger(i,j,this);}d.event.trigger(g,j,this);return this;};if(typeof e==="string"){d.each(d.unwhite(e),function(g,h){f[h]=function(j,i){return arguments.length?this.bind(h,j,i):this.trigger(h);};});}return f;};d.loadable=function(f,e){if(typeof e==="undefined"){e=f;f={};}f=d.bindable(f,"onLoadBeforeSend onLoadAbort onLoadSuccess onLoadError onLoadComplete");if(typeof e==="string"){e={url:e};}d.extend(f,{loadableConfig:function(h){var j,k,l,i,g;if(typeof h==="string"){h={url:h};}else{if(d.isFunction(h)){h={success:h};}}h=d.extend(true,{},e,h);j=h.beforeSend;k=h.dataFilter;l=h.success;i=h.error;g=h.complete;return d.extend(h,{beforeSend:d.proxy(function(o,m){var n=j&&j.apply(this,arguments);this.trigger("onLoadBeforeSend",arguments);if(n===false){this.trigger("onLoadAbort",arguments);}return n;},this),dataFilter:k&&d.proxy(k,this),success:d.proxy(function(o,m,p){var n;if(l){n=l.apply(this,arguments);}this.trigger("onLoadSuccess",arguments);return n;},this),error:d.proxy(function(p,m,o){var n;if(i){n=i.apply(this,arguments);}this.trigger("onLoadError",arguments);return n;},this),complete:d.proxy(function(o,m){var n;if(g){n=g.apply(this,arguments);}this.trigger("onLoadComplete",arguments);return n;},this)});},load:function(g){return d.ajax(this.loadableConfig(g));}});return f;};d.renderable=function(h,e,f){if(!(h instanceof Object)){f=e;e=h;h={};}h=d.bindable(h,"onBeforeRender onRender");if(typeof f!=="undefined"){f=d(f);}var g=d.isFunction(e)?e:d.template(e);h.render=function(k,j){if(!(k instanceof Object)){j=k;k=this;}else{k=d.extend(true,{},this,k);}this.trigger("onBeforeRender",[k]);var i=g.call(this,k,!!f||j);if(f){f.html(i);}this.trigger("onRender",[i]);return i;};return h;};d.pollable=function(e){if(typeof e==="undefined"){e={};}e=d.bindable(e,"onStart onExecute onStop");d.extend(e,{isExecuting:function(g){var f=d(this).data("pollable.timers")||{};return g in f;},start:function(k,h,j,f){var g,i;if(typeof j==="boolean"){f=j;j=null;}j=j||[];if(!this.isExecuting(k)&&d.isFunction(this[k])&&h>0){g=d(this);i=g.data("pollable.timers")||{};this[k].proxy=d.proxy(function(){this.trigger("onExecute",[k,this[k].apply(this,j)]);},this);i[k]=c.setInterval(this[k].proxy,h);g.data("pollable.timers",i);this.trigger("onStart",[k]);if(f){this[k].proxy();}}return this;},stop:function(h){var f,g;if(this.isExecuting(h)){f=d(this);g=f.data("pollable.timers")||{};c.clearInterval(g[h]);delete g[h];delete this[h].proxy;f.data("pollable.timers",g);this.trigger("onStop",[h]);}return this;}});return e;};d.cacheable=function(f,e){if(!(f instanceof Object)){e=f;f={};}f=f.prototype||f;e=typeof e!=="undefined"?e:Infinity;d.extend(f,{cacheSet:function(k,l,g){var j=d(this),i=j.data("cacheable.cache")||{},h=d.now()+(typeof g!=="undefined"?g:e);i[k]={value:l,expires:h};j.data("cacheable.cache",i);},cacheGet:function(i){var g=d(this).data("cacheable.cache")||{},j,h;if(i){if(i in g){j=g[i];if(j.expires<d.now()){this.cacheUnset(i);}else{h=j.value;}}}else{h=g;}return h;},cacheHas:function(h){var g=d(this).data("cacheable.cache");return(h in g);},cacheUnset:function(i){var h=d(this),g=h.data("cacheable.cache");if(g&&i in g){g[i]=null;delete g[i];h.data("cacheable.cache",g);}},cacheEmpty:function(){d(this).data("cacheable.cache",{});}});return f;};d.observable=function(e){if(typeof e==="undefined"){e={};}e=d.bindable(e,"onObserve");d.extend(e,{observe:function(g,f){g.bind("*",d.proxy(function(h){var l=h.originalEvent,k=l.type,j=Array.prototype.slice.call(arguments,1);if(namespace){var i=this;d.each(d.unwhite(namespace),function(m,n){l.type=k+"/"+n;i.trigger(l,j);});}l.type=k+"/*";this.trigger(l,j);},this));this.trigger("onObserve",[namespace]);return this;},ignore:function(f){this.trigger("onIgnore",[namespace]);}});return e;};})(this,this.document,this.jQuery);
