Changeset 2227 in subversion


Ignore:
Timestamp:
Jan 9, 2009 10:45:15 AM (4 years ago)
Author:
thomasb
Message:

Migrate splitter to jQuery

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-api/skins/default/splitter.js

    r2169 r2227  
    2323 
    2424    // create and position the handle for this splitter 
    25     this.p1pos = rcube_get_object_pos(this.p1, this.relative); 
    26     this.p2pos = rcube_get_object_pos(this.p2, this.relative); 
     25    this.p1pos = this.relative ? $(this.p1).position() : $(this.p1).offset(); 
     26    this.p2pos = this.relative ? $(this.p2).position() : $(this.p2).offset(); 
    2727     
    2828    if (this.horizontal) 
    2929      { 
    30       var top = this.p1pos.y + this.p1.offsetHeight; 
     30      var top = this.p1pos.top + this.p1.offsetHeight; 
    3131      this.layer = new rcube_layer(this.id, {x: 0, y: top, height: 10,  
    3232            width: '100%', vis: 1, parent: this.p1.parentNode}); 
     
    3434    else 
    3535      { 
    36       var left = this.p1pos.x + this.p1.offsetWidth; 
     36      var left = this.p1pos.left + this.p1.offsetWidth; 
    3737      this.layer = new rcube_layer(this.id, {x: left, y: 0, width: 10,  
    3838            height: '100%', vis: 1,  parent: this.p1.parentNode}); 
     
    7171      { 
    7272      var lh = this.layer.height - this.offset * 2; 
    73       this.p1.style.height = Math.floor(this.pos - this.p1pos.y - lh / 2) + 'px'; 
     73      this.p1.style.height = Math.floor(this.pos - this.p1pos.top - lh / 2) + 'px'; 
    7474      this.p2.style.top = Math.ceil(this.pos + lh / 2) + 'px'; 
    75       this.layer.move(this.layer.x, Math.round(this.pos - lh / 2 + 1));       
     75      this.layer.move(this.layer.x, Math.round(this.pos - lh / 2 + 1)); 
    7676      if (bw.ie) 
    77         { 
     77        { 
    7878        var new_height = (parseInt(this.p2.parentNode.offsetHeight) - parseInt(this.p2.style.top)); 
    7979        this.p2.style.height = (new_height > 0 ? new_height : 0) +'px'; 
     
    8282    else 
    8383      { 
    84       this.p1.style.width = Math.floor(this.pos - this.p1pos.x - this.layer.width / 2) + 'px'; 
     84      this.p1.style.width = Math.floor(this.pos - this.p1pos.left - this.layer.width / 2) + 'px'; 
    8585      this.p2.style.left = Math.ceil(this.pos + this.layer.width / 2) + 'px'; 
    8686      this.layer.move(Math.round(this.pos - this.layer.width / 2 + 1), this.layer.y); 
     
    9595  this.onDragStart = function(e) 
    9696    { 
    97     this.p1pos = rcube_get_object_pos(this.p1, this.relative); 
    98     this.p2pos = rcube_get_object_pos(this.p2, this.relative); 
     97    this.p1pos = this.relative ? $(this.p1).position() : $(this.p1).offset(); 
     98    this.p2pos = this.relative ? $(this.p2).position() : $(this.p2).offset(); 
    9999    this.drag_active = true; 
    100100     
     
    120120        // the position of each iframe when the event is received 
    121121        var s = this; 
    122         var id = iframes[n].id; 
    123         this.iframe_events[n] = function(e){ e._offset = rcube_get_object_pos(document.getElementById(id)); return s.onDrag(e); } 
     122        var id = '#'+iframes[n].id; 
     123        this.iframe_events[n] = function(e){ e._offset = $(id).offset(); return s.onDrag(e); } 
    124124 
    125125        if (iframedoc.addEventListener) 
     
    146146    if (this.relative) 
    147147      { 
    148       var parent = rcube_get_object_pos(this.p1.parentNode); 
    149       pos.x -= parent.x; 
    150       pos.y -= parent.y; 
    151       } 
    152  
    153     if (this.horizontal) 
    154       { 
    155       if (((pos.y - this.layer.height * 1.5) > this.p1pos.y) && ((pos.y + this.layer.height * 1.5) < (this.p2pos.y + this.p2.offsetHeight))) 
     148      var parent = $(this.p1.parentNode).offset(); 
     149      pos.x -= parent.left; 
     150      pos.y -= parent.top; 
     151      } 
     152 
     153    if (this.horizontal) 
     154      { 
     155      if (((pos.y - this.layer.height * 1.5) > this.p1pos.top) && ((pos.y + this.layer.height * 1.5) < (this.p2pos.top + this.p2.offsetHeight))) 
    156156        { 
    157157        this.pos = pos.y; 
     
    161161    else 
    162162      { 
    163       if (((pos.x - this.layer.width * 1.5) > this.p1pos.x) && ((pos.x + this.layer.width * 1.5) < (this.p2pos.x + this.p2.offsetWidth))) 
     163      if (((pos.x - this.layer.width * 1.5) > this.p1pos.left) && ((pos.x + this.layer.width * 1.5) < (this.p2pos.left + this.p2.offsetWidth))) 
    164164        { 
    165165        this.pos = pos.x; 
     
    168168      } 
    169169 
    170     this.p1pos = rcube_get_object_pos(this.p1, this.relative); 
    171     this.p2pos = rcube_get_object_pos(this.p2, this.relative); 
     170    this.p1pos = this.relative ? $(this.p1).position() : $(this.p1).offset(); 
     171    this.p2pos = this.relative ? $(this.p2).position() : $(this.p2).offset(); 
    172172    return false; 
    173173    }; 
     
    199199          if (iframedoc.removeEventListener) 
    200200            iframedoc.removeEventListener('mousemove', this.iframe_events[n], false); 
    201           else if (iframedoc.detachEvent) 
     201          else if (iframedoc.detachEvent) 
    202202            iframedoc.detachEvent('onmousemove', this.iframe_events[n]); 
    203203          else 
Note: See TracChangeset for help on using the changeset viewer.