Fixed closing of settings dialog.

Button event handling is getting pretty messy, as expected.
This commit is contained in:
WrinklyNinja
2014-07-12 15:22:14 +01:00
parent 17c998deef
commit 02c2d123db
2 changed files with 20 additions and 12 deletions
+17 -9
View File
@@ -155,12 +155,14 @@ function togglePlugins(evt) {
document.getElementById('hiddenPluginNo').textContent = hiddenNo;
}
function hideDialog(evt) {
hideElement(document.getElementById('overlay'));
var target = document.getElementById(evt.target.getAttribute('data-dialog'));
hideElement(target);
if (target.id == 'modalDialog') {
document.body.removeChild(target);
}
overlay.setAttribute('data-dialog', '');
overlay.removeEventListener('click', hideDialog, false);
hideElement(document.getElementById('overlay'));
}
function showMessageDialog(title, text) {
var content = document.getElementById('messageDialog').content;
@@ -312,6 +314,13 @@ function showEditor(sectionId) {
/* Finally, show editor. */
section.classList.toggle('flip');
}
function closeSettings(evt) {
if (evt.target.className.indexOf('accept') != -1) {
}
hideElement(evt.target.parentElement.parentElement);
hideElement(document.getElementById('overlay'));
}
function processButtonClick(evt) {
var overlay = document.getElementById('overlay');
var action = evt.currentTarget.getAttribute('data-action');
@@ -319,14 +328,9 @@ function processButtonClick(evt) {
var target = document.getElementById(evt.currentTarget.getAttribute('data-target'));
if (isVisible(target)) {
hideElement(target);
if (target.getAttribute('data-overlay')) {
overlay.setAttribute('data-dialog', '');
hideElement(overlay);
} else {
var replace = target.getAttribute('data-replace');
if (replace) {
showElement(document.getElementById(replace));
}
var replace = target.getAttribute('data-replace');
if (replace) {
showElement(document.getElementById(replace));
}
} else {
showElement(target);
@@ -334,6 +338,8 @@ function processButtonClick(evt) {
overlay.setAttribute('data-dialog', target.id);
overlay.addEventListener('click', hideDialog, false);
showElement(overlay);
} else if (target.id == 'settings') {
showElement(overlay);
} else {
var replace = target.getAttribute('data-replace');
if (replace) {
@@ -356,6 +362,8 @@ function processButtonClick(evt) {
clearAllMetadata();
} else if (action == 'show-editor') {
showEditor(evt.target.getAttribute('data-target'));
} else if (action == 'close-settings') {
closeSettings(evt);
}
}
function toggleInputRO(evt) {
+3 -3
View File
@@ -275,7 +275,7 @@ along with LOOT. If not, see <http://www.gnu.org/licenses/>.
</blockquote>
</div>
<div id="settings" class="dialog hidden" data-overlay="1">
<div id="settings" class="dialog hidden">
<h1>Settings</h1>
<label for="defaultGameSelect">Default Game</label>
<select id="defaultGameSelect">
@@ -302,8 +302,8 @@ along with LOOT. If not, see &lt;http://www.gnu.org/licenses/&gt;.
<p>Language and game changes will be applied after LOOT is restarted.
<hr>
<div class="buttons">
<button>Apply</button>
<button>Cancel</button>
<button class="accept" data-action="close-settings">Apply</button>
<button class="cancel" data-action="close-settings">Cancel</button>
</div>
</div>