sonarr-repo-only/NzbDrone.Web/Scripts/2010.3.1110/telerik.window.min.js

1 line
10 KiB
JavaScript

(function(d){var a=d.telerik;function c(f){var e=f?f.toLowerCase():"";return e&&e.indexOf("http")!==0&&e.indexOf("https")!==0}function b(e){if(d.browser.msie&&d.browser.version<7){e.find(".t-resize-e,.t-resize-w").css("height",e.height()).end().find(".t-resize-n,.t-resize-s").css("width",e.width()).end().find(".t-overlay").css({width:e.width(),height:e.height()})}}a.fx.zoom=function(e){this.element=e};a.fx.zoom.prototype={play:function(h,f){var i=this.element.show();var g=i.find("> .t-window-content");var e={width:g.width(),height:g.height(),left:parseInt(i.css("left")),top:parseInt(i.css("top"))};i.css({left:e.left+20,top:e.top+20}).animate({left:e.left,top:e.top},h.openDuration);g.css({width:e.width-40,height:e.height-40}).animate({width:e.width,height:e.height},h.openDuration,function(){if(f){f()}})},rewind:function(h,f){var i=this.element;var g=i.find("> .t-window-content");var e={width:g.width(),height:g.height(),left:parseInt(i.css("left")),top:parseInt(i.css("top"))};g.animate({width:e.width-40,height:e.height-40},h.closeDuration);i.animate({left:e.left+20,top:e.top+20},h.closeDuration,function(){i.css({left:e.left,top:e.top}).hide();g.css({width:e.width,height:e.height});if(f){f()}})}};a.fx.zoom.defaults=function(){return{list:[{name:"zoom"}],openDuration:"fast",closeDuration:"fast"}};a.window=function(f,g){this.element=f;var h=d(f);if(!h.is(".t-window")){h.addClass("t-widget t-window");a.window.create(f,g)}d.extend(this,g);var e=".t-window-titlebar .t-window-action";h.delegate(e,"mouseenter",a.hover).delegate(e,"mouseleave",a.leave).delegate(e,"click",d.proxy(this.windowActionHandler,this));if(this.resizable){h.delegate(".t-window-titlebar","dblclick",d.proxy(this.toggleMaximization,this)).append(a.window.getResizeHandlesHtml());b(h);(function(j){function l(n){var m=d(j.element);j.initialCursorPosition=m.offset();j.resizeDirection=n.$draggable.attr("className").replace("t-resize-handle t-resize-","").split("");j.resizeElement=m.find("> .t-window-content");j.initialSize={width:j.resizeElement.width(),height:j.resizeElement.height()};j.outlineSize={left:j.resizeElement.outerWidth()-j.resizeElement.width()+m.outerWidth()-m.width(),top:j.resizeElement.outerHeight()-j.resizeElement.height()+m.outerHeight()-m.height()+m.find("> .t-window-titlebar").outerHeight()};d('<div class="t-overlay" />').appendTo(j.element);m.find(".t-resize-handle").not(n.$draggable).hide();d(document.body).css("cursor",n.$draggable.css("cursor"))}function k(o){var n=d(j.element);var m={e:function(){var p=o.pageX-j.initialCursorPosition.left-j.outlineSize.left;j.resizeElement.width((p<j.minWidth?j.minWidth:(j.maxWidth&&p>j.maxWidth)?j.maxWidth:p))},s:function(){var p=o.pageY-j.initialCursorPosition.top-j.outlineSize.top;j.resizeElement.height((p<j.minHeight?j.minHeight:(j.maxHeight&&p>j.maxHeight)?j.maxHeight:p))},w:function(){var q=j.initialCursorPosition.left+j.initialSize.width;n.css("left",o.pageX>(q-j.minWidth)?q-j.minWidth:o.pageX<(q-j.maxWidth)?q-j.maxWidth:o.pageX);var p=q-o.pageX;j.resizeElement.width((p<j.minWidth?j.minWidth:(j.maxWidth&&p>j.maxWidth)?j.maxWidth:p))},n:function(){var p=j.initialCursorPosition.top+j.initialSize.height;n.css("top",o.pageY>(p-j.minHeight)?p-j.minHeight:o.pageY<(p-j.maxHeight)?p-j.maxHeight:o.pageY);var q=p-o.pageY;j.resizeElement.height((q<j.minHeight?j.minHeight:(j.maxHeight&&q>j.maxHeight)?j.maxHeight:q))}};d.each(j.resizeDirection,function(){m[this]()});b(n);a.trigger(j.element,"resize")}function i(m){d(j.element).find(".t-overlay").remove().end().find(".t-resize-handle").not(m.$draggable).show();d(document.body).css("cursor","");if(m.keyCode==27){b(d(j.element));j.resizeElement.css(j.initialSize)}return false}new a.draggable({owner:j.element,selector:".t-resize-handle",scope:j.element.id+"-resizing",distance:0,start:l,drag:k,stop:i})})(this)}if(this.draggable){(function(j){function l(m){j.initialWindowPosition=d(j.element).position();j.startPosition={left:m.pageX-j.initialWindowPosition.left,top:m.pageY-j.initialWindowPosition.top};d(".t-resize-handle",j.element).hide();d('<div class="t-overlay" />').appendTo(j.element);d(document.body).css("cursor",m.$draggable.css("cursor"))}function k(n){var m={left:n.pageX-j.startPosition.left,top:Math.max(n.pageY-j.startPosition.top,0)};d(j.element).css(m)}function i(m){d(j.element).find(".t-resize-handle").show().end().find(".t-overlay").remove();d(document.body).css("cursor","");if(m.keyCode==27){m.$draggable.closest(".t-window").css(j.initialWindowPosition)}return false}new a.draggable({owner:j.element,selector:".t-window-titlebar",scope:j.element.id+"-moving",start:l,drag:k,stop:i})})(this)}a.bind(this,{open:this.onOpen,activated:this.onActivate,close:this.onClose,refresh:this.onRefresh,resize:this.onResize,error:this.onError,load:this.onLoad,move:this.onMove});if(!h.parent().is("body")){if(h.is(":visible")){h.css(h.offset())}h.toggleClass("t-rtl",h.closest(".t-rtl").length>0).appendTo(document.body)}if(this.modal){this.overlay(h.is(":visible"))}d(window).resize(d.proxy(this.onDocumentResize,this));if(c(this.contentUrl)){this.ajaxRequest()}};a.window.prototype={overlay:function(e){var f=d("body > .t-overlay");if(f.length==0){f=d('<div class="t-overlay" />').toggle(e).appendTo(this.element.ownerDocument.body)}var g=d(document);if(d.browser.msie&&d.browser.version<7){f.css({width:g.width()-21,height:g.height(),position:"absolute"})}return f},windowActionHandler:function(h){var g=d(h.target).closest(".t-window-action").find(".t-icon");var f=this;d.each({"t-close":this.close,"t-maximize":this.maximize,"t-restore":this.restore,"t-refresh":this.refresh},function(i,e){if(g.hasClass(i)){h.preventDefault();e.call(f);return false}})},center:function(){var e=d(this.element);var f=d(window);e.css({left:f.scrollLeft()+(f.width()-e.width())/2,top:f.scrollTop()+(f.height()-e.height())/2});return this},title:function(f){var e=d(".t-window-titlebar > .t-window-title",this.element);if(!f){return e.text()}e.text(f);return this},content:function(e){var f=d("> .t-window-content",this.element);if(!e){return f.html()}f.html(e);return this},open:function(h){var f=d(this.element);if(!a.trigger(this.element,"open")){if(this.modal){var g=this.overlay(false);if(this.effects.list.length>0&&this.effects.list[0].name!="toggle"){g.css("opacity",0).show().animate({opacity:0.5},this.effects.openDuration)}else{g.css("opacity",0.5).show()}}if(!f.is(":visible")){a.fx.play(this.effects,f,{},function(){a.trigger(f[0],"activated")})}}if(this.isMaximized){d("html, body").css("overflow","hidden")}return this},close:function(h){var f=d(this.element);if(f.is(":visible")){if(!a.trigger(this.element,"close")){var g=this.modal?this.overlay(true):d(undefined);g.animate({opacity:0},this.effects.closeDuration);a.fx.rewind(this.effects,f,null,function(){g.add(f[0]).hide()})}}if(this.isMaximized){d("html, body").css("overflow","")}return this},toggleMaximization:function(f){if(f&&d(f.target).closest(".t-window-action").length>0){return}this[this.isMaximized?"restore":"maximize"]()},restore:function(){if(!this.isMaximized){return}d(this.element).css({position:"absolute",left:this.restorationSettings.left,top:this.restorationSettings.top}).find("> .t-window-content").css({width:this.restorationSettings.width,height:this.restorationSettings.height}).end().find(".t-resize-handle").show().end().find(".t-window-titlebar .t-restore").addClass("t-maximize").removeClass("t-restore");d("html, body").css("overflow","");this.isMaximized=false;a.trigger(this.element,"resize");return this},maximize:function(h){if(this.isMaximized){return}var f=d(this.element);var g=f.find("> .t-window-content");this.restorationSettings={left:f.position().left,top:f.position().top,width:g.width(),height:g.height()};f.css({left:0,top:0,position:"fixed"}).find(".t-resize-handle").hide().end().find(".t-window-titlebar .t-maximize").addClass("t-restore").removeClass("t-maximize");d("html, body").css("overflow","hidden");this.isMaximized=true;this.onDocumentResize();return this},onDocumentResize:function(){if(!this.isMaximized){return}var e=d(this.element);var f=e.find("> .t-window-content");f.css({width:d(window).width()-(f.outerWidth()-f.width()+e.outerWidth()-e.width()),height:d(window).height()-(f.outerHeight()-f.height()+e.outerHeight()-e.height()+e.find("> .t-window-titlebar").outerHeight())});b(e);a.trigger(e,"resize")},refresh:function(){if(c(this.contentUrl)){this.ajaxRequest()}return this},ajaxRequest:function(e){var g=setTimeout(function(){d(".t-refresh",this.element).addClass("t-loading")},100);var f={};d.ajax({type:"GET",url:e||this.contentUrl,dataType:"html",data:f,error:d.proxy(function(i,h){if(a.ajaxError(this.element,"error",i,h)){return}},this),complete:function(){clearTimeout(g);d(".t-refresh",this.element).removeClass("t-loading")},success:d.proxy(function(h,i){d(".t-window-content",this.element).html(h);a.trigger(this.element,"refresh")},this)})},destroy:function(){d(this.element).remove();if(this.modal){this.overlay(false).remove()}}};d.extend(a.window,{create:function(f,g){if(!f.nodeType){g=f;f=null}else{g.html=f.innerHTML}g=d.extend({title:"",html:"",actions:["Close"]},g);var e=new a.stringBuilder().catIf('<div class="t-widget t-window">',!f).cat('<div class="t-window-titlebar t-header">').cat('&nbsp;<span class="t-window-title">').cat(g.title).cat("</span>").cat('<div class="t-window-actions t-header">');d.map(g.actions,function(h){e.cat('<a href="#" class="t-window-action t-link">').cat('<span class="t-icon t-').cat(h.toLowerCase()).cat('">').cat(h).cat("</span></a>")});e.cat("</div></div>").cat('<div class="t-window-content t-content" style="');if(g.width){e.cat("width:").cat(g.width).cat("px;")}if(g.height){e.cat("height:").cat(g.height).cat("px;")}e.cat('">').cat(g.html).cat("</div>").catIf("</div>",!f);if(f){d(f).html(e.string())}else{return d(e.string()).tWindow(g)}},getResizeHandlesHtml:function(){var e=new a.stringBuilder();d.each("n e s w se sw ne nw".split(" "),function(f,g){e.cat('<div class="t-resize-handle t-resize-').cat(g).cat('"></div>')});return e.string()}});d.fn.tWindow=function(e){return a.create(this,{name:"tWindow",init:function(f,g){return new a.window(f,g)},success:function(h){var g=h.element,f=d(g);if(f.is(":visible")){a.trigger(g,"open");a.trigger(g,"activated")}},options:e})};d.fn.tWindow.defaults={effects:{list:[{name:"zoom"},{name:"property",properties:["opacity"]}],openDuration:"fast",closeDuration:"fast"},modal:false,resizable:true,draggable:true,minWidth:50,minHeight:50}})(jQuery);