kendo-ui-core
Version:
3 lines (2 loc) • 11.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("kendo.core.js")):"function"==typeof define&&define.amd?define(["kendo.core.min"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).kendopopup=e.kendopopup||{},e.kendopopup.js=t())}(this,(function(){return function(e,t){var o=window.kendo,n=o.ui,i=n.Widget,s=o.Class,r=o.support,a=o.getOffset,l=o._outerWidth,p=o._outerHeight,d="open",c="close",f="deactivate",u="activate",h="center",m="left",g="right",v="top",w="bottom",b="absolute",_="hidden",y="body",k="location",x="position",T="visible",z="effects",P="k-active",C=".k-picker-wrap, .k-dropdown-wrap, .k-link",S=e(document.documentElement),E=e(window),I="scroll",A="transform",O=e.extend,R=".kendoPopup",N=["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 j=i.extend({init:function(t,n){var s,a=this;(n=n||{}).isRtl&&(n.origin=n.origin||w+" "+g,n.position=n.position||v+" "+g),i.fn.init.call(a,t,n),t=a.element,n=a.options,a.collisions=n.collision?n.collision.split(" "):[],a.downEvent=o.applyEventMap("down",o.guid()),1===a.collisions.length&&a.collisions.push(a.collisions[0]),s=e(a.options.anchor).closest(".k-popup,.k-group").filter(":not([class^=km-])"),n.appendTo=e(e(n.appendTo)[0]||s[0]||document.body),a.element.hide().addClass("k-popup").toggleClass("k-rtl",!!n.isRtl).appendTo(n.appendTo).attr("aria-hidden",!0).on("mouseenter"+R,(function(){a._hovered=!0})).on("wheel"+R,(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"+R,(function(){a._hovered=!1})),a.wrapper=e(),!1===n.animation&&(n.animation={open:{effects:{}},close:{hide:!0,effects:{}}}),O(n.animation.open,{complete:function(){a.wrapper.addClass("k-animation-container-shown"),a.wrapper.css("overflow",""),a._activated=!0,a._trigger(u)}}),O(n.animation.close,{complete:function(){a._animationClose()}}),a._mousedownProxy=function(e){a._mousedown(e)},r.mobileOS.android?a._resizeProxy=function(e){setTimeout((function(){a._resize(e)}),600)}:a._resizeProxy=function(e){a._resize(e)},n.toggleTarget&&e(n.toggleTarget).on(n.toggleEvent+R,a.toggle.bind(a))},events:[d,u,c,f],options:{name:"Popup",toggleEvent:"click",origin:w+" "+m,position:v+" "+m,anchor:y,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!=y&&e._hideActiveClass(),e._closing=!1,e._trigger(f)},destroy:function(){var t,n=this,s=n.options,r=n.element.off(R);i.fn.destroy.call(n),s.toggleTarget&&e(s.toggleTarget).off(R),s.modal||(S.off(n.downEvent,n._mousedownProxy),n._toggleResize(!1)),o.destroy(n.element.children()),r.removeData(),s.appendTo[0]===document.body&&((t=r.closest(".k-animation-container"))[0]?t.remove():r.remove())},open:function(t,n){var i,s,a,l=this,p={isFixed:!isNaN(parseInt(n,10)),x:t,y:n},c=l._shouldCorrectWidth,f=l.element,u=l.options,h=e(u.anchor),m=f[0]&&f.hasClass("km-widget"),g=f.find("[role='listbox']");if(!l.visible()){if(u.copyAnchorStyles&&(m&&"font-size"==N[0]&&N.shift(),f.css(o.getComputedStyles(h[0],N))),l.element.parent().data("animating")||l._trigger(d))return;l._activated=!1,u.modal||(S.off(l.downEvent,l._mousedownProxy).on(l.downEvent,l._mousedownProxy),l._toggleResize(!1),l._toggleResize(!0)),l.wrapper=s=o.wrap(f,u.autosize,u._resizeOnWrap,c,u.autowidth).css({overflow:_,display:"block",position:b}).attr("aria-hidden",!1),a=f.parent(),g.attr("aria-label")?s.attr("aria-label",g.attr("aria-label")):g.attr("aria-labelledby")&&s.attr("aria-labelledby",g.attr("aria-labelledby")),r.mobileOS.android&&a.css(A,"translatez(0)"),s.css(x),e(u.appendTo)[0]==document.body&&s.css(v,"-10000px"),l.flipped=l._position(p),i=l._openAnimation(),u.anchor==y||l.element.hasClass("k-tooltip")||l._addActiveClass(),a.hide(),f.show(),l.wrapper.show(),a.data(z,i.effects).kendoStop(!0).kendoAnimate(i),f.attr("aria-hidden",!1)}},_location:function(t){var n,i=this,s=i.element,a=i.options,l=e(a.anchor),p=s[0]&&s.hasClass("km-widget");a.copyAnchorStyles&&(p&&"font-size"==N[0]&&N.shift(),s.css(o.getComputedStyles(l[0],N))),i.wrapper=n=o.wrap(s,a.autosize).css({overflow:_,display:"block",position:b}),r.mobileOS.android&&n.css(A,"translatez(0)"),n.css(x),e(a.appendTo)[0]==document.body&&n.css(v,"-10000px"),i._position(t||{});var d=n.offset();return{width:o._outerWidth(n),height:o._outerHeight(n),left:d.left,top:d.top}},_openAnimation:function(){var e=O(!0,{},this.options.animation.open);return e.effects=o.parseEffects(e.effects,this.flipped),e},_hideActiveClass:function(){e(this.options.anchor).children(C).removeClass(P)},_addActiveClass:function(){e(this.options.anchor).children(C).addClass(P)},position:function(){this.visible()&&(this.flipped=this._position())},toggle:function(){this[this.visible()?c:d]()},visible:function(){return this.wrapper.is(":"+T)&&this.element.is(":"+T)},close:function(t){var n,i,s,r,a=this,l=a.element.parent(),p=a.options;if(a.visible()){if(n=a.wrapper[0]?a.wrapper:o.wrap(a.element).hide(),a._toggleResize(!1),a._closing||a._trigger(c))return void a._toggleResize(!0);a.wrapper.removeClass("k-animation-container-shown"),a.element.find(".k-popup").each((function(){var o=e(this).data("kendoPopup");o&&o.close(t)})),S.off(a.downEvent,a._mousedownProxy),t?i={hide:!0,effects:{}}:(i=O(!0,{},p.animation.close),s=l.data(z),!(r=i.effects)&&!o.size(r)&&s&&o.size(s)&&(i.effects=s,i.reverse=!0),a._closing=!0),l.kendoStop(!0),a.element.attr("aria-hidden",!0),n.css({overflow:_}).attr("aria-hidden",!0),l.kendoAnimate(i),t&&a._animationClose()}},_trigger:function(e){return this.trigger(e,{type:e})},_resize:function(e){var t=this;-1!==r.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=r.resize;r.mobileOS.ios||r.mobileOS.android||r.browser.safari||(o+=" "+I),e&&!this.scrollableParents&&(this.scrollableParents=this._scrollableParents()),this.scrollableParents&&this.scrollableParents.length&&this.scrollableParents[t](I,this._resizeProxy),E[t](o,this._resizeProxy)},_mousedown:function(t){var n=this,i=n.element[0],s=n.options,r=e(s.anchor)[0],a=s.toggleTarget,l=o.eventTarget(t),p=e(l).closest(".k-popup"),d=p.parent().parent(".km-shim").length;p=p[0],!d&&p&&p!==n.element[0]||"popover"!==e(t.target).closest("a").data("rel")&&(W(i,l)||W(r,l)||a&&W(e(a)[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,r){var a=0;return r=r||t,s!==i&&s!==h&&i!==h&&(e+r>n&&(a+=-(o+t)),e+a<0&&(a+=o+t)),a},_scrollableParents:function(){return e(this.options.anchor).parentsUntil("body").filter((function(e,t){return o.isScrollable(t)}))},_position:function(t){var n,i,s,d,c,f,u,h=this,m=h.element,g=h.wrapper,v=h.options,w=e(v.viewport),b=r.zoomLevel(),_=!!(w[0]==window&&window.innerWidth&&b<=1.02),y=e(v.anchor),T=v.origin.toLowerCase().split(" "),z=v.position.toLowerCase().split(" "),P=h.collisions,C=10002,S=0,E=document.documentElement;(c=v.viewport===window?{top:window.pageYOffset||document.documentElement.scrollTop||0,left:window.pageXOffset||document.documentElement.scrollLeft||0}:w.offset(),_?(f=window.innerWidth,u=window.innerHeight):(f=w.width(),u=w.height()),_&&E.scrollHeight-E.clientHeight>0)&&(f-=(v.isRtl?-1:1)*o.support.scrollbar());if((n=y.parents().filter(g.siblings()))[0])if(s=Math.max(Number(n.css("zIndex")),0))C=s+10;else for(d=(i=y.parentsUntil(n)).length;S<d;S++)(s=Number(e(i[S]).css("zIndex")))&&C<s&&(C=s+10);g.css("zIndex",C),t&&t.isFixed?g.css({left:t.x,top:t.y}):g.css(h._align(T,z));var I=a(g,x,y[0]===g.offsetParent()[0]),A=a(g);y.offsetParent().parent(".k-animation-container,.k-popup,.k-group").length&&(I=a(g,x,!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),N=O({},I),W=v.adjustSize;"fit"===P[0]&&(N.top+=h._fit(R.top,p(g)+W.height,u/b)),"fit"===P[1]&&(N.left+=h._fit(R.left,l(g)+W.width,f/b));var j=O({},N),F=p(m),H=p(g);return!g.height()&&F&&(H+=F),"flip"===P[0]&&(N.top+=h._flip(R.top,F,p(y),u/b,T[0],z[0],H)),"flip"===P[1]&&(N.left+=h._flip(R.left,l(m),l(y),f/b,T[1],z[1],l(g))),g.css(N),N.left!=j.left||N.top!=j.top},_align:function(t,o){var n,i=this,s=i.wrapper,r=e(i.options.anchor),d=t[0],c=t[1],f=o[0],u=o[1],m=a(r),v=e(i.options.appendTo),b=l(s)||l(s.find(".k-child-animation-container").children().first()),_=p(s)||p(s.find(".k-child-animation-container").children().first()),y=l(r),k=p(r),x=i.options.omitOriginOffsets?0:m.top,T=i.options.omitOriginOffsets?0:m.left,z=Math.round;return v[0]!=document.body&&(x-=(n=a(v)).top,T-=n.left),d===w&&(x+=k),d===h&&(x+=z(k/2)),f===w&&(x-=_),f===h&&(x-=z(_/2)),c===g&&(T+=y),c===h&&(T+=z(y/2)),u===g&&(T-=b),u===h&&(T-=z(b/2)),{top:x,left:T}}});n.plugin(j);var F=o.support.stableSort,H="kendoTabKeyTrap",D=s.extend({init:function(t,o){this.element=e(t),this.element.autoApplyNS(H)},trap:function(){this.element.on("keydown",this._keepInTrap.bind(this))},removeTrap:function(){this.element.kendoDestroy(H)},destroy:function(){this.element.kendoDestroy(H),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(F)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}});n.Popup.TabKeyTrap=D}(window.kendo.jQuery),kendo}));
//# sourceMappingURL=kendo.popup.min.js.map