plugins/kolab_folders
Aleksander Machniak
machniak at kolabsys.com
Mon Aug 11 18:56:25 CEST 2014
plugins/kolab_folders/kolab_folders.js | 83 +++++++++++++++++++++++++++++++-
plugins/kolab_folders/kolab_folders.php | 26 ++++++++++
2 files changed, 108 insertions(+), 1 deletion(-)
New commits:
commit 44b8f1f6ee1cf1a587f10bd26245416c05a3389e
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Mon Aug 11 18:55:50 2014 +0200
Added folder type selection options to folder filter (#476)
diff --git a/plugins/kolab_folders/kolab_folders.js b/plugins/kolab_folders/kolab_folders.js
index 30d8170..a710657 100644
--- a/plugins/kolab_folders/kolab_folders.js
+++ b/plugins/kolab_folders/kolab_folders.js
@@ -25,7 +25,31 @@
* for the JavaScript code in this file.
*/
-$(document).ready(function() {
+window.rcmail && rcmail.env.action == 'folders' && rcmail.addEventListener('init', function() {
+ var filter = $(rcmail.gui_objects.foldersfilter),
+ optgroup = $('<optgroup>').attr('label', rcmail.gettext('kolab_folders.folderctype'));
+
+ // remove disabled namespaces
+ filter.children('option').each(function(i, opt) {
+ $.each(rcmail.env.skip_roots || [], function() {
+ if (opt.value == this) {
+ $(opt).remove();
+ }
+ });
+ });
+
+ // add type options to the filter
+ $.each(rcmail.env.foldertypes, function() {
+ optgroup.append($('<option>').attr('value', 'type-' + this).text(rcmail.gettext('kolab_folders.foldertype' + this)));
+ });
+
+ // overwrite default onchange handler
+ filter.attr('onchange', '')
+ .on('change', function() { return kolab_folders_filter(this.value); })
+ .append(optgroup);
+});
+
+window.rcmail && rcmail.env.action != 'folders' && $(document).ready(function() {
// IE doesn't allow setting OPTION's display/visibility
// We'll need to remove SELECT's options, see below
if (bw.ie) {
@@ -68,3 +92,60 @@ $(document).ready(function() {
}
}).change();
});
+
+function kolab_folders_filter(filter)
+{
+ var type = filter.match(/^type-([a-z]+)$/) ? RegExp.$1 : null;
+
+ rcmail.subscription_list.reset_search();
+
+ if (!type) {
+ // clear type filter
+ if (rcmail.folder_filter_type) {
+ $('li', rcmail.subscription_list.container).removeData('filtered').show();
+ rcmail.folder_filter_type = null;
+ }
+
+ // apply namespace filter
+ rcmail.folder_filter(filter);
+ }
+ else {
+ rcmail.folder_filter_type = type;
+ rcmail.subscription_list.container.children('li').each(function() {
+ kolab_folder_filter_match(this, type);
+ });
+ }
+
+ return false;
+}
+
+function kolab_folder_filter_match(elem, type, display)
+{
+ var t, found = 0, cl = elem.className || '',
+ $elem = $(elem),
+ sub = $('ul', elem),
+ disp = sub.css('display') == 'none',
+ children = sub.children('li');
+
+ // subfolders...
+ children.each(function() {
+ found += kolab_folder_filter_match(this, type);
+ });
+
+ if (found || cl.match(new RegExp('type-' + type))
+ || (type == 'mail' && !children.length && !cl.match(/(^| )type-([a-z]+)/) && !$elem.is('.virtual'))
+ ) {
+ if (found || !$elem.is('.virtual')) {
+ found++;
+ }
+ }
+
+ if (found) {
+ $elem.removeData('filtered').show();
+ }
+ else {
+ $elem.data('filtered', true).hide();
+ }
+
+ return found;
+}
diff --git a/plugins/kolab_folders/kolab_folders.php b/plugins/kolab_folders/kolab_folders.php
index 0cea259..a9c7b42 100644
--- a/plugins/kolab_folders/kolab_folders.php
+++ b/plugins/kolab_folders/kolab_folders.php
@@ -104,6 +104,32 @@ class kolab_folders extends rcube_plugin
return $args;
}
+ // load translations
+ $this->add_texts('localization/', false);
+
+ // Add javascript script to the client
+ $this->include_script('kolab_folders.js');
+
+ $this->add_label('folderctype');
+ foreach ($this->types as $type) {
+ $this->add_label('foldertype' . $type);
+ }
+
+ $skip_namespace = (array)$this->rc->config->get('kolab_skip_namespace');
+ $skip_roots = array();
+
+ if (!empty($skip_namespace)) {
+ $storage = $this->rc->get_storage();
+ foreach ($skip_namespace as $ns) {
+ foreach((array)$storage->get_namespace($ns) as $root) {
+ $skip_roots[] = rtrim($root[0], $root[1]);
+ }
+ }
+ }
+
+ $this->rc->output->set_env('skip_roots', $skip_roots);
+ $this->rc->output->set_env('foldertypes', $this->types);
+
// get folders types
$folderdata = kolab_storage::folders_typedata();
More information about the commits
mailing list