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