From 302eb266de6884dd6413f674cbc9af177dfcdc38 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 11 Dec 2013 09:31:19 +0100 Subject: Fix regression where only first new folder was placed in correct place on the list (#1489472) --- program/js/app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'program') diff --git a/program/js/app.js b/program/js/app.js index bad8a2f9c..cbe61ab4a 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -5744,19 +5744,23 @@ function rcube_webmail() .prop({checked: subscribed ? true : false, disabled: is_protected ? true : false}); // add to folder/row-ID map - this.env.subscriptionrows[id] = [name, display_name, 0]; + this.env.subscriptionrows[id] = [name, display_name, false]; // sort folders (to find a place where to insert the row) // replace delimiter with \0 character to fix sorting // issue where 'Abc Abc' would be placed before 'Abc/def' var replace_from = RegExp(RegExp.escape(this.env.delimiter), 'g'), replace_to = String.fromCharCode(0); + $.each(this.env.subscriptionrows, function(k,v) { - var n = v[0]; - n = n.replace(replace_from, replace_to); - v.push(n); + if (v.length < 4) { + var n = v[0]; + n = n.replace(replace_from, replace_to); + v.push(n); + } folders.push(v); }); + folders.sort(function(a, b) { var len = a.length - 1; n1 = a[len], n2 = b[len]; return n1 < n2 ? -1 : 1; -- cgit v1.2.3 From f8963705578ccb3e0554d948afcc1908c4596a08 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 11 Dec 2013 15:32:36 +0100 Subject: Improved drag-n-drop layer: - do not auto-select children of collapsed threads, display subjects in real order (not is selection order), some code improvements --- program/js/list.js | 86 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 37 deletions(-) (limited to 'program') 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 = $('
').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; n12) { - 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 = $('
').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($('
').text(subject)); + return false; } - }); - } - } + } + }); + }); this.draglayer.show(); this.drag_active = true; -- cgit v1.2.3 From 48660a881c698e3cd45dcff5075c8541e178331d Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 11 Dec 2013 15:36:16 +0100 Subject: Fix use of non-existing localization label (#1489474) --- program/steps/settings/save_folder.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'program') diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc index efb096d57..72a631cfc 100644 --- a/program/steps/settings/save_folder.inc +++ b/program/steps/settings/save_folder.inc @@ -40,7 +40,7 @@ $options = strlen($old_imap) ? rcmail_folder_options($old_imap) : array(); if ($options['protected'] || $options['norename']) { } else if (!strlen($name)) { - $error = rcube_label('cannotbeempty'); + $error = rcube_label('namecannotbeempty'); } else if (mb_strlen($name) > 128) { $error = rcube_label('nametoolong'); -- cgit v1.2.3