diff --git a/src/editor/dialogs/index.js b/src/editor/dialogs/index.js
index 793bde48..e45048fd 100644
--- a/src/editor/dialogs/index.js
+++ b/src/editor/dialogs/index.js
@@ -5,3 +5,4 @@ import './cmenuDialog.js';
import './cmenuLayersDialog.js';
import './seSelectDialog.js';
import './seConfirmDialog.js';
+import './seAlertDialog.js';
diff --git a/src/editor/dialogs/seAlertDialog.js b/src/editor/dialogs/seAlertDialog.js
new file mode 100644
index 00000000..bf07001a
--- /dev/null
+++ b/src/editor/dialogs/seAlertDialog.js
@@ -0,0 +1,59 @@
+// eslint-disable-next-line node/no-unpublished-import
+import AlertDialog from 'elix/define/AlertDialog.js';
+/**
+ * @class SeAlertDialog
+ */
+export class SeAlertDialog extends HTMLElement {
+ /**
+ * @function constructor
+ */
+ constructor () {
+ super();
+ // create the shadowDom and insert the template
+ this._shadowRoot = this.attachShadow({mode: 'open'});
+ this.dialog = new AlertDialog();
+ }
+ /**
+ * @function observedAttributes
+ * @returns {any} observed
+ */
+ static get observedAttributes () {
+ return ['title'];
+ }
+ /**
+ * @function attributeChangedCallback
+ * @param {string} name
+ * @param {string} oldValue
+ * @param {string} newValue
+ * @returns {void}
+ */
+ attributeChangedCallback (name, oldValue, newValue) {
+ switch (name) {
+ case 'title':
+ this.dialog.textContent = newValue;
+ this.dialog.open();
+ break;
+ default:
+ super.attributeChangedCallback(name, oldValue, newValue);
+ break;
+ }
+ }
+ /**
+ * @function get
+ * @returns {any}
+ */
+ get title () {
+ return this.getAttribute('title');
+ }
+
+ /**
+ * @function set
+ * @returns {void}
+ */
+ set title (value) {
+ this.setAttribute('title', value);
+ }
+}
+
+// Register
+customElements.define('se-alert-dialog', SeAlertDialog);
diff --git a/src/editor/extensions/ext-imagelib/index.js b/src/editor/extensions/ext-imagelib/index.js
index 6521469a..2e48c220 100644
--- a/src/editor/extensions/ext-imagelib/index.js
+++ b/src/editor/extensions/ext-imagelib/index.js
@@ -32,8 +32,7 @@ $('a').click(function () {
data = canvas.toDataURL();
} catch (err) {
// This fails in Firefox with `file:///` URLs :(
- // Todo: This could use a generic alert library instead
- alert('Data URL conversion failed: ' + err); // eslint-disable-line no-alert
+ document.getElementById('se-alert-dialog').title = 'Data URL conversion failed: ' + err;
data = '';
}
post({href, data});
diff --git a/src/editor/extensions/ext-imagelib/openclipart.js b/src/editor/extensions/ext-imagelib/openclipart.js
index 9563974b..d66b3e84 100644
--- a/src/editor/extensions/ext-imagelib/openclipart.js
+++ b/src/editor/extensions/ext-imagelib/openclipart.js
@@ -39,8 +39,7 @@ async function processResults (url) {
// console.log('json', json);
if (!json || json.msg !== 'success') {
- // Todo: This could use a generic alert library instead
- alert('There was a problem downloading the results'); // eslint-disable-line no-alert
+ document.getElementById('se-alert-dialog').title = 'There was a problem downloading the results';
return;
}
const {payload, info: {
diff --git a/src/editor/extensions/ext-mathjax/ext-mathjax.js b/src/editor/extensions/ext-mathjax/ext-mathjax.js
index 133c2375..85687cbe 100644
--- a/src/editor/extensions/ext-mathjax/ext-mathjax.js
+++ b/src/editor/extensions/ext-mathjax/ext-mathjax.js
@@ -202,8 +202,8 @@ export default {
});
} catch (e) {
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
- // eslint-disable-next-line no-alert
- alert('Failed loading MathJax. You will not be able to change the mathematics.');
+ // eslint-disable-next-line max-len
+ document.getElementById('se-alert-dialog').title = 'Failed loading MathJax. You will not be able to change the mathematics.';
}
}
}
diff --git a/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js b/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js
index a0bf4b38..be51a83a 100644
--- a/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js
+++ b/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js
@@ -64,8 +64,7 @@ export default {
`).appendTo('body')
.submit().remove();
- // eslint-disable-next-line no-alert
- alert(strings.saved);
+ document.getElementById('se-alert-dialog').title = strings.saved;
top.window.location = '/' + name;
}
});
diff --git a/src/editor/extensions/ext-webappfind/ext-webappfind.js b/src/editor/extensions/ext-webappfind/ext-webappfind.js
index 9a4cf89a..176b226a 100644
--- a/src/editor/extensions/ext-webappfind/ext-webappfind.js
+++ b/src/editor/extensions/ext-webappfind/ext-webappfind.js
@@ -63,8 +63,7 @@ export default {
} */
break;
case 'save-end':
- // eslint-disable-next-line no-alert
- alert(`save complete for pathID ${pathID}!`);
+ document.getElementById('se-alert-dialog').title = `save complete for pathID ${pathID}!`;
break;
default:
throw new Error('Unexpected WebAppFind event type');
diff --git a/src/editor/panels/LayersPanel.js b/src/editor/panels/LayersPanel.js
index 1b32e4de..400a3bd8 100644
--- a/src/editor/panels/LayersPanel.js
+++ b/src/editor/panels/LayersPanel.js
@@ -156,7 +156,7 @@ class LayersPanel {
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, uniqName);
if (!newName) { return; }
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
- alert(this.uiStrings.notification.dupeLayerName);
+ document.getElementById('se-alert-dialog').title = this.uiStrings.notification.dupeLayerName;
return;
}
this.svgCanvas.createLayer(newName);
@@ -190,7 +190,7 @@ class LayersPanel {
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, name);
if (!newName) { return; }
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
- alert(this.uiStrings.notification.dupeLayerName);
+ document.getElementById('se-alert-dialog').title = this.uiStrings.notification.dupeLayerName;
return;
}
this.svgCanvas.cloneLayer(newName);
@@ -235,7 +235,7 @@ class LayersPanel {
const newName = prompt(this.uiStrings.notification.enterNewLayerName, '');
if (!newName) { return; }
if (oldName === newName || this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
- alert(this.uiStrings.notification.layerHasThatName);
+ document.getElementById('se-alert-dialog').title = this.uiStrings.notification.layerHasThatName;
return;
}
this.svgCanvas.renameCurrentLayer(newName);
diff --git a/src/editor/panels/TopPanelHandlers.js b/src/editor/panels/TopPanelHandlers.js
index 5134418f..2dac9259 100644
--- a/src/editor/panels/TopPanelHandlers.js
+++ b/src/editor/panels/TopPanelHandlers.js
@@ -403,8 +403,7 @@ class TopPanelHandlers {
if (!valid) {
e.target.value = this.selectedElement().getAttribute(attr);
- // eslint-disable-next-line no-alert
- alert(this.uiStrings.notification.invalidAttrValGiven);
+ document.getElementById('se-alert-dialog').title = this.uiStrings.notification.invalidAttrValGiven;
return false;
}
diff --git a/src/editor/svgedit.js b/src/editor/svgedit.js
index 56cc07d0..ce81af8f 100644
--- a/src/editor/svgedit.js
+++ b/src/editor/svgedit.js
@@ -222,6 +222,10 @@ editor.init = () => {
const dialogBox = document.createElement('se-cmenu_canvas-dialog');
dialogBox.setAttribute('id', 'se-cmenu_canvas');
document.body.append(dialogBox);
+ // alertDialog added to DOM
+ const alertBox = document.createElement('se-alert-dialog');
+ alertBox.setAttribute('id', 'se-alert-dialog');
+ document.body.append(alertBox);
} catch (err) {}
editor.configObj.load();
@@ -436,7 +440,6 @@ editor.init = () => {
// Alert will only appear the first time saved OR the
// first time the bug is encountered
let done = editor.pref('save_notice_done');
-
if (done !== 'all') {
let note = uiStrings.notification.saveFromBrowser.replace('%s', 'SVG');
// Check if FF and has
@@ -453,7 +456,7 @@ editor.init = () => {
editor.pref('save_notice_done', 'all');
}
if (done !== 'part') {
- alert(note);
+ document.getElementById('se-alert-dialog').title = note;
}
}
};
@@ -470,7 +473,7 @@ editor.init = () => {
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
if (!exportWindow || exportWindow.closed) {
- alert(uiStrings.notification.popupWindowBlocked);
+ document.getElementById('se-alert-dialog').title = uiStrings.notification.popupWindowBlocked;
return;
}
@@ -1901,15 +1904,15 @@ editor.init = () => {
svgCanvas.setDocumentTitle(title);
if (w !== 'fit' && !isValidUnit('width', w)) {
- alert(uiStrings.notification.invalidAttrValGiven);
+ document.getElementById('se-alert-dialog').title = uiStrings.notification.invalidAttrValGiven;
return false;
}
if (h !== 'fit' && !isValidUnit('height', h)) {
- alert(uiStrings.notification.invalidAttrValGiven);
+ document.getElementById('se-alert-dialog').title = uiStrings.notification.invalidAttrValGiven;
return false;
}
if (!svgCanvas.setResolution(w, h)) {
- alert(uiStrings.notification.noContentToFitTo);
+ document.getElementById('se-alert-dialog').title = uiStrings.notification.noContentToFitTo;
return false;
}
// Set image save option
@@ -2000,7 +2003,7 @@ editor.init = () => {
});
$('#url_notice').click(() => {
- alert(this.title);
+ document.getElementById('se-alert-dialog').title = this.title;
});
$('#stroke_width').val(editor.configObj.curConfig.initStroke.width);
@@ -2702,7 +2705,7 @@ editor.loadFromURL = function (url, {cache, noAlert} = {}) {
reject(new Error('URLLoadFail'));
return;
}
- alert(uiStrings.notification.URLLoadFail + ': \n' + err);
+ document.getElementById('se-alert-dialog').title = uiStrings.notification.URLLoadFail + ': \n' + err;
resolve();
},
complete () {