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

6 lines
1.4 KiB
JavaScript

/**
* hilojs 2.0.3 for cmd
* Copyright 2016 alibaba.com
* Licensed under the MIT License
*/
define(function(t,e,s){var a=t("hilo/core/Hilo"),i=t("hilo/core/Class"),o=t("hilo/view/View"),r=t("hilo/view/Drawable"),h=t("hilo/util/util"),n=i.create({Extends:o,constructor:function(t){t=t||{},this.id=this.id||t.id||a.getUid("Button"),n.superclass.constructor.call(this,t),this.drawable=new r(t),this.setState(n.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(n.UP):this.setState(n.DISABLED)),this},setState:function(t){if(this.state!==t){this.state=t,this.pointerEnabled=this.enabled=t!==n.DISABLED;var e;switch(t){case n.UP:e=this.upState;break;case n.OVER:e=this.overState;break;case n.DOWN:e=this.downState;break;case n.DISABLED:e=this.disabledState}e&&(this.drawable.init(e),h.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(n.DOWN);break;case"mouseover":this.setState(n.OVER);break;case"mouseup":this.overState?this.setState(n.OVER):this.upState&&this.setState(n.UP);break;case"touchend":case"touchout":case"mouseout":this.setState(n.UP)}return n.superclass.fire.call(this,t,e)}},Statics:{UP:"up",OVER:"over",DOWN:"down",DISABLED:"disabled"}});return n});