jquery removal, isolate svgcavas from svgedit, tests

master
JFH 2020-12-26 00:08:54 +01:00
parent 9bf5f559bb
commit c0ca1dd621
58 changed files with 166 additions and 391 deletions

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="428" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="green" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h87v20h-87zM316 0h112v20H316z"/><path fill="url(#smooth)" d="M0 0h428v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 52.95%</text><text class="high" x="5" y="14">Statements 52.95%</text><text class="shadow" x="125.5" y="15">Branches 41.89%</text><text class="high" x="125" y="14">Branches 41.89%</text><text class="shadow" x="234.5" y="15">Lines 53.76%</text><text class="high" x="234" y="14">Lines 53.76%</text><text class="shadow" x="321.5" y="15">Functions 60.47%</text><text class="high" x="321" y="14">Functions 60.47%</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" width="403" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="green" stroke="#000" d="M0 0h120v20H0zM120 0h109v20H120zM229 0h80v20h-80zM309 0h94v20h-94z"/><path fill="url(#smooth)" d="M0 0h403v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Statements 47.23%</text><text class="high" x="5" y="14">Statements 47.23%</text><text class="shadow" x="125.5" y="15">Branches 34.77%</text><text class="high" x="125" y="14">Branches 34.77%</text><text class="shadow" x="234.5" y="15">Lines 48.3%</text><text class="high" x="234" y="14">Lines 48.3%</text><text class="shadow" x="314.5" y="15">Functions 53%</text><text class="high" x="314" y="14">Functions 53%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#4c1" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">144/144</text><text class="high" x="46" y="14">144/144</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" width="97" height="20"><defs><style>text{font-size:11px;font-family:Verdana,DejaVu Sans,Geneva,sans-serif}text.shadow{fill:#010101;fill-opacity:.3}text.high{fill:#fff}</style><linearGradient id="smooth" x2="0" y2="100%"><stop offset="0" stop-color="#aaa" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="round"><rect width="100%" height="100%" rx="3" fill="#fff"/></mask></defs><g id="bg" mask="url(#round)"><path fill="#696969" d="M0 0h41v20H0z"/><path fill="#e05d44" d="M41 0h56v20H41z"/><path fill="url(#smooth)" d="M0 0h97v20H0z"/></g><g id="fg"><text class="shadow" x="5.5" y="15">Tests</text><text class="high" x="5" y="14">Tests</text><text class="shadow" x="46.5" y="15">140/143</text><text class="high" x="46" y="14">140/143</text></g></svg>

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 823 B

View File

@ -8,6 +8,7 @@
"ignoreTestFiles": ["**/__snapshots__/*", "**/__image_snapshots__/*"], "ignoreTestFiles": ["**/__snapshots__/*", "**/__image_snapshots__/*"],
"defaultCommandTimeout": 10000, "defaultCommandTimeout": 10000,
"pageLoadTimeout": 120000, "pageLoadTimeout": 120000,
"includeShadowDom": true,
"cypress-plugin-snapshots": { "cypress-plugin-snapshots": {
"autoCleanUp": true, "autoCleanUp": true,
"prettier": true, "prettier": true,

View File

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View File

@ -880,8 +880,8 @@ exports[`use various parts of svg-edit > check tool_text_anchor_middle #0`] = `
strokecolor="#000000" strokecolor="#000000"
strokewidth="5" strokewidth="5"
fill-opacity="1" fill-opacity="1"
stroke="none"
stroke-opacity="1" stroke-opacity="1"
stroke="none"
></polygon> ></polygon>
<polygon <polygon
cx="115" cx="115"
@ -1016,8 +1016,8 @@ exports[`use various parts of svg-edit > check tool_text_anchor_end #0`] = `
strokecolor="#000000" strokecolor="#000000"
strokewidth="5" strokewidth="5"
fill-opacity="1" fill-opacity="1"
stroke="none"
stroke-opacity="1" stroke-opacity="1"
stroke="none"
></polygon> ></polygon>
<polygon <polygon
cx="115" cx="115"
@ -1031,8 +1031,8 @@ exports[`use various parts of svg-edit > check tool_text_anchor_end #0`] = `
strokecolor="none" strokecolor="none"
strokewidth="5" strokewidth="5"
fill-opacity="1" fill-opacity="1"
stroke="none"
stroke-opacity="1" stroke-opacity="1"
stroke="none"
></polygon> ></polygon>
<polygon <polygon
cx="115" cx="115"

View File

@ -1,21 +0,0 @@
import {
visitAndApproveStorage
} from '../../../support/ui-test-helper.js';
// See https://github.com/SVG-Edit/svgedit/issues/364
describe('Issue 364; IE errorwith rectangle selection by click', function () {
beforeEach(() => {
visitAndApproveStorage();
});
it('should set rectangle selection after click', function () {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.get('#tools_rect_show')
.trigger('mousedown', {force: true})
.wait(100) // this delay seems necessary
.trigger('mouseup', {force: true})
.should((button) => {
expect(button).to.have.class('tool_button_current');
});
});
});

View File

@ -20,7 +20,7 @@ describe('Fix issue 407', function () {
<text fill="#000000" id="a_text" text-anchor="middle" x="260.5" xml:space="preserve" y="192.5">hello</text> <text fill="#000000" id="a_text" text-anchor="middle" x="260.5" xml:space="preserve" y="192.5">hello</text>
</g> </g>
</g> </g>
</svg>`, {parseSpecialCharSequences: false}); </svg>`, {force: true, parseSpecialCharSequences: false});
cy.get('#tool_source_save').click(); cy.get('#tool_source_save').click();
cy.get('#svg_1').click().dblclick(); cy.get('#svg_1').click().dblclick();
cy.get('#a_text').should('exist'); cy.get('#a_text').should('exist');
@ -30,6 +30,6 @@ describe('Fix issue 407', function () {
.dblclick({force: true}); .dblclick({force: true});
// svgedit use the #text text field to capture the text // svgedit use the #text text field to capture the text
cy.get('#text').type('1234', {force: true}); cy.get('#text').type('1234', {force: true});
cy.get('#a_text').should('have.text', 'he1234llo'); cy.get('#a_text').should('have.text', 'hell1234o');
}); });
}); });

View File

@ -20,7 +20,7 @@ describe('Fix issue 408', function () {
<circle cx="117.5" cy="87.5" fill="#ffff00" r="19.84943" stroke="#000000" /> <circle cx="117.5" cy="87.5" fill="#ffff00" r="19.84943" stroke="#000000" />
</g> </g>
</g> </g>
</svg>`, {parseSpecialCharSequences: false}); </svg>`, {force: true, parseSpecialCharSequences: false});
cy.get('#tool_source_save').click(); cy.get('#tool_source_save').click();
cy.get('#svg_6').click().dblclick(); // change context cy.get('#svg_6').click().dblclick(); // change context
cy.get('#tool_source').click(); // reopen tool_source cy.get('#tool_source').click(); // reopen tool_source

View File

@ -41,7 +41,6 @@ describe('use various parts of svg-edit', function () {
.trigger('mousedown', 'center', {force: true}) .trigger('mousedown', 'center', {force: true})
.trigger('mouseup', {force: true}); .trigger('mouseup', {force: true});
// svgedit use the #text text field to capture the text // svgedit use the #text text field to capture the text
// cy.get('#text').type('1234', {force: true});
cy.get('#text').type('B', {force: true}); cy.get('#text').type('B', {force: true});
testSnapshot(); testSnapshot();
}); });

View File

@ -8,13 +8,10 @@ describe('UI - Tool selection', function () {
}); });
it('should set rectangle selection by click', function () { it('should set rectangle selection by click', function () {
// eslint-disable-next-line cypress/no-unnecessary-waiting cy.get('#tools_rect')
cy.get('#tools_rect_show') .should('not.have.attr', 'pressed');
.trigger('mousedown', {force: true}) cy.get('#tools_rect')
.wait(100) // this delay seems necessary .trigger('click', {force: true})
.trigger('mouseup', {force: true}) .should('have.attr', 'pressed');
.should((button) => {
expect(button).to.have.class('tool_button_current');
});
}); });
}); });

View File

@ -1,7 +1,7 @@
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js'; import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
import * as coords from '../../../instrumented/svgcanvas/coords.js'; import * as coords from '../../../instrumented/svgcanvas/coords.js';
describe('coords', function () { describe('coords', function () {

View File

@ -1,8 +1,8 @@
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; import * as transformlist from '../../../instrumented/svgcanvas/svgtransformlist.js';
import * as utilities from '../../../instrumented/common/utilities.js'; import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
import * as hstory from '../../../instrumented/svgcanvas/history.js'; import * as hstory from '../../../instrumented/svgcanvas/history.js';
describe('history', function () { describe('history', function () {

View File

@ -1,7 +1,7 @@
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as math from '../../../instrumented/common/math.js'; import * as math from '../../../instrumented/svgcanvas/math.js';
describe('math', function () { describe('math', function () {
const svg = document.createElementNS(NS.SVG, 'svg'); const svg = document.createElementNS(NS.SVG, 'svg');

View File

@ -4,7 +4,7 @@ import 'pathseg';
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js'; import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
import * as pathModule from '../../../instrumented/svgcanvas/path.js'; import * as pathModule from '../../../instrumented/svgcanvas/path.js';
import {Path, Segment} from '../../../instrumented/svgcanvas/path-method.js'; import {Path, Segment} from '../../../instrumented/svgcanvas/path-method.js';
import {init as unitsInit} from '../../../instrumented/common/units.js'; import {init as unitsInit} from '../../../instrumented/common/units.js';

View File

@ -1,7 +1,7 @@
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js'; import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
import * as coords from '../../../instrumented/svgcanvas/coords.js'; import * as coords from '../../../instrumented/svgcanvas/coords.js';
import * as recalculate from '../../../instrumented/svgcanvas/recalculate.js'; import * as recalculate from '../../../instrumented/svgcanvas/recalculate.js';

View File

@ -1,7 +1,7 @@
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; import * as transformlist from '../../../instrumented/svgcanvas/svgtransformlist.js';
import {disableSupportsNativeTransformLists} from '../../../instrumented/common/browser.js'; import {disableSupportsNativeTransformLists} from '../../../instrumented/common/browser.js';
import almostEqualsPlugin from '../../support/assert-almostEquals.js'; import almostEqualsPlugin from '../../support/assert-almostEquals.js';

View File

@ -4,9 +4,9 @@ import 'pathseg';
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js'; import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; import * as transformlist from '../../../instrumented/svgcanvas/svgtransformlist.js';
import * as math from '../../../instrumented/common/math.js'; import * as math from '../../../instrumented/svgcanvas/math.js';
import * as path from '../../../instrumented/svgcanvas/path.js'; import * as path from '../../../instrumented/svgcanvas/path.js';
import setAssertionMethods from '../../support/assert-close.js'; import setAssertionMethods from '../../support/assert-close.js';

View File

@ -3,9 +3,9 @@ import 'pathseg';
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
import * as utilities from '../../../instrumented/common/utilities.js'; import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
import * as transformlist from '../../../instrumented/common/svgtransformlist.js'; import * as transformlist from '../../../instrumented/svgcanvas/svgtransformlist.js';
import * as math from '../../../instrumented/common/math.js'; import * as math from '../../../instrumented/svgcanvas/math.js';
describe('utilities performance', function () { describe('utilities performance', function () {
let currentLayer, groupWithMatrixTransform, textWithMatrixTransform; let currentLayer, groupWithMatrixTransform, textWithMatrixTransform;

View File

@ -2,7 +2,7 @@
import '../../../instrumented/editor/jquery.min.js'; import '../../../instrumented/editor/jquery.min.js';
import * as browser from '../../../instrumented/common/browser.js'; import * as browser from '../../../instrumented/common/browser.js';
import * as utilities from '../../../instrumented/common/utilities.js'; import * as utilities from '../../../instrumented/svgcanvas/utilities.js';
import {NS} from '../../../instrumented/common/namespaces.js'; import {NS} from '../../../instrumented/common/namespaces.js';
describe('utilities', function () { describe('utilities', function () {

View File

@ -1,5 +1,6 @@
export const approveStorage = () => { export const approveStorage = () => {
return cy.get('#dialog_buttons > input[type=button][data-ok]') // JFH will need to be chnaged when dialog is changed...
cy.get('elix-alert-dialog').shadow().find('#choiceButtonContainer > plain-border-button-0:nth-child(1)')
.click(); .click();
}; };
@ -9,7 +10,7 @@ export const visitAndApproveStorage = () => {
}; };
export const openMainMenu = () => { export const openMainMenu = () => {
return cy.get('#main_icon').click(); return cy.get('#main_button').click();
}; };
export const openEditorPreferences = () => { export const openEditorPreferences = () => {

View File

@ -6,9 +6,6 @@
* @copyright 2010 Jeff Schiller, 2010 Alexis Deveria * @copyright 2010 Jeff Schiller, 2010 Alexis Deveria
*/ */
// Dependencies:
// 1) jQuery (for $.alert())
import 'pathseg'; import 'pathseg';
import {NS} from './namespaces.js'; import {NS} from './namespaces.js';

View File

@ -1,3 +1,4 @@
/* eslint-disable no-alert */
/* globals $ */ /* globals $ */
/** /**
@ -27,17 +28,17 @@ class LayersPanel {
/** /**
* @returns {void} * @returns {void}
*/ */
async newLayer () { newLayer () {
let uniqName; let uniqName;
let i = this.svgCanvas.getCurrentDrawing().getNumLayers(); let i = this.svgCanvas.getCurrentDrawing().getNumLayers();
do { do {
uniqName = this.uiStrings.layers.layer + ' ' + (++i); uniqName = this.uiStrings.layers.layer + ' ' + (++i);
} while (this.svgCanvas.getCurrentDrawing().hasLayer(uniqName)); } while (this.svgCanvas.getCurrentDrawing().hasLayer(uniqName));
const newName = await $.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)) {
/* await */ $.alert(this.uiStrings.notification.dupeLayerName); alert(this.uiStrings.notification.dupeLayerName);
return; return;
} }
this.svgCanvas.createLayer(newName); this.svgCanvas.createLayer(newName);
@ -63,15 +64,15 @@ class LayersPanel {
/** /**
* *
* @returns {Promise<void>} * @returns {void}
*/ */
async cloneLayer () { cloneLayer () {
const name = this.svgCanvas.getCurrentDrawing().getCurrentLayerName() + ' copy'; const name = this.svgCanvas.getCurrentDrawing().getCurrentLayerName() + ' copy';
const newName = await $.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)) {
/* await */ $.alert(this.uiStrings.notification.dupeLayerName); alert(this.uiStrings.notification.dupeLayerName);
return; return;
} }
this.svgCanvas.cloneLayer(newName); this.svgCanvas.cloneLayer(newName);
@ -110,13 +111,13 @@ class LayersPanel {
/** /**
* @returns {void} * @returns {void}
*/ */
async layerRename () { layerRename () {
// const curIndex = $('#layerlist tr.layersel').prevAll().length; // Currently unused // const curIndex = $('#layerlist tr.layersel').prevAll().length; // Currently unused
const oldName = $('#layerlist tr.layersel td.layername').text(); const oldName = $('#layerlist tr.layersel td.layername').text();
const newName = await $.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)) {
/* await */ $.alert(this.uiStrings.notification.layerHasThatName); alert(this.uiStrings.notification.layerHasThatName);
return; return;
} }
this.svgCanvas.renameCurrentLayer(newName); this.svgCanvas.renameCurrentLayer(newName);

View File

@ -138,22 +138,6 @@ class PaintBox {
this.setPaint(paint); this.setPaint(paint);
return (paint); return (paint);
} }
/**
* @returns {void}
*/
prep () {
const ptype = this.paint.type;
switch (ptype) {
case 'linearGradient':
case 'radialGradient': {
const paint = new $.jGraduate.Paint({copy: this.paint});
this.setPaint(this.type, paint);
break;
}
}
}
} }
PaintBox.ctr = 0; PaintBox.ctr = 0;

View File

@ -283,7 +283,8 @@ export default function jQueryPluginJGraduate ($) {
const $wc = (selector) => $($shadowRoot.querySelectorAll(selector)); const $wc = (selector) => $($shadowRoot.querySelectorAll(selector));
if (!idref) { if (!idref) {
/* await */ $.alert('Container element must have an id attribute to maintain unique id strings for sub-elements.'); // eslint-disable-next-line no-alert
alert('Container element must have an id attribute to maintain unique id strings for sub-elements.');
return; return;
} }

View File

@ -8,7 +8,7 @@ template.innerHTML = `
</style> </style>
<elix-menu-item> <elix-menu-item>
<div style="display:inline-block;"> <div style="display:inline-block;">
<img src="" alt="icon" style="display:none;" /> <img src="./images/logo.svg" alt="icon" style="display:none;" />
<span></span> <span></span>
</div> </div>
</elix-menu-item> </elix-menu-item>

View File

@ -18,7 +18,7 @@ template.innerHTML = `
padding: 0px; padding: 0px;
} }
</style> </style>
<img src="./images/logo.svg" alt="icon" width="12" height="12" /> <img src="./images/logo.svg" alt="icon" width="12" height="12" aria-labelledby="label" />
<span id="label">label</span> <span id="label">label</span>
<elix-number-spin-box min="1" step="1"></elix-number-spin-box> <elix-number-spin-box min="1" step="1"></elix-number-spin-box>
`; `;

View File

@ -184,7 +184,7 @@ export class SeCMenuDialog extends HTMLElement {
}); });
break; break;
default: default:
super.attributeChangedCallback(name, oldValue, newValue); // super.attributeChangedCallback(name, oldValue, newValue);
break; break;
} }
} }

View File

@ -115,7 +115,7 @@ export class SeCMenuLayerDialog extends HTMLElement {
} }
break; break;
default: default:
super.attributeChangedCallback(name, oldValue, newValue); // super.attributeChangedCallback(name, oldValue, newValue);
break; break;
} }
} }

View File

@ -194,11 +194,11 @@ template.innerHTML = `
</fieldset> </fieldset>
<fieldset id="change_grid"> <fieldset id="change_grid">
<legend id="svginfo_grid_settings">Grid</legend> <legend id="svginfo_grid_settings">Grid</legend>
<label> <label for="svginfo_snap_onoff">
<span id="svginfo_snap_onoff">Snapping on/off</span> <span id="svginfo_snap_onoff">Snapping on/off</span>
<input type="checkbox" value="snapping_on" id="grid_snapping_on" /> <input type="checkbox" value="snapping_on" id="grid_snapping_on" />
</label> </label>
<label> <label for="grid_snapping_step">
<span id="svginfo_snap_step">Snapping Step-Size:</span> <span id="svginfo_snap_step">Snapping Step-Size:</span>
<input type="text" id="grid_snapping_step" size="3" value="10" /> <input type="text" id="grid_snapping_step" size="3" value="10" />
</label> </label>

View File

@ -3,3 +3,4 @@ import './editorPreferencesDialog.js';
import './svgSourceDialog.js'; import './svgSourceDialog.js';
import './cmenuDialog.js'; import './cmenuDialog.js';
import './cmenuLayersDialog.js'; import './cmenuLayersDialog.js';
import './seSelectDialog.js';

View File

@ -0,0 +1,13 @@
// eslint-disable-next-line node/no-unpublished-import
import AlertDialog from 'elix/define/AlertDialog.js';
const dialog = new AlertDialog();
const seSelect = async (text, choices) => {
dialog.textContent = text;
dialog.choices = choices;
dialog.open();
const response = await dialog.whenClosed();
return response.choice;
};
window.seSelect = seSelect;

View File

@ -196,11 +196,12 @@ export default {
// Create source save/cancel buttons // Create source save/cancel buttons
/* const save = */ $('#tool_source_save').clone() /* const save = */ $('#tool_source_save').clone()
.hide().attr('id', 'foreign_save').unbind() .hide().attr('id', 'foreign_save').unbind()
.appendTo('#tool_source_back').click(async function () { .appendTo('#tool_source_back').click(function () {
if (!editingforeign) { return; } if (!editingforeign) { return; }
if (!setForeignString($('#svg_source_textarea').val())) { if (!setForeignString($('#svg_source_textarea').val())) {
const ok = await $.confirm('Errors found. Revert to original?'); // eslint-disable-next-line no-alert
const ok = confirm('Errors found. Revert to original?');
if (!ok) { return; } if (!ok) { return; }
endChanges(); endChanges();
} else { } else {

View File

@ -78,7 +78,7 @@ export default {
}); });
// Show the text using the custom alert function // Show the text using the custom alert function
$.alert(text); alert(text); // eslint-disable-line no-alert
} }
} }
}; };

View File

@ -223,7 +223,7 @@ export default {
} else { } else {
pending[id].entry.remove(); pending[id].entry.remove();
} }
// await $.alert('Unexpected data was returned: ' + response, function() { // await alert('Unexpected data was returned: ' + response, function() {
// if (mode !== 'm') { // if (mode !== 'm') {
// closeBrowser(); // closeBrowser();
// } else { // } else {

View File

@ -404,12 +404,13 @@ export default {
/** /**
* @param {"start"|"mid"|"end"} pos * @param {"start"|"mid"|"end"} pos
* @returns {Promise<void>} Resolves to `undefined` * @returns {void} Resolves to `undefined`
*/ */
async function showTextPrompt (pos) { function showTextPrompt (pos) {
let def = $('#' + pos + '_marker').val(); let def = $('#' + pos + '_marker').val();
if (def.substr(0, 1) === '\\') { def = ''; } if (def.substr(0, 1) === '\\') { def = ''; }
const txt = await $.prompt('Enter text for ' + pos + ' marker', def); // eslint-disable-next-line no-alert
const txt = prompt('Enter text for ' + pos + ' marker', def);
if (txt) { if (txt) {
triggerTextEntry(pos, txt); triggerTextEntry(pos, txt);
} }

View File

@ -202,7 +202,8 @@ 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
$.alert('Failed loading MathJax. You will not be able to change the mathematics.'); // eslint-disable-next-line no-alert
alert('Failed loading MathJax. You will not be able to change the mathematics.');
} }
} }
} }

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 = await $.confirm('Errors found. Revert to original?', function (ok) { const ok = confirm('Errors found. Revert to original?', function (ok) {
if (!ok) { if (!ok) {
return false; return false;
} }

View File

@ -64,7 +64,8 @@ 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();
$.alert(strings.saved); // eslint-disable-next-line no-alert
alert(strings.saved);
top.window.location = '/' + name; top.window.location = '/' + name;
} }
}); });

View File

@ -146,7 +146,8 @@ export default {
} }
if (note.length) { if (note.length) {
await $.alert(note); // eslint-disable-next-line no-alert
alert(note);
} }
const filename = getFileNameFromTitle(); const filename = getFileNameFromTitle();

View File

@ -1,3 +1,4 @@
/* globals seSelect */
/** /**
* @file ext-storage.js * @file ext-storage.js
* *
@ -181,9 +182,9 @@ export default {
const storagePrompt = new URL(top.location).searchParams.get('storagePrompt'); const storagePrompt = new URL(top.location).searchParams.get('storagePrompt');
const strings = await loadExtensionTranslation(svgEditor.pref('lang')); const strings = await loadExtensionTranslation(svgEditor.pref('lang'));
const { const {
message, storagePrefsAndContent, storagePrefsOnly, message /* , storagePrefsAndContent, storagePrefsOnly,
storagePrefs, storageNoPrefsOrContent, storageNoPrefs, storagePrefs, storageNoPrefsOrContent, storageNoPrefs,
rememberLabel, rememberTooltip rememberLabel, rememberTooltip */
} = strings; } = strings;
// No need to run this one-time dialog again just because the user // No need to run this one-time dialog again just because the user
@ -213,6 +214,7 @@ export default {
) )
// ...then show the storage prompt. // ...then show the storage prompt.
)) { )) {
/*
const options = []; const options = [];
if (storage) { if (storage) {
options.unshift( options.unshift(
@ -226,20 +228,13 @@ export default {
{value: 'noPrefsOrContent', text: storageNoPrefs} {value: 'noPrefsOrContent', text: storageNoPrefs}
); );
} }
*/
// Hack to temporarily provide a wide and high enough dialog const options = storage ? ['prefsAndContent', 'prefsOnly', 'noPrefsOrContent'] : ['prefsOnly', 'noPrefsOrContent'];
const oldContainerWidth = $('#dialog_container')[0].style.width,
oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft,
oldContentHeight = $('#dialog_content')[0].style.height,
oldContainerHeight = $('#dialog_container')[0].style.height;
$('#dialog_content')[0].style.height = '120px';
$('#dialog_container')[0].style.height = '170px';
$('#dialog_container')[0].style.width = '800px';
$('#dialog_container')[0].style.marginLeft = '-400px';
// Open select-with-checkbox dialog // Open select-with-checkbox dialog
// From svg-editor.js // From svg-editor.js
svgEditor.storagePromptState = 'waiting'; svgEditor.storagePromptState = 'waiting';
/* JFH !!!!!
const {response: pref, checked} = await $.select( const {response: pref, checked} = await $.select(
message, message,
options, options,
@ -251,6 +246,8 @@ export default {
tooltip: rememberTooltip tooltip: rememberTooltip
} }
); );
*/
const pref = await seSelect(message, options);
if (pref && pref !== 'noPrefsOrContent') { if (pref && pref !== 'noPrefsOrContent') {
// Regardless of whether the user opted // Regardless of whether the user opted
// to remember the choice (and move to a URL which won't // to remember the choice (and move to a URL which won't
@ -263,7 +260,7 @@ export default {
// the user does indicate a wish to store their info, we // the user does indicate a wish to store their info, we
// don't want ask them again upon page refresh so move // don't want ask them again upon page refresh so move
// them instead to a URL which does not always prompt // them instead to a URL which does not always prompt
if (storagePrompt === 'true' && checked) { if (storagePrompt === 'true' /* && checked */) {
replaceStoragePrompt(); replaceStoragePrompt();
return; return;
} }
@ -274,19 +271,13 @@ export default {
) { ) {
emptyStorage(); emptyStorage();
} }
if (pref && checked) { if (pref /* && checked */) {
// Open a URL which won't set storage and won't prompt user about storage // Open a URL which won't set storage and won't prompt user about storage
replaceStoragePrompt('false'); replaceStoragePrompt('false');
return; return;
} }
} }
// Reset width/height of dialog (e.g., for use by Export)
$('#dialog_container')[0].style.width = oldContainerWidth;
$('#dialog_container')[0].style.marginLeft = oldContainerMarginLeft;
$('#dialog_content')[0].style.height = oldContentHeight;
$('#dialog_container')[0].style.height = oldContainerHeight;
// It should be enough to (conditionally) add to storage on // It should be enough to (conditionally) add to storage on
// beforeunload, but if we wished to update immediately, // beforeunload, but if we wished to update immediately,
// we might wish to try setting: // we might wish to try setting:

View File

@ -63,7 +63,8 @@ export default {
} */ } */
break; break;
case 'save-end': case 'save-end':
$.alert(`save complete for pathID ${pathID}!`); // eslint-disable-next-line no-alert
alert(`save complete for pathID ${pathID}!`);
break; break;
default: default:
throw new Error('Unexpected WebAppFind event type'); throw new Error('Unexpected WebAppFind event type');

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -74,7 +74,7 @@
<div id="sidepanel_handle" title="Drag left/right to resize side panel [X]">L a y e r s <div id="sidepanel_handle" title="Drag left/right to resize side panel [X]">L a y e r s
</div> </div>
</div> </div>
<se-menu id="main_button" label="SVG-Edit" src="./images/logo.svg"> <se-menu id="main_button" label="SVG-Edit" src="./images/logo.svg" alt="logo">
<!-- File-like buttons: New, Save, Source --> <!-- File-like buttons: New, Save, Source -->
<se-menu-item id="tool_clear" label="New Image" shortcut="N" src="./images/new.svg"></se-menu-item> <se-menu-item id="tool_clear" label="New Image" shortcut="N" src="./images/new.svg"></se-menu-item>
<se-menu-item id="tool_open" label="Open SVG" src="./images/open.svg"></se-menu-item> <se-menu-item id="tool_open" label="Open SVG" src="./images/open.svg"></se-menu-item>
@ -86,7 +86,7 @@
<se-menu-item id="tool_editor_homepage" label="SVG-Edit Home Page" src="./images/svg-edit-home.svg"></se-menu-item> <se-menu-item id="tool_editor_homepage" label="SVG-Edit Home Page" src="./images/svg-edit-home.svg"></se-menu-item>
<div style="width:50%;margin:auto;"> <div style="width:50%;margin:auto;">
<a href="https://www.netlify.com"> <a href="https://www.netlify.com">
<img style="height:25px;" src="https://www.netlify.com/img/global/badges/netlify-dark.svg" <img style="height:25px;" src="./images/netlify-dark.svg"
alt="Deploys by Netlify" /> alt="Deploys by Netlify" />
</a> </a>
</div> </div>

View File

@ -1,4 +1,5 @@
/* globals jQuery */ /* eslint-disable no-alert */
/* globals jQuery seSelect */
/** /**
* The main module for the visual SVG Editor. * The main module for the visual SVG Editor.
* *
@ -24,11 +25,7 @@ import {
} from './contextmenu.js'; } from './contextmenu.js';
import SvgCanvas from '../svgcanvas/svgcanvas.js'; import SvgCanvas from '../svgcanvas/svgcanvas.js';
import jQueryPluginJSHotkeys from './js-hotkeys/jquery.hotkeys.min.js'; import jQueryPluginJSHotkeys from './js-hotkeys/jquery.hotkeys.min.js';
import jQueryPluginContextMenu from './contextmenu/jQuery.contextMenu.js';
import jQueryPluginDBox from '../svgcanvas/dbox.js';
import ConfigObj from './ConfigObj.js'; import ConfigObj from './ConfigObj.js';
import LayersPanel from './LayersPanel.js'; import LayersPanel from './LayersPanel.js';
@ -69,8 +66,8 @@ const editor = {
setStrings setStrings
}; };
const $ = [jQueryPluginJSHotkeys, jQueryPluginContextMenu].reduce((jq, func) => func(jq), jQuery); // JFH hotkey is used for text input.
const $ = [jQueryPluginJSHotkeys].reduce((jq, func) => func(jq), jQuery);
const homePage = 'https://github.com/SVG-Edit/svgedit'; const homePage = 'https://github.com/SVG-Edit/svgedit';
const callbacks = []; const callbacks = [];
@ -97,7 +94,6 @@ let svgCanvas,
const loadSvgString = (str, {noAlert} = {}) => { const loadSvgString = (str, {noAlert} = {}) => {
const success = svgCanvas.setSvgString(str) !== false; const success = svgCanvas.setSvgString(str) !== false;
if (success) return; if (success) return;
// eslint-disable-next-line no-alert
if (!noAlert) window.alert(uiStrings.notification.errorLoadingSVG); if (!noAlert) window.alert(uiStrings.notification.errorLoadingSVG);
throw new Error('Error loading SVG'); throw new Error('Error loading SVG');
}; };
@ -260,9 +256,6 @@ editor.init = () => {
const {langParam, langData} = await editor.putLocale(editor.pref('lang'), goodLangs); const {langParam, langData} = await editor.putLocale(editor.pref('lang'), goodLangs);
await setLang(langParam, langData); await setLang(langParam, langData);
const {ok, cancel} = uiStrings.common;
jQueryPluginDBox($, {ok, cancel});
$id('svg_container').style.visibility = 'visible'; $id('svg_container').style.visibility = 'visible';
try { try {
@ -718,7 +711,7 @@ editor.init = () => {
editor.pref('save_notice_done', 'all'); editor.pref('save_notice_done', 'all');
} }
if (done !== 'part') { if (done !== 'part') {
$.alert(note); alert(note);
} }
} }
}; };
@ -735,7 +728,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) {
/* await */ $.alert(uiStrings.notification.popupWindowBlocked); alert(uiStrings.notification.popupWindowBlocked);
return; return;
} }
@ -852,12 +845,12 @@ editor.init = () => {
/** /**
* @param {PlainObject} [opts={}] * @param {PlainObject} [opts={}]
* @param {boolean} [opts.cancelDeletes=false] * @param {boolean} [opts.cancelDeletes=false]
* @returns {Promise<void>} Resolves to `undefined` * @returns {void} Resolves to `undefined`
*/ */
async function promptImgURL ({cancelDeletes = false} = {}) { function promptImgURL ({cancelDeletes = false} = {}) {
let curhref = svgCanvas.getHref(selectedElement); let curhref = svgCanvas.getHref(selectedElement);
curhref = curhref.startsWith('data:') ? '' : curhref; curhref = curhref.startsWith('data:') ? '' : curhref;
const url = await $.prompt(uiStrings.notification.enterNewImgURL, curhref); const url = prompt(uiStrings.notification.enterNewImgURL, curhref);
if (url) { if (url) {
setImageURL(url); setImageURL(url);
} else if (cancelDeletes) { } else if (cancelDeletes) {
@ -1514,15 +1507,6 @@ editor.init = () => {
updateTitle(); updateTitle();
}; };
/**
* Makes sure the current selected paint is available to work with.
* @returns {void}
*/
const prepPaints = () => {
$id('fill_color').prep();
$id('stroke_color').prep();
};
/** /**
* @param {external:Window} win * @param {external:Window} win
* @param {module:svgcanvas.SvgCanvas#event:extension_added} ext * @param {module:svgcanvas.SvgCanvas#event:extension_added} ext
@ -1666,7 +1650,7 @@ editor.init = () => {
exportWindow = window.open('', exportWindowName); // A hack to get the window via JSON-able name without opening a new one exportWindow = window.open('', exportWindowName); // A hack to get the window via JSON-able name without opening a new one
} }
if (!exportWindow || exportWindow.closed) { if (!exportWindow || exportWindow.closed) {
/* await */ $.alert(uiStrings.notification.popupWindowBlocked); alert(uiStrings.notification.popupWindowBlocked);
return; return;
} }
exportWindow.location.href = data.output; exportWindow.location.href = data.output;
@ -1772,7 +1756,7 @@ editor.init = () => {
// fired when user wants to move elements to another layer // fired when user wants to move elements to another layer
let promptMoveLayerOnce = false; let promptMoveLayerOnce = false;
$('#selLayerNames').change(async (evt) => { $('#selLayerNames').change((evt) => {
const destLayer = evt.currentTarget.options[evt.currentTarget.selectedIndex].value; const destLayer = evt.currentTarget.options[evt.currentTarget.selectedIndex].value;
const confirmStr = uiStrings.notification.QmoveElemsToLayer.replace('%s', destLayer); const confirmStr = uiStrings.notification.QmoveElemsToLayer.replace('%s', destLayer);
/** /**
@ -1790,7 +1774,7 @@ editor.init = () => {
if (promptMoveLayerOnce) { if (promptMoveLayerOnce) {
moveToLayer(true); moveToLayer(true);
} else { } else {
const ok = await $.confirm(confirmStr); const ok = confirm(confirmStr);
if (!ok) { if (!ok) {
return; return;
} }
@ -1834,7 +1818,7 @@ editor.init = () => {
if (!valid) { if (!valid) {
e.target.value = selectedElement.getAttribute(attr); e.target.value = selectedElement.getAttribute(attr);
/* await */ $.alert(uiStrings.notification.invalidAttrValGiven); alert(uiStrings.notification.invalidAttrValGiven);
return false; return false;
} }
@ -1872,7 +1856,7 @@ editor.init = () => {
if (!valid) { if (!valid) {
evt.currentTarget.value = selectedElement.getAttribute(attr); evt.currentTarget.value = selectedElement.getAttribute(attr);
/* await */ $.alert(uiStrings.notification.invalidAttrValGiven); alert(uiStrings.notification.invalidAttrValGiven);
return false; return false;
} }
@ -2403,11 +2387,11 @@ editor.init = () => {
/** /**
* *
* @returns {Promise<void>} Resolves to `undefined` * @returns {void} Resolves to `undefined`
*/ */
const makeHyperlink = async () => { const makeHyperlink = () => {
if (!isNullish(selectedElement) || multiselected) { if (!isNullish(selectedElement) || multiselected) {
const url = await $.prompt(uiStrings.notification.enterNewLinkURL, 'http://'); const url = prompt(uiStrings.notification.enterNewLinkURL, 'http://');
if (url) { if (url) {
svgCanvas.makeHyperlink(url); svgCanvas.makeHyperlink(url);
} }
@ -2512,11 +2496,11 @@ editor.init = () => {
/** /**
* @fires module:svgcanvas.SvgCanvas#event:ext_onNewDocument * @fires module:svgcanvas.SvgCanvas#event:ext_onNewDocument
* @returns {Promise<void>} Resolves to `undefined` * @returns {void}
*/ */
const clickClear = async () => { const clickClear = () => {
const [x, y] = configObj.curConfig.dimensions; const [x, y] = configObj.curConfig.dimensions;
const ok = await $.confirm(uiStrings.notification.QwantToClear); const ok = confirm(uiStrings.notification.QwantToClear);
if (!ok) { if (!ok) {
return; return;
} }
@ -2527,7 +2511,6 @@ editor.init = () => {
zoomImage(); zoomImage();
layersPanel.populateLayers(); layersPanel.populateLayers();
updateContextPanel(); updateContextPanel();
prepPaints();
svgCanvas.runExtensions('onNewDocument'); svgCanvas.runExtensions('onNewDocument');
}; };
@ -2581,24 +2564,13 @@ editor.init = () => {
* @returns {Promise<void>} Resolves to `undefined` * @returns {Promise<void>} Resolves to `undefined`
*/ */
const clickExport = async () => { const clickExport = async () => {
const imgType = await $.select('Select an image type for export: ', [ const imgType = await seSelect('Select an image type for export: ', [
// See http://kangax.github.io/jstests/toDataUrl_mime_type_test/ for a useful list of MIME types and browser support // See http://kangax.github.io/jstests/toDataUrl_mime_type_test/ for a useful list of MIME types and browser support
// 'ICO', // Todo: Find a way to preserve transparency in SVG-Edit if not working presently and do full packaging for x-icon; then switch back to position after 'PNG' // 'ICO', // Todo: Find a way to preserve transparency in SVG-Edit if not working presently and do full packaging for x-icon; then switch back to position after 'PNG'
'PNG', 'PNG',
'JPEG', 'BMP', 'WEBP', 'PDF' 'JPEG', 'BMP', 'WEBP', 'PDF'
], () => { ]);
const sel = $(this);
if (sel.val() === 'JPEG' || sel.val() === 'WEBP') {
if (!$('#image-slider').length) {
$(`<div><label>${uiStrings.ui.quality}
<input id="image-slider"
type="range" min="1" max="100" value="92" />
</label></div>`).appendTo(sel.parent());
}
} else {
$('#image-slider').parent().remove();
}
}); // todo: replace hard-coded msg with uiStrings.notification.
if (!imgType) { if (!imgType) {
return; return;
} }
@ -2646,7 +2618,7 @@ editor.init = () => {
if (!customExportImage) { if (!customExportImage) {
openExportWindow(); openExportWindow();
} }
const quality = Number.parseInt($('#image-slider').val()) / 100; const quality = 1; // JFH !!! Number.parseInt($('#image-slider').val()) / 100;
/* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName); /* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName);
} }
}; };
@ -2824,9 +2796,9 @@ editor.init = () => {
/** /**
* @param {Event} e * @param {Event} e
* @returns {Promise<void>} Resolves to `undefined` * @returns {void} Resolves to `undefined`
*/ */
const saveSourceEditor = async (e) => { const saveSourceEditor = (e) => {
if (!editingsource) { return; } if (!editingsource) { return; }
const saveChanges = () => { const saveChanges = () => {
svgCanvas.clearSelection(); svgCanvas.clearSelection();
@ -2834,11 +2806,10 @@ editor.init = () => {
zoomImage(); zoomImage();
layersPanel.populateLayers(); layersPanel.populateLayers();
updateTitle(); updateTitle();
prepPaints();
}; };
if (!svgCanvas.setSvgString(e.detail.value)) { if (!svgCanvas.setSvgString(e.detail.value)) {
const ok = await $.confirm(uiStrings.notification.QerrorsRevertToSource); const ok = confirm(uiStrings.notification.QerrorsRevertToSource);
if (!ok) { if (!ok) {
return; return;
} }
@ -2881,15 +2852,15 @@ editor.init = () => {
svgCanvas.setDocumentTitle(title); svgCanvas.setDocumentTitle(title);
if (w !== 'fit' && !isValidUnit('width', w)) { if (w !== 'fit' && !isValidUnit('width', w)) {
/* await */ $.alert(uiStrings.notification.invalidAttrValGiven); alert(uiStrings.notification.invalidAttrValGiven);
return false; return false;
} }
if (h !== 'fit' && !isValidUnit('height', h)) { if (h !== 'fit' && !isValidUnit('height', h)) {
/* await */ $.alert(uiStrings.notification.invalidAttrValGiven); alert(uiStrings.notification.invalidAttrValGiven);
return false; return false;
} }
if (!svgCanvas.setResolution(w, h)) { if (!svgCanvas.setResolution(w, h)) {
/* await */ $.alert(uiStrings.notification.noContentToFitTo); alert(uiStrings.notification.noContentToFitTo);
return false; return false;
} }
// Set image save option // Set image save option
@ -2933,9 +2904,9 @@ editor.init = () => {
/** /**
* @param {Event} e * @param {Event} e
* @returns {Promise<void>} Resolves to `undefined` * @returns {void} Resolves to `undefined`
*/ */
const cancelOverlays = async (e) => { const cancelOverlays = (e) => {
$('#dialog_box').hide(); $('#dialog_box').hide();
if (!editingsource && !docprops && !preferences) { if (!editingsource && !docprops && !preferences) {
if (curContext) { if (curContext) {
@ -2946,7 +2917,7 @@ editor.init = () => {
if (editingsource) { if (editingsource) {
if (origSource !== e.detail.value) { if (origSource !== e.detail.value) {
const ok = await $.confirm(uiStrings.notification.QignoreSourceChanges); const ok = confirm(uiStrings.notification.QignoreSourceChanges);
if (ok) { if (ok) {
hideSourceEditor(); hideSourceEditor();
} }
@ -2977,7 +2948,7 @@ editor.init = () => {
}); });
$('#url_notice').click(() => { $('#url_notice').click(() => {
/* await */ $.alert(this.title); alert(this.title);
}); });
$('#change_image_url').click(promptImgURL); $('#change_image_url').click(promptImgURL);
@ -3571,7 +3542,7 @@ editor.init = () => {
if (undoMgr.getUndoStackSize() === 0) { if (undoMgr.getUndoStackSize() === 0) {
return true; return true;
} }
return $.confirm(uiStrings.notification.QwantToOpen); return confirm(uiStrings.notification.QwantToOpen);
}; };
/** /**
@ -3883,7 +3854,7 @@ editor.loadFromURL = function (url, {cache, noAlert} = {}) {
reject(new Error('URLLoadFail')); reject(new Error('URLLoadFail'));
return; return;
} }
$.alert(uiStrings.notification.URLLoadFail + ': \n' + err); alert(uiStrings.notification.URLLoadFail + ': \n' + err);
resolve(); resolve();
}, },
complete () { complete () {

View File

@ -5,7 +5,7 @@
* @license MIT * @license MIT
* @copyright 2011 Jeff Schiller * @copyright 2011 Jeff Schiller
*/ */
import jQueryPluginSVG from '../common/jQuery.attr.js'; import jQueryPluginSVG from './jQuery.attr.js';
import {NS} from '../common/namespaces.js'; import {NS} from '../common/namespaces.js';
const $ = jQueryPluginSVG(jQuery); const $ = jQueryPluginSVG(jQuery);

View File

@ -1,6 +1,6 @@
/* globals jQuery */ /* globals jQuery */
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr` import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import {isWebkit} from '../common/browser.js'; import {isWebkit} from '../common/browser.js';
import {convertPath} from './path.js'; import {convertPath} from './path.js';
import {preventClickDefault} from './utilities.js'; import {preventClickDefault} from './utilities.js';

View File

@ -1,178 +0,0 @@
/**
* @module jQueryPluginDBox
*/
/**
* @param {external:jQuery} $
* @param {PlainObject} [strings]
* @param {PlainObject} [strings.ok]
* @param {PlainObject} [strings.cancel]
* @returns {external:jQuery}
*/
export default function jQueryPluginDBox ($, {
ok: okString = 'Ok',
cancel: cancelString = 'Cancel'
} = {}) {
// This sets up alternative dialog boxes. They mostly work the same way as
// their UI counterparts, expect instead of returning the result, a callback
// needs to be included that returns the result as its first parameter.
// In the future we may want to add additional types of dialog boxes, since
// they should be easy to handle this way.
$('#dialog_container').draggable({
cancel: '#dialog_content, #dialog_buttons *',
containment: 'window'
}).css('position', 'absolute');
const box = $('#dialog_box'),
btnHolder = $('#dialog_buttons'),
dialogContent = $('#dialog_content');
/**
* @typedef {PlainObject} module:jQueryPluginDBox.PromiseResultObject
* @property {string|true} response
* @property {boolean} checked
*/
/**
* Resolves to `false` (if cancelled), for prompts and selects
* without checkboxes, it resolves to the value of the form control. For other
* types without checkboxes, it resolves to `true`. For checkboxes, it resolves
* to an object with the `response` key containing the same value as the previous
* mentioned (string or `true`) and a `checked` (boolean) property.
* @typedef {Promise<boolean|string|module:jQueryPluginDBox.PromiseResultObject>} module:jQueryPluginDBox.ResultPromise
*/
/**
* @typedef {PlainObject} module:jQueryPluginDBox.SelectOption
* @property {string} text
* @property {string} value
*/
/**
* @typedef {PlainObject} module:jQueryPluginDBox.CheckboxInfo
* @property {string} label Label for the checkbox
* @property {string} value Value of the checkbox
* @property {string} tooltip Tooltip on the checkbox label
* @property {boolean} checked Whether the checkbox is checked by default
*/
/**
* Triggered upon a change of value for the select pull-down.
* @callback module:jQueryPluginDBox.SelectChangeListener
* @returns {void}
*/
/**
* Creates a dialog of the specified type with a given message
* and any defaults and type-specific metadata. Returns a `Promise`
* which resolves differently depending on whether the dialog
* was cancelled or okayed (with the response and any checked state).
* @param {"alert"|"prompt"|"select"|"process"} type
* @param {string} msg
* @param {string} [defaultVal]
* @param {module:jQueryPluginDBox.SelectOption[]} [opts]
* @param {module:jQueryPluginDBox.SelectChangeListener} [changeListener]
* @param {module:jQueryPluginDBox.CheckboxInfo} [checkbox]
* @returns {jQueryPluginDBox.ResultPromise}
*/
function dbox (type, msg, defaultVal, opts, changeListener, checkbox) {
dialogContent.html('<p>' + msg.replace(/\n/g, '</p><p>') + '</p>')
.toggleClass('prompt', (type === 'prompt'));
btnHolder.empty();
const ok = $('<input type="button" data-ok="" value="' + okString + '">').appendTo(btnHolder);
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
if (type !== 'alert') {
$('<input type="button" value="' + cancelString + '">')
.appendTo(btnHolder)
.click(function () {
box.hide();
resolve(false);
});
}
let ctrl, chkbx;
if (type === 'prompt') {
ctrl = $('<input type="text">').prependTo(btnHolder);
ctrl.val(defaultVal || '');
ctrl.bind('keydown', 'return', function () { ok.click(); });
} else if (type === 'select') {
const div = $('<div style="text-align:center;">');
ctrl = $(`<select aria-label="${msg}">`).appendTo(div);
if (checkbox) {
const label = $('<label>').text(checkbox.label);
chkbx = $('<input type="checkbox">').appendTo(label);
chkbx.val(checkbox.value);
if (checkbox.tooltip) {
label.attr('title', checkbox.tooltip);
}
chkbx.prop('checked', Boolean(checkbox.checked));
div.append($('<div>').append(label));
}
$.each(opts || [], function (opt, val) {
if (typeof val === 'object') {
ctrl.append($('<option>').val(val.value).html(val.text));
} else {
ctrl.append($('<option>').html(val));
}
});
dialogContent.append(div);
if (defaultVal) {
ctrl.val(defaultVal);
}
if (changeListener) {
ctrl.bind('change', 'return', changeListener);
}
ctrl.bind('keydown', 'return', function () { ok.click(); });
} else if (type === 'process') {
ok.hide();
}
box.show();
ok.click(function () {
box.hide();
const response = (type === 'prompt' || type === 'select') ? ctrl.val() : true;
if (chkbx) {
resolve({response, checked: chkbx.prop('checked')});
return;
}
resolve(response);
}).focus();
if (type === 'prompt' || type === 'select') {
ctrl.focus();
}
});
}
/**
* @param {string} msg Message to alert
* @returns {jQueryPluginDBox.ResultPromise}
*/
$.alert = function (msg) {
return dbox('alert', msg);
};
/**
* @param {string} msg Message for which to ask confirmation
* @returns {jQueryPluginDBox.ResultPromise}
*/
$.confirm = function (msg) {
return dbox('confirm', msg);
};
/**
* @param {string} msg Message to indicate upon cancelable indicator
* @returns {jQueryPluginDBox.ResultPromise}
*/
$.process_cancel = function (msg) {
return dbox('process', msg);
};
/**
* @param {string} msg Message to accompany the prompt
* @param {string} [defaultText=""] The default text to show for the prompt
* @returns {jQueryPluginDBox.ResultPromise}
*/
$.prompt = function (msg, defaultText = '') {
return dbox('prompt', msg, defaultText);
};
$.select = function (msg, opts, changeListener, txt, checkbox) {
return dbox('select', msg, txt, opts, changeListener, checkbox);
};
return $;
}

View File

@ -6,7 +6,7 @@
*/ */
import * as hstry from './history.js'; import * as hstry from './history.js';
import jQueryPluginSVG from '../common/jQuery.attr.js'; import jQueryPluginSVG from './jQuery.attr.js';
import {NS} from '../common/namespaces.js'; import {NS} from '../common/namespaces.js';
import { import {
getVisibleElements, getStrokedBBoxDefaultVisible, findDefs, getVisibleElements, getStrokedBBoxDefaultVisible, findDefs,

View File

@ -5,7 +5,7 @@
* @license MIT * @license MIT
* @copyright 2011 Jeff Schiller * @copyright 2011 Jeff Schiller
*/ */
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute
import { import {
assignAttributes, cleanupElement, getElem, getRotationAngle, snapToGrid, walkTree, assignAttributes, cleanupElement, getElem, getRotationAngle, snapToGrid, walkTree,
getBBox as utilsGetBBox, isNullish, preventClickDefault, setHref getBBox as utilsGetBBox, isNullish, preventClickDefault, setHref

View File

@ -1,6 +1,6 @@
/* globals jQuery */ /* globals jQuery */
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr` import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import { import {
getStrokedBBoxDefaultVisible getStrokedBBoxDefaultVisible
} from './utilities.js'; } from './utilities.js';

View File

@ -5,7 +5,7 @@
* @license MIT * @license MIT
*/ */
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr` import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import {NS} from '../common/namespaces.js'; import {NS} from '../common/namespaces.js';
import {convertToNum} from '../common/units.js'; import {convertToNum} from '../common/units.js';
import {isWebkit} from '../common/browser.js'; import {isWebkit} from '../common/browser.js';

View File

@ -6,7 +6,7 @@
* *
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/ */
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute
import {NS} from '../common/namespaces.js'; import {NS} from '../common/namespaces.js';
import * as hstry from './history.js'; import * as hstry from './history.js';
import * as pathModule from './path.js'; import * as pathModule from './path.js';

View File

@ -11,7 +11,7 @@ import {
isNullish, getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible isNullish, getBBox as utilsGetBBox, getStrokedBBoxDefaultVisible
} from './utilities.js'; } from './utilities.js';
import {transformPoint, transformListToTransform, rectsIntersect} from './math.js'; import {transformPoint, transformListToTransform, rectsIntersect} from './math.js';
import jQueryPluginSVG from '../common/jQuery.attr.js'; import jQueryPluginSVG from './jQuery.attr.js';
import { import {
getTransformList getTransformList
} from './svgtransformlist.js'; } from './svgtransformlist.js';

View File

@ -8,7 +8,7 @@
import {jsPDF} from 'jspdf/dist/jspdf.es.min.js'; import {jsPDF} from 'jspdf/dist/jspdf.es.min.js';
import 'svg2pdf.js/dist/svg2pdf.es.js'; import 'svg2pdf.js/dist/svg2pdf.es.js';
import jQueryPluginSVG from '../common/jQuery.attr.js'; import jQueryPluginSVG from './jQuery.attr.js';
import * as hstry from './history.js'; import * as hstry from './history.js';
import { import {
text2xml, cleanupElement, findDefs, getHref, preventClickDefault, text2xml, cleanupElement, findDefs, getHref, preventClickDefault,

View File

@ -17,8 +17,7 @@
import {Canvg as canvg} from 'canvg'; import {Canvg as canvg} from 'canvg';
import 'pathseg'; import 'pathseg';
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr` import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import jQueryPluginDBox from './dbox.js';
import * as pathModule from './path.js'; import * as pathModule from './path.js';
import * as hstry from './history.js'; import * as hstry from './history.js';
@ -117,7 +116,7 @@ import {
init as clearInit init as clearInit
} from './clear.js'; } from './clear.js';
let $ = jQueryPluginSVG(jQuery); const $ = jQueryPluginSVG(jQuery);
const { const {
MoveElementCommand, InsertElementCommand, RemoveElementCommand, MoveElementCommand, InsertElementCommand, RemoveElementCommand,
ChangeElementCommand, BatchCommand ChangeElementCommand, BatchCommand
@ -1741,7 +1740,6 @@ class SvgCanvas {
*/ */
this.setUiStrings = function (strs) { this.setUiStrings = function (strs) {
Object.assign(uiStrings, strs.notification); Object.assign(uiStrings, strs.notification);
$ = jQueryPluginDBox($, strs.common);
pathModule.setUiStrings(strs); pathModule.setUiStrings(strs);
}; };

View File

@ -6,7 +6,7 @@
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/ */
import jQueryPluginSVG from '../common/jQuery.attr.js'; import jQueryPluginSVG from './jQuery.attr.js';
import {NS} from '../common/namespaces.js'; import {NS} from '../common/namespaces.js';
import { import {
transformPoint, getMatrix transformPoint, getMatrix
@ -263,15 +263,6 @@ export const textActionsMethod = (function () {
return out; return out;
} }
/*
// Not currently in use
function hideCursor () {
if (cursor) {
cursor.setAttribute('visibility', 'hidden');
}
}
*/
/** /**
* *
* @param {Event} evt * @param {Event} evt

View File

@ -7,7 +7,7 @@
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller * @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/ */
import jQueryPluginSVG from '../common/jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr` import jQueryPluginSVG from './jQuery.attr.js'; // Needed for SVG attribute setting and array form with `attr`
import {NS} from '../common/namespaces.js'; import {NS} from '../common/namespaces.js';
import {getTransformList} from './svgtransformlist.js'; import {getTransformList} from './svgtransformlist.js';
import {setUnitAttr, getTypeMap} from '../common/units.js'; import {setUnitAttr, getTypeMap} from '../common/units.js';