mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Use separate content filter event handler
This commit is contained in:
+27
-33
@@ -1,13 +1,34 @@
|
||||
'use strict';
|
||||
function onSidebarFilterToggle(evt) {
|
||||
if (evt.target.id !== 'contentFilter') {
|
||||
loot.filters[evt.target.id] = evt.target.checked;
|
||||
loot.query('saveFilterState', evt.target.id, evt.target.checked).catch(loot.handlePromiseError);
|
||||
} else {
|
||||
loot.filters.contentSearchString = evt.target.value;
|
||||
}
|
||||
loot.filters[evt.target.id] = evt.target.checked;
|
||||
loot.query('saveFilterState', evt.target.id, evt.target.checked).catch(loot.handlePromiseError);
|
||||
loot.filters.apply(loot.game.plugins);
|
||||
}
|
||||
function onContentFilter(evt) {
|
||||
loot.filters.contentSearchString = evt.target.value;
|
||||
loot.filters.apply(loot.game.plugins);
|
||||
}
|
||||
function onConflictsFilter(evt) {
|
||||
/* evt.currentTarget.value is the name of the target plugin, or an empty string
|
||||
if the filter has been deactivated. */
|
||||
if (evt.currentTarget.value) {
|
||||
/* Now get conflicts for the plugin. */
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Identifying conflicting plugins...'));
|
||||
loot.filters.activateConflictsFilter(evt.currentTarget.value).then((plugins) => {
|
||||
plugins.forEach((plugin) => {
|
||||
const gamePlugin = loot.game.plugins.find(item => item.name === plugin.name);
|
||||
if (gamePlugin) {
|
||||
gamePlugin.update(plugin);
|
||||
}
|
||||
});
|
||||
loot.filters.apply(loot.game.plugins);
|
||||
loot.Dialog.closeProgress();
|
||||
}).catch(loot.handlePromiseError);
|
||||
} else {
|
||||
loot.filters.deactivateConflictsFilter();
|
||||
loot.filters.apply(loot.game.plugins);
|
||||
}
|
||||
}
|
||||
function onJumpToGeneralInfo() {
|
||||
document.getElementById('pluginCardList').scroll(0, 0);
|
||||
}
|
||||
@@ -408,33 +429,6 @@ function onEditorClose(evt) {
|
||||
loot.state.exitEditingState();
|
||||
}).catch(loot.handlePromiseError);
|
||||
}
|
||||
function onConflictsFilter(evt) {
|
||||
/* evt.currentTarget.value is the name of the target plugin, or an empty string
|
||||
if the filter has been deactivated. */
|
||||
if (evt.currentTarget.value) {
|
||||
/* Now get conflicts for the plugin. */
|
||||
loot.Dialog.showProgress(loot.l10n.translate('Identifying conflicting plugins...'));
|
||||
loot.filters.activateConflictsFilter(evt.currentTarget.value).then((plugins) => {
|
||||
plugins.forEach((plugin) => {
|
||||
const gamePlugin = loot.game.plugins.find(item => item.name === plugin.name);
|
||||
if (gamePlugin) {
|
||||
gamePlugin.update(plugin);
|
||||
}
|
||||
});
|
||||
loot.filters.apply(loot.game.plugins);
|
||||
|
||||
/* Scroll to the target plugin */
|
||||
const list = document.getElementById('pluginCardList');
|
||||
const index = list.items.findIndex(item => item.name === evt.target.value);
|
||||
list.scrollToIndex(index);
|
||||
|
||||
loot.Dialog.closeProgress();
|
||||
}).catch(loot.handlePromiseError);
|
||||
} else {
|
||||
loot.filters.deactivateConflictsFilter();
|
||||
loot.filters.apply(loot.game.plugins);
|
||||
}
|
||||
}
|
||||
function onCopyMetadata(evt) {
|
||||
loot.query('copyMetadata', evt.target.getName()).then(() => {
|
||||
loot.Dialog.showNotification(loot.l10n.translate('The metadata for "%s" has been copied to the clipboard.', evt.target.getName()));
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
document.getElementById('hideInactivePlugins').addEventListener('change', onSidebarFilterToggle);
|
||||
document.getElementById('hideAllPluginMessages').addEventListener('change', onSidebarFilterToggle);
|
||||
document.getElementById('hideMessagelessPlugins').addEventListener('change', onSidebarFilterToggle);
|
||||
document.getElementById('contentFilter').addEventListener('change', onSidebarFilterToggle);
|
||||
document.getElementById('contentFilter').addEventListener('change', onContentFilter);
|
||||
document.getElementById('conflictsFilter').addEventListener('iron-select', onConflictsFilter);
|
||||
document.addEventListener('loot-filter-conflicts-deactivate', Filters.onDeactivateConflictsFilter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user