#process_cancel prompt changes to alertDialog and seConfirmDialog
parent
9a7d60dfe7
commit
36e3c8dd49
|
@ -18,7 +18,7 @@ export class SeAlertDialog extends HTMLElement {
|
||||||
* @returns {any} observed
|
* @returns {any} observed
|
||||||
*/
|
*/
|
||||||
static get observedAttributes () {
|
static get observedAttributes () {
|
||||||
return ['title'];
|
return ['title', 'type', 'close'];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @function attributeChangedCallback
|
* @function attributeChangedCallback
|
||||||
|
@ -30,9 +30,24 @@ export class SeAlertDialog extends HTMLElement {
|
||||||
attributeChangedCallback (name, oldValue, newValue) {
|
attributeChangedCallback (name, oldValue, newValue) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 'title':
|
case 'title':
|
||||||
|
if (this.dialog.opened) {
|
||||||
|
this.dialog.close();
|
||||||
|
}
|
||||||
this.dialog.textContent = newValue;
|
this.dialog.textContent = newValue;
|
||||||
this.dialog.open();
|
this.dialog.open();
|
||||||
break;
|
break;
|
||||||
|
case 'type':
|
||||||
|
if (newValue === 'prompt_cancel') {
|
||||||
|
this.dialog.choices = ['Cancel'];
|
||||||
|
} else {
|
||||||
|
this.dialog.choices = ['Ok'];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'close':
|
||||||
|
if (this.dialog.opened) {
|
||||||
|
this.dialog.close();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.error('unkonw attr for:', name, 'newValue =', newValue);
|
console.error('unkonw attr for:', name, 'newValue =', newValue);
|
||||||
break;
|
break;
|
||||||
|
@ -53,6 +68,36 @@ export class SeAlertDialog extends HTMLElement {
|
||||||
set title (value) {
|
set title (value) {
|
||||||
this.setAttribute('title', value);
|
this.setAttribute('title', value);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @function get
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
get type () {
|
||||||
|
return this.getAttribute('type');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function set
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
set type (value) {
|
||||||
|
this.setAttribute('type', value);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @function get
|
||||||
|
* @returns {any}
|
||||||
|
*/
|
||||||
|
get close () {
|
||||||
|
return this.getAttribute('close');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function set
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
set close (value) {
|
||||||
|
this.setAttribute('close', value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register
|
// Register
|
||||||
|
|
|
@ -181,11 +181,9 @@ export default {
|
||||||
const message = uiStrings.notification.retrieving.replace('%s', name);
|
const message = uiStrings.notification.retrieving.replace('%s', name);
|
||||||
|
|
||||||
if (mode !== 'm') {
|
if (mode !== 'm') {
|
||||||
await $.process_cancel(message);
|
await seConfirm(message, [uiStrings.common.cancel]);
|
||||||
transferStopped = true;
|
transferStopped = true;
|
||||||
// Should a message be sent back to the frame?
|
// Should a message be sent back to the frame?
|
||||||
|
|
||||||
$('#dialog_box').hide();
|
|
||||||
} else {
|
} else {
|
||||||
entry = $('<div>').text(message).data('id', curMeta.id);
|
entry = $('<div>').text(message).data('id', curMeta.id);
|
||||||
preview.append(entry);
|
preview.append(entry);
|
||||||
|
|
|
@ -32,6 +32,7 @@ $('a').click(function () {
|
||||||
data = canvas.toDataURL();
|
data = canvas.toDataURL();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// This fails in Firefox with `file:///` URLs :(
|
// This fails in Firefox with `file:///` URLs :(
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = 'Data URL conversion failed: ' + err;
|
document.getElementById('se-alert-dialog').title = 'Data URL conversion failed: ' + err;
|
||||||
data = '';
|
data = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ async function processResults (url) {
|
||||||
// console.log('json', json);
|
// console.log('json', json);
|
||||||
|
|
||||||
if (!json || json.msg !== 'success') {
|
if (!json || json.msg !== 'success') {
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = 'There was a problem downloading the results';
|
document.getElementById('se-alert-dialog').title = 'There was a problem downloading the results';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,6 +202,7 @@ export default {
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
|
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
document.getElementById('se-alert-dialog').title = 'Failed loading MathJax. You will not be able to change the mathematics.';
|
document.getElementById('se-alert-dialog').title = 'Failed loading MathJax. You will not be able to change the mathematics.';
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ export default {
|
||||||
<input type="hidden" name="contenttype" value="application/x-svgdraw">
|
<input type="hidden" name="contenttype" value="application/x-svgdraw">
|
||||||
`).appendTo('body')
|
`).appendTo('body')
|
||||||
.submit().remove();
|
.submit().remove();
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = strings.saved;
|
document.getElementById('se-alert-dialog').title = strings.saved;
|
||||||
top.window.location = '/' + name;
|
top.window.location = '/' + name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,9 +245,8 @@ export default {
|
||||||
form.submit();
|
form.submit();
|
||||||
|
|
||||||
rebuildInput(form);
|
rebuildInput(form);
|
||||||
await $.process_cancel(strings.uploading);
|
await seConfirm(strings.uploading, ['Cancel']);
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
$('#dialog_box').hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form[0] === openSvgForm[0]) {
|
if (form[0] === openSvgForm[0]) {
|
||||||
|
|
|
@ -63,6 +63,7 @@ export default {
|
||||||
} */
|
} */
|
||||||
break;
|
break;
|
||||||
case 'save-end':
|
case 'save-end':
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = `save complete for pathID ${pathID}!`;
|
document.getElementById('se-alert-dialog').title = `save complete for pathID ${pathID}!`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -156,6 +156,7 @@ class LayersPanel {
|
||||||
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, uniqName);
|
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, uniqName);
|
||||||
if (!newName) { return; }
|
if (!newName) { return; }
|
||||||
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.dupeLayerName;
|
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.dupeLayerName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -190,6 +191,7 @@ class LayersPanel {
|
||||||
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, name);
|
const newName = prompt(this.uiStrings.notification.enterUniqueLayerName, name);
|
||||||
if (!newName) { return; }
|
if (!newName) { return; }
|
||||||
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
if (this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.dupeLayerName;
|
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.dupeLayerName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -235,6 +237,7 @@ class LayersPanel {
|
||||||
const newName = prompt(this.uiStrings.notification.enterNewLayerName, '');
|
const newName = prompt(this.uiStrings.notification.enterNewLayerName, '');
|
||||||
if (!newName) { return; }
|
if (!newName) { return; }
|
||||||
if (oldName === newName || this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
if (oldName === newName || this.svgCanvas.getCurrentDrawing().hasLayer(newName)) {
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.layerHasThatName;
|
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.layerHasThatName;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,6 +403,7 @@ class TopPanelHandlers {
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
e.target.value = this.selectedElement().getAttribute(attr);
|
e.target.value = this.selectedElement().getAttribute(attr);
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.invalidAttrValGiven;
|
document.getElementById('se-alert-dialog').title = this.uiStrings.notification.invalidAttrValGiven;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,6 +456,7 @@ editor.init = () => {
|
||||||
editor.pref('save_notice_done', 'all');
|
editor.pref('save_notice_done', 'all');
|
||||||
}
|
}
|
||||||
if (done !== 'part') {
|
if (done !== 'part') {
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = note;
|
document.getElementById('se-alert-dialog').title = note;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,6 +474,7 @@ editor.init = () => {
|
||||||
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
|
exportWindow = window.open(blankPageObjectURL || '', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
|
||||||
|
|
||||||
if (!exportWindow || exportWindow.closed) {
|
if (!exportWindow || exportWindow.closed) {
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = uiStrings.notification.popupWindowBlocked;
|
document.getElementById('se-alert-dialog').title = uiStrings.notification.popupWindowBlocked;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -789,7 +791,7 @@ editor.init = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor.configObj.urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {
|
if (editor.configObj.urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {
|
||||||
$('#dialog_box').hide();
|
document.getElementById('se-alert-dialog').setAttribute('close', true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1902,7 +1904,7 @@ editor.init = () => {
|
||||||
const {title, w, h, save} = e.detail;
|
const {title, w, h, save} = e.detail;
|
||||||
// set document title
|
// set document title
|
||||||
svgCanvas.setDocumentTitle(title);
|
svgCanvas.setDocumentTitle(title);
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
if (w !== 'fit' && !isValidUnit('width', w)) {
|
if (w !== 'fit' && !isValidUnit('width', w)) {
|
||||||
document.getElementById('se-alert-dialog').title = uiStrings.notification.invalidAttrValGiven;
|
document.getElementById('se-alert-dialog').title = uiStrings.notification.invalidAttrValGiven;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1959,7 +1961,6 @@ editor.init = () => {
|
||||||
* @returns {void} Resolves to `undefined`
|
* @returns {void} Resolves to `undefined`
|
||||||
*/
|
*/
|
||||||
const cancelOverlays = async (e) => {
|
const cancelOverlays = async (e) => {
|
||||||
$('#dialog_box').hide();
|
|
||||||
const $editorDialog = document.getElementById('se-svg-editor-dialog');
|
const $editorDialog = document.getElementById('se-svg-editor-dialog');
|
||||||
const editingsource = $editorDialog.getAttribute('dialog') === 'open';
|
const editingsource = $editorDialog.getAttribute('dialog') === 'open';
|
||||||
if (!editingsource && !docprops && !preferences) {
|
if (!editingsource && !docprops && !preferences) {
|
||||||
|
@ -2003,6 +2004,7 @@ editor.init = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#url_notice').click(() => {
|
$('#url_notice').click(() => {
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = this.title;
|
document.getElementById('se-alert-dialog').title = this.title;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2440,13 +2442,14 @@ editor.init = () => {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
const importImage = function (e) {
|
const importImage = function (e) {
|
||||||
$.process_cancel(uiStrings.notification.loadingImage);
|
document.getElementById('se-alert-dialog').setAttribute('type', 'prompt_cancel');
|
||||||
|
document.getElementById('se-alert-dialog').title = uiStrings.notification.loadingImage;
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('#main_menu').hide();
|
$('#main_menu').hide();
|
||||||
const file = (e.type === 'drop') ? e.dataTransfer.files[0] : this.files[0];
|
const file = (e.type === 'drop') ? e.dataTransfer.files[0] : this.files[0];
|
||||||
if (!file) {
|
if (!file) {
|
||||||
$('#dialog_box').hide();
|
document.getElementById('se-alert-dialog').setAttribute('close', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2467,7 +2470,7 @@ editor.init = () => {
|
||||||
svgCanvas.alignSelectedElements('c', 'page');
|
svgCanvas.alignSelectedElements('c', 'page');
|
||||||
// highlight imported element, otherwise we get strange empty selectbox
|
// highlight imported element, otherwise we get strange empty selectbox
|
||||||
svgCanvas.selectOnly([newElement]);
|
svgCanvas.selectOnly([newElement]);
|
||||||
$('#dialog_box').hide();
|
document.getElementById('se-alert-dialog').setAttribute('close', true);
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2497,7 +2500,7 @@ editor.init = () => {
|
||||||
svgCanvas.alignSelectedElements('m', 'page');
|
svgCanvas.alignSelectedElements('m', 'page');
|
||||||
svgCanvas.alignSelectedElements('c', 'page');
|
svgCanvas.alignSelectedElements('c', 'page');
|
||||||
editor.topPanelHandlers.updateContextPanel();
|
editor.topPanelHandlers.updateContextPanel();
|
||||||
$('#dialog_box').hide();
|
document.getElementById('se-alert-dialog').setAttribute('close', true);
|
||||||
};
|
};
|
||||||
// create dummy img so we know the default dimensions
|
// create dummy img so we know the default dimensions
|
||||||
let imgWidth = 100;
|
let imgWidth = 100;
|
||||||
|
@ -2525,7 +2528,8 @@ editor.init = () => {
|
||||||
if (!ok) { return; }
|
if (!ok) { return; }
|
||||||
svgCanvas.clear();
|
svgCanvas.clear();
|
||||||
if (this.files.length === 1) {
|
if (this.files.length === 1) {
|
||||||
$.process_cancel(uiStrings.notification.loadingImage);
|
document.getElementById('se-alert-dialog').setAttribute('type', 'prompt_cancel');
|
||||||
|
document.getElementById('se-alert-dialog').title = uiStrings.notification.loadingImage;
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onloadend = async function ({target}) {
|
reader.onloadend = async function ({target}) {
|
||||||
await loadSvgString(target.result);
|
await loadSvgString(target.result);
|
||||||
|
@ -2691,7 +2695,8 @@ editor.loadFromURL = function (url, {cache, noAlert} = {}) {
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
cache: Boolean(cache),
|
cache: Boolean(cache),
|
||||||
beforeSend () {
|
beforeSend () {
|
||||||
$.process_cancel(uiStrings.notification.loadingImage);
|
document.getElementById('se-alert-dialog').setAttribute('type', 'prompt_cancel');
|
||||||
|
document.getElementById('se-alert-dialog').title = uiStrings.notification.loadingImage;
|
||||||
},
|
},
|
||||||
success (str) {
|
success (str) {
|
||||||
loadSvgString(str, {noAlert});
|
loadSvgString(str, {noAlert});
|
||||||
|
@ -2705,11 +2710,13 @@ editor.loadFromURL = function (url, {cache, noAlert} = {}) {
|
||||||
reject(new Error('URLLoadFail'));
|
reject(new Error('URLLoadFail'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('close', true);
|
||||||
|
document.getElementById('se-alert-dialog').setAttribute('type', 'alert');
|
||||||
document.getElementById('se-alert-dialog').title = uiStrings.notification.URLLoadFail + ': \n' + err;
|
document.getElementById('se-alert-dialog').title = uiStrings.notification.URLLoadFail + ': \n' + err;
|
||||||
resolve();
|
resolve();
|
||||||
},
|
},
|
||||||
complete () {
|
complete () {
|
||||||
$('#dialog_box').hide();
|
document.getElementById('se-alert-dialog').setAttribute('close', true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue