@syncfusion/ej2-splitbuttons
Version:
A package of feature-rich Essential JS 2 components such as DropDownButton, SplitButton, ProgressButton and ButtonGroup.
12 lines (11 loc) • 41.4 kB
JavaScript
/*!
* filename: ej2-splitbuttons.min.js
* version : 29.2.4
* Copyright Syncfusion Inc. 2001 - 2024. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
* licensing@syncfusion.com. Any infringement will be prosecuted under
* applicable laws.
*/
this.ej=this.ej||{},this.ej.splitbuttons=function(e,t,i,s){"use strict";function n(e,i){for(var s=t.extend({},e),n=0,o=Object.keys(s);n<o.length;n++){var r=o[n];i.indexOf(r)<0&&t.deleteObject(s,r)}return s}function o(e,i){var s=40===i?0:e.childElementCount-1,n=s,o=e.querySelector(".e-selected");o&&o.classList.remove("e-selected");for(var a=0,p=e.children.length;a<p;a++)e.children[a].classList.contains("e-focused")&&(n=a,e.children[a].classList.remove("e-focused"),40===i?n++:n--,n===(40===i?e.childElementCount:-1)&&(n=s));-1!==(n=r(e,e.children[n],n,i))&&(t.addClass([e.children[n]],"e-focused"),e.children[n].focus())}function r(e,t,i,s,n){if(void 0===n&&(n=0),(t.classList.contains("e-separator")||t.classList.contains("e-disabled"))&&(i===(40===s?e.childElementCount-1:0)?i=40===s?0:e.childElementCount-1:40===s?i++:i--),(t=e.children[i]).classList.contains("e-separator")||t.classList.contains("e-disabled")){if(++n===e.childElementCount)return i=-1;i=r(e,t,i,s,n)}return i}function a(e,i){var s=[].slice.call(e.getElementsByClassName("e-blank-icon"));if(i&&[].slice.call(e.getElementsByClassName("e-item")).forEach(function(e){(e.style.paddingLeft||e.style.paddingRight)&&e.removeAttribute("style")}),s.length){var n=e.querySelector(".e-item:not(.e-blank-icon):not(.e-separator)");if(!t.isNullOrUndefined(n)){n.classList.contains("e-url")&&(n=n.querySelector(".e-menu-url"));var o,r=n.querySelector(".e-menu-icon"),a=e.classList.contains("e-rtl");o=a?{padding:"paddingRight",margin:"marginLeft"}:{padding:"paddingLeft",margin:"marginRight"};var p=parseInt(getComputedStyle(r).fontSize,10)+parseInt(getComputedStyle(r)[o.margin],10)+parseInt(getComputedStyle(n).paddingLeft,10)+"px";s.forEach(function(e){e.classList.contains("e-url")&&e.querySelector(".e-menu-url")?e.querySelector(".e-menu-url").style[o.padding]=p:e.style[o.padding]=p})}}}function p(e,s,n){void 0===s&&(s={});var o,r,a,p;t.isNullOrUndefined(n)&&(n=t.createElement);var l=document.querySelector(e);t.addClass([l],["e-btn-group","e-css"]),l.setAttribute("role","group");var c=l.children;s.buttons=s.buttons||[];for(var d=0,h=0;h<c.length;d++,h++)o=c[h],null!==(p=s.buttons[d])&&("BUTTON"===o.tagName?r=o:(r=n("label"),(a=c[h+1])?l.insertBefore(r,a):l.appendChild(r),o.id&&r.setAttribute("for",o.id),p&&p.disabled&&(o.disabled=!0),h++),s.cssClass&&p&&!p.cssClass&&(p.cssClass=s.cssClass),new i.Button(p||{},r));return l}var l=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(t,i)};return function(t,i){function s(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),c=function(e,t,i,s){var n,o=arguments.length,r=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,i,r):n(t,i))||r);return o>3&&r&&Object.defineProperty(t,i,r),r},d=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return l(i,e),c([t.Property("")],i.prototype,"iconCss",void 0),c([t.Property("")],i.prototype,"id",void 0),c([t.Property(!1)],i.prototype,"separator",void 0),c([t.Property("")],i.prototype,"text",void 0),c([t.Property("")],i.prototype,"url",void 0),c([t.Property(!1)],i.prototype,"disabled",void 0),i}(t.ChildProperty),h=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(t,i)};return function(t,i){function s(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),u=function(e,t,i,s){var n,o=arguments.length,r=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,i,r):n(t,i))||r);return o>3&&r&&Object.defineProperty(t,i,r),r},m={DISABLED:"e-disabled",FOCUS:"e-focused",ICON:"e-menu-icon",ITEM:"e-item",POPUP:"e-dropdown-popup",RTL:"e-rtl",SEPARATOR:"e-separator",VERTICAL:"e-vertical",POPUPWIDTH:"e-dropdown-popup-width"},y=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return h(i,e),u([t.Property("SlideDown")],i.prototype,"effect",void 0),u([t.Property(400)],i.prototype,"duration",void 0),u([t.Property("ease")],i.prototype,"easing",void 0),i}(t.ChildProperty),f=function(e){function r(t,i){var s=e.call(this,t,i)||this;return s.isPopupCreated=!0,s}return h(r,e),r.prototype.preRender=function(){},r.prototype.getPersistData=function(){return this.addOnPersist([])},r.prototype.toggle=function(){this.canOpen()?this.openPopUp():this.createPopupOnClick&&!this.isPopupCreated?(this.createPopup(),this.openPopUp()):this.closePopup()},r.prototype.render=function(){this.initialize(),this.disabled||this.wireEvents(),this.renderComplete()},r.prototype.addItems=function(e,t){for(var i,s=this.items.length,n=0,o=this.items.length;n<o;n++)if(t===this.items[n].text){s=n;break}for(var r=e.length-1;r>=0;r--)i=new d(this,"items",e[r],!0),this.items.splice(s,0,i);this.canOpen()||this.createItems()},r.prototype.removeItems=function(e,t){for(var i=!1,s=0,n=e.length;s<n;s++)for(var o=0,r=this.items.length;o<r;o++)if(e[s]===(t?this.items[o].id:this.items[o].text)){this.items.splice(o,1),i=!0;break}i&&this.getULElement()&&this.createItems()},r.prototype.createPopup=function(){var e,i=this.createElement("div",{className:"auto"!==this.popupWidth?m.POPUP+" "+m.POPUPWIDTH:m.POPUP,id:this.element.id+"-popup"});if(document.body.appendChild(i),this.dropDown=new s.Popup(i,{width:this.popupWidth,relateTo:this.element,collision:{X:"fit",Y:"flip"},position:{X:"left",Y:"bottom"},targetType:"relative",content:this.target?this.getTargetElement():"",enableRtl:this.enableRtl}),this.dropDown.element.setAttribute("role","dialog"),this.dropDown.element.setAttribute("aria-label","dropdown menu"),t.isNullOrUndefined(this.popupContent)||(this.popupContent.style.display=""),"fixed"===this.dropDown.element.style.position&&this.dropDown.refreshPosition(this.element),this.dropDown.hide(),t.attributes(this.element,(e={},e["aria-haspopup"]=this.items.length||this.target?"true":"false",e["aria-expanded"]="false",e.type="button",e)),this.cssClass&&t.addClass([i],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.isPopupCreated=!0,this.createPopupOnClick){var n=t.getComponent(this.activeElem[0],"split-btn");n&&(n.isPopupCreated=!0)}},r.prototype.getTargetElement=function(){return!this.createPopupOnClick||this.isColorPicker()||t.isNullOrUndefined(this.popupContent)?"string"==typeof this.target?t.select(this.target):this.target:this.popupContent},r.prototype.createItems=function(e){var i,s,n,o,r=this,p=this.items,l=this.hasIcon(this.items,"iconCss"),c=this.getULElement();if(c?c.innerHTML="":c=this.createElement("ul",{attrs:{role:"menu",tabindex:"0"}}),this.itemTemplate){var d=this.compiletemplate(this.itemTemplate);p.forEach(function(e){var i=r.createElement("li",{className:e.separator?m.ITEM+" "+m.SEPARATOR:m.ITEM,attrs:e.separator?{role:"separator",tabindex:"-1","aria-label":"separator","aria-hidden":"true"}:{role:"menuitem",tabindex:"-1","aria-label":e.text},id:e.id?e.id:t.getUniqueID("e-"+r.getModuleName()+"-item")}),s=d(e,r,"template",null,!1,null,i);s&&t.append(s,i),e.disabled&&i.classList.add("e-disabled");var n={item:e,element:i};r.trigger("beforeItemRender",n),n.item.disabled!==e.disabled&&i.classList[n.item.disabled?"add":"remove"]("e-disabled"),c.appendChild(i)}),this.isReact&&this.renderReactTemplates()}else for(var h=0;h<p.length;h++){s=p[h],this.enableHtmlSanitizer&&(s.text=t.SanitizeHtmlHelper.sanitize(s.text));var u=s.text;n=this.createElement("li",{innerHTML:s.url?"":u,className:s.separator?m.ITEM+" "+m.SEPARATOR:m.ITEM,attrs:s.separator?{role:"separator",tabindex:"-1","aria-label":"separator","aria-hidden":"true"}:{role:"menuitem",tabindex:"-1","aria-label":u},id:s.id?s.id:t.getUniqueID("e-"+this.getModuleName()+"-item")}),this.enableHtmlSanitizer?n.textContent=s.url?"":u:n.innerHTML=s.url?"":u,s.url&&(n.appendChild(this.createAnchor(s)),n.classList.add("e-url")),s.iconCss?(i=this.createElement("span",{className:m.ICON+" "+s.iconCss}),s.url?n.childNodes[0].appendChild(i):n.insertBefore(i,n.childNodes[0])):l&&!s.separator&&n.classList.add("e-blank-icon");var y=s.disabled;s.disabled&&n.classList.add("e-disabled"),o={item:s,element:n},this.trigger("beforeItemRender",o),y!==o.item.disabled&&(o.item.disabled?n.classList.add("e-disabled"):n.classList.remove("e-disabled")),c.appendChild(n)}e&&this.getPopUpElement().appendChild(c),l&&a(this.getPopUpElement())},r.prototype.compiletemplate=function(e){if(this.itemTemplate)try{if("function"!=typeof this.itemTemplate){var i=document.querySelector(this.itemTemplate);if(i)return t.compile(i.innerHTML.trim())}return t.compile(e)}catch(i){return t.compile(e)}},r.prototype.hasIcon=function(e,t){for(var i=0,s=e.length;i<s;i++)if(e[i][""+t])return!0;return!1},r.prototype.createAnchor=function(e){var t=e.text,i=this.createElement("a",{className:"e-menu-text e-menu-url",attrs:{href:e.url}});return this.enableHtmlSanitizer?i.textContent=t:i.innerHTML=t,i},r.prototype.initialize=function(){this.button=new i.Button({iconCss:this.iconCss,iconPosition:this.iconPosition,cssClass:this.cssClass,content:this.content,disabled:this.disabled,enableRtl:this.enableRtl,enablePersistence:this.enablePersistence}),this.button.createElement=this.createElement,this.button.appendTo(this.element),this.element.id||(this.element.id=t.getUniqueID("e-"+this.getModuleName())),this.appendArrowSpan(),this.setActiveElem([this.element]),this.element.setAttribute("tabindex","0"),this.element.setAttribute("aria-label",this.element.textContent?this.element.textContent:"dropdownbutton"),this.target&&!this.isColorPicker()&&!this.createPopupOnClick||!this.createPopupOnClick?this.createPopup():(this.isPopupCreated=!1,this.target&&!this.isColorPicker()&&this.createPopupOnClick&&(this.popupContent=this.getTargetElement(),this.popupContent.style.display="none"))},r.prototype.isColorPicker=function(){if(!this.element)return!1;var e=this.element.previousSibling;return!!(e&&e.classList&&e.classList.contains("e-split-colorpicker"))},r.prototype.appendArrowSpan=function(){this.cssClass=t.isNullOrUndefined(this.cssClass)?"":this.cssClass,this.element.appendChild(this.createElement("span",{className:"e-btn-icon e-icons e-icon-"+(this.cssClass.indexOf(m.VERTICAL)>-1?"bottom":"right")+" e-caret"}))},r.prototype.setActiveElem=function(e){this.activeElem=e},r.prototype.getModuleName=function(){return"dropdown-btn"},r.prototype.canOpen=function(){var e=!1;return this.isPopupCreated&&(e=this.getPopUpElement().classList.contains("e-popup-close")),e},r.prototype.destroy=function(){var i=this;if(e.prototype.destroy.call(this),"dropdown-btn"===this.getModuleName()){var s;this.element.querySelector("span.e-caret")&&t.detach(this.element.querySelector("span.e-caret")),this.cssClass&&(s=this.cssClass.split(" ")),this.button.destroy(),s&&t.removeClass([this.element],s),t.removeClass(this.activeElem,["e-active"]),(this.element.getAttribute("class")?["aria-haspopup","aria-expanded","aria-owns","type"]:["aria-haspopup","aria-expanded","aria-owns","type","class"]).forEach(function(e){i.element.removeAttribute(e)}),this.popupUnWireEvents(),this.destroyPopup(),this.isPopupCreated=!1,this.disabled||this.unWireEvents()}},r.prototype.destroyPopup=function(){if(this.isPopupCreated){if(this.dropDown.destroy(),this.getPopUpElement()){var e=document.getElementById(this.getPopUpElement().id);e&&(t.removeClass([e],["e-popup-open","e-popup-close"]),t.detach(e))}t.EventHandler.remove(this.getPopUpElement(),"click",this.clickHandler),t.EventHandler.remove(this.getPopUpElement(),"keydown",this.keyBoardHandler),this.isPopupCreated&&this.dropDown&&(this.dropDown.element=null,this.dropDown=void 0)}this.isPopupCreated=!1;var i=t.getComponent(this.activeElem[0],"split-btn");if(this.createPopupOnClick&&i){var s=t.getComponent(this.activeElem[1],"dropdown-btn");s&&(s.isPopupCreated=!1)}},r.prototype.getPopUpElement=function(){var e=null;if(!this.dropDown&&this.activeElem[0].classList.contains("e-split-btn")){var i=t.getComponent(this.activeElem[1],"dropdown-btn");i&&(this.dropDown=i.dropDown)}return this.dropDown&&(e=this.dropDown.element),e},r.prototype.getULElement=function(){var e=null;return this.getPopUpElement()&&(e=this.getPopUpElement().children[0]),e},r.prototype.wireEvents=function(){this.delegateMousedownHandler=this.mousedownHandler.bind(this),this.createPopupOnClick||t.EventHandler.add(document,"mousedown touchstart",this.delegateMousedownHandler,this),t.EventHandler.add(this.element,"click",this.clickHandler,this),t.EventHandler.add(this.element,"keydown",this.keyBoardHandler,this),t.EventHandler.add(window,"resize",this.windowResize,this)},r.prototype.windowResize=function(){!this.canOpen()&&this.dropDown&&this.dropDown.refreshPosition(this.element)},r.prototype.popupWireEvents=function(){this.delegateMousedownHandler||(this.delegateMousedownHandler=this.mousedownHandler.bind(this));var e=this.getPopUpElement();this.createPopupOnClick&&t.EventHandler.add(document,"mousedown touchstart",this.delegateMousedownHandler,this),e&&(t.EventHandler.add(e,"click",this.clickHandler,this),t.EventHandler.add(e,"keydown",this.keyBoardHandler,this),this.closeActionEvents&&t.EventHandler.add(e,this.closeActionEvents,this.focusoutHandler,this)),this.rippleFn=t.rippleEffect(e,{selector:"."+m.ITEM})},r.prototype.popupUnWireEvents=function(){var e=this.getPopUpElement();this.createPopupOnClick&&t.EventHandler.remove(document,"mousedown touchstart",this.delegateMousedownHandler),e&&e.parentElement&&(t.EventHandler.remove(e,"click",this.clickHandler),t.EventHandler.remove(e,"keydown",this.keyBoardHandler),this.closeActionEvents&&t.EventHandler.remove(e,this.closeActionEvents,this.focusoutHandler)),t.isRippleEnabled&&this.rippleFn&&this.rippleFn()},r.prototype.keyBoardHandler=function(e){if(e.target!==this.element||9!==e.keyCode&&(e.altKey||40!==e.keyCode)&&38!==e.keyCode)switch(e.target&&(e.target.classList.contains("e-item")||e.target.parentElement&&e.target.parentElement.classList.contains("e-split-btn-wrapper"))&&13===e.keyCode&&e.preventDefault(),e.keyCode){case 38:case 40:!e.altKey||38!==e.keyCode&&40!==e.keyCode?this.upDownKeyHandler(e):this.keyEventHandler(e);break;case 9:case 13:case 27:case 32:this.keyEventHandler(e)}},r.prototype.isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},r.prototype.upDownKeyHandler=function(e){(!this.target||38!==e.keyCode&&40!==e.keyCode)&&(e.preventDefault(),o(this.getULElement(),e.keyCode))},r.prototype.keyEventHandler=function(e){if(!this.target||13!==e.keyCode&&9!==e.keyCode)return 13===e.keyCode&&this.activeElem[0].classList.contains("e-split-btn")?(this.triggerSelect(e),void this.activeElem[0].focus()):void(e.target&&e.target.className.indexOf("e-edit-template")>-1&&32===e.keyCode||(9!==e.keyCode&&e.preventDefault(),27===e.keyCode||38===e.keyCode||9===e.keyCode?this.canOpen()||this.closePopup(e,this.element):this.clickHandler(e)))},r.prototype.getLI=function(e){return"LI"===e.tagName?e:t.closest(e,"li")},r.prototype.mousedownHandler=function(e){var i=e.target;!this.dropDown||this.canOpen()||!this.getPopUpElement()||t.closest(i,'[id="'+this.getPopUpElement().id+'"]')||t.closest(i,'[id="'+this.element.id+'"]')||this.closePopup(e)},r.prototype.focusoutHandler=function(e){if(this.isPopupCreated&&!this.canOpen()){var t=e.relatedTarget||e.target;if(t&&t.className.indexOf("e-item")>-1){var i=this.getLI(t);if(i){var s=Array.prototype.indexOf.call(this.getULElement().children,i),n=this.items[s];if(n){var o={element:i,item:n,event:e};this.trigger("select",o)}}}this.closePopup(e)}},r.prototype.clickHandler=function(e){var i=e.target;t.closest(i,'[id="'+this.element.id+'"]')?!this.createPopupOnClick||this.target&&""!==this.target&&!this.isColorPicker()&&!this.createPopupOnClick?this.getPopUpElement().classList.contains("e-popup-close")?this.openPopUp(e):this.closePopup(e):this.isPopupCreated?this.closePopup(e,this.activeElem[0]):(this.createPopup(),this.openPopUp(e)):t.closest(i,'[id="'+this.getPopUpElement().id+'"]')&&this.getLI(e.target)&&(this.triggerSelect(e),this.closePopup(e,this.activeElem[0]))},r.prototype.triggerSelect=function(e){var t,i,s,n=this.getLI(e.target);n&&(i=Array.prototype.indexOf.call(this.getULElement().children,n),(s=this.items[i])&&(t={element:n,item:s,event:e},this.trigger("select",t)))},r.prototype.openPopUp=function(e){var i=this;void 0===e&&(e=null);var s=this.getPopUpElement();if(this.activeElem[0]&&this.activeElem[0].classList.contains("e-dropdown-btn")&&s.style.width&&"auto"!==s.style.width&&this.setWidth(s),this.target)if(this.activeElem.length>1){var n=t.getComponent(this.activeElem[0],"split-btn");n.isReact&&s.childNodes.length<1&&(n.appendReactElement&&n.appendReactElement(this.getTargetElement(),this.getPopUpElement()),this.renderReactTemplates())}else this.isReact&&s.childNodes.length<1&&(this.appendReactElement&&this.appendReactElement(this.getTargetElement(),this.getPopUpElement()),this.renderReactTemplates());else this.createItems(!0);var o=this.getULElement();this.popupWireEvents();var r={element:o,items:this.items,event:e,cancel:!1};this.trigger("beforeOpen",r,function(e){if(!e.cancel){var s=i.getULElement(),n="None"!==i.animationSettings.effect?{name:i.animationSettings.effect,duration:i.animationSettings.duration,timingFunction:i.animationSettings.easing}:null;if(n&&i.animatePopup(n,s),i.dropDown.show(null,i.element),t.addClass([i.element],"e-active"),i.element.setAttribute("aria-expanded","true"),i.element.setAttribute("aria-owns",i.getPopUpElement().id),s&&!i.isSafari()&&s.focus(),i.enableRtl&&"0px"!==s.parentElement.style.left){var o=void 0;o=i.element.parentElement&&i.element.parentElement.classList.contains("e-split-btn-wrapper")?i.element.parentElement.offsetWidth:i.element.offsetWidth;var r=s.parentElement.offsetWidth-o,a=parseFloat(s.parentElement.style.left)-r;a<0&&(a=0),s.parentElement.style.left=a+"px"}var p={element:s,items:i.items};i.trigger("open",p),s&&i.isSafari()&&s.focus()}})},r.prototype.animatePopup=function(e,i){new t.Animation(e).animate(i,{begin:function(e){e.element.parentElement.style.height=e.element.parentElement.offsetHeight+"px"}})},r.prototype.setWidth=function(e){var i=t.formatUnit(e.style.width);if(i.indexOf("%")>-1){var s=this.element.offsetWidth*parseFloat(i)/100;e.style.width=s+"px"}},r.prototype.closePopup=function(e,i){var s=this;void 0===e&&(e=null);var n=this.getULElement(),o={element:n,items:this.items,event:e,cancel:!1};this.trigger("beforeClose",o,function(o){if(o.cancel)n&&n.focus();else{var r=s.getPopUpElement();r&&t.EventHandler.remove(r,"keydown",s.keyBoardHandler),s.popupUnWireEvents();var a=s.getULElement(),p=void 0;a&&(p=a.querySelector(".e-selected")),p&&p.classList.remove("e-selected"),s.dropDown&&s.dropDown.hide(),t.removeClass(s.activeElem,"e-active"),s.element.setAttribute("aria-expanded","false"),s.element.removeAttribute("aria-owns"),i&&(s.isSafari()?i.focus({preventScroll:!0}):s.isColorPicker()&&27===e.keyCode||i.focus());var l={element:a,items:s.items};s.trigger("close",l),!s.target&&a&&t.detach(a),(!s.target||s.isColorPicker()||s.target&&!s.isColorPicker())&&s.createPopupOnClick&&s.destroyPopup()}})},r.prototype.unWireEvents=function(){this.createPopupOnClick||t.EventHandler.remove(document,"mousedown touchstart",this.delegateMousedownHandler),t.EventHandler.remove(this.element,"click",this.clickHandler),t.EventHandler.remove(this.element,"keydown",this.keyBoardHandler),this.isPopupCreated&&(t.EventHandler.remove(this.getPopUpElement(),"click",this.clickHandler),t.EventHandler.remove(this.getPopUpElement(),"keydown",this.keyBoardHandler)),t.EventHandler.remove(window,"resize",this.windowResize)},r.prototype.onPropertyChanged=function(e,i){var s=["content","cssClass","iconCss","iconPosition","disabled","enableRtl"];this.button.setProperties(n(e,s));var o;this.isPopupCreated&&(o=this.getPopUpElement(),this.dropDown.setProperties(n(e,["enableRtl"])));for(var r=0,a=Object.keys(e);r<a.length;r++)switch(a[r]){case"content":this.element.querySelector("span.e-caret")||this.appendArrowSpan();break;case"disabled":e.disabled?(this.unWireEvents(),this.isPopupCreated&&!this.canOpen()&&this.closePopup()):this.wireEvents();break;case"cssClass":if(i.cssClass=t.isNullOrUndefined(i.cssClass)?"":i.cssClass,e.cssClass.indexOf(m.VERTICAL)>-1||i.cssClass.indexOf(m.VERTICAL)>-1){this.element.querySelector("span.e-caret")||this.appendArrowSpan();var p=this.element.querySelector("span.e-caret");e.cssClass.indexOf(m.VERTICAL)>-1?t.classList(p,["e-icon-bottom"],["e-icon-right"]):t.classList(p,["e-icon-right"],["e-icon-bottom"])}this.isPopupCreated&&(i.cssClass&&t.removeClass([o],i.cssClass.split(" ")),e.cssClass&&t.addClass([o],e.cssClass.replace(/\s+/g," ").trim().split(" ")));break;case"target":this.dropDown.content=this.getTargetElement(),this.dropDown.dataBind();break;case"items":this.isPopupCreated&&this.getULElement()&&this.createItems();break;case"createPopupOnClick":e.createPopupOnClick?this.destroyPopup():this.createPopup()}},r.prototype.focusIn=function(){this.element.focus()},u([t.Property("")],r.prototype,"content",void 0),u([t.Property("")],r.prototype,"cssClass",void 0),u([t.Property(!1)],r.prototype,"disabled",void 0),u([t.Property("")],r.prototype,"iconCss",void 0),u([t.Property("Left")],r.prototype,"iconPosition",void 0),u([t.Property(!0)],r.prototype,"enableHtmlSanitizer",void 0),u([t.Collection([],d)],r.prototype,"items",void 0),u([t.Property(!1)],r.prototype,"createPopupOnClick",void 0),u([t.Property("")],r.prototype,"target",void 0),u([t.Property("")],r.prototype,"closeActionEvents",void 0),u([t.Property(null)],r.prototype,"itemTemplate",void 0),u([t.Property("auto")],r.prototype,"popupWidth",void 0),u([t.Complex({effect:"None"},y)],r.prototype,"animationSettings",void 0),u([t.Event()],r.prototype,"beforeItemRender",void 0),u([t.Event()],r.prototype,"beforeOpen",void 0),u([t.Event()],r.prototype,"beforeClose",void 0),u([t.Event()],r.prototype,"close",void 0),u([t.Event()],r.prototype,"open",void 0),u([t.Event()],r.prototype,"select",void 0),u([t.Event()],r.prototype,"created",void 0),r=u([t.NotifyPropertyChanges],r)}(t.Component),v=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(t,i)};return function(t,i){function s(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),g=function(e,t,i,s){var n,o=arguments.length,r=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,i,r):n(t,i))||r);return o>3&&r&&Object.defineProperty(t,i,r),r},b="e-rtl",C="EJS-SPLITBUTTON",P=function(e){function s(t,i){return e.call(this,t,i)||this}return v(s,e),s.prototype.preRender=function(){var e=this.element;if(e.tagName===C){for(var i=t.getValue("ej2_instances",e),s=this.createElement("button",{attrs:{type:"button"}}),n=this.createElement(C,{className:"e-"+this.getModuleName()+"-wrapper"}),o=0,r=e.attributes.length;o<r;o++)s.setAttribute(e.attributes[o].nodeName,e.attributes[o].nodeValue);e.parentNode.insertBefore(n,e),t.detach(e),e=s,n.appendChild(e),t.setValue("ej2_instances",i,e),this.wrapper=n,this.element=e}this.element.id||(this.element.id=t.getUniqueID("e-"+this.getModuleName()))},s.prototype.render=function(){this.initWrapper(),this.createPrimaryButton(),this.renderControl()},s.prototype.renderControl=function(){this.createSecondaryButton(),this.setActiveElem([this.element,this.secondaryBtnObj.element]),this.setAria(),this.wireEvents(),this.renderComplete()},s.prototype.addItems=function(t,i){e.prototype.addItems.call(this,t,i),this.secondaryBtnObj.items=this.items},s.prototype.removeItems=function(t,i){e.prototype.removeItems.call(this,t,i),this.secondaryBtnObj.items=this.items},s.prototype.initWrapper=function(){this.wrapper||(this.wrapper=this.createElement("div",{className:"e-"+this.getModuleName()+"-wrapper"}),this.element.parentNode.insertBefore(this.wrapper,this.element)),this.element.classList.remove("e-"+this.getModuleName()),this.enableRtl&&this.wrapper.classList.add(b),this.cssClass&&t.addClass([this.wrapper],this.cssClass.replace(/\s+/g," ").trim().split(" "))},s.prototype.createPrimaryButton=function(){var e={cssClass:this.cssClass,enableRtl:this.enableRtl,iconCss:this.iconCss,iconPosition:this.iconPosition,content:this.content,disabled:this.disabled};this.primaryBtnObj=new i.Button(e),this.primaryBtnObj.createElement=this.createElement,this.primaryBtnObj.appendTo(this.element),this.element.classList.add("e-"+this.getModuleName()),this.element.type="button",this.wrapper.appendChild(this.element)},s.prototype.createSecondaryButton=function(){var e=this,t=this.createElement("button",{className:"e-icon-btn",attrs:{tabindex:"-1"},id:this.element.id+"_dropdownbtn"});this.wrapper.appendChild(t);var i={cssClass:this.cssClass,disabled:this.disabled,enableRtl:this.enableRtl,items:this.items,target:this.target,createPopupOnClick:this.createPopupOnClick};i.beforeItemRender=function(t){e.createPopupOnClick&&(e.secondaryBtnObj.dropDown.relateTo=e.wrapper,e.dropDown=e.secondaryBtnObj.dropDown),e.trigger("beforeItemRender",t)},i.open=function(t){e.trigger("open",t)},i.close=function(t){e.trigger("close",t)},i.select=function(t){e.trigger("select",t)},i.beforeOpen=function(t){e.createPopupOnClick&&0===e.items.length&&(e.secondaryBtnObj.dropDown.relateTo=e.wrapper,e.dropDown=e.secondaryBtnObj.dropDown);var i=new E;return e.trigger("beforeOpen",t,function(e){i.resolve(e)}),i},i.beforeClose=function(t){var i=new E;return e.trigger("beforeClose",t,function(e){i.resolve(e)}),i},this.secondaryBtnObj=new f(i),this.secondaryBtnObj.createElement=this.createElement,this.secondaryBtnObj.appendTo(t),this.createPopupOnClick||(this.secondaryBtnObj.dropDown.relateTo=this.wrapper,this.dropDown=this.secondaryBtnObj.dropDown),this.isPopupCreated=this.secondaryBtnObj.isPopupCreated,this.secondaryBtnObj.activeElem=[this.element,this.secondaryBtnObj.element],this.secondaryBtnObj.element.querySelector(".e-btn-icon").classList.remove("e-icon-right"),this.disabled&&this.wrapper.classList.add("e-splitbtn-disabled")},s.prototype.setAria=function(){t.attributes(this.element,{"aria-expanded":"false","aria-haspopup":"true","aria-label":this.element.textContent?this.element.textContent+" splitbutton":"splitbutton","aria-owns":this.element.id+"_dropdownbtn-popup"})},s.prototype.getModuleName=function(){return"split-btn"},s.prototype.toggle=function(){this.secondaryBtnObj.toggle()},s.prototype.destroy=function(){var i=this,s=[b];if(this.cssClass&&(s=s.concat(this.cssClass.split(" "))),this.element){var n=document.getElementById(this.element.id);n&&n.parentElement===this.wrapper&&(this.wrapper.tagName===C?(this.wrapper.innerHTML="",t.removeClass([this.wrapper],["e-rtl","e-"+this.getModuleName()+"-wrapper"]),t.removeClass([this.wrapper],this.cssClass.split(" "))):(t.removeClass([this.element],s),["aria-label","aria-haspopup","aria-expanded","aria-owns","type"].forEach(function(e){i.element.removeAttribute(e)}),this.wrapper.parentNode.insertBefore(this.element,this.wrapper),t.remove(this.wrapper)),this.unWireEvents())}this.primaryBtnObj.destroy(),this.secondaryBtnObj.destroy(),e.prototype.destroy.call(this),this.element&&!this.element.getAttribute("class")&&this.element.removeAttribute("class"),this.refreshing&&this.isAngular&&(this.element=this.wrapper,["e-control","e-split-btn","e-lib"].forEach(function(e){i.element.classList.add(e)}),t.setValue("ej2_instances",[this],this.element)),this.wrapper=null},s.prototype.wireEvents=function(){t.EventHandler.add(this.element,"click",this.primaryBtnClickHandler,this),new t.KeyboardEvents(this.element,{keyAction:this.btnKeyBoardHandler.bind(this),keyConfigs:{altdownarrow:"alt+downarrow",enter:"enter"}})},s.prototype.unWireEvents=function(){t.EventHandler.remove(this.element,"click",this.primaryBtnClickHandler),t.getInstance(this.element,t.KeyboardEvents).destroy()},s.prototype.primaryBtnClickHandler=function(){this.trigger("click",{element:this.element})},s.prototype.btnKeyBoardHandler=function(e){switch(e.action){case"altdownarrow":this.clickHandler(e);break;case"enter":this.clickHandler(e),this.getPopUpElement()&&!this.getPopUpElement().classList.contains("e-popup-close")?(this.element.classList.remove("e-active"),this.secondaryBtnObj.element.classList.add("e-active")):this.secondaryBtnObj.element.classList.remove("e-active")}},s.prototype.onPropertyChanged=function(e,i){var s=["content","iconCss","iconPosition","cssClass","disabled","enableRtl"];this.primaryBtnObj.setProperties(n(e,s)),s=["beforeOpen","beforeItemRender","select","open","close","cssClass","disabled","enableRtl","createPopupOnClick"],Object.keys(e).indexOf("items")>-1&&(this.secondaryBtnObj.items=e.items,this.secondaryBtnObj.dataBind()),this.secondaryBtnObj.setProperties(n(e,s));for(var o=0,r=Object.keys(e);o<r.length;o++)switch(r[o]){case"cssClass":i.cssClass&&t.removeClass([this.wrapper],i.cssClass.split(" ")),t.addClass([this.wrapper],e.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"enableRtl":e.enableRtl?t.addClass([this.wrapper],b):t.removeClass([this.wrapper],b);break;case"disabled":e.disabled?t.addClass([this.wrapper],"e-splitbtn-disabled"):t.removeClass([this.wrapper],"e-splitbtn-disabled")}},s.prototype.focusIn=function(){this.element.focus()},g([t.Property("")],s.prototype,"content",void 0),g([t.Property("")],s.prototype,"cssClass",void 0),g([t.Property(!1)],s.prototype,"disabled",void 0),g([t.Property("")],s.prototype,"iconCss",void 0),g([t.Property("Left")],s.prototype,"iconPosition",void 0),g([t.Property(!1)],s.prototype,"createPopupOnClick",void 0),g([t.Collection([],d)],s.prototype,"items",void 0),g([t.Property("")],s.prototype,"target",void 0),g([t.Event()],s.prototype,"beforeItemRender",void 0),g([t.Event()],s.prototype,"beforeOpen",void 0),g([t.Event()],s.prototype,"beforeClose",void 0),g([t.Event()],s.prototype,"click",void 0),g([t.Event()],s.prototype,"close",void 0),g([t.Event()],s.prototype,"open",void 0),g([t.Event()],s.prototype,"select",void 0),g([t.Event()],s.prototype,"created",void 0),s=g([t.NotifyPropertyChanges],s)}(f),E=function(){function e(){var e=this;this.promise=new Promise(function(t,i){e.resolve=t,e.reject=i}),this.catch=this.promise.catch.bind(this.promise),this.then=this.promise.then.bind(this.promise)}return e}(),w=function(){var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(t,i)};return function(t,i){function s(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(s.prototype=i.prototype,new s)}}(),O=function(e,t,i,s){var n,o=arguments.length,r=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(o<3?n(r):o>3?n(t,i,r):n(t,i))||r);return o>3&&r&&Object.defineProperty(t,i,r),r},k="e-btn-content",S=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return w(i,e),O([t.Property(null)],i.prototype,"template",void 0),O([t.Property(16)],i.prototype,"width",void 0),O([t.Property("Left")],i.prototype,"position",void 0),i}(t.ChildProperty),L=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return w(i,e),O([t.Property(400)],i.prototype,"duration",void 0),O([t.Property("None")],i.prototype,"effect",void 0),O([t.Property("ease")],i.prototype,"easing",void 0),i}(t.ChildProperty),H=function(e){function i(t,i){var s=e.call(this,t,i)||this;return s.step=1,s}return w(i,e),i.prototype.preRender=function(){e.prototype.preRender.call(this)},i.prototype.render=function(){e.prototype.render.call(this),this.init(),this.wireEvents(),this.setAria(),this.renderComplete()},i.prototype.start=function(e){this.isPaused=!1,this.startProgress(e||this.percent,this.progressTime)},i.prototype.stop=function(){this.isPaused=!0,cancelAnimationFrame(this.timerId)},i.prototype.progressComplete=function(){this.isPaused=!1,this.finishProgress()},i.prototype.getModuleName=function(){return"progress-btn"},i.prototype.destroy=function(){var i=this,s=["e-hide-spinner","e-progress-active","e-round-corner","e-"+e.prototype.getModuleName.call(this)];this.spinSettings.position&&s.push("e-spin-"+this.spinSettings.position.toLowerCase()),e.prototype.destroy.call(this),this.unWireEvents(),this.element.innerHTML="",this.cssClass&&(s=s.concat(this.cssClass.split(" "))),t.removeClass([this.element],s),(this.element.getAttribute("class")?["aria-label","aria-valuemin","aria-valuemax","aria-valuenow"]:["aria-label","aria-valuemin","aria-valuemax","aria-valuenow","class"]).forEach(function(e){i.element.removeAttribute(e)}),this.disabled&&this.element.removeAttribute("disabled")},i.prototype.init=function(){this.element.classList.add("e-"+e.prototype.getModuleName.call(this)),this.setContent(),this.createSpinner(),this.enableProgress&&this.createProgress()},i.prototype.createSpinner=function(){var e=this.createElement("span",{className:"e-spinner"});this.setSpinPosition(e),s.createSpinner({target:e,width:this.spinSettings.width||16,template:this.spinSettings.template},this.createElement)},i.prototype.getSpinner=function(){return this.element.getElementsByClassName("e-spinner")[0]},i.prototype.getProgress=function(){return this.element.getElementsByClassName("e-progress")[0]},i.prototype.setSpinPosition=function(e){var t=this.spinSettings.position||"Left";"Left"===t||"Top"===t?this.element.insertBefore(e,this.element.getElementsByClassName(k)[0]):this.element.appendChild(e),this.element.classList.add("e-spin-"+t.toLowerCase())},i.prototype.createProgress=function(){this.element.appendChild(this.createElement("span",{className:"e-progress"}))},i.prototype.setContent=function(){var e;e=this.element.innerHTML,this.enableHtmlSanitizer&&(e=t.SanitizeHtmlHelper.sanitize(this.element.innerHTML)),this.element.innerHTML="",this.element.appendChild(this.createElement("span",{className:k,innerHTML:e}))},i.prototype.clickHandler=function(){this.element.classList.contains("e-progress-active")||this.startProgress()},i.prototype.startProgress=function(e,t){var i=this.element.classList,n=i.contains("e-vertical");i.add("e-progress-active"),i.contains("e-hide-spinner")||s.showSpinner(this.element.querySelector(".e-spinner")),this.startAnimate(Date.now(),t||0,t?Date.now()-1*this.duration/100:Date.now(),e||0,0,this.step,0,n),this.startContAnimate()},i.prototype.startAnimate=function(e,t,i,s,n,o,r,a){var p=this;try{var l=e-i,c=this.duration*o/100,d=l?l<c?l-c:l%c:0;this.progressTime=t=t+l-d,i=e-d,s+=(l-d)/this.duration*100;var h={percent:n=(t-r)%c==0||100===s?s:n,currentDuration:t,step:o};this.eIsVertical=a,0===s?this.trigger("begin",h,function(e){p.successCallback(e,s,n,t,r,d,i)}):100===s||t===this.duration?this.trigger("end",h,function(e){p.successCallback(e,s,n,t,r,d,i)}):this.trigger("progress",h,function(e){p.successCallback(e,s,n,t,r,d,i)})}catch(e){cancelAnimationFrame(this.timerId),this.trigger("fail",e)}},i.prototype.successCallback=function(e,t,i,s,n,o,r){var a=this,p=t,l=i,c=o,d=s,h=n,u=r,m=this.eIsVertical;p!==e.percent&&e.percent!==l&&(p=e.percent),this.percent=p,this.step=e.step,(d-h)%(this.duration*e.step/100)!=0&&100!==p||(this.timerId=requestAnimationFrame(function(){a.enableProgress&&a.getProgress()&&(a.getProgress().style[m?"height":"width"]=p+"%"),a.element.setAttribute("aria-valuenow",p.toString())}),l=p,h=d),this.isPaused||(d<this.duration&&p<100?this.interval=window.setTimeout(function(){a.startAnimate(Date.now(),d,u,p,l,e.step,h,m)},this.duration/100-c):this.interval=window.setTimeout(function(){a.progressTime=a.percent=0,a.enableProgress&&a.getProgress()&&(a.getProgress().style[m?"height":"width"]="0%"),a.element.setAttribute("aria-valuenow","0"),a.hideSpin()},100))},i.prototype.startContAnimate=function(){var e=this,i=this.element.getElementsByClassName(k)[0];"None"!==this.animationSettings.effect?new t.Animation({}).animate(i,{duration:0===this.animationSettings.duration&&"Enable"===t.animationMode?400:this.animationSettings.duration,name:"Progress"+this.animationSettings.effect,timingFunction:this.animationSettings.easing,begin:function(){"Center"===e.spinSettings.position&&e.setSpinnerSize()},end:function(){i.classList.add("e-animate-end")}}):"Center"===this.spinSettings.position&&this.setSpinnerSize()},i.prototype.finishProgress=function(){var e=this.element.classList,t=e.contains("e-vertical");e.add("e-progress-active");for(var i=this.percent;i<100;i++)(i+=10)>100&&(i=100),this.enableProgress&&this.getProgress()&&(this.getProgress().style[t?"height":"width"]=this.percent<100?i+"%":"100%");this.element.setAttribute("aria-valuenow","0"),this.hideSpin();var s={step:this.step,currentDuration:this.progressTime,percent:100};clearTimeout(this.interval),this.trigger("end",s),this.progressTime=this.percent=0},i.prototype.setSpinnerSize=function(){var e=this.element.getElementsByClassName(k)[0],t=this.getSpinner();t.style.width=Math.max(t.offsetWidth,e.offsetWidth)+"px",t.style.height=Math.max(t.offsetHeight,e.offsetHeight)+"px",e.classList.add("e-cont-animate")},i.prototype.hideSpin=function(){var e=this.element.getElementsByClassName(k)[0];if(this.element.classList.contains("e-hide-spinner")||s.hideSpinner(this.element.querySelector(".e-spinner")),this.element.classList.remove("e-progress-active"),"None"!==this.animationSettings.effect&&e.classList.remove("e-animate-end"),"Center"===this.spinSettings.position){var t=this.getSpinner();e.classList.remove("e-cont-animate"),t.style.width="auto",t.style.height="auto"}},i.prototype.setIconSpan=function(){var e=this.element.getElementsByClassName(k)[0],t=this.element.getElementsByClassName("e-btn-icon")[0];!e.childNodes[0]||"Left"!==this.iconPosition&&"Top"!==this.iconPosition?e.appendChild(t):e.insertBefore(t,e.childNodes[0])},i.prototype.setAria=function(){t.attributes(this.element,{"aria-label":this.element.textContent+" progress"})},i.prototype.wireEvents=function(){t.EventHandler.add(this.element,"click",this.clickHandler,this)},i.prototype.unWireEvents=function(){t.EventHandler.remove(this.element,"click",this.clickHandler)},i.prototype.onPropertyChanged=function(i,n){var o=this.element,r=!1;this.element.querySelector(".e-spinner-pane").classList.contains("e-spin-show")&&(r=!0),e.prototype.onPropertyChanged.call(this,i,n);for(var a=0,p=Object.keys(i);a<p.length;a++)switch(p[a]){case"content":this.setContent(),this.createSpinner(),r&&(s.showSpinner(this.element.querySelector(".e-spinner")),r=!1),this.enableProgress&&this.createProgress(),o.setAttribute("aria-label",o.textContent+" progress");break;case"iconCss":n.iconCss||this.setIconSpan();break;case"iconPosition":this.setIconSpan();break;case"enableProgress":i.enableProgress?this.createProgress():t.remove(this.getProgress());break;case"spinSettings":i.spinSettings.position&&(o.classList.remove("e-spin-"+n.spinSettings.position.toLowerCase()),this.setSpinPosition(this.getSpinner())),(i.spinSettings.template||i.spinSettings.width)&&(o.removeChild(this.getSpinner()),this.createSpinner())}},i.prototype.focusIn=function(){this.element.focus()},O([t.Property(!1)],i.prototype,"enableProgress",void 0),O([t.Property(2e3)],i.prototype,"duration",void 0),O([t.Property("Left")],i.prototype,"iconPosition",void 0),O([t.Property("")],i.prototype,"iconCss",void 0),O([t.Property(!1)],i.prototype,"disabled",void 0),O([t.Property(!1)],i.prototype,"isPrimary",void 0),O([t.Property("")],i.prototype,"cssClass",void 0),O([t.Property("")],i.prototype,"content",void 0),O([t.Property(!1)],i.prototype,"isToggle",void 0),O([t.Property(!0)],i.prototype,"enableHtmlSanitizer",void 0),O([t.Complex({},S)],i.prototype,"spinSettings",void 0),O([t.Complex({},L)],i.prototype,"animationSettings",void 0),O([t.Event()],i.prototype,"created",void 0),O([t.Event()],i.prototype,"begin",void 0),O([t.Event()],i.prototype,"progress",void 0),O([t.Event()],i.prototype,"end",void 0),O([t.Event()],i.prototype,"fail",void 0),i=O([t.NotifyPropertyChanges],i)}(i.Button);return e.AnimationSettings=L,e.Deferred=E,e.DropDownButton=f,e.DropDownMenuAnimationSettings=y,e.Item=d,e.ProgressButton=H,e.SpinSettings=S,e.SplitButton=P,e.createButtonGroup=p,e.getModel=n,e.setBlankIconStyle=a,e.upDownKeyHandler=o,e}({},ej.base,ej.buttons,ej.popups),this.ejs=ej;
//# sourceMappingURL=ej2-splitbuttons.min.js.map