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

Issue/#637 #646

Merged
merged 5 commits into from
Apr 17, 2015
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
4 changes: 4 additions & 0 deletions frontend/src/core/dashboard/less/dashboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@ ul.dashboard-options {
&.selected span:first-child i:before{
content:'\f205';
}
}

.search-highlight{
box-shadow: inset 0 0 8px 5px #ff0;
}
12 changes: 11 additions & 1 deletion frontend/src/core/dashboard/views/dashboardSidebarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ define(function(require) {
this.usedTags = [];
},

highlightSearchBox: function(){
this.$('.dashboard-sidebar-filter-search-input').removeClass('search-highlight')
if (this.$('.dashboard-sidebar-filter-search-input').val()) {
this.$('.dashboard-sidebar-filter-search-input').addClass('search-highlight')
}
},

updateUI: function(userPreferences) {
if (userPreferences.search) {
this.$('.dashboard-sidebar-filter-search-input').val(userPreferences.search);
}
this.highlightSearchBox();
if (userPreferences.tags) {
this.tags = userPreferences.tags;
var systemTags = [/*'archive', 'favourites'*/];
Expand Down Expand Up @@ -71,15 +79,17 @@ define(function(require) {
event.preventDefault();
}
if (13 == event.keyCode || filter) {
var filterText = $(event.currentTarget).val();
var filterText = $(event.currentTarget).val().trim();
Origin.trigger('dashboard:dashboardSidebarView:filterBySearch', filterText);
}
this.highlightSearchBox();
},

clearFilterInput: function(event) {
event.preventDefault();
var $currentTarget = $(event.currentTarget);
$currentTarget.prev('.dashboard-sidebar-filter-input').val('').trigger('keyup', [true]);
this.highlightSearchBox();
},

onFilterButtonClicked: function(event) {
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/core/dashboard/views/dashboardView.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ define(function(require){
}
},
success: _.bind(function(data) {

// On successful collection fetching set lazy render to enabled
if (this.collectionLength === this.collection.length) {
this.shouldStopFetches = true;
Expand All @@ -252,13 +253,29 @@ define(function(require){
},

appendProjectItem: function(projectModel) {

projectModel.attributes.title=this.highlight(projectModel.attributes.title)

if (!projectModel.isEditable()) {
this.$('.dashboard-projects').append(new SharedProjectView({ model: projectModel }).$el);
} else {
this.$('.dashboard-projects').append(new ProjectView({ model: projectModel }).$el);
}
},

highlight: function(text){

regExpEscape = function(str){
var specials = /[.*+?|()\[\]{}\\$^]/g; // .*+?|()[]{}\$^
return str.replace(specials, "\\$&");
};

var userPreferences =this.getUserPreferences()
var search = userPreferences.search || '';
var regex = new RegExp( regExpEscape(search), "gi");
return text.replace(regex, function(term) {return '<span class="highlighted">'+ term+ '</span>'});
},

addTag: function(filterType) {
// add filter to this.filters
this.tags.push(filterType);
Expand Down Expand Up @@ -287,6 +304,7 @@ define(function(require){
},

filterBySearchInput: function (filterText) {
this.filterText = filterText;
this.search = this.convertFilterTextToPattern(filterText);
this.setUserPreference('search', filterText);
this.updateCollection(true);
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/core/project/less/project.less
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ h4.project-detail-title-inner {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;

& span.highlighted {
background-color: #ff0;
}
}

.pos {
Expand Down