@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) • 6.33 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("kendo.core.js"),require("kendo.icons.js"),require("kendo.button.js")):"function"==typeof define&&define.amd?define(["exports","kendo.core.min","kendo.icons.min","kendo.button.min"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).kendo=t.kendo||{},t.kendo._globals=t.kendo._globals||{},t.kendo._globals.ActionsheetView={}))}(this,(function(t){!function(t){const e=kendo.htmlEncode,n=kendo.ui.Widget,o=kendo.template,i=t.extend,s=kendo.guid(),a="k-disabled",c="aria-disabled",r=/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,l="k-actionsheet-view",d="k-actionsheet-content",u=t=>{const e=t.startButton?'<div class="k-actionsheet-actions">'+kendo.html.renderButton(`<button ${kendo.attr("ref-actionsheet-start-button")} aria-label="${t.startButton.text||"Start"}"></button>`,{icon:"chevron-left",fillMode:"flat",size:"large",...t.startButton})+"</div>":"",n=(t.closeButton&&kendo.html.renderButton(`<button ${kendo.attr("ref-actionsheet-close-button")}></button>`,{icon:"x",fillMode:"flat",size:"large"}),t.subtitle||""===t.subtitle?`<div class="k-actionsheet-subtitle k-text-center">${t.subtitle||""}</div>`:"");return'<div class="k-text-center k-actionsheet-titlebar" >'+(t.title||""===t.title?'<div class="k-actionsheet-titlebar-group k-hbox">'+e+`<div id="${s}" class="k-actionsheet-title">`+`<div class="k-text-center">${t.title}</div>`+n+"</div>"+(t.closeButton?'<div class="k-actionsheet-actions">'+kendo.html.renderButton(`<button ${kendo.attr("ref-actionsheet-close-button")} aria-label="${t.closeButton.text||"Close"}"></button>`,{icon:"x",fillMode:"flat",size:"large",...t.closeButton})+"</div>":"")+"</div>":"")+"</div>"},p=({disabled:t,icon:n,text:o,description:i})=>`<span role="button" tabindex="0" class="k-actionsheet-item ${t?a:""}"><span class="k-actionsheet-action">`+(n?`<span class="k-icon-wrap">${n}</span>`:"")+'<span class="k-actionsheet-item-text">'+`<span class="k-actionsheet-item-title">${e(o)}</span>`+(i?'<span class="k-actionsheet-item-description">'+e(i)+"</span>":"")+"</span></span></span>",h={text:"",description:"",iconClass:"",iconSize:0,iconColor:"",click:t.noop,group:"top",disabled:!1},f={text:"",icon:"",iconClass:"",click:t.noop,disabled:!1};function m(t){return i({},h,t)}function k(t){return i({},f,t)}const _=n.extend({init:function(t,e){const o=this;e=e||{},n.fn.init.call(o,t,e),e=i(!0,{},o.options,e),o._hasItems=e.items&&e.items.length,o._hasActionButtons=e.actionButtons&&e.actionButtons.length,o.index=e.index||1,o.ref=o.options.ref,o._mapItems(),o._mapActionButtons(),o._createContent(),o._createHeader(),o._createFooter(),o._wrapInView()},options:{id:"actionsheet-view",name:"ActionSheetView",headerTemplate:null,contentTemplate:null,footerTemplate:null,actionButtons:[],title:null,items:[],actionButtonsAlignment:"stretched",actionButtonsOrientation:"horizontal",closeButton:!1,startButton:!1,ref:"actionsheet-view",addAnimationClass:!1},_hasOtherView:function(){const t=this.element.children(`.${l}`);return t.length&&t.last()},_mapItems:function(){var t=this;t._hasItems&&(t.options.items=t.options.items.map(m))},_mapActionButtons:function(){var t=this;t._hasActionButtons&&(t.options.actionButtons=t.options.actionButtons.map(k))},_createContent:function(e){const n=this,i=n.options,s=t(`<div class='${d}'></div>`),a=n._hasOtherView();a&&a.length?n.element.append(s):n.element.wrapInner(s);const c=n._content=n.element.children("."+d);if(n._hasItems)return c.empty(),void n._items();(i.contentTemplate||e)&&c.html(o(e||i.contentTemplate)(i))},_items:function(){var t=this;if(t._hasItems){var e=t.options.items.reduce(((t,e)=>{const n=e.group||"top";return t[n]=t[n]||[],t[n].push(e),t}),new Map),n=e.top,o=e.bottom;t._createItems(n),n&&n.length&&o&&o.length&&t._content.append('<hr class="k-hr" />'),t._createItems(o)}},_createItems:function(e){var n,s,a,c,l,d,u,h,f=this._content,m=t("<div class='k-list-ul' role='group'></div>");if(e&&e.length)for(f.append(m),a=o(p),n=0;n<e.length;n++)s=e[n],u=void 0,h=void 0,h={},l=(d=s).iconClass||d.icon?(u=t(kendo.html.renderIcon({icon:d.icon,iconClass:d.iconClass+" k-actionsheet-item-icon"})),d.iconColor&&r.test(d.iconColor)?h.color=d.iconColor:d.iconColor&&u.addClass("k-text-"+d.iconColor),d.iconSize&&(h.fontSize=d.iconSize+"px"),Object.keys(h).length&&u.css(h),u):"",c=t(a(i({},s,{icon:l&&l.prop("outerHTML")}))),m.append(c),s.click&&c.data("action",s.click)},_createHeader:function(){var e=this,n=e.options;if(!n.title&&""!==n.title&&!n.headerTemplate)return;const i=e._hasOtherView();e._header=t(o(n.headerTemplate||u)(n)),i&&i.length?e._content.before(e._header):e.element.prepend(e._header)},_createFooter:function(e){const n=this,i=n.options;let s;if(n._hasActionButtons||i.footerTemplate||e){if(s=n._footer=t("<div class='k-actionsheet-footer'></div>"),s.insertAfter(n._content),n._hasActionButtons)return s.addClass(`k-actions k-actions-${i.actionButtonsAlignment} k-actions-${i.actionButtonsOrientation}`),void n._createActionButtons();(i.footerTemplate||e)&&n._footer.append(o(e||i.footerTemplate)(i))}},_createActionButtons:function(){for(var e,n=this.options.actionButtons,o=this._footer,i=0;i<n.length;i++){var s=n[i],r=!0!==s.disabled;e=t(kendo.html.renderButton(`<button ref-actionsheet-action-button>${s.text||""}</button>`,t.extend({size:"large"},s))),o.append(e),e.toggleClass(a,!r),e.attr("disabled",!r),r?e.removeAttr(c):e.attr(c,!r),s.click&&e.data("action",s.click)}},_wrapInView:function(){const e=this;e.wrapper&&e.wrapper.hasClass(l)||(e.wrapper=e._content.add(e._footer).add(e._header).wrapAll(t(`<div ref-${e.options.ref} class='${l}${e.options.addAnimationClass?" k-actionsheet-view-animated":""}'></div>`)).parent())},destroy:function(){const t=this;n.fn.destroy.call(t),t._content&&(t._content.remove(),t._content=null),t._footer&&(t._footer.remove(),t._footer=null),t._header&&(t._header.remove(),t._header=null),t.wrapper&&(t.wrapper.remove(),t.wrapper=null)}});kendo.ui.plugin(_)}(window.kendo.jQuery);var e=kendo;t.__meta__={id:"actionsheet.view",name:"ActionsheetView",category:"web",description:"A reusable outputed chunk of code",depends:["core","icons","button"],hidden:!0,chunk:!0},t.default=e,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=kendo.actionsheet.view.min.js.map