Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve file filter #147

Merged
merged 3 commits into from
Apr 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ To concatenate js files into a single figure.js file that is used in the app:

$ grunt concat

During development, you'll want to have both of these run whenever the relevant are edited.
During development, you'll want to have both of these run whenever the relevant files are edited.
This can be achieved with:

$ grunt watch
Expand Down
10 changes: 7 additions & 3 deletions static/figure/figure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3084,9 +3084,13 @@ var FigureFile = Backbone.Model.extend({
}
}
if (filter.name) {
if (this.get('name').toLowerCase().indexOf(filter.name) < 0) {
return false;
}
// Search for files that have all words in
var name = this.get('name').toLowerCase();
var words = $.trim(filter.name).split(" ");
var visible = words.reduce(function(prev, t){
return prev && name.indexOf(t) > -1
}, true);
return visible;
}
return true;
}
Expand Down
10 changes: 7 additions & 3 deletions static/figure/js/views/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ var FigureFile = Backbone.Model.extend({
}
}
if (filter.name) {
if (this.get('name').toLowerCase().indexOf(filter.name) < 0) {
return false;
}
// Search for files that have all words in
var name = this.get('name').toLowerCase();
var words = $.trim(filter.name).split(" ");
var visible = words.reduce(function(prev, t){
return prev && name.indexOf(t) > -1
}, true);
return visible;
}
return true;
}
Expand Down