Mercurial > hg > rc2
comparison skins/classic/splitter.min.js @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:52:31 -0500 |
parents | |
children | bf99236cc5cd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4681f974d28b |
---|---|
1 function rcube_splitter(e){this.p1id=e.p1;this.p2id=e.p2;this.id=e.id?e.id:this.p1id+"_"+this.p2id+"_splitter";this.orientation=e.orientation;this.horizontal=(this.orientation=="horizontal"||this.orientation=="h");this.pos=e.start?e.start*1:0;this.relative=e.relative?true:false;this.drag_active=false;this.callback=e.callback;var d=this;this.init=function(){this.p1=document.getElementById(this.p1id);this.p2=document.getElementById(this.p2id);this.p1pos=this.relative?$(this.p1).position():$(this.p1).offset();this.p2pos=this.relative?$(this.p2).position():$(this.p2).offset();if(this.horizontal){var j=this.p1pos.top+this.p1.offsetHeight;this.layer=new rcube_layer(this.id,{x:0,y:j,height:10,width:"100%",vis:1,parent:this.p1.parentNode})}else{var i=this.p1pos.left+this.p1.offsetWidth;this.layer=new rcube_layer(this.id,{x:i,y:0,width:10,height:"100%",vis:1,parent:this.p1.parentNode})}this.elm=this.layer.elm;this.elm.className="splitter "+(this.horizontal?"splitter-h":"splitter-v");this.elm.unselectable="on";$(this.elm).mousedown(f);if(bw.ie){$(window).resize(c)}var h=rcmail.get_cookie(this.id);if(h&&!isNaN(h)){this.pos=parseFloat(h);this.resize()}else{if(this.pos){this.resize();this.set_cookie()}}};this.resize=function(){if(this.horizontal){var h=this.layer.height;this.p1.style.height=Math.floor(this.pos-this.p1pos.top-h/2)+"px";this.p2.style.top=Math.ceil(this.pos+h/2)+"px";this.layer.move(this.layer.x,Math.round(this.pos-h/2+1));if(bw.ie){var j=parseInt(this.p2.parentNode.offsetHeight,10)-parseInt(this.p2.style.top,10)-(bw.ie8?2:0);this.p2.style.height=(j>0?j:0)+"px"}}else{this.p1.style.width=Math.floor(this.pos-this.p1pos.left-this.layer.width/2)+"px";this.p2.style.left=Math.ceil(this.pos+this.layer.width/2)+"px";this.layer.move(Math.round(this.pos-this.layer.width/2+1),this.layer.y);if(bw.ie){var i=parseInt(this.p2.parentNode.offsetWidth,10)-parseInt(this.p2.style.left,10);this.p2.style.width=(i>0?i:0)+"px"}}$(this.p2).resize();$(this.p1).resize()};function f(h){d.drag_active=true;if(bw.konq||bw.chrome||bw.safari){document.body.style.webkitUserSelect="none"}d.p1pos=d.relative?$(d.p1).position():$(d.p1).offset();d.p2pos=d.relative?$(d.p2).position():$(d.p2).offset();$(document).bind("mousemove."+d.id,a).bind("mouseup."+d.id,g);$("iframe").each(function(){$('<div class="iframe-splitter-fix"></div>').css({background:"#fff",width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css($(this).offset()).appendTo("body")})}function a(h){if(!d.drag_active){return false}window.clearTimeout(d.ts);d.ts=window.setTimeout(function(){b(h)},1);return false}function b(i){var j=rcube_event.get_mouse_pos(i);if(d.relative){var h=$(d.p1.parentNode).offset();j.x-=h.left;j.y-=h.top}if(d.horizontal){if(((j.y-d.layer.height*1.5)>d.p1pos.top)&&((j.y+d.layer.height*1.5)<(d.p2pos.top+d.p2.offsetHeight))){d.pos=j.y;d.resize()}}else{if(((j.x-d.layer.width*1.5)>d.p1pos.left)&&((j.x+d.layer.width*1.5)<(d.p2pos.left+d.p2.offsetWidth))){d.pos=j.x;d.resize()}}d.p1pos=d.relative?$(d.p1).position():$(d.p1).offset();d.p2pos=d.relative?$(d.p2).position():$(d.p2).offset()}function g(h){d.drag_active=false;if(bw.konq||bw.chrome||bw.safari){document.body.style.webkitUserSelect="auto"}$(document).unbind("."+d.id);$("div.iframe-splitter-fix").remove();d.set_cookie();if(typeof d.callback=="function"){d.callback(d)}return bw.safari?true:rcube_event.cancel(h)}function c(j){if(d.horizontal){var i=parseInt(d.p2.parentNode.offsetHeight,10)-parseInt(d.p2.style.top,10)-(bw.ie8?2:0);d.p2.style.height=(i>0?i:0)+"px"}else{var h=parseInt(d.p2.parentNode.offsetWidth,10)-parseInt(d.p2.style.left,10);d.p2.style.width=(h>0?h:0)+"px"}}this.set_cookie=function(){var h=new Date();h.setYear(h.getFullYear()+1);rcmail.set_cookie(this.id,this.pos,h)}}; |