Sonarr/NzbDrone.Web/Scripts/2011.1.315/telerik.splitter.min.js

1 line
7.3 KiB
JavaScript

(function(f){var i=f.telerik,h=7,a=/^\d+px$/i,d=/^\d+(\.\d+)?%$/i;function b(j){return d.test(j)}function g(j){return a.test(j)}function c(j){return !b(j)&&!g(j)}i.splitter=function(j,k){this.element=j;var m=this.$element=f(j),l=this;f.extend(this,k);var r=this.orientation.toLowerCase()!="vertical"?"horizontal":"vertical",p=this.panes;this.orientation=r;i.bind(this,{load:this.onLoad,expand:this.onExpand,collapse:this.onCollapse,contentLoad:this.onContentLoad,resize:function(s){s.stopPropagation();l.resize.call(l,s);if(f.isFunction(l.onResize)){l.onResize.call(j,s)}}});var n=".t-splitbar-draggable-"+r,o=".t-splitbar .t-icon:not(.t-resize-handle)";var q=function(s){return function(v){var u=f(v.target),t;if(u.closest(".t-splitter")[0]!=j){return}if(u.is(".t-"+s+"-prev")){t=u.parent().prev()}else{t=u.parent().next()}if(!i.trigger(j,s,{pane:t[0]})){l[s](t[0])}}};m.addClass("t-widget").addClass("t-splitter").children().addClass("t-pane").each(f.proxy(function(t,u){var s=f(u);s.data("pane",p?p[t]:{}).toggleClass("t-scrollable",p?p[t].scrollable!==false:true);this.ajaxRequest(s)},this)).end().trigger("resize").delegate(n,"mouseenter",function(){f(this).addClass("t-splitbar-"+r+"-hover")}).delegate(n,"mouseleave",function(){f(this).removeClass("t-splitbar-"+r+"-hover")}).delegate(o,"mouseenter",i.hover).delegate(o,"mouseleave",i.leave).delegate(".t-splitbar .t-collapse-next, .t-splitbar .t-collapse-prev","click",q("collapse")).delegate(".t-splitbar .t-expand-next, .t-splitbar .t-expand-prev","click",q("expand")).delegate(".t-splitbar","dblclick",function(v){var t=f(v.target),u=function(x,w){if(!i.trigger(j,x,{pane:w[0]})){l[x](w[0])}};if(t.closest(".t-splitter")[0]!=j){return}var s=t.children(".t-icon:not(.t-resize-handle)");if(s.length!==1){return}if(s.is(".t-collapse-prev")){u("collapse",t.prev())}else{if(s.is(".t-collapse-next")){u("collapse",t.next())}else{if(s.is(".t-expand-prev")){u("expand",t.prev())}else{if(s.is(".t-expand-next")){u("expand",t.next())}}}}}).parent().closest(".t-splitter").bind("resize",function(){m.trigger("resize")});this.resizing=new i.splitter.PaneResizing(this)};function e(j,k){return function(n,l){var m=f(n).data("pane");if(arguments.length==1){return m[j]}m[j]=l;if(k){this.$element.trigger("resize")}}}i.splitter.prototype={toggle:function(l,n){var l=f(l),j=l.prev(".t-splitbar"),m=l.next(".t-splitbar"),o=j.add(m),k=l.data("pane");if(arguments.length==1){n=k.collapsed===undefined?false:k.collapsed}o.toggleClass("t-splitbar-draggable-"+this.orientation,n).removeClass("t-splitbar-"+this.orientation+"-hover");j.find(n?".t-expand-next":".t-collapse-next").toggleClass("t-expand-next",!n).toggleClass("t-collapse-next",n);m.find(n?".t-expand-prev":".t-collapse-prev").toggleClass("t-expand-prev",!n).toggleClass("t-collapse-prev",n);k.collapsed=!n;this.$element.trigger("resize")},collapse:function(j){this.toggle(j,false)},expand:function(j){this.toggle(j,true)},size:e("size",true),minSize:e("minSize"),maxSize:e("maxSize"),ajaxOptions:function(j,l){var k=this;return f.extend({type:"POST",dataType:"html",success:function(m){j.html(m);i.trigger(k.element,"contentLoad",{pane:j[0]})}},l)},ajaxRequest:function(m,j){var k=f(m),l=k.data("pane");if(j||l.contentUrl){k.append("<span class='t-icon t-loading t-pane-loading' />");f.ajax(this.ajaxOptions(k,{url:j||l.contentUrl}))}},resize:function(){var v=this.$element,C=v.children(":not(.t-splitbar)"),k=this.orientation=="horizontal",q=v.children(".t-splitbar").length,z=k?"width":"height",D=v[z]();if(q===0){q=C.length-1;for(var l=0;l<q;l++){var j=C.eq(l),n=j.data("pane"),o=j.next().data("pane"),s=(n.resizable!==false)&&(o.resizable!==false),t=new i.stringBuilder();t.catIconIf=function(F,E){if(E){this.cat("<div class='t-icon ").cat(F).cat("' />")}return this};t.cat("<div class='t-splitbar t-state-default t-splitbar-").cat(this.orientation).catIf(" t-splitbar-draggable-",this.orientation,s&&!n.collapsed&&!o.collapsed).cat("'>").catIconIf("t-collapse-prev",n.collapsible&&!n.collapsed).catIconIf("t-expand-prev",n.collapsible&&n.collapsed).catIconIf("t-resize-handle",s).catIconIf("t-collapse-next",o.collapsible&&!o.collapsed).catIconIf("t-expand-next",o.collapsible&&o.collapsed).cat("</div>");j.after(t.string())}}D-=h*q;var y=0,x=0,p=f();C.css({position:"absolute",top:0})[z](function(){var E=f(this).data("pane"),F;if(E.collapsed){F=0}else{if(c(E.size)){p=p.add(this);return}else{F=parseInt(E.size,10);if(b(E.size)){F=Math.floor(F*D/100)}}}x++;y+=F;return F});D-=y;var u=p.length,B=Math.floor(D/u);p.slice(0,u-1).css(z,B).end().eq(u-1).css(z,D-(u-1)*B);var w=0,r=k?"height":"width",m=k?"left":"top",A=k?"offsetWidth":"offsetHeight";v.children().css(r,v[r]()).each(function(E,F){F.style[m]=Math.floor(w)+"px";w+=F[A]})}};i.splitter.PaneResizing=function(j){this.owner=j;new i.draggable({distance:0,owner:j.element,selector:".t-splitbar-draggable-horizontal, .t-splitbar-draggable-vertical",scope:j.element.id,start:f.proxy(this.start,this),drag:f.proxy(this.drag,this),stop:f.proxy(this.stop,this)})};i.splitter.PaneResizing.prototype={start:function(x){var l=x.$draggable,o=l.prev(),p=l.next(),m=o.data("pane"),q=p.data("pane"),u=this.owner.orientation==="horizontal",y=u?"width":"height",z=u?"offsetWidth":"offsetHeight",s=u?"height":"width";this.positioningProperty=u?"left":"top";this.mousePositioningProperty=u?"pageX":"pageY";this.previousPane=o;this.nextPane=p;this.initialSplitBarPosition=parseInt(l[0].style[this.positioningProperty]);this.initialMousePosition=x[this.mousePositioningProperty];this.ghostSplitBar=f("<div class='t-ghost-splitbar t-ghost-splitbar-"+this.owner.orientation+" t-state-default' />").css(s,x.$draggable[s]()).css(this.positioningProperty,this.initialSplitBarPosition).appendTo(this.owner.element);var A=parseInt(o[0].style[this.positioningProperty]),n=parseInt(p[0].style[this.positioningProperty])+p[0][z]-h,w=this.owner.$element.css(y),t=function(C){var B=parseInt(C,10);return(g(C)?B:(w*B)/100)||0},v=t(m.minSize),k=t(m.maxSize)||n-A,j=t(q.minSize),r=t(q.maxSize)||n-A;this.maxSize=Math.min(n-j,A+k);this.minSize=Math.max(A+v,n-r);f(document.body).css("cursor",l.css("cursor"))},drag:function(k){var j=Math.min(this.maxSize,Math.max(this.minSize,this.initialSplitBarPosition+(k[this.mousePositioningProperty]-this.initialMousePosition)));this.ghostSplitBar.toggleClass("t-restricted-size-"+this.owner.orientation,j==this.maxSize||j==this.minSize)[0].style[this.positioningProperty]=j+"px"},stop:function(r){if(r.keyCode!==27){var n=parseInt(this.ghostSplitBar[0].style[this.positioningProperty]),j=this.owner.orientation==="horizontal",p=j?"width":"height",o=j?"offsetWidth":"offsetHeight",k=this.previousPane.data("pane"),q=this.nextPane.data("pane"),l=n-parseInt(this.previousPane[0].style[this.positioningProperty]),t=parseInt(this.nextPane[0].style[this.positioningProperty])+this.nextPane[0][o]-n-h,m=this.owner.$element[p]();m-=h*this.owner.$element.children(".t-splitbar").length;var s=this.owner.$element.children(".t-pane").filter(function(){return c(f(this).data("pane").size)}).length;if(!c(k.size)||s>1){if(c(k.size)){s--}k.size=l+"px"}if(!c(q.size)||s>1){q.size=t+"px"}}this.ghostSplitBar.remove();if(r.keyCode!==27){this.owner.$element.trigger("resize")}f(document.body).css("cursor","");return false}};f.fn.tSplitter=function(j){return i.create(this,{name:"tSplitter",init:function(k,l){return new i.splitter(k,l)},options:j})};f.fn.tSplitter.defaults={orientation:"horizontal"}})(jQuery);