1 line
994 B
JavaScript
1 line
994 B
JavaScript
!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); |