Hilo/build/amd/hilo/view/Button.min.js
2022-06-29 10:45:02 +08:00

6 lines
1.4 KiB
JavaScript

/**
* hilojs 2.0.3 for amd
* Copyright 2016 alibaba.com
* Licensed under the MIT License
*/
define("hilo/view/Button",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Drawable","hilo/util/util"],function(t,e,s,a,i){var o=e.create({Extends:s,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("Button"),o.superclass.constructor.call(this,e),this.drawable=new a(e),this.setState(o.UP)},upState:null,overState:null,downState:null,disabledState:null,state:null,enabled:!0,useHandCursor:!0,setEnabled:function(t){return this.enabled!=t&&(t?this.setState(o.UP):this.setState(o.DISABLED)),this},setState:function(t){if(this.state!==t){this.state=t,this.pointerEnabled=this.enabled=t!==o.DISABLED;var e;switch(t){case o.UP:e=this.upState;break;case o.OVER:e=this.overState;break;case o.DOWN:e=this.downState;break;case o.DISABLED:e=this.disabledState}e&&(this.drawable.init(e),i.copy(this,e,!0))}return this},fire:function(t,e){if(this.enabled){var s="string"==typeof t?t:t.type;switch(s){case"mousedown":case"touchstart":case"touchmove":this.setState(o.DOWN);break;case"mouseover":this.setState(o.OVER);break;case"mouseup":this.overState?this.setState(o.OVER):this.upState&&this.setState(o.UP);break;case"touchend":case"touchout":case"mouseout":this.setState(o.UP)}return o.superclass.fire.call(this,t,e)}},Statics:{UP:"up",OVER:"over",DOWN:"down",DISABLED:"disabled"}});return o});