src/js/model.js
changeset 1026 420608a77566
parent 1013 392ddcd212d7
child 1044 d8339b45edc4
--- a/src/js/model.js	Thu Feb 06 12:29:31 2014 +0100
+++ b/src/js/model.js	Thu Feb 06 14:43:30 2014 +0100
@@ -276,6 +276,26 @@
     return res;
 };
 
+List.prototype.searchByTags = function(_text) {
+    if (!_text) {
+        this.trigger("clear-search");
+        return this;
+    }
+    this.searching = true;
+    this.trigger("search", _text);
+    var rxsource = fullTextRegexps(_text),
+        rgxp = new RegExp(rxsource,"im");
+    this.regexp = new RegExp(rxsource,"gim");
+    var res = this.filter(function(_element, _k) {
+        var _isfound = rgxp.test(_element.getTagTexts());
+        _element.found = _isfound;
+        _element.trigger(_isfound ? "found" : "not-found");
+        return _isfound;
+    });
+    this.trigger(res.length ? "found" : "not-found",res);
+    return res;
+};
+
 List.prototype.getTitles = function() {
     return this.map(function(_el) {
         return _el.title;