UNPKG

@progress/kendo-ui

Version:

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

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