@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines • 9.52 kB
JavaScript
/* @license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`),require(`kendo.popup.min.js`),require(`kendo.fx.min.js`),require(`kendo.icons.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`,`kendo.popup.min`,`kendo.fx.min`,`kendo.icons.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Tooltip={}),e.kendo._globals.Core,e.kendo._globals.Popup,e.kendo._globals.Fx,e.kendo._globals.Icons))})(this,function(e,t,n,r,i){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let a={id:`tooltip`,name:`Tooltip`,category:`web`,description:`The Tooltip widget displays a popup hint for a given html element.`,depends:[`core`,`popup`,`icons`],features:[{id:`tooltip-fx`,name:`Animation`,description:`Support for animation`,depends:[`fx`]}]};(function(e,t){var n=window.kendo,r=n.ui.Widget,i=n.ui.Popup,a=n.isFunction,o=e.isPlainObject,s=e.extend,c=e(document),l=n.isLocalUrl,u=`_tb_active`,d=`aria-describedby`,f=`show`,p=`hide`,m=`error`,h=`contentLoad`,g=`requestStart`,_=`k-content-frame`,v=({autoHide:t,callout:r,dir:i})=>`<div role="tooltip" class="k-tooltip${t?``:` k-tooltip-closable`}"><div class="k-tooltip-content"></div>`+(t?``:`<div class="k-tooltip-button">${n.ui.icon(e(`<span title="Close"></span>`),{icon:`x`})}</div>`)+(r?`<div class="k-callout k-callout-${i}"></div>`:``)+`</div>`,y=n.template(({content:e})=>`<iframe frameborder='0' class='${_}' src='${e.url}'>This page requires frames in order to show content</iframe>`),b=`.kendoTooltip`,x={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`}},S={top:`bottom`,bottom:`top`,left:`right`,right:`left`,center:`center`},C={bottom:`n`,top:`s`,left:`e`,right:`w`,center:`n`},w={horizontal:{offset:`top`,size:`outerHeight`},vertical:{offset:`left`,size:`outerWidth`}},T=function(e){return e.target.data(n.ns+`title`)};function E(e){for(;e.length&&!D(e);)e=e.parent()}function D(e){var t=e.data(n.ns+`title`);if(t)return e.attr(`title`,t),e.removeData(n.ns+`title`),!0}function O(e){var t=e.attr(`title`);if(t)return e.data(n.ns+`title`,t),e.attr(`title`,``),!0}function k(e){for(;e.length&&!e.is(`body`)&&!O(e);)e=e.parent()}var A=r.extend({init:function(e,t){var i=this,a;r.fn.init.call(i,e,t),a=i.options.position.match(/left|right/)?`horizontal`:`vertical`,i.dimensions=w[a],n.support.touch&&this._isShownOnMouseEnter()&&i.element.on(n.support.mousedown+b,i.options.filter,i._showOn.bind(i)),i.element.on(i.options.showOn+b,i.options.filter,i._showOn.bind(i)),i.options.showOn===`click`&&i.element.on(`keydown`+b,i.options.filter,i._keydown.bind(i))},options:{name:`TooltipBase`,filter:``,offset:0,showAfter:100,hideAfter:100,callout:!0,position:`bottom`,showOn:`mouseenter`,animation:{open:{effects:`fade:in`,duration:0},close:{duration:40,hide:!0}}},destroy:function(){var e=this.popup;e&&(e.element.off(b),e.destroy()),clearTimeout(this.timeout),r.fn.destroy.call(this)},hide:function(){this.popup&&(this._shown=!1,this.popup.close())},show:function(e){e||=this.element,this._saveTitle(e),this._show(e)},target:function(){return this.popup?this.popup.options.anchor:null},_keydown:function(t){var r=e(t.currentTarget);t.keyCode==n.keys.ENTER&&this._show(r)},_showOn:function(t){let n=this,r=e(t.currentTarget);n._isShownOnClick()&&!n._isShownOnMouseEnter()?n._show(r):n._isShownOnFocus()?(n._saveTitle(r),n._show(r)):(clearTimeout(n.timeout),n.timeout=setTimeout(function(){n._show(r)},n.options.showAfter))},_isShownOnFocus:function(){return this.options.showOn&&this.options.showOn.match(/focus/)},_isShownOnMouseEnter:function(){return this.options.showOn&&this.options.showOn.match(/mouseenter/)},_isShownOnClick:function(){return this.options.showOn&&this.options.showOn.match(/click/)},_recalculatePopupDimensions:function(){var e=this;e.popup.wrapper.css(`height`,n._outerHeight(e.popup.element)+`px`),e.popup.wrapper.css(`width`,n._outerWidth(e.popup.element)+`px`),e.popup.position(),e._positionCallout()},_positionCallout:function(){var t=this,n=t.options.position,r=t.dimensions,i=r.offset,a=t.popup,o=a.options.anchor,s=e(o).offset(),c=e(a.element).offset(),l=C[a.flipped?S[n]:n],u=s[i]-c[i]+e(o)[r.size]()/2;t._offset(n,t.options.offset),t.arrow.removeClass(`k-callout-n k-callout-s k-callout-w k-callout-e`).addClass(`k-callout-`+l).css(i,u)},_offset:function(e,t,r){var i=this,a=e==`top`||e==`left`,o=i.popup.flipped,s=a&&o||!a&&!o?1:-1,c=a?`margin-`+e:`margin-`+S[e],l=(r||n._outerWidth(i.arrow))/2+t;i.popup.wrapper.css(c,l*s+`px`)},_addDescribedBy:function(){var e=this,t=e.popup.options.anchor,r=t[0].id||e.element[0].id||n.guid(),i=[];t.attr(d)&&i.push(t.attr(d)),r&&(i.push(r+u),t.attr(d,i.join(` `)),e.popup.element.attr(`id`,r+u))},_removeDescribedBy:function(e){var t=this.popup.element.attr(`id`),n=e.attr(d),r,i,a;n&&(r=n.split(` `),r&&r.length>0&&(i=r.filter(function(e){return e!==t})),i&&i.length>0?(a=i.join(` `),e.attr(d,a)):e.removeAttr(d))},_openPopup:function(){this.popup&&(this.popup.visible()||(this.popup._hovered=!0),this.popup._shouldCorrectWidth=!1,this.popup.open())}});n.ui.plugin(A);var j=A.extend({init:function(e,t){var r=this,i;A.fn.init.call(r,e,t),i=r.options.position.match(/left|right/)?`horizontal`:`vertical`,r.dimensions=w[i],r._documentKeyDownHandler=r._documentKeyDown.bind(r),(this._isShownOnMouseEnter()||this._isShownOnClick())&&r.element.on(`mouseenter`+b,r.options.filter,r._mouseenter.bind(r)),this.options.autoHide&&this._isShownOnMouseEnter()&&r.element.on(`mouseleave`+b,r.options.filter,r._mouseleave.bind(r)),this.options.autoHide&&this._isShownOnFocus()&&r.element.on(`blur`+b,r.options.filter,r._blur.bind(r)),n.support.touch&&r.element.on(n.support.mousedown+b,r.options.filter,r._mouseenter.bind(r))},options:{name:`Tooltip`,filter:``,content:T,showAfter:100,callout:!0,offset:0,position:`bottom`,showOn:`mouseenter`,autoHide:!0,width:null,height:null,animation:{open:{effects:`fade:in`,duration:0},close:{duration:40,hide:!0}}},events:[f,p,h,m,g],_mouseenter:function(t){k(e(t.currentTarget))},_saveTitle:function(e){k(e)},_appendContent:function(e){var t=this,r=t.options.content,i=t.content,s=t.options.iframe,c;o(r)&&r.url?(`iframe`in t.options||(s=!l(r.url)),t.trigger(g,{options:r,target:e}),s?(i.hide(),c=i.find(`.`+_)[0],c?c.src=r.url||c.src:i.html(y({content:r})),i.find(`.`+_).off(`load`+b).on(`load`+b,function(){t.trigger(h),i.show()})):(i.empty(),n.ui.progress(i,!0),t._ajaxRequest(r))):r&&a(r)?(r=r({sender:this,target:e}),i.html(r||``)):i.html(r)},_verifyContentLoaded(){var e=this,t=e.content.find(`[src]`),n=t.length,r=0;if(n===0){e._recalculatePopupDimensions();return}t.on(`load`,function(){r++,n===r&&e._recalculatePopupDimensions()})},_ajaxRequest:function(e){var t=this;jQuery.ajax(s({type:`GET`,dataType:`html`,cache:!1,error:function(e,r){n.ui.progress(t.content,!1),t._recalculatePopupDimensions(),t.trigger(m,{status:r,xhr:e})},success:function(e){n.ui.progress(t.content,!1),t.content.html(e),t._verifyContentLoaded(),t.trigger(h)}.bind(t)},e))},_documentKeyDown:function(e){e.keyCode===n.keys.ESC&&this.hide()},refresh:function(){var e=this,t=e.popup;t&&t.options.anchor&&e._appendContent(t.options.anchor)},_show:function(e){var t=this,n=t.target();let r=!1;t.popup||(t._initPopup(),r=!0),n&&n[0]!=e[0]&&(t.popup.close(!0),t.popup.element.kendoStop(!0,!0)),(!n||n[0]!=e[0])&&(t._appendContent(e),t.popup.options.anchor=e),t.popup.one(`deactivate`,function(){E(e),t._removeDescribedBy(e),this.element.removeAttr(`id`).attr(`aria-hidden`,!0),c.off(`keydown`+b,t._documentKeyDownHandler)}),t._openPopup(),r&&=(t.options.autoHide&&this._isShownOnMouseEnter()?t.popup.wrapper.on(`mouseleave`+b,t._mouseleave.bind(t)):t.popup.element.on(`click`+b,`.k-tooltip-button`,t._closeButtonClick.bind(t)),!1)},_initPopup:function(){var r=this,a=r.options,o=e(n.template(v)({callout:a.callout&&a.position!==`center`,dir:C[a.position],autoHide:a.autoHide}));r.popup=new i(o,s({autosize:!0,activate:function(){r._addDescribedBy(),a.callout?r._positionCallout():r._offset(r.options.position,r.options.offset),this.element.removeAttr(`aria-hidden`),c.on(`keydown`+b,r._documentKeyDownHandler),r.trigger(f),r.popup._hovered=t},close:function(){r.trigger(p)},copyAnchorStyles:!1,animation:a.animation},x[a.position])),o.css({width:a.width,height:a.height}),r.content=o.find(`.k-tooltip-content`),r.arrow=o.find(`.k-callout`)},_closeButtonClick:function(e){e.preventDefault(),this.hide()},_mouseleave:function(t){let n=this,r=e(t.relatedTarget).closest(`.k-animation-container`).length>0,i=!e(t.relatedTarget).is(n.element);n.options.filter&&(i=i?!n.element.find(t.relatedTarget).length>0:!i);let a=n.options.position===`center`?i&&!r:!0;clearTimeout(n.timeout),a&&(n.timeout=setTimeout(function(){n._closePopup(t.currentTarget)},n.options.hideAfter))},_blur:function(e){this._closePopup(e.currentTarget)},_closePopup:function(t){this.popup&&!this.popup._hovered?this.popup.close():E(e(t))},destroy:function(){this.element.off(b),c.off(`keydown`+b,this._documentKeyDownHandler),A.fn.destroy.call(this)}});n.ui.plugin(j)})(window.kendo.jQuery);var o=kendo;e.__meta__=a,e.default=o});
//# sourceMappingURL=kendo.tooltip.min.js.map