mirror of https://github.com/Radarr/Radarr
1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
(function(a){var b=a.telerik;b.scripts.push("telerik.window.js");function d(e){return e&&!(/^([a-z]+:)?\/\//i).test(e)}function c(e){if(a.browser.msie&&a.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()})}}b.fx.zoom=function(e){this.element=e};b.fx.zoom.prototype={play:function(h,f){var e=this.element.show();var i=e.find("> .t-window-content");var g={width:i.width(),height:i.height(),left:parseInt(e.css("left"))||0,top:parseInt(e.css("top"))||0};e.css({left:g.left+20,top:g.top+20}).animate({left:g.left,top:g.top},h.openDuration);i.css({width:g.width-40,height:g.height-40}).animate({width:g.width,height:g.height},h.openDuration,function(){if(f){f()}})},rewind:function(h,f){var e=this.element;var i=e.find("> .t-window-content");var g={width:i.width(),height:i.height(),left:parseInt(e.css("left")),top:parseInt(e.css("top"))};i.animate({width:g.width-40,height:g.height-40},h.closeDuration);e.animate({left:g.left+20,top:g.top+20},h.closeDuration,function(){e.css({left:g.left,top:g.top}).hide();setTimeout(function(){i.css({width:g.width,height:g.height})},0);if(f){f()}})}};b.fx.zoom.defaults=function(){return{list:[{name:"zoom"}],openDuration:"fast",closeDuration:"fast"}};b.window=function(f,i){this.element=f;var e=a(f),g=a.extend({},i);delete g.title;delete g.content;a.extend(this,g);if(!e.is(".t-window")){e.addClass("t-widget t-window");b.window.create(f,i)}if(!e.is("body")){var h;if(e.is(":visible")){h=e.offset();e.css({top:h.top,left:h.left})}else{e.css({visibility:"hidden",display:""});h=e.offset();e.css({top:h.top,left:h.left}).css({visibility:"visible",display:"none"})}e.toggleClass("t-rtl",e.closest(".t-rtl").length>0).appendTo(document.body)}this.bringToTop();e.bind("mousedown",a.proxy(this.bringToTop,this));if(this.modal&&e.is(":visible")){this.overlay(true).css({opacity:0.5,zIndex:parseInt(e.css("zIndex"),10)-1})}var j=".t-window-titlebar .t-link";e.delegate(j,"mouseenter",b.hover).delegate(j,"mouseleave",b.leave).delegate(j,"click",a.proxy(this.windowActionHandler,this));if(this.resizable){e.delegate(".t-window-titlebar","dblclick",a.proxy(this.toggleMaximization,this)).append(b.window.getResizeHandlesHtml());c(e);(function(n){function l(p){var o=a(n.element);n.initialCursorPosition=o.offset();n.resizeDirection=/t-resize-([nesw]+)/gi.exec(p.$draggable[0].className)[1];n.resizeElement=o.find("> .t-window-content");n.initialSize={width:n.resizeElement.width(),height:n.resizeElement.height()};n.outlineSize={left:n.resizeElement.outerWidth()-n.resizeElement.width()+o.outerWidth()-o.width(),top:n.resizeElement.outerHeight()-n.resizeElement.height()+o.outerHeight()-o.height()+o.find("> .t-window-titlebar").outerHeight()};a('<div class="t-overlay" />').appendTo(n.element);o.find(".t-resize-handle").not(p.$draggable).hide();a(document.body).css("cursor",p.$draggable.css("cursor"))}function k(p){var o=a(n.element);var q={e:function(){var r=b.touchLocation(p),s=r.x-n.initialCursorPosition.left-n.outlineSize.left;n.resizeElement.width((s<n.minWidth?n.minWidth:(n.maxWidth&&s>n.maxWidth)?n.maxWidth:s))},s:function(){var s=b.touchLocation(p),r=s.y-n.initialCursorPosition.top-n.outlineSize.top;n.resizeElement.height((r<n.minHeight?n.minHeight:(n.maxHeight&&r>n.maxHeight)?n.maxHeight:r))},w:function(){var r=b.touchLocation(p),t=n.initialCursorPosition.left+n.initialSize.width;o.css("left",r.x>(t-n.minWidth)?t-n.minWidth:r.x<(t-n.maxWidth)?t-n.maxWidth:r.x);var s=t-r.x;n.resizeElement.width((s<n.minWidth?n.minWidth:(n.maxWidth&&s>n.maxWidth)?n.maxWidth:s))},n:function(){var s=b.touchLocation(p),t=n.initialCursorPosition.top+n.initialSize.height;o.css("top",s.y>(t-n.minHeight)?t-n.minHeight:s.y<(t-n.maxHeight)?t-n.maxHeight:s.y);var r=t-s.y;n.resizeElement.height((r<n.minHeight?n.minHeight:(n.maxHeight&&r>n.maxHeight)?n.maxHeight:r))}};a.each(n.resizeDirection.split(""),function(){q[this]()});c(o);if(a.browser.msie&&parseInt(a.browser.version)>=9){o[0].style.cssText=o[0].style.cssText}b.trigger(n.element,"resize")}function m(p){var o=a(n.element);o.find(".t-overlay").remove().end().find(".t-resize-handle").not(p.$draggable).show();a(document.body).css("cursor","");if(p.keyCode==27){c(o);o.css(n.initialCursorPosition);n.resizeElement.css(n.initialSize)}return false}new b.draggable({owner:n.element,selector:".t-resize-handle",scope:n.element.id+"-resizing",distance:0,start:l,drag:k,stop:m})})(this)}if(this.draggable){(function(n){function l(q){var o=a(n.element),r=b.touchLocation(q);n.initialWindowPosition=o.position();n.startPosition={left:r.x-n.initialWindowPosition.left,top:r.y-n.initialWindowPosition.top};var p=o.find(".t-window-actions");if(p.length>0){n.minLeftPosition=p.outerWidth()+parseInt(p.css("right"),10)-o.outerWidth()}else{n.minLeftPosition=20-o.outerWidth()}a(".t-resize-handle",n.element).hide();a('<div class="t-overlay" />').appendTo(n.element);a(document.body).css("cursor",q.$draggable.css("cursor"))}function k(p){var q=b.touchLocation(p),o={left:Math.max(q.x-n.startPosition.left,n.minLeftPosition),top:Math.max(q.y-n.startPosition.top,0)};a(n.element).css(o)}function m(o){a(n.element).find(".t-resize-handle").show().end().find(".t-overlay").remove();a(document.body).css("cursor","");if(o.keyCode==27){o.$draggable.closest(".t-window").css(n.initialWindowPosition)}return false}new b.draggable({owner:n.element,selector:".t-window-titlebar",scope:n.element.id+"-moving",start:l,drag:k,stop:m})})(this)}b.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});a(window).resize(a.proxy(this.onDocumentResize,this));if(d(this.contentUrl)){this.ajaxRequest()}};b.window.prototype={overlay:function(g){var f=a("body > .t-overlay"),e=this.element;if(f.length==0){f=a('<div class="t-overlay" />').toggle(g).insertBefore(e)}else{f.insertBefore(e).toggle(g)}this.positionOverlay(f);return f},positionOverlay:function(f){var e=a(document);if(a.browser.msie&&a.browser.version<7){f.css({width:e.width()-21,height:e.height(),position:"absolute"})}else{if((/ipad/gi).test(navigator.appVersion)){f.css({width:e.width(),height:e.height(),position:"absolute"})}}},overlayOnClose:function(f){var e=this;var h=a(".t-window").filter(function(){var n=a(this);return this!==e.element&&n.is(":visible")&&n.data("tWindow").modal});var m=e.modal&&h.length==0;var k=e.modal?e.overlay(true):a(undefined);if(m){if(e.effects.list.length>0&&e.effects.list[0].name!="toggle"){k.fadeOut(e.effects.closeDuration,function(){if(f){k.remove()}})}else{if(f){k.remove()}else{k.hide()}}}else{if(h.length>0){var l=parseInt(a(".t-overlay").css("zIndex"),10);var g=0;var j;h.each(function(o,n){var p=parseInt(a(n).css("zIndex"),10);if(p>=g){g=p;j=a(n)}});var i=j.data("tWindow");i.overlay(true).css("zIndex",g-1)}}},windowActionHandler:function(h){var f=a(h.target).closest(".t-link").find(".t-icon"),g=this;a.each({"t-close":this.close,"t-maximize":this.maximize,"t-restore":this.restore,"t-refresh":this.refresh},function(e,i){if(f.hasClass(e)){h.preventDefault();i.call(g);return false}})},center:function(){var f=a(this.element),g=a(window),e=a(document.body);var j=g.scrollLeft();var h=e.scrollLeft();var k=g.scrollTop();var i=e.scrollTop();if(jQuery.browser.webkit&&k==i){i=0;h=0}f.css({left:j+h+Math.max(0,(g.width()-f.width())/2),top:k+i+Math.max(0,(g.height()-f.height())/2)});return this},title:function(f){var e=a(".t-window-titlebar > .t-window-title",this.element);if(!f){return e.text()}e.text(f);return this},content:function(f){var e=a("> .t-window-content",this.element);if(!f){return e.html()}e.html(f);return this},bringToTop:function(){var f=0,e=this;a(".t-window").each(function(){var g=a(this);var h=g.css("zIndex");if(!isNaN(h)){f=Math.max(parseInt(h,10),f)}if(this!=e.element&&g.find(".t-window-content > iframe").length>0){g.find(".t-window-content").append("<div class='t-overlay' />")}});a(e.element).css("zIndex",f+2).find(".t-window-content > .t-overlay").remove();return e},open:function(g){var f=a(this.element);this.bringToTop();if(!b.trigger(this.element,"open")){if(this.modal){var h=this.overlay(false).css("zIndex",parseInt(f.css("zIndex"),10)-1);if(this.effects.list.length>0&&this.effects.list[0].name!="toggle"){h.css("opacity",0).show().animate({opacity:0.5},this.effects.openDuration)}else{h.css("opacity",0.5).show()}}if(!f.is(":visible")){b.fx.play(this.effects,f,{},function(){b.trigger(f[0],"activated")})}}if(this.isMaximized){a("html, body").css("overflow","hidden")}return this},close:function(){var e=a(this.element);if(e.is(":visible")){if(!b.trigger(this.element,"close")){this.overlayOnClose();b.fx.rewind(this.effects,e,null,function(){e.hide()})}}if(this.isMaximized){a("html, body").css("overflow","")}return this},toggleMaximization:function(f){if(f&&a(f.target).closest(".t-link").length>0){return}this[this.isMaximized?"restore":"maximize"]()},restore:function(){if(!this.isMaximized){return}a(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");a("html, body").css("overflow","");this.isMaximized=false;b.trigger(this.element,"resize");return this},maximize:function(g){if(this.isMaximized){return}var f=a(this.element),h=f.find("> .t-window-content");this.restorationSettings={left:f.position().left,top:f.position().top,width:h.width(),height:h.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");a("html, body").css("overflow","hidden");this.isMaximized=true;this.onDocumentResize();return this},onDocumentResize:function(){if(!this.isMaximized){return}var e=a(this.element),f=e.find("> .t-window-content");f.css({width:a(window).width()-(f.outerWidth()-f.width()+e.outerWidth()-e.width()),height:a(window).height()-(f.outerHeight()-f.height()+e.outerHeight()-e.height()+e.find("> .t-window-titlebar").outerHeight())});c(e);b.trigger(e,"resize")},refresh:function(){if(d(this.contentUrl)){this.ajaxRequest()}else{var e=a(this.element).find("> .t-window-content > iframe")[0];if(e){e.src=e.src}}return this},ajaxRequest:function(g,e){var f=setTimeout(function(){a(".t-refresh",this.element).addClass("t-loading")},100);a.ajax({type:"GET",url:g||this.contentUrl,dataType:"html",data:e||{},cache:false,error:a.proxy(function(i,h){if(b.ajaxError(this.element,"error",i,h)){return}},this),complete:function(){clearTimeout(f);a(".t-refresh",this.element).removeClass("t-loading")},success:a.proxy(function(h,i){a(".t-window-content",this.element).html(h);b.trigger(this.element,"refresh")},this)})},destroy:function(){a(this.element).remove();this.overlayOnClose(true)}};a.extend(b.window,{create:function(){var f,g,e;if(a.isPlainObject(arguments[0])){g=arguments[0]}else{f=arguments[0];g=a.extend({html:f.innerHTML},arguments[1])}g=a.extend({title:"",html:"",actions:["Close"]},g);e=g.contentUrl;var h=new b.stringBuilder().catIf('<div class="t-widget t-window">',!f).cat('<div class="t-window-titlebar t-header">').cat(' <span class="t-window-title">').cat(g.title).cat("</span>").cat('<div class="t-window-actions t-header">');a.map(g.actions,function(i){h.cat('<a href="#" class="t-link">').cat('<span class="t-icon t-').cat(i.toLowerCase()).cat('">').cat(i).cat("</span></a>")});h.cat("</div></div>").cat('<div class="t-window-content t-content" style="');if(g.width){h.cat("width:").cat(g.width).cat("px;")}if(g.height){h.cat("height:").cat(g.height).cat("px;")}if(typeof(g.scrollable)!="undefined"&&g.scrollable===false){h.cat("overflow:hidden;")}h.cat('">').catIf(g.html,!e||(e&&d(e))).catIf('<iframe src="',e,'" title="',g.title,'" frameborder="0" style="border:0;width:100%;height:100%;">This page requires frames in order to show content</iframe>',e&&!d(e)).cat("</div>").catIf("</div>",!f);if(f){a(f).html(h.string())}else{delete g.title;return a(h.string()).appendTo(document.body).eq(0).tWindow(g)}},getResizeHandlesHtml:function(){var e=new b.stringBuilder();a.each("n e s w se sw ne nw".split(" "),function(f,g){e.cat('<div class="t-resize-handle t-resize-').cat(g).catIf(" t-icon",g=="se").cat('"></div>')});return e.string()}});a.fn.tWindow=function(e){return b.create(this,{name:"tWindow",init:function(f,g){return new b.window(f,g)},success:function(g){var h=g.element,f=a(h);if(f.is(":visible")){b.trigger(h,"open");b.trigger(h,"activated")}},options:e})};a.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); |