UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines (2 loc) 1.9 kB
!function(e){"function"==typeof define&&define.amd?define(["kendo.core.min"],e):e()}((function(){!function(e,n){var t=window.kendo,i=t.mobile.ui,a=i.Widget,s="state-active",d="state-disabled",o="select";function l(e){return"k-"+e+" km-"+e}function r(n){return e('<span class="'+l("badge")+'">'+n+"</span>")}var c=a.extend({init:function(e,n){var t=this;a.fn.init.call(t,e,n),t.element.addClass("km-buttongroup k-widget k-button-group").find("li").each(t._button),t.element.on(t.options.selectOn,"li:not(.km-state-active)","_select"),t._enable=!0,t.select(t.options.index),t.options.enable||(t._enable=!1,t.wrapper.addClass(l(d)))},events:[o],options:{name:"ButtonGroup",selectOn:"down",index:-1,enable:!0},current:function(){return this.element.find(".km-"+s)},select:function(n){var t=this,i=-1;undefined!==n&&-1!==n&&t._enable&&!e(n).is(".km-"+d)&&(t.current().removeClass(l(s)),"number"==typeof n?(i=n,n=e(t.element[0].children[n])):n.nodeType&&(i=(n=e(n)).index()),n.addClass(l(s)),t.selectedIndex=i)},badge:function(n,t){var i,a=this.element;return isNaN(n)||(n=a.children().get(n)),n=a.find(n),i=e(n.children(".km-badge")[0]||r(t).appendTo(n)),t||0===t?(i.html(t),this):!1===t?(i.empty().remove(),this):i.html()},enable:function(e){void 0===e&&(e=!0),this.wrapper.toggleClass(l(d),!e),this._enable=this.options.enable=e},_button:function(){var n=e(this).addClass(l("button")),i=t.attrValue(n,"icon"),a=t.attrValue(n,"badge"),s=n.children("span"),d=n.find("img").addClass(l("image"));s[0]||(s=n.wrapInner("<span/>").children("span")),s.addClass(l("text")),!d[0]&&i&&n.prepend(e('<span class="'+l("icon")+" "+l(i)+'"/>')),(a||0===a)&&r(a).appendTo(n)},_select:function(e){e.which>1||e.isDefaultPrevented()||!this._enable||(this.select(e.currentTarget),this.trigger(o,{index:this.selectedIndex}))}});i.plugin(c)}(window.kendo.jQuery)})); //# sourceMappingURL=kendo.mobile.buttongroup.min.js.map