From e9ecd49f7460f571e2bf13161038371e2d5f8bfb Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 11 Aug 2014 13:11:10 +0200 Subject: Added namespace filter in Folder Manager --- program/js/app.js | 36 ++++++++++++++++++++++++++++++++++-- program/js/treelist.js | 7 ++++++- 2 files changed, 40 insertions(+), 3 deletions(-) (limited to 'program/js') 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 = $('
  • ') .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; -- cgit v1.2.3