Added search result highlighting.

This commit is contained in:
Oliver Hamlet
2015-05-27 15:05:53 +01:00
parent 6488d58e36
commit d3c27c7f0d
4 changed files with 26 additions and 3 deletions
@@ -60,6 +60,10 @@ loot-clear-metadata
:host(:not([data-edits])) #hasUserEdits {
display: none;
}
:host(.search-result) #front,
:host(.search-result) #editor {
box-shadow: inset 4px 0 #3F51B5;
}
#front {
display: block;
transform: translateZ(1px);
@@ -219,6 +223,7 @@ loot-clear-metadata
'data.tags': 'onTagsChange',
'data.computed.messages': 'onMessagesChange',
'data.userlist': 'onUserlistChange',
'data.isSearchResult' : 'onSearchResultChange',
'data.isMenuOpen': 'onMenuToggle'
},
@@ -261,6 +266,9 @@ loot-clear-metadata
/* Also set highlight if the conflict filter is active. */
this.classList.toggle('highlight', newValue.isConflictFilterChecked);
/* Set highlight if the plugin is a search result. */
this.onSearchResultChange(oldValue.isSearchResult, newValue.isSearchResult);
/* Update tooltip positions. */
var tooltips = this.shadowRoot.querySelectorAll('core-tooltip');
for (var i = 0; i < tooltips.length; ++i) {
@@ -301,6 +309,10 @@ loot-clear-metadata
}
},
onSearchResultChange: function(oldValue, newValue) {
this.classList.toggle('search-result', newValue);
},
onMenuToggle: function(oldValue, newValue) {
if (newValue) {
this.style.marginBottom = '190px';
@@ -91,8 +91,11 @@ loot-editor-close
}
/* Misc Styling. */
core-toolbar.medium-tall {
:host {
background: #CFD4E9;
}
core-toolbar.medium-tall {
background: transparent;
height: 104px;
}
core-toolbar > div {
@@ -105,8 +108,9 @@ loot-editor-close
vertical-align: inherit !important;
}
core-selector > * {
border: 4px solid #CFD4E9;
border-top: none;
border-bottom: 4px solid #CFD4E9;
background: white;
margin: 0 4px 4px 4px;
}
#main {
padding: 16px;
+6
View File
@@ -89,6 +89,9 @@ searchTarget is the ID of the core-list element to search the elements of.
},
resetResults: function() {
loot.game.plugins.forEach(function(plugin){
plugin.isSearchResult = false;
});
this.results = [];
this.currentResult = -1;
this.shadowRoot.getElementById('prev').setAttribute('disabled', '');
@@ -137,6 +140,7 @@ searchTarget is the ID of the core-list element to search the elements of.
|| (!crcHidden && plugin.getCrcString().toLowerCase().indexOf(needle) != -1)) {
host.results.push(index);
plugin.isSearchResult = true;
return;
}
@@ -146,6 +150,7 @@ searchTarget is the ID of the core-list element to search the elements of.
|| tags.removed.toLowerCase().indexOf(needle) != -1) {
host.results.push(index);
plugin.isSearchResult = true;
return;
}
}
@@ -153,6 +158,7 @@ searchTarget is the ID of the core-list element to search the elements of.
for (var i = 0; i < plugin.computed.messages.length; ++i) {
if (plugin.computed.messages[i].textContent.toLowerCase().indexOf(needle) != -1) {
host.results.push(index);
plugin.isSearchResult = true;
return;
}
}
+1
View File
@@ -45,6 +45,7 @@ function Plugin(obj) {
this.isMenuOpen = false;
this.isEditorOpen = false;
this.isConflictFilterChecked = false;
this.isSearchResult = false;
/* Converts between the LOOT metadata object for tags, and their
editor row representation. */