- Refactoring (minor): Array destructuring

- Refactoring (minor): ES6 templates
- i18n: picking stroke/fill paint and opacity
master
Brett Zamir 2018-07-25 16:43:29 -07:00
parent 5d0dd85507
commit a68696ee34
2 changed files with 22 additions and 8 deletions

View File

@ -23,7 +23,9 @@ export default {
panel_drag: 'Drag left/right to resize side panel', panel_drag: 'Drag left/right to resize side panel',
quality: 'Quality:', quality: 'Quality:',
pathNodeTooltip: 'Drag node to move it. Double-click node to change segment type', pathNodeTooltip: 'Drag node to move it. Double-click node to change segment type',
pathCtrlPtTooltip: 'Drag control point to adjust curve properties' pathCtrlPtTooltip: 'Drag control point to adjust curve properties',
pick_stroke_paint_opacity: 'Pick a Stroke Paint and Opacity',
pick_fill_paint_opacity: 'Pick a Fill Paint and Opacity'
}, },
properties: { properties: {
id: 'id', id: 'id',

View File

@ -4074,12 +4074,12 @@ editor.init = function () {
* @returns {undefined} * @returns {undefined}
*/ */
const clickClear = function () { const clickClear = function () {
const dims = curConfig.dimensions; const [x, y] = curConfig.dimensions;
$.confirm(uiStrings.notification.QwantToClear, function (ok) { $.confirm(uiStrings.notification.QwantToClear, function (ok) {
if (!ok) { return; } if (!ok) { return; }
setSelectMode(); setSelectMode();
svgCanvas.clear(); svgCanvas.clear();
svgCanvas.setResolution(dims[0], dims[1]); svgCanvas.setResolution(x, y);
updateCanvas(true); updateCanvas(true);
zoomImage(); zoomImage();
populateLayers(); populateLayers();
@ -4133,7 +4133,13 @@ editor.init = function () {
if (loadingURL) { if (loadingURL) {
popURL = loadingURL; popURL = loadingURL;
} else { } else {
popHTML = '<!DOCTYPE html><html><head><meta charset="utf-8"><title>' + str + '</title></head><body><h1>' + str + '</h1></body><html>'; popHTML = `<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>${str}</title>
</head>
<body><h1>${str}</h1></body>
<html>`;
if (typeof URL && URL.createObjectURL) { if (typeof URL && URL.createObjectURL) {
const blob = new Blob([popHTML], {type: 'text/html'}); const blob = new Blob([popHTML], {type: 'text/html'});
popURL = URL.createObjectURL(blob); popURL = URL.createObjectURL(blob);
@ -4534,7 +4540,9 @@ editor.init = function () {
const colorPicker = function (elem) { const colorPicker = function (elem) {
const picker = elem.attr('id') === 'stroke_color' ? 'stroke' : 'fill'; const picker = elem.attr('id') === 'stroke_color' ? 'stroke' : 'fill';
// const opacity = (picker == 'stroke' ? $('#stroke_opacity') : $('#fill_opacity')); // const opacity = (picker == 'stroke' ? $('#stroke_opacity') : $('#fill_opacity'));
const title = (picker === 'stroke' ? 'Pick a Stroke Paint and Opacity' : 'Pick a Fill Paint and Opacity'); const title = picker === 'stroke'
? uiStrings.ui.pick_stroke_paint_opacity
: uiStrings.ui.pick_fill_paint_opacity;
// let wasNone = false; // Currently unused // let wasNone = false; // Currently unused
const pos = elem.offset(); const pos = elem.offset();
let {paint} = paintBox[picker]; let {paint} = paintBox[picker];
@ -4568,9 +4576,13 @@ editor.init = function () {
const cur = curConfig[type === 'fill' ? 'initFill' : 'initStroke']; const cur = curConfig[type === 'fill' ? 'initFill' : 'initStroke'];
// set up gradients to be used for the buttons // set up gradients to be used for the buttons
const svgdocbox = new DOMParser().parseFromString( const svgdocbox = new DOMParser().parseFromString(
'<svg xmlns="http://www.w3.org/2000/svg"><rect width="16.5" height="16.5"' + `<svg xmlns="http://www.w3.org/2000/svg">
' fill="#' + cur.color + '" opacity="' + cur.opacity + '"/>' + <rect width="16.5" height="16.5"
' <defs><linearGradient id="gradbox_"/></defs></svg>', 'text/xml'); fill="#${cur.color}" opacity="${cur.opacity}"/>
<defs><linearGradient id="gradbox_"/></defs>
</svg>`,
'text/xml'
);
let docElem = svgdocbox.documentElement; let docElem = svgdocbox.documentElement;
docElem = $(container)[0].appendChild(document.importNode(docElem, true)); docElem = $(container)[0].appendChild(document.importNode(docElem, true));