You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
5.8 KiB
1 line
5.8 KiB
5 years ago
|
!function(){var e={name:"oojs",namespace:"",$oojs:function(){if(Function.prototype.proxy=function(){var e=this,t=Array.prototype.slice.apply(arguments),n=t.shift();return function(){var s=Array.prototype.slice.apply(arguments);return e.apply(n,s.concat(t))}},"undefined"!=typeof window)this.global=window,this.runtime="browser",this.basePath="http://cpro.baidustatic.cn/js/",this.version="1.0.0",this.global.oojs=e,this.global.define=this.define.proxy(this);else if(global){var t=require("path");this.basePath=t.resolve(__dirname,"../../../src")+"/",this.global=global,this.runtime="nodejs",global.oojs=e,global.define=this.define.proxy(this);var n=module.constructor,s=n.wrap;n.wrap=function(e){return e=e.replace(/define\s*&&\s*define\s*\(/gi,"define(module,"),s(e)},module.exports=this}},fastClone:function(e){var t=function(){};t.prototype=e;var n=new t;return n},create:function(e){var t=Array.prototype.slice.call(arguments,0);t.shift();var n=e.name||"init",s=function(e){this[n]=this[n]||function(){},this[n].apply(this,e)};s.prototype=e;var i=new s(t);i.dispose=i.dispose||function(){},"browser"===this.runtime&&(window.addEventListener?window.addEventListener("unload",i.dispose.proxy(i),!1):window.attachEvent&&window.attachEvent("onunload",i.dispose.proxy(i)));for(var r in e){var a=e[r];a&&e.hasOwnProperty(r)&&"object"==typeof a&&(i[r]=this.fastClone(a))}return i.instances=null,i},define:function(e,t){t||(t=e);var n=t.name;t.namespace=t.namespace||"",t.dispose=t.dispose||function(){};var s=t.namespace.split("."),i="nodejs";"undefined"!=typeof window&&(global=window,i="browser");for(var r,a=s.length,o=global,l=0;a>l;l++)r=s[l],r&&(o[r]=o[r]||{},o=o[r]);if(o[n]=o[n]||{},o[n].name&&o[n].___registered){if(o[n].___registered&&t.classType&&"extend"===t.classType){for(var u in t)u&&t.hasOwnProperty(u)&&(o[n][u]=t[u]);t=o[n]}}else t.___registered=!0,o[n]=t;if(this.loadDeps&&t&&t.deps)this.loadDeps(t);else{var c="$"+n;t[c]&&t[c]()}return e&&(e.exports=t),this},find:function(e){var t,n=e.split(".");t=this.global[n[0]];for(var s=1,i=n.length;i>s;s++){if(!t||!t[n[s]]){t=null;break}t=t[n[s]]}return t},using:function(e){var t=this.find(e);return t||"nodejs"===this.runtime&&(require(this.getClassPath(e)),t=this.find(e)),t},getClassPath:function(e){return this.basePath+e.replace(/\./gi,"/")+".js"},config:function(e){return this.basePath=e.basePath||this.basePath,this}};e.define("undefined"!=typeof module?module:null,e)}(),define&&define({name:"event",namespace:"oojs",eventList:null,groupList:null,eventGroupIndexer:null,$event:function(){},event:function(){this.eventList={},this.groupList={},this.eventGroupIndexer={}},bind:function(e,t){var n=this.eventList[e]=this.eventList[e]||{};return(n.callbacks=n.callbacks||[]).push(t),n.status=!1,this},removeListener:function(e,t){if(this.eventList[e]){var n=this.eventList[e];if(n.callbacks&&n.callbacks.length)for(var s=0,i=n.callbacks.length;i>s;s++)if(t){if(t===n.callbacks[s]){n.callbacks[s]=null;break}}else n.callbacks[s]=null}},unbind:function(e,t){if(e||t)this.removeListener(e,t);else{var n;for(n in this.eventList)n&&this.eventList[n]&&this.eventList.hasOwnProperty(n)&&this.removeListener(n)}},emit:function(e,t){var n=this.eventList[e];if(n&&n.callbacks&&n.callbacks.length){var s=n.callbacks.length;n.data=[];for(var i=0;s>i;i++){var r=n.callbacks[i];r&&n.data.push(r(t))}n.callbacks=null,n.status=!0}for(var a,o=this.eventGroupIndexer[e]||[],i=0,l=o.length;l>i;i++)a=o[i],a&&this.groupEmit(a)},group:function(e,t,n){this.groupList[e]=this.groupList[e]||{};var s=this.groupList[e],i=s.events=s.events||{};n&&(s.callbacks=s.callbacks||[]).push(n);for(var r,t=t||[],a=0,o=t.length;o>a;a++)r=t[a],i[r]=1,(this.eventGroupIndexer[r]=this.eventGroupIndexer[r]||[]).push(e)},groupEmit:function(e){var t=this.groupList[e];if(t){var n,s,i=t.events=t.events||{},r=!0,a={};for(n in i)if(n&&i.hasOwnProperty(n)){if(s=this.eventList[n],!s||!s.status){r=!1,a=null;break}a[n]=s.data}if(n=null,r){t.callbacks=t.callbacks||[];for(var o,l=t.callbacks,u=l.length||0,c=0;u>c;c++)o=t.callbacks[c],o&&(o(a),t.callbacks[c]=null);o=null,t.c
|