UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 11.7 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Popup={}),e.kendo._globals.Core))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let n={id:`popup`,name:`Pop-up`,category:`framework`,depends:[`core`],advanced:!0};(function(e,t){var n=window.kendo,r=n.ui,i=r.Widget,a=n.Class,o=n.support,s=n.getOffset,c=n._outerWidth,l=n._outerHeight,u=`open`,d=`close`,f=`deactivate`,p=`activate`,m=`center`,h=`left`,g=`right`,_=`top`,v=`bottom`,y=`absolute`,b=`hidden`,x=`body`,S=`location`,C=`position`,w=`visible`,T=`effects`,E=`k-active`,D=`.k-picker-wrap, .k-dropdown-wrap, .k-link`,O=`down`,k=e(document.documentElement),A=e(window),j=`scroll`,M=`transform`,N=e.extend,P=`.kendoPopup`,F=[`font-size`,`font-family`,`font-stretch`,`font-style`,`font-weight`,`line-height`];function I(t,n){return!t||!n?!1:t===n||e.contains(t,n)}var L=i.extend({init:function(t,r){var a=this,s;r||={},r.isRtl&&(r.origin=r.origin||v+` `+g,r.position=r.position||_+` `+g),i.fn.init.call(a,t,r),t=a.element,r=a.options,a.collisions=r.collision?r.collision.split(` `):[],a.downEvent=n.applyEventMap(O,n.guid()),a.collisions.length===1&&a.collisions.push(a.collisions[0]),s=e(a.options.anchor).closest(`.k-popup,.k-group,.k-menu-group`).filter(`:not([class^=km-])`),r.appendTo=e(e(r.appendTo)[0]||s[0]||document.body),a.element.hide().addClass(`k-popup`).toggleClass(`k-rtl`,!!r.isRtl).appendTo(r.appendTo).attr(`aria-hidden`,!0).on(`mouseenter`+P,function(){a._hovered=!0}).on(`wheel`+P,function(t){var n=e(t.target).find(`.k-list`),r=n.parent();n.length&&n.is(`:visible`)&&(r.scrollTop()===0&&t.originalEvent.deltaY<0||r.scrollTop()===r.prop(`scrollHeight`)-r.prop(`offsetHeight`)&&t.originalEvent.deltaY>0)&&t.preventDefault()}).on(`mouseleave`+P,function(){a._hovered=!1}),a.wrapper=e(),r.animation===!1&&(r.animation={open:{effects:{}},close:{hide:!0,effects:{}}}),N(r.animation.open,{complete:function(){a.wrapper.addClass(`k-animation-container-shown`),a.wrapper.css(`overflow`,``),a._activated=!0,a._trigger(p)}}),N(r.animation.close,{complete:function(){a._animationClose()}}),a._mousedownProxy=function(e){a._mousedown(e)},o.mobileOS.android?a._resizeProxy=function(e){setTimeout(function(){a._resize(e)},600)}:a._resizeProxy=function(e){a._resize(e)},r.toggleTarget&&e(r.toggleTarget).on(r.toggleEvent+P,a.toggle.bind(a))},events:[u,p,d,f],options:{name:`Popup`,toggleEvent:`click`,origin:v+` `+h,position:_+` `+h,anchor:x,appendTo:null,collision:`flip fit`,viewport:window,copyAnchorStyles:!0,autosize:!1,autowidth:!1,modal:!1,adjustSize:{width:0,height:0},animation:{open:{effects:`slideIn:down`,transition:!0,duration:200},close:{duration:100,hide:!0}},omitOriginOffsets:!1},_animationClose:function(){var e=this,t=e.wrapper.data(S);e.wrapper.hide(),t&&e.wrapper.css(t),e.options.anchor!=x&&e._hideActiveClass(),e._closing=!1,e._trigger(f),setTimeout(function(){e.element.attr(`aria-hidden`,!0)},0)},destroy:function(){var t=this,r=t.options,a=t.element.off(P),o;i.fn.destroy.call(t),r.toggleTarget&&e(r.toggleTarget).off(P),r.modal||(k.off(t.downEvent,t._mousedownProxy),t._toggleResize(!1)),n.destroy(t.element.children()),a.removeData(),r.appendTo[0]===document.body&&(o=a.closest(`.k-animation-container`),o[0]?o.remove():a.remove())},open:function(t,r){var i=this,a={isFixed:!isNaN(parseInt(r,10)),x:t,y:r},s=i._shouldCorrectWidth,c=i.element,l=i.options,d,f,p=e(l.anchor),m=c[0]&&c.hasClass(`km-widget`),h=c.find(`[role='listbox']`),g;if(!i.visible()){if(l.copyAnchorStyles&&(m&&F[0]==`font-size`&&F.shift(),c.css(n.getComputedStyles(p[0],F))),i.element.parent().data(`animating`)||i._trigger(u))return;i._activated=!1,l.modal||(k.off(i.downEvent,i._mousedownProxy).on(i.downEvent,i._mousedownProxy),i._toggleResize(!1),i._toggleResize(!0)),i.wrapper=f=n.wrap(c,l.autosize,l._resizeOnWrap,s,l.autowidth).css({overflow:b,display:`block`,position:y}),g=c.parent(),h.attr(`aria-label`)?f.attr(`aria-label`,h.attr(`aria-label`)):h.attr(`aria-labelledby`)&&f.attr(`aria-labelledby`,h.attr(`aria-labelledby`)),o.mobileOS.android&&g.css(M,`translatez(0)`),f.css(C),e(l.appendTo)[0]==document.body&&f.css(_,`-10000px`),i.flipped=i._position(a),d=i._openAnimation(),l.anchor!=x&&!i.element.hasClass(`k-tooltip`)&&i._addActiveClass(),g.hide(),c.show(),i.wrapper.show(),g.data(T,d.effects).kendoStop(!0).kendoAnimate(d),c.attr(`aria-hidden`,!1)}},_updateDimensions:function(){let e=this,t=e._shouldCorrectWidth,r=e.element,i=e.options;e.wrapper=n.wrap(r,i.autosize,i._resizeOnWrap,t,i.autowidth).css({display:`block`,position:y}).attr(`aria-hidden`,!1)},_location:function(t){var r=this,i=r.element,a=r.options,s,c=e(a.anchor),l=i[0]&&i.hasClass(`km-widget`);a.copyAnchorStyles&&(l&&F[0]==`font-size`&&F.shift(),i.css(n.getComputedStyles(c[0],F))),r.wrapper=s=n.wrap(i,a.autosize).css({overflow:b,display:`block`,position:y}),o.mobileOS.android&&s.css(M,`translatez(0)`),s.css(C),e(a.appendTo)[0]==document.body&&s.css(_,`-10000px`),r._position(t||{});var u=s.offset();return{width:n._outerWidth(s),height:n._outerHeight(s),left:u.left,top:u.top}},_openAnimation:function(){var e=N(!0,{},this.options.animation.open);return e.effects=n.parseEffects(e.effects,this.flipped),e},_hideActiveClass:function(){e(this.options.anchor).children(D).removeClass(E)},_addActiveClass:function(){e(this.options.anchor).children(D).addClass(E)},position:function(){this.visible()&&(this._updateDimensions(),this.flipped=this._position())},toggle:function(){var e=this;e[e.visible()?d:u]()},visible:function(){return this.wrapper.is(`:`+w)&&this.element.is(`:`+w)},close:function(t){var r=this,i=r.element.parent(),a=r.options,o,s,c,l;if(r.visible()){if(o=r.wrapper[0]?r.wrapper:n.wrap(r.element).hide(),r._toggleResize(!1),r._closing||r._trigger(d)){r._toggleResize(!0);return}r.wrapper.removeClass(`k-animation-container-shown`),r.element.find(`.k-popup`).each(function(){var n=e(this).data(`kendoPopup`);n&&n.close(t)}),k.off(r.downEvent,r._mousedownProxy),t?s={hide:!0,effects:{}}:(s=N(!0,{},a.animation.close),c=i.data(T),l=s.effects,!l&&!n.size(l)&&c&&n.size(c)&&(s.effects=c,s.reverse=!0),r._closing=!0),i.kendoStop(!0),o.css({overflow:b}),i.kendoAnimate(s),t&&r._animationClose()}},_trigger:function(e){return this.trigger(e,{type:e})},_resize:function(e){var t=this;o.resize.indexOf(e.type)===-1?(!t._hovered||t._activated&&t.element.find(`.k-list:visible`).length>0)&&t.close():(clearTimeout(t._resizeTimeout),t._resizeTimeout=setTimeout(function(){t._position(),t._resizeTimeout=null},50))},_toggleResize:function(e){var t=e?`on`:`off`,n=o.resize;o.mobileOS.ios||o.mobileOS.android||o.browser.safari||(n+=` `+j),e&&!this.scrollableParents&&(this.scrollableParents=this._scrollableParents()),this.scrollableParents&&this.scrollableParents.length&&this.scrollableParents[t](j,this._resizeProxy),A[t](n,this._resizeProxy)},_mousedown:function(t){var r=this,i=r.element[0],a=r.options,o=e(a.anchor)[0],s=a.toggleTarget,c=n.eventTarget(t),l=e(c).closest(`.k-popup`),u=l.parent().parent(`.km-shim`).length;l=l[0],!(!u&&l&&l!==r.element[0])&&e(t.target).closest(`a`).data(`rel`)!==`popover`&&!I(i,c)&&!I(o,c)&&!(s&&I(e(s)[0],c))&&r.close()},_fit:function(e,t,n){var r=0;return e+t>n&&(r=n-(e+t)),e<0&&(r=-e),r},_flip:function(e,t,n,r,i,a,o){var s=0;return o||=t,a!==i&&a!==m&&i!==m&&(e+o>r&&(s+=-(n+t)),e+s<0&&(s+=n+t)),s},_scrollableParents:function(){return e(this.options.anchor).parentsUntil(`body`).filter(function(e,t){return n.isScrollable(t)})},_position:function(t){var r=this,i=r.element,a=r.wrapper,u=r.options,d=e(u.viewport),f=o.zoomLevel(),p=!!(d[0]==window&&window.innerWidth&&f<=1.02),m=e(u.anchor),h=u.origin.toLowerCase().split(` `),g=u.position.toLowerCase().split(` `),_=r.collisions,v,y,b,x=10002,w=0,T=document.documentElement,E,D=u.viewport===window?{top:window.pageYOffset||document.documentElement.scrollTop||0,left:window.pageXOffset||document.documentElement.scrollLeft||0}:d.offset(),O,k;if(p?(O=window.innerWidth,k=window.innerHeight):(O=d.width(),k=d.height()),p&&T.scrollHeight-T.clientHeight>0){var A=u.isRtl?-1:1;O-=A*n.support.scrollbar()}if(v=m.parents().filter(a.siblings()),v[0])if(b=Math.max(Number(v.css(`zIndex`)),0),b)x=b+10;else for(y=m.parentsUntil(v),E=y.length;w<E;w++)b=Number(e(y[w]).css(`zIndex`)),b&&x<b&&(x=b+10);a.css(`zIndex`,x),t&&t.isFixed?a.css({left:t.x,top:t.y}):a.css(r._align(h,g));var j=s(a,C,m[0]===a.offsetParent()[0]),M=s(a);m.offsetParent().parent(`.k-animation-container,.k-popup,.k-group,.k-menu-group`).length&&(j=s(a,C,!0),M=s(a)),M.top-=D.top,M.left-=D.left,r.wrapper.data(S)||a.data(S,N({},j));var P=N({},M),F=N({},j),I=u.adjustSize;_[0]===`fit`&&(F.top+=r._fit(P.top,l(a)+I.height,k/f)),_[1]===`fit`&&(F.left+=r._fit(P.left,c(a)+I.width,O/f));var L=N({},F),R=l(i),z=l(a);return!a.height()&&R&&(z+=R),_[0]===`flip`&&(F.top+=r._flip(P.top,R,l(m),k/f,h[0],g[0],z)),_[1]===`flip`&&(F.left+=r._flip(P.left,c(i),c(m),O/f,h[1],g[1],c(a))),a.css(F),F.left!=L.left||F.top!=L.top},_align:function(t,n){var r=this,i=r.wrapper,a=e(r.options.anchor),o=t[0],u=t[1],d=n[0],f=n[1],p=s(a),h=e(r.options.appendTo),_,y=c(i)||c(i.find(`.k-child-animation-container`).children().first()),b=l(i)||l(i.find(`.k-child-animation-container`).children().first()),x=c(a),S=l(a),C=r.options.omitOriginOffsets?0:p.top,w=r.options.omitOriginOffsets?0:p.left,T=Math.round;return h[0]!=document.body&&(_=s(h),C-=_.top,w-=_.left),o===v&&(C+=S),o===m&&(C+=T(S/2)),d===v&&(C-=b),d===m&&(C-=T(b/2)),u===g&&(w+=x),u===m&&(w+=T(x/2)),f===g&&(w-=y),f===m&&(w-=T(y/2)),{top:C,left:w}}});r.plugin(L);var R=n.support.stableSort,z=`kendoTabKeyTrap`,B=`a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex], *[contenteditable]`,V=a.extend({init:function(t,n){this.element=e(t),this.element.autoApplyNS(z)},trap:function(){this.element.on(`keydown`,this._keepInTrap.bind(this))},removeTrap:function(){this.element.kendoDestroy(z)},destroy:function(){this.element.kendoDestroy(z),this.element=t},shouldTrap:function(){return!0},_keepInTrap:function(e){if(!(e.which!==9||!this.shouldTrap()||e.isDefaultPrevented())){var t=this._focusableElements(),n=this._sortFocusableElements(t),r=this._nextFocusable(e,n);r&&this._focus(r),e.preventDefault()}},_focusableElements:function(){var t=this.element.find(B).filter(function(t,n){return n.tabIndex>=0&&e(n).is(`:visible`)&&!e(n).is(`[disabled]`)});return this.element.is(`[tabindex]`)&&[].push.call(t,this.element[0]),t},_sortFocusableElements:function(e){var t;if(R)t=[].sort.call(e,function(e,t){return e.tabIndex-t.tabIndex});else{var n=`__k_index`;e.each(function(e,t){t.setAttribute(n,e)}),t=[].sort.call(e,function(e,t){return e.tabIndex===t.tabIndex?parseInt(e.getAttribute(n),10)-parseInt(t.getAttribute(n),10):e.tabIndex-t.tabIndex}),e.removeAttr(n)}return t},_nextFocusable:function(e,t){var n=t.length,r=t.index(e.target);return t.get((r+(e.shiftKey?-1:1))%n)},_focus:function(e){if(e.nodeName==`IFRAME`){e.contentWindow.document.body.focus();return}e.focus(),e.nodeName==`INPUT`&&e.setSelectionRange&&this._haveSelectionRange(e)&&e.setSelectionRange(0,e.value.length)},_haveSelectionRange:function(e){var t=e.type.toLowerCase();return t===`text`||t===`search`||t===`url`||t===`tel`||t===`password`}});r.Popup.TabKeyTrap=V})(window.kendo.jQuery);var r=kendo;e.__meta__=n,e.default=r}); //# sourceMappingURL=kendo.popup.min.js.map