Fixed l10n and import scripts failing.

The l10n script was failing because the location of the pluginLI
template had changed. The import scripts were failing because their
importDoc JS var was getting overwritten by the other script.

Localised text has also been added back into message dialogs.
This commit is contained in:
Oliver Hamlet
2014-11-06 22:38:32 +00:00
parent 18c0737d4e
commit 196ae4b038
4 changed files with 29 additions and 14 deletions
+20 -9
View File
@@ -23,33 +23,44 @@
}
.accept, .cancel {
margin: 0.5em;
font-size: 2em;
font-size: 1.5em;
display: inline-block;
cursor: pointer;
}
.accept {
.accept > span:last-child, .cancel > span:last-child {
margin-left: 0.5em;
display: inline-block;
}
.accept:hover {
color: green;
cursor: pointer;
}
.cancel {
.cancel:hover {
color: red;
cursor: pointer;
}
</style>
<span class="icon fa fa-exclamation-circle"></span>
<h1><content select="h1"></content></h1>
<p><content select="p"></content></p>
<div class="buttons">
<span class="accept fa fa-check"></span>
<span class="cancel fa fa-close"></span>
<div class="accept"><span class="fa fa-check"></span><span></span></div>
<div class="cancel"><span class="fa fa-close"></span><span></span></div>
</div>
</template>
<script>
'use strict';
// Record this document.
var importDoc = document.currentScript.ownerDocument;
var messageDialogImportDoc = document.currentScript.ownerDocument;
/* Create a <dialog is="message-dialog"> element type. */
var messageDialogProto = Object.create(HTMLDialogElement.prototype, {
setButtonText: {
value: function(accept, cancel) {
this.shadowRoot.getElementsByClassName('accept')[0].lastChild.textContent = accept;
this.shadowRoot.getElementsByClassName('cancel')[0].lastChild.textContent = cancel;
}
},
onClose: {
value: function(evt) {
var ret = evt.target.returnValue == 'true';
@@ -90,7 +101,7 @@ var messageDialogProto = Object.create(HTMLDialogElement.prototype, {
createdCallback: {
value: function() {
var template = importDoc.querySelector('#messageDialog');
var template = messageDialogImportDoc.querySelector('#messageDialog');
var clone = document.importNode(template.content, true);
var root = this.createShadowRoot();
root.appendChild(clone);
+2 -2
View File
@@ -31,7 +31,7 @@
<script>
'use strict';
// Record this document.
var importDoc = document.currentScript.ownerDocument;
var pluginLiImportDoc = document.currentScript.ownerDocument;
/* Create a <li is="plugin-li"> element type. */
var pluginLIProto = Object.create(HTMLLIElement.prototype, {
@@ -57,7 +57,7 @@ var pluginLIProto = Object.create(HTMLLIElement.prototype, {
createdCallback: {
value: function() {
var template = importDoc.querySelector('#pluginLI');
var template = pluginLiImportDoc.querySelector('#pluginLI');
var clone = document.importNode(template.content, true);
var root = this.createShadowRoot();
root.appendChild(clone);
+1 -1
View File
@@ -96,7 +96,7 @@
pluginCard.getElementById('cancel').textContent = l10n.translate("Cancel").fetch();
/* Plugin List Item Template */
var pluginLI = document.getElementById('pluginLI').content;
var pluginLI = pluginLiImportDoc.querySelector('#pluginLI').content;
pluginLI.querySelector('.dummyPlugin').title = l10n.translate("Dummy Plugin").fetch();
pluginLI.querySelector('.loadsBSA').title = l10n.translate("Loads BSA").fetch();
pluginLI.querySelector('.hasUserEdits').title = l10n.translate("Has User Metadata").fetch();
+6 -2
View File
@@ -549,13 +549,17 @@ function applyFilters(evt) {
}
function showMessageDialog(title, text, closeCallback) {
var dialog = new MessageDialog();
dialog.setButtonText(l10n.jed.translate('Yes').fetch(), l10n.jed.translate('Cancel').fetch());
document.body.appendChild(dialog);
dialog.showModal('warn', title, text, closeCallback);
}
function showMessageBox(type, title, text) {
var dialog = new MessageDialog();
if (type == 'error' || type == 'info') {
dialog.setButtonText(l10n.jed.translate('OK').fetch(), l10n.jed.translate('Cancel').fetch());
} else {
dialog.setButtonText(l10n.jed.translate('Yes').fetch(), l10n.jed.translate('Cancel').fetch());
}
document.body.appendChild(dialog);
dialog.showModal(type, title, text);
}