#seConfirmDialog alert change to elix alert dialog
This commit is contained in:
@@ -5,3 +5,4 @@ import './cmenuDialog.js';
|
||||
import './cmenuLayersDialog.js';
|
||||
import './seSelectDialog.js';
|
||||
import './seConfirmDialog.js';
|
||||
import './seAlertDialog.js';
|
||||
|
||||
59
src/editor/dialogs/seAlertDialog.js
Normal file
59
src/editor/dialogs/seAlertDialog.js
Normal file
@@ -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);
|
||||
@@ -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});
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ export default {
|
||||
<input type="hidden" name="contenttype" value="application/x-svgdraw">
|
||||
`).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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <defs/>
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user