Aleksander Machniak
2013-10-17 037af6890fe6fdb84a08d3c86083e847c90ec0ad
program/js/list.js
@@ -110,17 +110,25 @@
    row.onmousedown = function(e){ return self.drag_row(e, this.uid); };
    row.onmouseup = function(e){ return self.click_row(e, this.uid); };
    if (bw.mobile) {
    if (bw.touch) {
      row.addEventListener('touchstart', function(e) {
        if (e.touches.length == 1) {
          if (!self.drag_row(rcube_event.touchevent(e.touches[0]), this.uid))
            e.preventDefault();
          self.touchmoved = false;
          self.drag_row(rcube_event.touchevent(e.touches[0]), this.uid)
        }
      }, false);
      row.addEventListener('touchend', function(e) {
        if (e.changedTouches.length == 1)
          if (!self.click_row(rcube_event.touchevent(e.changedTouches[0]), this.uid))
        if (e.changedTouches.length == 1) {
          if (!self.touchmoved && !self.click_row(rcube_event.touchevent(e.changedTouches[0]), this.uid))
            e.preventDefault();
        }
      }, false);
      row.addEventListener('touchmove', function(e) {
        if (e.changedTouches.length == 1) {
          self.touchmoved = true;
          if (self.drag_active)
            e.preventDefault();
        }
      }, false);
    }
@@ -230,8 +238,9 @@
  }
  // Un-focus already focused elements (#1487123, #1487316, #1488600, #1488620)
  // It looks that window.focus() does the job for all browsers, but not Firefox (#1489058)
  $(':focus:not(body)').blur();
  $('iframe').each(function() { this.blur(); });
  window.focus();
  if (e || (e = window.event))
    rcube_event.cancel(e);
@@ -298,7 +307,7 @@
  if (rcube_event.get_button(e) == 2)
    return true;
  this.in_selection_before = this.in_selection(id) ? id : false;
  this.in_selection_before = e && e.istouch || this.in_selection(id) ? id : false;
  // selects currently unselected row
  if (!this.in_selection_before) {
@@ -306,12 +315,12 @@
    this.select_row(id, mod_key, false);
  }
  if (this.draggable && this.selection.length) {
  if (this.draggable && this.selection.length && this.in_selection(id)) {
    this.drag_start = true;
    this.drag_mouse_start = rcube_event.get_mouse_pos(e);
    rcube_event.add_listener({event:'mousemove', object:this, method:'drag_mouse_move'});
    rcube_event.add_listener({event:'mouseup', object:this, method:'drag_mouse_up'});
    if (bw.mobile) {
    if (bw.touch) {
      rcube_event.add_listener({event:'touchmove', object:this, method:'drag_mouse_move'});
      rcube_event.add_listener({event:'touchend', object:this, method:'drag_mouse_up'});
    }
@@ -687,7 +696,6 @@
    this.shift_start = null;
  this.last_selected = id;
  this.list.focus();
},
@@ -775,10 +783,16 @@
  if (!this.rows[this.shift_start] || !this.selection.length)
    this.shift_start = id;
  var n, from_rowIndex = this.rows[this.shift_start].obj.rowIndex,
    to_rowIndex = this.rows[id].obj.rowIndex,
    i = ((from_rowIndex < to_rowIndex)? from_rowIndex : to_rowIndex),
    j = ((from_rowIndex > to_rowIndex)? from_rowIndex : to_rowIndex);
  var n, i, j, to_row = this.rows[id],
    from_rowIndex = this.rows[this.shift_start].obj.rowIndex,
    to_rowIndex = to_row.obj.rowIndex;
  if (!to_row.expanded && to_row.has_children)
    if (to_row = this.rows[(this.row_children(id)).pop()])
      to_rowIndex = to_row.obj.rowIndex;
  i = ((from_rowIndex < to_rowIndex) ? from_rowIndex : to_rowIndex),
  j = ((from_rowIndex > to_rowIndex) ? from_rowIndex : to_rowIndex);
  // iterate through the entire message list
  for (n in this.rows) {
@@ -824,7 +838,7 @@
  for (n in this.rows) {
    if (!filter || this.rows[n][filter] == true) {
      this.last_selected = n;
      this.highlight_row(n, true);
      this.highlight_row(n, true, true);
    }
    else {
      $(this.rows[n].obj).removeClass('selected').removeClass('unfocused');
@@ -919,7 +933,7 @@
/**
 * Highlight/unhighlight a row
 */
highlight_row: function(id, multiple)
highlight_row: function(id, multiple, norecur)
{
  if (!this.rows[id])
    return;
@@ -935,7 +949,7 @@
    if (!this.in_selection(id)) { // select row
      this.selection.push(id);
      $(this.rows[id].obj).addClass('selected');
      if (!this.rows[id].expanded)
      if (!norecur && !this.rows[id].expanded)
        this.highlight_children(id, true);
    }
    else { // unselect row
@@ -945,7 +959,7 @@
      this.selection = a_pre.concat(a_post);
      $(this.rows[id].obj).removeClass('selected').removeClass('unfocused');
      if (!this.rows[id].expanded)
      if (!norecur && !this.rows[id].expanded)
        this.highlight_children(id, false);
    }
  }
@@ -963,7 +977,7 @@
  for (i=0; i<len; i++) {
    selected = this.in_selection(children[i]);
    if ((status && !selected) || (!status && selected))
      this.highlight_row(children[i], true);
      this.highlight_row(children[i], true, true);
  }
},
@@ -1109,7 +1123,7 @@
{
  // convert touch event
  if (e.type == 'touchmove') {
    if (e.changedTouches.length == 1)
    if (e.touches.length == 1 && e.changedTouches.length == 1)
      e = rcube_event.touchevent(e.changedTouches[0]);
    else
      return rcube_event.cancel(e);
@@ -1225,7 +1239,7 @@
  rcube_event.remove_listener({event:'mousemove', object:this, method:'drag_mouse_move'});
  rcube_event.remove_listener({event:'mouseup', object:this, method:'drag_mouse_up'});
  if (bw.mobile) {
  if (bw.touch) {
    rcube_event.remove_listener({event:'touchmove', object:this, method:'drag_mouse_move'});
    rcube_event.remove_listener({event:'touchend', object:this, method:'drag_mouse_up'});
  }