summaryrefslogtreecommitdiff
path: root/program/js/list.js
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-12-12 08:59:41 +0100
committerAleksander Machniak <alec@alec.pl>2013-12-12 08:59:41 +0100
commit4187b3e26ff00b607d05cb9b588e83db18c3cab7 (patch)
tree65e2f2263cf96a7765e54d7fb303e5c0173a05ee /program/js/list.js
parentd19c0f9f309cbe63411a8ddcbbda3daf7461a30d (diff)
parent48660a881c698e3cd45dcff5075c8541e178331d (diff)
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'program/js/list.js')
-rw-r--r--program/js/list.js86
1 files changed, 49 insertions, 37 deletions
diff --git a/program/js/list.js b/program/js/list.js
index 8677f029d..895a9e645 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -1322,59 +1322,71 @@ drag_mouse_move: function(e)
if (this.drag_start) {
// check mouse movement, of less than 3 pixels, don't start dragging
- var m = rcube_event.get_mouse_pos(e);
+ var m = rcube_event.get_mouse_pos(e),
+ limit = 10, selection = [], self = this;
if (!this.drag_mouse_start || (Math.abs(m.x - this.drag_mouse_start.x) < 3 && Math.abs(m.y - this.drag_mouse_start.y) < 3))
return false;
+ // remember dragging start position
+ this.drag_start_pos = {left: m.x, top: m.y};
+
+ // initialize drag layer
if (!this.draglayer)
this.draglayer = $('<div>').attr('id', 'rcmdraglayer')
- .css({ position:'absolute', display:'none', 'z-index':2000 })
+ .css({position: 'absolute', display: 'none', 'z-index': 2000})
.appendTo(document.body);
+ else
+ this.draglayer.html('');
- // also select childs of (collapsed) threads for dragging
- var n, uid, selection = $.merge([], this.selection);
- for (n in selection) {
- uid = selection[n];
- if (!this.rows[uid].expanded)
- this.select_children(uid);
- }
+ // get selected rows (in display order), don't use this.selection here
+ $(this.row_tagname() + '.selected', this.tbody).each(function() {
+ if (!String(this.id).match(self.id_regexp))
+ return;
- // reset content
- this.draglayer.html('');
+ var uid = RegExp.$1, row = self.rows[uid];
- // get subjects of selected messages
- var n, obj, me = this;
- for (n=0; n<this.selection.length; n++) {
- // only show 12 lines
- if (n>12) {
- this.draglayer.append('...');
- break;
- }
+ if ($.inArray(uid, selection) > -1)
+ return;
- if (obj = this.rows[this.selection[n]].obj) {
- $('> '+this.col_tagname(), obj).each(function(i, elem) {
- if (n == 0)
- me.drag_start_pos = $(elem).offset();
+ selection.push(uid);
- if (me.subject_col < 0 || (me.subject_col >= 0 && me.subject_col == i)) {
- var subject = $(elem).text();
+ // also handle children of (collapsed) trees for dragging (they might be not selected)
+ if (row.has_children && !row.expanded)
+ $.each(self.row_children(uid), function() {
+ if ($.inArray(this, selection) > -1)
+ return;
+ selection.push(this);
+ });
- if (subject) {
- // remove leading spaces
- subject = $.trim(subject);
- // truncate line to 50 characters
- subject = (subject.length > 50 ? subject.substring(0, 50) + '...' : subject);
+ // break the loop asap
+ if (selection.length > limit + 1)
+ return false;
+ });
- var entry = $('<div>').text(subject);
- me.draglayer.append(entry);
- }
+ // append subject (of every row up to the limit) to the drag layer
+ $.each(selection, function(i, uid) {
+ if (i > limit) {
+ self.draglayer.append('...');
+ return false;
+ }
+
+ $('> ' + self.col_tagname(), self.rows[uid].obj).each(function(n, cell) {
+ if (self.subject_col < 0 || (self.subject_col >= 0 && self.subject_col == n)) {
+ var subject = $(cell).text();
- return false; // break
+ if (subject) {
+ // remove leading spaces
+ subject = $.trim(subject);
+ // truncate line to 50 characters
+ subject = (subject.length > 50 ? subject.substring(0, 50) + '...' : subject);
+
+ self.draglayer.append($('<div>').text(subject));
+ return false;
}
- });
- }
- }
+ }
+ });
+ });
this.draglayer.show();
this.drag_active = true;