Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

splitter.min.js 4.1KB

1234567891011121314151617181920212223242526
  1. /**
  2. * Roundcube splitter GUI class
  3. *
  4. * @licstart The following is the entire license notice for the
  5. * JavaScript code in this file.
  6. *
  7. * Copyright (c) 2006-2014, The Roundcube Dev Team
  8. *
  9. * The JavaScript code in this page is free software: you can redistribute it
  10. * and/or modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation, either version 3 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * @licend The above is the entire license notice
  15. * for the JavaScript code in this file.
  16. *
  17. * @constructor
  18. */
  19. function rcube_splitter(b){function e(c){a.drag_active=!0;if(bw.konq||bw.chrome||bw.safari)document.body.style.webkitUserSelect="none";a.p1pos=a.relative?$(a.p1).position():$(a.p1).offset();a.p2pos=a.relative?$(a.p2).position():$(a.p2).offset();$(document).on("mousemove."+a.id,f).on("mouseup."+a.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:1E3}).css($(this).offset()).appendTo("body")})}
  20. function f(c){if(!a.drag_active)return!1;window.clearTimeout(a.ts);a.ts=window.setTimeout(function(){var d=rcube_event.get_mouse_pos(c);if(a.relative){var b=$(a.p1.parentNode).offset();d.x-=b.left;d.y-=b.top}a.horizontal?d.y-1.5*a.layer.height>a.p1pos.top&&d.y+1.5*a.layer.height<a.p2pos.top+a.p2.offsetHeight&&(a.pos=d.y,a.resize()):d.x-1.5*a.layer.width>a.p1pos.left&&d.x+1.5*a.layer.width<a.p2pos.left+a.p2.offsetWidth&&(a.pos=d.x,a.resize());a.p1pos=a.relative?$(a.p1).position():$(a.p1).offset();
  21. a.p2pos=a.relative?$(a.p2).position():$(a.p2).offset()},1);return!1}function g(c){a.drag_active=!1;if(bw.konq||bw.chrome||bw.safari)document.body.style.webkitUserSelect="auto";$(document).off("."+a.id);$("div.iframe-splitter-fix").remove();a.set_cookie();"function"==typeof a.callback&&a.callback(a);return bw.safari?!0:rcube_event.cancel(c)}function h(c){a.horizontal?(c=parseInt(a.p2.parentNode.offsetHeight,10)-parseInt(a.p2.style.top,10)-(bw.ie8?2:0),a.p2.style.height=(0<c?c:0)+"px"):(c=parseInt(a.p2.parentNode.offsetWidth,
  22. 10)-parseInt(a.p2.style.left,10),a.p2.style.width=(0<c?c:0)+"px")}this.p1id=b.p1;this.p2id=b.p2;this.id=b.id?b.id:this.p1id+"_"+this.p2id+"_splitter";this.orientation=b.orientation;this.horizontal="horizontal"==this.orientation||"h"==this.orientation;this.pos=b.start?1*b.start:0;this.relative=b.relative?!0:!1;this.drag_active=!1;this.callback=b.callback;var a=this;this.init=function(){this.p1=document.getElementById(this.p1id);this.p2=document.getElementById(this.p2id);this.p1pos=this.relative?$(this.p1).position():
  23. $(this.p1).offset();this.p2pos=this.relative?$(this.p2).position():$(this.p2).offset();this.layer=this.horizontal?new rcube_layer(this.id,{x:0,y:this.p1pos.top+this.p1.offsetHeight,height:10,width:"100%",vis:1,parent:this.p1.parentNode}):new rcube_layer(this.id,{x:this.p1pos.left+this.p1.offsetWidth,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(e);
  24. bw.ie&&$(window).resize(h);var a=rcmail.get_cookie(this.id);a&&!isNaN(a)?(this.pos=parseFloat(a),this.resize()):this.pos&&(this.resize(),this.set_cookie())};this.resize=function(){if(this.horizontal){var a=this.layer.height;this.p1.style.height=Math.floor(this.pos-this.p1pos.top-a/2)+"px";this.p2.style.top=Math.ceil(this.pos+a/2)+"px";this.layer.move(this.layer.x,Math.round(this.pos-a/2+1));bw.ie&&(a=parseInt(this.p2.parentNode.offsetHeight,10)-parseInt(this.p2.style.top,10)-(bw.ie8?2:0),this.p2.style.height=
  25. (0<a?a: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),bw.ie&&(a=parseInt(this.p2.parentNode.offsetWidth,10)-parseInt(this.p2.style.left,10),this.p2.style.width=(0<a?a:0)+"px");$(this.p2).resize();$(this.p1).resize()};this.set_cookie=function(){var a=new Date;a.setYear(a.getFullYear()+1);rcmail.set_cookie(this.id,this.pos,
  26. a)}};