Skip to content

Commit

Permalink
Adding playlists insensitve search - Fixes #45
Browse files Browse the repository at this point in the history
Signed-off-by: José Luis Di Biase <[email protected]>
  • Loading branch information
josx committed Mar 28, 2013
1 parent 2b6e6bb commit d7d61e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
19 changes: 15 additions & 4 deletions public/js/views/universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,26 @@ window.UniverseListView2 = function(options){
},
});

var MediaListViewModel = kb.ViewModel.extend({
var UniverseListViewModel = kb.ViewModel.extend({
constructor: function(model) {
kb.ViewModel.prototype.constructor.apply(this, arguments);
var _this = this;
this.playlists = kb.collectionObservable(collection, {view_model:UniItemViewModel});
},
this.filterUniverse = ko.observable('');
this.playlists = kb.collectionObservable(collection, {
view_model: UniItemViewModel,
filters: function(model) {
var filter;
filter = _this.filterUniverse();
if (!filter) return false;
var re = new RegExp(filter,"i");
return model.get('name').search(re) < 0;
},

});
}
});

this.view_model = new MediaListViewModel(this.collection);
this.view_model = new UniverseListViewModel(this.collection);

this.destroy = function () {
kb.release(this.view_model);
Expand Down
11 changes: 10 additions & 1 deletion views/templates/universe.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
- inndbind += ',drag: id, dragOptions: { zIndex: 900, cursorAt: { top: 5, left: 5 } } ';

block content
#media-search
.form-search
.input-prepend
button.btn(type="submit")
i.icon-search
input.span5.search-query#media-search(
type="text",
data-provide="typeahead",
data-items="4",
placeholder= i18n.gettext('search playlists'),
data-bind="value: filterUniverse, valueUpdate: 'keyup'")
.total-time-div
h1.label.label-inverse.format
i.icon-time.icon-white
Expand Down

0 comments on commit d7d61e5

Please sign in to comment.