forked from maccman/holla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.js
More file actions
32 lines (25 loc) · 749 Bytes
/
Copy pathsearch.js
File metadata and controls
32 lines (25 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var Search = SuperModel.setup("Search");
Search.attributes = ["value", "record"];
Search.extend({
search: function(query){
this.query = query;
this.populate([]);
if ( $.isBlank(query) ) return;
this.query = this.query.toLowerCase()
var items = ChannelActivity.all();
var atts = ["name", "body"];
for(var i=0, len = items.length; i < len; i++) {
if ( !items[i].data ) continue;
for (var j=0; j < atts.length; j++) {
var value = items[i].data[atts[j]];
if ( value && value.toLowerCase().indexOf(this.query) != -1 ) {
this.create({
value: value,
record: items[i]
});
break;
}
}
}
}
});