master
JFH 2020-12-30 17:23:14 +01:00
parent d37494c2af
commit d574e73ecb
5 changed files with 23 additions and 24 deletions

View File

@ -2,9 +2,9 @@
import AlertDialog from 'elix/define/AlertDialog.js'; import AlertDialog from 'elix/define/AlertDialog.js';
const dialog = new AlertDialog(); const dialog = new AlertDialog();
const seAlert = (type, text) => { const seAlert = (text) => {
dialog.textContent = text; dialog.textContent = text;
dialog.choices = (type === 'alert') ? ['Ok'] : ['Cancel']; dialog.choices = ['Ok'];
dialog.open(); dialog.open();
}; };

View File

@ -1,3 +1,4 @@
/* globals seConfirm */
/** /**
* @file ext-foreignobject.js * @file ext-foreignobject.js
* *
@ -200,8 +201,7 @@ export default {
if (!editingforeign) { return; } if (!editingforeign) { return; }
if (!setForeignString($('#svg_source_textarea').val())) { if (!setForeignString($('#svg_source_textarea').val())) {
// eslint-disable-next-line no-alert const ok = seConfirm('Errors found. Revert to original?');
const ok = confirm('Errors found. Revert to original?');
if (!ok) { return; } if (!ok) { return; }
endChanges(); endChanges();
} else { } else {

View File

@ -133,7 +133,7 @@ export default {
// Todo: Uncomment the setItexString() function above and handle ajaxEndpoint? // Todo: Uncomment the setItexString() function above and handle ajaxEndpoint?
/* /*
if (!setItexString($('#svg_source_textarea').val())) { if (!setItexString($('#svg_source_textarea').val())) {
const ok = confirm('Errors found. Revert to original?', function (ok) { const ok = seConfirm('Errors found. Revert to original?', function (ok) {
if (!ok) { if (!ok) {
return false; return false;
} }

View File

@ -54,7 +54,7 @@ export default {
// the "noStorageOnLoad" config setting to true in svgedit-config-*.js. // the "noStorageOnLoad" config setting to true in svgedit-config-*.js.
noStorageOnLoad, noStorageOnLoad,
forceStorage forceStorage
} = svgEditor.curConfig; } = svgEditor.configObj.curConfig;
const {storage} = svgEditor; const {storage} = svgEditor;
/** /**

View File

@ -1,5 +1,4 @@
/* eslint-disable no-alert */ /* globals jQuery seConfirm seAlert seSelect */
/* globals jQuery seSelect */
/** /**
* The main module for the visual SVG this. * The main module for the visual SVG this.
* *
@ -146,7 +145,7 @@ class Editor {
loadSvgString (str, {noAlert} = {}) { loadSvgString (str, {noAlert} = {}) {
const success = this.svgCanvas.setSvgString(str) !== false; const success = this.svgCanvas.setSvgString(str) !== false;
if (success) return; if (success) return;
if (!noAlert) window.alert(this.uiStrings.notification.errorLoadingSVG); if (!noAlert) seAlert(this.uiStrings.notification.errorLoadingSVG);
throw new Error('Error loading SVG'); throw new Error('Error loading SVG');
} }
@ -566,7 +565,7 @@ class Editor {
this.exportWindow = window.open('', this.exportWindowName); // A hack to get the window via JSON-able name without opening a new one this.exportWindow = window.open('', this.exportWindowName); // A hack to get the window via JSON-able name without opening a new one
} }
if (!this.exportWindow || this.exportWindow.closed) { if (!this.exportWindow || this.exportWindow.closed) {
alert(this.uiStrings.notification.popupWindowBlocked); seAlert(this.uiStrings.notification.popupWindowBlocked);
return; return;
} }
this.exportWindow.location.href = data.output; this.exportWindow.location.href = data.output;
@ -628,7 +627,7 @@ class Editor {
if (promptMoveLayerOnce) { if (promptMoveLayerOnce) {
moveToLayer(true); moveToLayer(true);
} else { } else {
const ok = confirm(confirmStr); const ok = seConfirm(confirmStr);
if (!ok) { if (!ok) {
return; return;
} }
@ -828,7 +827,7 @@ class Editor {
}); });
$('#url_notice').click(() => { $('#url_notice').click(() => {
alert(this.title); seAlert(this.title);
}); });
$('#stroke_width').val(this.configObj.curConfig.initStroke.width); $('#stroke_width').val(this.configObj.curConfig.initStroke.width);
@ -1217,7 +1216,7 @@ class Editor {
this.pref('save_notice_done', 'all'); this.pref('save_notice_done', 'all');
} }
if (done !== 'part') { if (done !== 'part') {
alert(note); seAlert(note);
} }
} }
} }
@ -1234,7 +1233,7 @@ class Editor {
this.exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one this.exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
if (!this.exportWindow || this.exportWindow.closed) { if (!this.exportWindow || this.exportWindow.closed) {
alert(this.uiStrings.notification.popupWindowBlocked); seAlert(this.uiStrings.notification.popupWindowBlocked);
return; return;
} }
@ -1252,7 +1251,7 @@ class Editor {
// Note that this will also prevent the notice even though new issues may appear later. // Note that this will also prevent the notice even though new issues may appear later.
// May want to find a way to deal with that without annoying the user // May want to find a way to deal with that without annoying the user
this.pref('export_notice_done', 'all'); this.pref('export_notice_done', 'all');
this.exportWindow.alert(note); this.exportWindow.seAlert(note);
} }
} }
@ -1728,7 +1727,7 @@ class Editor {
* @typedef {PlainObject} module:SVGthis.ContextTool * @typedef {PlainObject} module:SVGthis.ContextTool
* @property {string} panel The ID of the existing panel to which the tool is being added. Required. * @property {string} panel The ID of the existing panel to which the tool is being added. Required.
* @property {string} id The ID of the actual tool element. Required. * @property {string} id The ID of the actual tool element. Required.
* @property {PlainObject<string, external:jQuery.Function>|PlainObject<"change", external:jQuery.Function>} events DOM event names keyed to associated functions. Example: `{change () { alert('Option was changed') } }`. "change" event is one specifically handled for the "button-select" type. Required. * @property {PlainObject<string, external:jQuery.Function>|PlainObject<"change", external:jQuery.Function>} events DOM event names keyed to associated functions. Example: `{change () { seAlert('Option was changed') } }`. "change" event is one specifically handled for the "button-select" type. Required.
* @property {string} title The tooltip text that will appear when the user hovers over the tool. Required. * @property {string} title The tooltip text that will appear when the user hovers over the tool. Required.
* @property {"tool_button"|"select"|"button-select"|"input"|string} type The type of tool being added. Expected. * @property {"tool_button"|"select"|"button-select"|"input"|string} type The type of tool being added. Expected.
* @property {PlainObject<string, string>} [options] List of options and their labels for select tools. Example: `{1: 'One', 2: 'Two', all: 'All' }`. Required by "select" tools. * @property {PlainObject<string, string>} [options] List of options and their labels for select tools. Example: `{1: 'One', 2: 'Two', all: 'All' }`. Required by "select" tools.
@ -1932,7 +1931,7 @@ class Editor {
*/ */
clickClear () { clickClear () {
const [x, y] = this.configObj.curConfig.dimensions; const [x, y] = this.configObj.curConfig.dimensions;
const ok = confirm(this.uiStrings.notification.QwantToClear); const ok = seConfirm(this.uiStrings.notification.QwantToClear);
if (!ok) { if (!ok) {
return; return;
} }
@ -2121,7 +2120,7 @@ class Editor {
}; };
if (!this.svgCanvas.setSvgString(e.detail.value)) { if (!this.svgCanvas.setSvgString(e.detail.value)) {
const ok = confirm(this.uiStrings.notification.QerrorsRevertToSource); const ok = seConfirm(this.uiStrings.notification.QerrorsRevertToSource);
if (!ok) { if (!ok) {
return; return;
} }
@ -2164,15 +2163,15 @@ class Editor {
this.svgCanvas.setDocumentTitle(title); this.svgCanvas.setDocumentTitle(title);
if (w !== 'fit' && !isValidUnit('width', w)) { if (w !== 'fit' && !isValidUnit('width', w)) {
alert(this.uiStrings.notification.invalidAttrValGiven); seAlert(this.uiStrings.notification.invalidAttrValGiven);
return false; return false;
} }
if (h !== 'fit' && !isValidUnit('height', h)) { if (h !== 'fit' && !isValidUnit('height', h)) {
alert(this.uiStrings.notification.invalidAttrValGiven); seAlert(this.uiStrings.notification.invalidAttrValGiven);
return false; return false;
} }
if (!this.svgCanvas.setResolution(w, h)) { if (!this.svgCanvas.setResolution(w, h)) {
alert(this.uiStrings.notification.noContentToFitTo); seAlert(this.uiStrings.notification.noContentToFitTo);
return false; return false;
} }
// Set image save option // Set image save option
@ -2231,7 +2230,7 @@ class Editor {
if (editingsource) { if (editingsource) {
const origSource = this.svgCanvas.getSvgString(); const origSource = this.svgCanvas.getSvgString();
if (origSource !== e.detail.value) { if (origSource !== e.detail.value) {
const ok = confirm(this.uiStrings.notification.QignoreSourceChanges); const ok = seConfirm(this.uiStrings.notification.QignoreSourceChanges);
if (ok) { if (ok) {
this.hideSourceEditor(); this.hideSourceEditor();
} }
@ -2262,7 +2261,7 @@ class Editor {
if (this.undoMgr.getUndoStackSize() === 0) { if (this.undoMgr.getUndoStackSize() === 0) {
return true; return true;
} }
return confirm(this.uiStrings.notification.QwantToOpen); return seConfirm(this.uiStrings.notification.QwantToOpen);
} }
/** /**
@ -2457,7 +2456,7 @@ class Editor {
reject(new Error('URLLoadFail')); reject(new Error('URLLoadFail'));
return; return;
} }
alert(this.uiStrings.notification.URLLoadFail + ': \n' + err); seAlert(this.uiStrings.notification.URLLoadFail + ': \n' + err);
resolve(); resolve();
}, },
complete () { complete () {