Changeset 1633bca in github


Ignore:
Timestamp:
Apr 13, 2011 8:37:54 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
bf80b5a
Parents:
34d7287
Message:
  • Added scroll position reset for Opera (#1487689), small code improvements
File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/js/list.js

    ref4f591 r1633bca  
    103103  // make references in internal array and set event handlers 
    104104  if (row && String(row.id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i)) { 
    105     var self = this; 
    106     var uid = RegExp.$1; 
     105    var self = this, 
     106      uid = RegExp.$1; 
    107107    row.uid = uid; 
    108108    this.rows[uid] = {uid:uid, id:row.id, obj:row}; 
     
    171171  if (sel) 
    172172    this.clear_selection(); 
     173 
     174  // reset scroll position (in Opera) 
     175  if (this.frame) 
     176    this.frame.scrollTop = 0; 
    173177}, 
    174178 
     
    213217focus: function(e) 
    214218{ 
    215   var id; 
     219  var n, id; 
    216220  this.focused = true; 
    217221 
    218   for (var n in this.selection) { 
     222  for (n in this.selection) { 
    219223    id = this.selection[n]; 
    220224    if (this.rows[id] && this.rows[id].obj) { 
     
    237241blur: function() 
    238242{ 
    239   var id; 
     243  var n, id; 
    240244  this.focused = false; 
    241   for (var n in this.selection) { 
     245  for (n in this.selection) { 
    242246    id = this.selection[n]; 
    243247    if (this.rows[id] && this.rows[id].obj) { 
     
    431435expand: function(row) 
    432436{ 
    433   var depth, new_row; 
    434   var last_expanded_parent_depth; 
     437  var r, p, depth, new_row, last_expanded_parent_depth; 
    435438 
    436439  if (row) { 
     
    450453  while (new_row) { 
    451454    if (new_row.nodeType == 1) { 
    452       var r = this.rows[new_row.uid]; 
     455      r = this.rows[new_row.uid]; 
    453456      if (r) { 
    454457        if (row && (!r.depth || r.depth <= depth)) 
     
    456459 
    457460        if (r.parent_uid) { 
    458           var p = this.rows[r.parent_uid]; 
     461          p = this.rows[r.parent_uid]; 
    459462          if (p && p.expanded) { 
    460463            if ((row && p == row) || last_expanded_parent_depth >= p.depth - 1) { 
     
    697700select_next: function() 
    698701{ 
    699   var next_row = this.get_next_row(); 
    700   var prev_row = this.get_prev_row(); 
    701   var new_row = (next_row) ? next_row : prev_row; 
     702  var next_row = this.get_next_row(), 
     703    prev_row = this.get_prev_row(), 
     704    new_row = (next_row) ? next_row : prev_row; 
     705 
    702706  if (new_row) 
    703707    this.select_row(new_row.uid, false, false); 
     
    711715{ 
    712716  var row = this.get_first_row(); 
    713   if (row && mod_key) { 
    714     this.shift_select(row, mod_key); 
    715     this.triggerEvent('select'); 
    716     this.scrollto(row); 
    717   } 
    718   else if (row) 
    719     this.select(row); 
     717  if (row) { 
     718    if (mod_key) { 
     719      this.shift_select(row, mod_key); 
     720      this.triggerEvent('select'); 
     721      this.scrollto(row); 
     722    } 
     723    else { 
     724      this.select(row); 
     725    } 
     726  } 
    720727}, 
    721728 
     
    727734{ 
    728735  var row = this.get_last_row(); 
    729   if (row && mod_key) { 
    730     this.shift_select(row, mod_key); 
    731     this.triggerEvent('select'); 
    732     this.scrollto(row); 
    733   } 
    734   else if (row) 
    735     this.select(row); 
     736  if (row) { 
     737    if (mod_key) { 
     738      this.shift_select(row, mod_key); 
     739      this.triggerEvent('select'); 
     740      this.scrollto(row); 
     741    } 
     742    else { 
     743      this.select(row); 
     744    } 
     745  } 
    736746}, 
    737747 
     
    745755    return; 
    746756 
    747   var depth = this.rows[uid].depth; 
    748   var row = this.rows[uid].obj.nextSibling; 
     757  var depth = this.rows[uid].depth, 
     758    row = this.rows[uid].obj.nextSibling; 
     759 
    749760  while (row) { 
    750761    if (row.nodeType == 1) { 
     
    769780    this.shift_start = id; 
    770781 
    771   var from_rowIndex = this.rows[this.shift_start].obj.rowIndex, 
     782  var n, from_rowIndex = this.rows[this.shift_start].obj.rowIndex, 
    772783    to_rowIndex = this.rows[id].obj.rowIndex, 
    773784    i = ((from_rowIndex < to_rowIndex)? from_rowIndex : to_rowIndex), 
     
    775786 
    776787  // iterate through the entire message list 
    777   for (var n in this.rows) { 
     788  for (n in this.rows) { 
    778789    if (this.rows[n].obj.rowIndex >= i && this.rows[n].obj.rowIndex <= j) { 
    779790      if (!this.in_selection(n)) { 
     
    782793    } 
    783794    else { 
    784       if  (this.in_selection(n) && !control) { 
     795      if (this.in_selection(n) && !control) { 
    785796        this.highlight_row(n, true); 
    786797      } 
     
    795806in_selection: function(id) 
    796807{ 
    797   for(var n in this.selection) 
     808  for (var n in this.selection) 
    798809    if (this.selection[n]==id) 
    799810      return true; 
     
    812823 
    813824  // reset but remember selection first 
    814   var select_before = this.selection.join(','); 
     825  var n, select_before = this.selection.join(','); 
    815826  this.selection = []; 
    816827 
    817   for (var n in this.rows) { 
     828  for (n in this.rows) { 
    818829    if (!filter || this.rows[n][filter] == true) { 
    819830      this.last_selected = n; 
     
    844855 
    845856  // remember old selection 
    846   var select_before = this.selection.join(','); 
    847  
    848   for (var n in this.rows) 
     857  var n, select_before = this.selection.join(','); 
     858 
     859  for (n in this.rows) 
    849860    this.highlight_row(n, true); 
    850861 
     
    864875clear_selection: function(id) 
    865876{ 
    866   var num_select = this.selection.length; 
     877  var n, num_select = this.selection.length; 
    867878 
    868879  // one row 
    869880  if (id) { 
    870     for (var n in this.selection) 
     881    for (n in this.selection) 
    871882      if (this.selection[n] == id) { 
    872883        this.selection.splice(n,1); 
     
    876887  // all rows 
    877888  else { 
    878     for (var n in this.selection) 
     889    for (n in this.selection) 
    879890      if (this.rows[this.selection[n]]) { 
    880891        $(this.rows[this.selection[n]].obj).removeClass('selected').removeClass('unfocused'); 
     
    928939    } 
    929940    else { // unselect row 
    930       var p = $.inArray(id, this.selection); 
    931       var a_pre = this.selection.slice(0, p); 
    932       var a_post = this.selection.slice(p+1, this.selection.length); 
     941      var p = $.inArray(id, this.selection), 
     942        a_pre = this.selection.slice(0, p), 
     943        a_post = this.selection.slice(p+1, this.selection.length); 
     944 
    933945      this.selection = a_pre.concat(a_post); 
    934946      $(this.rows[id].obj).removeClass('selected').removeClass('unfocused'); 
     
    946958    return true; 
    947959 
    948   var keyCode = rcube_event.get_keycode(e); 
    949   var mod_key = rcube_event.get_modifier(e); 
     960  var keyCode = rcube_event.get_keycode(e), 
     961    mod_key = rcube_event.get_modifier(e); 
    950962 
    951963  switch (keyCode) { 
     
    13721384column_replace: function(from, to) 
    13731385{ 
    1374   var cells = this.list.tHead.rows[0].cells, 
     1386  var len, cells = this.list.tHead.rows[0].cells, 
    13751387    elem = cells[from], 
    13761388    before = cells[to], 
     
    13851397 
    13861398  // replace list cells 
    1387   for (r=0; r<this.list.tBodies[0].rows.length; r++) { 
     1399  for (r=0, len=this.list.tBodies[0].rows.length; r<len; r++) { 
    13881400    row = this.list.tBodies[0].rows[r]; 
    13891401 
Note: See TracChangeset for help on using the changeset viewer.