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.

0 lines
71 KiB

7 years ago
  1. jindo.Component=jindo.$Class({_htEventHandler:null,_htOption:null,$init:function(){var a=this.constructor.getInstance();a.push(this);this._htEventHandler={};this._htOption={};this._htOption._htSetter={}},option:function(c,b){switch(typeof c){case"undefined":return this._htOption;case"string":if(typeof b!="undefined"){if(c=="htCustomEventHandler"){if(typeof this._htOption[c]=="undefined"){this.attach(b)}else{return this}}this._htOption[c]=b;if(typeof this._htOption._htSetter[c]=="function"){this._htOption._htSetter[c](b)}}else{return this._htOption[c]}break;case"object":for(var a in c){if(a=="htCustomEventHandler"){if(typeof this._htOption[a]=="undefined"){this.attach(c[a])}else{continue}}this._htOption[a]=c[a];if(typeof this._htOption._htSetter[a]=="function"){this._htOption._htSetter[a](c[a])}}break}return this},optionSetter:function(c,a){switch(typeof c){case"undefined":return this._htOption._htSetter;case"string":if(typeof a!="undefined"){this._htOption._htSetter[c]=jindo.$Fn(a,this).bind()}else{return this._htOption._htSetter[c]}break;case"object":for(var b in c){this._htOption._htSetter[b]=jindo.$Fn(c[b],this).bind()}break}return this},fireEvent:function(b,k){k=k||{};var d=this["on"+b],c=this._htEventHandler[b]||[],h=typeof d=="function",g=c.length>0;if(!h&&!g){return true}c=c.concat();k.sType=b;if(typeof k._aExtend=="undefined"){k._aExtend=[];k.stop=function(){if(k._aExtend.length>0){k._aExtend[k._aExtend.length-1].bCanceled=true}}}k._aExtend.push({sType:b,bCanceled:false});var f=[k],e,j;for(e=2,j=arguments.length;e<j;e++){f.push(arguments[e])}if(h){d.apply(this,f)}if(g){var a;for(e=0,a;(a=c[e]);e++){a.apply(this,f)}}return !k._aExtend.pop().bCanceled},attach:function(c,a){if(arguments.length==1){jindo.$H(arguments[0]).forEach(jindo.$Fn(function(d,e){this.attach(e,d)},this).bind());return this}var b=this._htEventHandler[c];if(typeof b=="undefined"){b=this._htEventHandler[c]=[]}b.push(a);return this},detach:function(e,b){if(arguments.length==1){jindo.$H(arguments[0]).forEach(jindo.$Fn(function(f,g){this.detach(g,f)},this).bind());return this}var d=this._htEventHandler[e];if(d){for(var a=0,c;(c=d[a]);a++){if(c===b){d=d.splice(a,1);break}}}return this},detachAll:function(c){var b=this._htEventHandler;if(arguments.length){if(typeof b[c]=="undefined"){return this}delete b[c];return this}for(var a in b){delete b[a]}return this}});jindo.Component.factory=function(b,f){var c=[],a;if(typeof f=="undefined"){f={}}for(var d=0,e;(e=b[d]);d++){a=new this(e,f);c[c.length]=a}return c};jindo.Component.getInstance=function(){if(typeof this._aInstance=="undefined"){this._aInstance=[]}return this._aInstance};jindo.UIComponent=jindo.$Class({$init:function(){this._bIsActivating=false},isActivating:function(){return this._bIsActivating},activate:function(){if(this.isActivating()){return this}this._bIsActivating=true;if(arguments.length>0){this._onActivate.apply(this,arguments)}else{this._onActivate()}return this},deactivate:function(){if(!this.isActivating()){return this}this._bIsActivating=false;if(arguments.length>0){this._onDeactivate.apply(this,arguments)}else{this._onDeactivate()}return this}}).extend(jindo.Component);jindo.RolloverArea=jindo.$Class({$init:function(a,b){this.option({sClassName:"rollover",sClassPrefix:"rollover-",bCheckMouseDown:true,bActivateOnload:true,htStatus:{sOver:"over",sDown:"down"}});this.option(b||{});this._elArea=jindo.$(a);this._aOveredElements=[];this._aDownedElements=[];this._wfMouseOver=jindo.$Fn(this._onMouseOver,this);this._wfMouseOut=jindo.$Fn(this._onMouseOut,this);this._wfMouseDown=jindo.$Fn(this._onMouseDown,this);this._wfMouseUp=jindo.$Fn(this._onMouseUp,this);if(this.option("bActivateOnload")){this.activate()}},_addOvered:function(a){this._aOveredElements.push(a)},_removeOvered:function(a){this._aOveredElements.splice(jindo.$A(this._aOveredElements).indexOf(a),1)},_addStatus:function(b,a){jindo.$Element(b).addClass(this.option("sClassPrefix")+a)},_removeStatus:function(b,a){jindo.$Element(b).removeClass(this.option("sClassPrefix")+a)},_isInnerElement:function(a,b){return a===b?true:jindo.$Elem