16 lines
7.7 KiB
JavaScript
16 lines
7.7 KiB
JavaScript
/**
|
|
* Copyright 2014 Telerik AD
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
!function(e,define){define(["./kendo.core.min"],e)}(function(){return function(e){function t(t,n){return t===n||e.contains(t,n)}var n=window.kendo,i=n.ui,r=i.Widget,o=n.support,a=n.getOffset,s=n._activeElement,l="open",u="close",d="deactivate",c="activate",f="center",h="left",p="right",g="top",m="bottom",v="absolute",_="hidden",y="body",b="location",w="position",x="visible",k="effects",T="k-state-active",C="k-state-border",S=/k-state-border-(\w+)/,F=".k-picker-wrap, .k-dropdown-wrap, .k-link",M="down",D=e(document.documentElement),E="resize scroll",z=o.transitions.css,O=z+"transform",P=e.extend,A=".kendoPopup",N=["font-size","font-family","font-stretch","font-style","font-weight","line-height"],H=r.extend({init:function(t,i){var o,a=this;i=i||{},i.isRtl&&(i.origin=i.origin||m+" "+p,i.position=i.position||g+" "+p),r.fn.init.call(a,t,i),t=a.element,i=a.options,a.collisions=i.collision?i.collision.split(" "):[],a.downEvent=n.applyEventMap(M,n.guid()),1===a.collisions.length&&a.collisions.push(a.collisions[0]),o=e(a.options.anchor).closest(".k-popup,.k-group").filter(":not([class^=km-])"),i.appendTo=e(e(i.appendTo)[0]||o[0]||y),a.element.hide().addClass("k-popup k-group k-reset").toggleClass("k-rtl",!!i.isRtl).css({position:v}).appendTo(i.appendTo).on("mouseenter"+A,function(){a._hovered=!0}).on("mouseleave"+A,function(){a._hovered=!1}),a.wrapper=e(),i.animation===!1&&(i.animation={open:{effects:{}},close:{hide:!0,effects:{}}}),P(i.animation.open,{complete:function(){a.wrapper.css({overflow:x}),a._trigger(c)}}),P(i.animation.close,{complete:function(){a._animationClose()}}),a._mousedownProxy=function(e){a._mousedown(e)},a._resizeProxy=function(e){a._resize(e)},i.toggleTarget&&e(i.toggleTarget).on(i.toggleEvent+A,e.proxy(a.toggle,a))},events:[l,c,u,d],options:{name:"Popup",toggleEvent:"click",origin:m+" "+h,position:g+" "+h,anchor:y,appendTo:null,collision:"flip fit",viewport:window,copyAnchorStyles:!0,autosize:!1,modal:!1,animation:{open:{effects:"slideIn:down",transition:!0,duration:200},close:{duration:100,hide:!0}}},_animationClose:function(){var t,i,r,o,a=this,s=a.options;a.wrapper.hide(),t=a.wrapper.data(b),i=e(s.anchor),t&&a.wrapper.css(t),s.anchor!=y&&(r=(i[0].className.match(S)||["","down"])[1],o=C+"-"+r,i.removeClass(o).children(F).removeClass(T).removeClass(o),a.element.removeClass(C+"-"+n.directions[r].reverse)),a._closing=!1,a._trigger(d)},destroy:function(){var t,i=this,o=i.options,a=i.element.off(A);r.fn.destroy.call(i),o.toggleTarget&&e(o.toggleTarget).off(A),o.modal||(D.unbind(i.downEvent,i._mousedownProxy),i._scrollableParents().unbind(E,i._resizeProxy)),n.destroy(i.element.children()),a.removeData(),o.appendTo[0]===document.body&&(t=a.parent(".k-animation-container"),t[0]?t.remove():a.remove())},open:function(t,i){var r,a,s,u=this,d={isFixed:!isNaN(parseInt(i,10)),x:t,y:i},c=u.element,f=u.options,h="down",p=e(f.anchor),m=c[0]&&c.hasClass("km-widget");if(!u.visible()){if(f.copyAnchorStyles&&(m&&"font-size"==N[0]&&N.shift(),c.css(n.getComputedStyles(p[0],N))),c.data("animating")||u._trigger(l))return;f.modal||(D.unbind(u.downEvent,u._mousedownProxy).bind(u.downEvent,u._mousedownProxy),o.mobileOS.ios||o.mobileOS.android||this._scrollableParents().unbind(E,u._resizeProxy).bind(E,u._resizeProxy)),u.wrapper=a=n.wrap(c,f.autosize).css({overflow:_,display:"block",position:v}),o.mobileOS.android&&a.css(O,"translatez(0)"),a.css(w),e(f.appendTo)[0]==document.body&&a.css(g,"-10000px"),r=P(!0,{},f.animation.open),u.flipped=u._position(d),r.effects=n.parseEffects(r.effects,u.flipped),h=r.effects.slideIn?r.effects.slideIn.direction:h,f.anchor!=y&&(s=C+"-"+h,c.addClass(C+"-"+n.directions[h].reverse),p.addClass(s).children(F).addClass(T).addClass(s)),c.data(k,r.effects).kendoStop(!0).kendoAnimate(r)}},toggle:function(){var e=this;e[e.visible()?u:l]()},visible:function(){return this.element.is(":"+x)},close:function(t){var i,r,o,a,s=this,l=s.options;if(s.visible()){if(i=s.wrapper[0]?s.wrapper:n.wrap(s.element).hide(),s._closing||s._trigger(u))return;s.element.find(".k-popup").each(function(){var n=e(this),i=n.data("kendoPopup");i&&i.close(t)}),D.unbind(s.downEvent,s._mousedownProxy),s._scrollableParents().unbind(E,s._resizeProxy),t?r={hide:!0,effects:{}}:(r=P(!0,{},l.animation.close),o=s.element.data(k),a=r.effects,!a&&!n.size(a)&&o&&n.size(o)&&(r.effects=o,r.reverse=!0),s._closing=!0),s.element.kendoStop(!0),i.css({overflow:_}),s.element.kendoAnimate(r)}},_trigger:function(e){return this.trigger(e,{type:e})},_resize:function(e){var n=this;"resize"===e.type?(clearTimeout(n._resizeTimeout),n._resizeTimeout=setTimeout(function(){n._position(),n._resizeTimeout=null},50)):n._hovered||t(n.element[0],s())||n.close()},_mousedown:function(i){var r=this,o=r.element[0],a=r.options,s=e(a.anchor)[0],l=a.toggleTarget,u=n.eventTarget(i),d=e(u).closest(".k-popup"),c=d.parent().parent(".km-shim").length;d=d[0],(c||!d||d===r.element[0])&&"popover"!==e(i.target).closest("a").data("rel")&&(t(o,u)||t(s,u)||l&&t(e(l)[0],u)||r.close())},_fit:function(e,t,n){var i=0;return e+t>n&&(i=n-(e+t)),0>e&&(i=-e),i},_flip:function(e,t,n,i,r,o,a){var s=0;return a=a||t,o!==r&&o!==f&&r!==f&&(e+a>i&&(s+=-(n+t)),0>e+s&&(s+=n+t)),s},_scrollableParents:function(){return e(this.options.anchor).parentsUntil("body").filter(function(e,t){var i=n.getComputedStyles(t,["overflow"]);return"visible"!=i.overflow}).add(window)},_position:function(t){var n,i,r,s,l,u,d,c,f,h=this,p=h.element.css(w,""),g=h.wrapper,m=h.options,_=e(m.viewport),y=_.offset(),x=e(m.anchor),k=m.origin.toLowerCase().split(" "),T=m.position.toLowerCase().split(" "),C=h.collisions,S=o.zoomLevel(),F=10002,M=!!(_[0]==window&&window.innerWidth&&1.02>=S),D=0,E=M?window.innerWidth:_.width(),z=M?window.innerHeight:_.height(),O=x.parents().filter(g.siblings());if(O[0])if(i=Math.max(+O.css("zIndex"),0))F=i+10;else for(n=x.parentsUntil(O),r=n.length;r>D;D++)i=+e(n[D]).css("zIndex"),i&&i>F&&(F=i+10);return g.css("zIndex",F),g.css(t&&t.isFixed?{left:t.x,top:t.y}:h._align(k,T)),s=a(g,w,x[0]===g.offsetParent()[0]),l=a(g),u=x.offsetParent().parent(".k-animation-container,.k-popup,.k-group"),u.length&&(s=a(g,w,!0),l=a(g)),_[0]===window?(l.top-=window.pageYOffset||document.documentElement.scrollTop||0,l.left-=window.pageXOffset||document.documentElement.scrollLeft||0):(l.top-=y.top,l.left-=y.left),h.wrapper.data(b)||g.data(b,P({},s)),d=P({},l),c=P({},s),"fit"===C[0]&&(c.top+=h._fit(d.top,g.outerHeight(),z/S)),"fit"===C[1]&&(c.left+=h._fit(d.left,g.outerWidth(),E/S)),f=P({},c),"flip"===C[0]&&(c.top+=h._flip(d.top,p.outerHeight(),x.outerHeight(),z/S,k[0],T[0],g.outerHeight())),"flip"===C[1]&&(c.left+=h._flip(d.left,p.outerWidth(),x.outerWidth(),E/S,k[1],T[1],g.outerWidth())),p.css(w,v),g.css(c),c.left!=f.left||c.top!=f.top},_align:function(t,n){var i,r=this,o=r.wrapper,s=e(r.options.anchor),l=t[0],u=t[1],d=n[0],c=n[1],h=a(s),g=e(r.options.appendTo),v=o.outerWidth(),_=o.outerHeight(),y=s.outerWidth(),b=s.outerHeight(),w=h.top,x=h.left,k=Math.round;return g[0]!=document.body&&(i=a(g),w-=i.top,x-=i.left),l===m&&(w+=b),l===f&&(w+=k(b/2)),d===m&&(w-=_),d===f&&(w-=k(_/2)),u===p&&(x+=y),u===f&&(x+=k(y/2)),c===p&&(x-=v),c===f&&(x-=k(v/2)),{top:w,left:x}}});i.plugin(H)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()}); |