@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines • 6.89 kB
JavaScript
/* @license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.tooltip.min.js`),require(`kendo.html.button.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.tooltip.min`,`kendo.html.button.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Popover={}),e.kendo._globals.Tooltip,e.kendo._globals.HtmlButton))})(this,function(e,t,n){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let r={id:`popover`,name:`Popover`,category:`web`,description:`The Popover widget displays a popup with additional information for an element.`,depends:[`tooltip`,`html.button`],features:[{id:`popover-fx`,name:`Animation`,description:`Support for animation`,depends:[`fx`]}]};(function(e,t){var n=window.kendo,r=n.ui.Popup,i=n.ui.TooltipBase,a=e.extend,o=e(document),s=`.kendoPopover`,c=28,l=({index:e,text:t})=>n.html.renderButton(`<button ${e}>${t}</button>`,{fillMode:`flat`,themeColor:`primary`}),u=({index:e,text:t,icon:r,iconClass:i})=>n.html.renderButton(`<button ${e}>${t}</button>`,{icon:r,iconClass:`k-button-icon`+(i?` ${i}`:``)}),d=({index:e,icon:t,iconClass:r})=>n.html.renderButton(`<button ${e}></button>`,{icon:t,iconClass:`k-button-icon`+(r?` ${r}`:``)}),f=({header:e,actions:t,body:n,positioning:r})=>`${e?`<div class="k-popover-header">`+e+`</div>`:``}<div class="k-popover-body">${n}</div>${t?`<div class="k-popover-actions k-actions k-actions-horizontal k-justify-content-`+r+`">`+t+`</div>`:``}`,p=({callout:e,dir:t})=>`<div role="tooltip" class="k-popover">${e?`<div class="k-popover-callout k-callout-`+t+`"></div><div class="k-popover-inner"></div>`:``}</div>`,m=`show`,h=`hide`,g={top:`bottom`,bottom:`top`,left:`right`,right:`left`,center:`center`},_={bottom:{origin:`bottom center`,position:`top center`},top:{origin:`top center`,position:`bottom center`},left:{origin:`center left`,position:`center right`,collision:`fit flip`},right:{origin:`center right`,position:`center left`,collision:`fit flip`},center:{position:`center center`,origin:`center center`}},v={bottom:`n`,top:`s`,left:`e`,right:`w`,center:`n`},y={mouseenter:`mouseleave`,focus:`blur`,focusin:`focusout`},b={horizontal:{offset:`top`,size:`outerHeight`},vertical:{offset:`left`,size:`outerWidth`}},x=i.extend({init:function(t,r){var a=this,o;i.fn.init.call(a,t,r),o=a.options.position.match(/left|right/)?`horizontal`:`vertical`,a.dimensions=b[o],a._saveTitle=e.noop,a._documentKeyDownHandler=a._documentKeyDown.bind(a),a._actionsHandler=a._actionsClick.bind(a),a.options.toggleOnClick&&a._isShownOnClick()&&a.element.on((n.support.touch?n.support.mousedown:a.options.showOn)+s,a.options.filter,a._showAction.bind(a)),a._isShownOnClick()||a.element.on(y[a.options.showOn],a.options.filter,a._dismissAction.bind(a))},options:{name:`Popover`,filter:``,actions:[],actionsLayout:`center`,position:`bottom`,showOn:`mouseenter`,toggleOnClick:!1,width:null,height:null,animation:{open:{effects:`fade:in`,duration:0},close:{duration:40,hide:!0}}},events:[m,h],_addAria:function(){var e=this,t=e.options,r;e._isShownOnClick()&&e.wrapper.find(`a,input,select,textarea,button`).length?(e.wrapper.attr(`role`,`dialog`),e._isDialog=!0,t.header&&(r=n.guid(),e.wrapper.attr(`aria-labelledby`,r).find(`.k-popover-header`).attr(`id`,r)),t.body&&(r=n.guid(),e.wrapper.attr(`aria-describedby`,r).find(`.k-popover-body`).attr(`id`,r))):e.wrapper.attr(`role`,`tooltip`)},_appendContent:function(e){var t=this,r=t.options,i=t.wrapper.find(`.k-popover-inner`),a=t.options.template,o=()=>``;i.length?i.children().remove():t.wrapper.children(`:not(.k-popover-callout)`).remove(),i=i.length?i:t.wrapper,a?i.append(n.template(a)({target:e})):i.append(f({header:n.template(r.header||o)({target:e}),body:n.template(r.body||o)({target:e}),actions:t._buildActions(r.actions),positioning:r.actionsLayout}))},_actionsClick:function(t){var r=this,i=r.options.actions,a=e(t.currentTarget),o=i[parseInt(a.attr(n.attr(`index`)),10)];o.click&&o.click.call(r,{sender:r,target:a})},_attachActions:function(){var e=this;e.wrapper.on(`click`+s,`.k-popover-actions .k-button`,e._actionsHandler)},_dettachActions:function(){var e=this;e.wrapper&&e.wrapper.off(`click`+s,e._actionsHandler)},_buildActions:function(e){if(e.length){for(var t=``,r,i=0;i<e.length;i++)r=e[i],r.text&&(r.icon||r.iconClass)?t+=n.template(u)({text:r.text,index:n.attr(`index`)+`=`+i,icon:r.icon,iconClass:r.iconClass}):(r.icon||r.iconClass)&&!r.text?t+=n.template(d)({index:n.attr(`index`)+`=`+i,icon:r.icon,iconClass:r.iconClass}):t+=n.template(l)({text:r.text,index:n.attr(`index`)+`=`+i});return t}},_documentKeyDown:function(e){if(e.keyCode===n.keys.ESC&&(this._shown=!1,this._dismissAction()),e.keyCode===n.keys.TAB){var t=this.wrapper.find(`:kendoFocusable`),r=t.first(),i=t.last();e.shiftKey?document.activeElement===r[0]&&(i.trigger(`focus`),e.preventDefault()):document.activeElement===i[0]&&(r.trigger(`focus`),e.preventDefault())}},_initPopup:function(){var i=this,l=i.options,u=e(n.template(p)({callout:l.callout&&l.position!==`center`,dir:v[l.position]}));i.wrapper=u,i.popup=new r(u,a({activate:function(){i._offset(i.options.position,i.options.offset,c),i._positionCallout(),i._attachActions(),o.on(`keydown`+s,i._documentKeyDownHandler),i._isDialog?i.wrapper.find(`:kendoFocusable`).first().trigger(`focus`):i._addDescribedBy(),i.trigger(m),i.popup._hovered=t},close:function(e){if(i.options.toggleOnClick&&i._shown){e.preventDefault();return}i.trigger(h)},copyAnchorStyles:!1,animation:l.animation},_[l.position])),u.css({width:l.width,height:l.height}),i._isShownOnMouseEnter()&&u.on(`mouseleave`+s,i._dismissAction.bind(i)),i.arrow=u.find(`.k-popover-callout`)},_dismissAction:function(){var e=this;clearTimeout(e.timeout),e.timeout=setTimeout(function(){e.popup&&!e.popup._hovered&&e.popup.close()},e.options.hideAfter)},_showAction:function(){var e=this;e._shown=!e._shown,e._shown||e.popup.close()},_show:function(e){var t=this,n=t.target();t.popup||t._initPopup(),n&&n[0]!=e[0]&&(t.popup.close(),t.popup.element.parent().kendoStop(!0,!0)),(!n||n[0]!=e[0])&&(t._appendContent(e),t._addAria(),t.popup.options.anchor=e),t.popup.one(`deactivate`,function(){o.off(`keydown`+s,t._documentKeyDownHandler),t._isDialog||(t._removeDescribedBy(t.target()),this.element.removeAttr(`id`)),t._dettachActions()}),t._openPopup()},_positionCallout:function(){var e=this,t=e.options.position,n=v[e.popup.flipped?g[t]:t];e.arrow.removeClass(`k-callout-s k-callout-w k-callout-e k-callout-n`).addClass(`k-callout-`+n)},destroy:function(){this.element.off(s),this._dettachActions(),clearTimeout(this.timeout),o.off(`keydown`+s,this._documentKeyDownHandler),i.fn.destroy.call(this)}});n.ui.plugin(x)})(window.kendo.jQuery);var i=kendo;e.__meta__=r,e.default=i});
//# sourceMappingURL=kendo.popover.min.js.map