summaryrefslogtreecommitdiff
path: root/program/js
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-08-11 13:11:10 +0200
committerAleksander Machniak <alec@alec.pl>2014-08-11 13:11:10 +0200
commite9ecd49f7460f571e2bf13161038371e2d5f8bfb (patch)
treefa3c3ad4ab2b87485905879f52c6b45e545303a6 /program/js
parent1c70ff9d2471fa48f5ffe9d270b3b04e6ec58a63 (diff)
Added namespace filter in Folder Manager
Diffstat (limited to 'program/js')
-rw-r--r--program/js/app.js36
-rw-r--r--program/js/treelist.js7
2 files changed, 40 insertions, 3 deletions
diff --git a/program/js/app.js b/program/js/app.js
index c64318858..5a8734772 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -5862,8 +5862,9 @@ function rcube_webmail()
row.attr({id: 'rcmli' + this.html_identifier_encode(id), 'class': class_name});
if (!refrow || !refrow.length) {
- // remove old subfolders and toggle
+ // remove old data, subfolders and toggle
$('ul,div.treetoggle', row).remove();
+ row.removeData('filtered');
}
// set folder name
@@ -5990,7 +5991,7 @@ function rcube_webmail()
this.subscription_list.expand(this.folder_id2name(parent.id));
}
- row = row.get(0);
+ row = row.show().get(0);
if (row.scrollIntoView)
row.scrollIntoView();
@@ -6134,6 +6135,37 @@ function rcube_webmail()
$('#folder-size').replaceWith(size);
};
+ // filter folders by namespace
+ this.folder_filter = function(prefix)
+ {
+ this.subscription_list.reset_search();
+
+ this.subscription_list.container.children('li').each(function() {
+ var i, folder = ref.folder_id2name(this.id);
+ // show all folders
+ if (prefix == '---') {
+ }
+ // got namespace prefix
+ else if (prefix) {
+ if (folder !== prefix) {
+ $(this).data('filtered', true).hide();
+ return
+ }
+ }
+ // no namespace prefix, filter out all other namespaces
+ else {
+ // first get all namespace roots
+ for (i in ref.env.ns_roots) {
+ if (folder === ref.env.ns_roots[i]) {
+ $(this).data('filtered', true).hide();
+ return;
+ }
+ }
+ }
+
+ $(this).removeData('filtered').show();
+ });
+ };
/*********************************************************/
/********* GUI functionality *********/
diff --git a/program/js/treelist.js b/program/js/treelist.js
index cc1880da2..5e6d326fc 100644
--- a/program/js/treelist.js
+++ b/program/js/treelist.js
@@ -522,6 +522,11 @@ function rcube_treelist_widget(node, p)
var li, sli;
if (!node.virtual && !node.deleted && String(node.text).toLowerCase().indexOf(q) >= 0 && hits.indexOf(node.id) < 0) {
li = id2dom(node.id);
+
+ // skip already filtered nodes
+ if (li.data('filtered'))
+ return;
+
sli = $('<li>')
.attr('id', li.attr('id') + '--xsR')
.attr('class', li.attr('class'))
@@ -566,7 +571,7 @@ function rcube_treelist_widget(node, p)
searchfield.val('');
$(container).children('li.searchresult__').remove();
- $(container).children('li').show();
+ $(container).children('li').filter(function() { return !$(this).data('filtered'); }).show();
search_active = false;