@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) • 3.84 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("kendo.html.button.js"),require("kendo.button.menu.js")):"function"==typeof define&&define.amd?define(["exports","kendo.html.button","kendo.button.menu"],n):n(((e="undefined"!=typeof globalThis?globalThis:e||self).kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Dropdownbutton={}))}(this,(function(e){!function(e){var n=window.kendo,t=n.ui.Widget,o=".kendoDropDownButton",i=n.ui,a=n.keys,l=e.extend,u=n.html,d=n._outerWidth,r="aria-disabled",s="aria-label",m="aria-expanded",p="disabled",c="k-disabled",f="click",h="open",b="close",g="focus",k="k-menu-button",w=t.extend({init:function(o,i){var a=this;i.enabled=!1!==i.enabled&&!e(o).prop(p),t.fn.init.call(a,o,i),a.wrapper=a.element,a._mainButton(),a._renderMenu(),a._enable(a.options.enabled),a._aria(),a._attachEvents(),n.notify(a),a._applyCssClasses()},options:{name:"DropDownButton",direction:"down",enabled:!0,items:[],rounded:"medium",size:"medium",fillMode:"solid",themeColor:"base",showArrowButton:!1,icon:null,popup:null,messages:{labelSuffix:"dropdownbutton"}},events:[f,h,b],_mainButton:function(){var t=this,o=l({},t.options,{type:t.element.attr("type")||"button"});if(delete o.click,t.element.addClass(k),u.renderButton(t.element,o),t.options.showArrowButton)e("<span></span>").addClass("k-button-arrow").addClass("k-menu-button-arrow").append(n.ui.icon(n.htmlEncode("caret-alt-down"))).appendTo(t.element);else{const e=t.element.find(".k-button-arrow");e&&e.remove()}},_aria:function(){var e=this,n=e.element,t=e.menu;n.attr("aria-haspopup",t?"menu":null),n.attr(m,!t&&null),n.attr("aria-controls",t?t.list.attr("id"):null),n.attr(s)||n.attr(s,n.text()+" "+e.options.messages.labelSuffix)},_renderMenu:function(){var n=this,t=l({},n.options),o=e("<div></div>");delete t.click,delete t.name,n.menu=o.appendTo(document.body).kendoButtonMenu(l({mainButton:n.element,toggleTarget:n.element,menuOpen:n.menuOpenHandler.bind(n),menuClose:n.menuCloseHandler.bind(n),menuClick:n._click.bind(n)},t)).data("kendoButtonMenu")},menuOpenHandler:function(e){var n=this,t=d(n.element);n.trigger(h,{target:n.element})?e.preventDefault():(e.sender.adjustPopupWidth(t),n.element.attr(m,!0))},menuCloseHandler:function(e){var n=this;n.trigger(b,{target:n.element})?e.preventDefault():(n.element.attr(m,!1),n.element.trigger(g))},_attachEvents:function(){var e=this;e.element.on("keydown"+o,e._keydown.bind(e))},_click:function(e){var n=e.id,t=e.target,o=e.originalEvent;this.menu.close(),this.trigger(f,{id:n,target:t,originalEvent:o})},_keydown:function(e){!this.element.is("."+c)||e.keyCode!==a.ENTER&&e.keyCode!==a.SPACEBAR||e.preventDefault()},focus:function(){this.element.trigger(g)},_enable:function(e,n){this.element.toggleClass(c,!e),e?this.element.removeAttr(r):this.element.attr(r,!e),n||this.element.attr(p,!e)},enable:function(e,n,t){var o=this;undefined===e&&(e=!0),n&&n.length?o.menu.enable(e,n):(o.options.enabled=e,o._enable(e,t),o.menu.enable(e))},hide:function(e){e&&e.length&&this.menu.hide(e)},show:function(e){e&&e.length&&this.menu.show(e)},open:function(){this.menu.open()},close:function(){this.menu.close()},items:function(){return this.menu.items()},setOptions:function(e){var n=this;t.fn.setOptions.call(n,e),(e.popup||e.items||e.size)&&(n.menu.destroy(),n._renderMenu()),n._mainButton(),n._aria()},destroy:function(){var e=this;e.menu.destroy(),e.element.off(o),t.fn.destroy.call(e)}});i.plugin(w)}(window.kendo.jQuery);var n=kendo;e.__meta__={id:"dropdownbutton",name:"DropDownButton",category:"web",description:"The DropDownButton allows the user to execute an action from a drop-down list.",depends:["button.menu","html.button"]},e.default=n,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=kendo.dropdownbutton.min.js.map