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 lines
994 B

!function(e){e.add("module","selector",{init:function(e,t){this.app=e,this.context=t,this.$element=t.getElement()},start:function(){this.$selector=this._buildSelector(),this.$selector.on("change.kube.selector",this._toggle.bind(this))},stop:function(){this.$selector.off(".kube.selector")},_isSelect:function(){return"SELECT"===this.$element.get().tagName},_isHashValue:function(e){return 0===e.search(/^#/)},_buildSelector:function(){return this._isSelect()?this.$element:this.$element.find('input[type="radio"]')},_getValue:function(){return this._isSelect()?this.$selector.val():this.$selector.filter(":checked").val()},_getBoxes:function(){var t=e.dom([]),i=this._isSelect()?this.$selector.find("option"):this.$selector;return i.each(function(i){this._isHashValue(i.value)&&t.add(e.dom(i.value))}.bind(this)),t},_toggle:function(){var t=this._getValue(),i=this._getBoxes(),s=e.dom(t);i.addClass("is-hidden"),s.removeClass("is-hidden"),this.app.broadcast("selector.opened",this,s)}})}(Kube);