summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-10-24 09:24:26 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-10-31 11:52:12 (GMT)
commitb52df5e51e8159cc80a2a6d11deceacf27471da2 (patch)
treebfaae9c7612571fb21485fc999a24201c0721532
parent66371500664f1d4ddf4743249b676d0d41b09526 (diff)
downloadroundcubemail-plugins-kolab-b52df5e51e8159cc80a2a6d11deceacf27471da2.tar.gz
List (inherited) tags only once
-rw-r--r--plugins/tasklist/tasklist.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/plugins/tasklist/tasklist.js b/plugins/tasklist/tasklist.js
index 198ba82..d318011 100644
--- a/plugins/tasklist/tasklist.js
+++ b/plugins/tasklist/tasklist.js
@@ -998,7 +998,8 @@ function rcube_tasklist_ui(settings)
// append inherited tags
if (itags.length) {
$.each(itags, function(i,val){
- $('<span>').addClass('tag-element inherit').html(Q(val)).appendTo(taglist);
+ if (!rec.tags || rec.tags.indexOf(val) < 0)
+ $('<span>').addClass('tag-element inherit').html(Q(val)).appendTo(taglist);
});
// re-sort tags list
$(taglist).children().sortElements(function(a,b){
@@ -1498,7 +1499,7 @@ function rcube_tasklist_ui(settings)
}
}
- return itags;
+ return $.unqiqueStrings(itags);
}
/**
@@ -1816,6 +1817,22 @@ jQuery.fn.sortElements = (function(){
};
})();
+// equivalent to $.unique() but working on arrays of strings
+jQuery.unqiqueStrings = (function() {
+ return function(arr) {
+ var hash = {}, out = [];
+
+ for (var i = 0; i < arr.length; i++) {
+ hash[arr[i]] = 0;
+ }
+ for (var val in hash) {
+ out.push(val);
+ }
+
+ return out;
+ };
+})();
+
/* tasklist plugin UI initialization */
var rctasks;