diff --git a/resources/report/js/custom.js b/resources/report/html/plugin-card.html similarity index 71% rename from resources/report/js/custom.js rename to resources/report/html/plugin-card.html index a188b7be..7931f2e7 100644 --- a/resources/report/js/custom.js +++ b/resources/report/html/plugin-card.html @@ -1,164 +1,293 @@ -/* LOOT + - A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and - Fallout: New Vegas. - - Copyright (C) 2013-2014 WrinklyNinja - - This file is part of LOOT. - - LOOT is free software: you can redistribute - it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - LOOT is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with LOOT. If not, see - . -*/ -'use strict'; - -/* Create a element type. */ -var pluginMenuProto = Object.create(HTMLElement.prototype, { - - getPluginCard: { - value: function() { - return document.getElementById(this.getAttribute('data-for')); - } - }, - - onShowOnlyConflicts: { - value: function(evt) { - /* Depending on what was clicked, this function may be run before - the checkbox state has updated. Handle both cases. */ - var activateFilter; - if (evt.currentTarget == evt.target) { - /* Clicked on the label, checkbox state isn't updated yet. */ - activateFilter = !evt.target.firstElementChild.checked; - } else { - /* Clicked on the checkbox. */ - activateFilter = evt.target.checked; - } - if (activateFilter) { - /* Un-highlight any existing filter plugin. */ - var cards = document.getElementsByTagName('main')[0].getElementsByTagName('plugin-card'); - for (var i = 0; i < cards.length; ++i) { - cards[i].classList.toggle('highlight', false); - } - evt.currentTarget.parentNode.host.getPluginCard().classList.toggle('highlight', true); - document.body.setAttribute('data-conflicts', evt.currentTarget.parentNode.host.getPluginCard().getName()); - } else { - evt.currentTarget.parentNode.host.getPluginCard().classList.toggle('highlight', false); - document.body.removeAttribute('data-conflicts'); - } - applyFilters(evt); - } - }, - - onEditMetadata: { - value: function(evt) { - evt.target.parentNode.host.getPluginCard().showEditor(); - } - }, - - onCopyMetadata: { - value: function(evt) { - var request = JSON.stringify({ - name: 'copyMetadata', - args: [ - evt.target.parentNode.host.getPluginCard().getName() - ] - }); - - loot.query(request).catch(processCefError); - } - }, - - onClearMetadata: { - value: function(evt) { - var pluginCard = evt.target.parentNode.host.getPluginCard(); - - showMessageDialog('Clear Plugin Metadata', 'Are you sure you want to clear all existing user-added metadata from "' + pluginCard.getName() + '"?', function(result){ - if (result) { - var request = JSON.stringify({ - name: 'clearPluginMetadata', - args: [ - pluginCard.getName() - ] - }); - - loot.query(request).then(JSON.parse).then(function(result){ - if (result) { - /* Need to empty the UI-side user metadata. */ - for (var i = 0; i < loot.game.plugins.length; ++i) { - if (loot.game.plugins[i].id == pluginCard.id) { - loot.game.plugins[i].userlist = undefined; - - loot.game.plugins[i].modPriority = result.modPriority; - loot.game.plugins[i].isGlobalPriority = result.isGlobalPriority; - loot.game.plugins[i].messages = result.messages; - loot.game.plugins[i].tags = result.tags; - loot.game.plugins[i].isDirty = result.isDirty; - - break; - } - } - } - }).catch(processCefError); - } - }); - } - }, - - createdCallback: { - value: function() { - - var template = document.getElementById('pluginMenu'); - var clone = document.importNode(template.content, true); - - this.createShadowRoot().appendChild(clone); - } - }, - - attachedCallback: { - value: function() { - /* Add event listeners for the menu items. */ - /* For some reason clicking on the label is processed slower - than the checkbox state, and in the time difference the menu - gets closed, so that the conflicts filter never gets applied. - To get around this, listen for a click on the label rather - than for checkbox state change. */ - if (document.body.getAttribute('data-conflicts') == this.getPluginCard().getName()) { - this.shadowRoot.getElementById('showOnlyConflicts').checked = true; - } - this.shadowRoot.getElementById('showOnlyConflicts').parentElement.addEventListener('click', this.onShowOnlyConflicts, false); - this.shadowRoot.getElementById('editMetadata').addEventListener('click', this.onEditMetadata, false); - this.shadowRoot.getElementById('copyMetadata').addEventListener('click', this.onCopyMetadata, false); - this.shadowRoot.getElementById('clearMetadata').addEventListener('click', this.onClearMetadata, false); - } - }, - - detachedCallback: { - value: function() { - /* Remove event listeners for the menu items. */ - /* Nothing happens if we try to remove a listener that doesn't exist, - so don't bother checking first. */ - this.shadowRoot.getElementById('showOnlyConflicts').parentElement.removeEventListener('click', this.onShowOnlyConflicts, false); - this.shadowRoot.getElementById('editMetadata').removeEventListener('click', this.onEditMetadata, false); - this.shadowRoot.getElementById('copyMetadata').removeEventListener('click', this.onCopyMetadata, false); - this.shadowRoot.getElementById('clearMetadata').removeEventListener('click', this.onClearMetadata, false); - - } + + + \ No newline at end of file diff --git a/resources/report/html/plugin-menu.html b/resources/report/html/plugin-menu.html new file mode 100644 index 00000000..770697aa --- /dev/null +++ b/resources/report/html/plugin-menu.html @@ -0,0 +1,195 @@ + + + + diff --git a/resources/report/js/l10n.js b/resources/report/js/l10n.js index 66d4e9c2..b5811f23 100644 --- a/resources/report/js/l10n.js +++ b/resources/report/js/l10n.js @@ -40,7 +40,7 @@ translateStaticText: function(l10n) { /* Plugin card template. */ - var pluginCard = document.getElementById('pluginCard').content; + var pluginCard = pluginCardImportDoc.querySelector('#pluginCard').content; pluginCard.getElementById('activeTick').title = l10n.translate("Active Plugin").fetch(); pluginCard.getElementById('dummyPlugin').title = l10n.translate("Dummy Plugin").fetch(); pluginCard.getElementById('loadsBSA').title = l10n.translate("Loads BSA").fetch(); @@ -103,7 +103,7 @@ pluginLI.querySelector('.hasGlobalPriority').title = l10n.translate("Priority Is Global").fetch(); /* Plugin menu template */ - var pluginMenu = document.getElementById('pluginMenu').content; + var pluginMenu = pluginMenuImportDoc.querySelector('#pluginMenu').content; pluginMenu.getElementById('showOnlyConflicts').nextSibling.textContent = l10n.translate("Show Only Conflicts").fetch(); pluginMenu.getElementById('editMetadata').firstChild.nextSibling.textContent = l10n.translate("Edit Metadata").fetch(); pluginMenu.getElementById('copyMetadata').firstChild.nextSibling.textContent = l10n.translate("Copy Metadata As Text").fetch(); diff --git a/resources/report/js/script.js b/resources/report/js/script.js index ac37476f..6f2a613a 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -1485,7 +1485,7 @@ function onFocus(evt) { require.config({ baseUrl: "js", }); -require(['marked', 'l10n', 'custom', 'plugin'], function(markedResponse, l10nResponse) { +require(['marked', 'l10n', 'plugin'], function(markedResponse, l10nResponse) { marked = markedResponse; l10n = l10nResponse; /* Make sure settings are what I want. */ diff --git a/resources/report/report.html b/resources/report/report.html index 8ac04ccb..a564939c 100644 --- a/resources/report/report.html +++ b/resources/report/report.html @@ -6,337 +6,13 @@ + + - - - -