eslint rule for declarations
This commit is contained in:
@@ -453,8 +453,8 @@ class Editor extends EditorStartup {
|
||||
const wArea = this.workarea;
|
||||
const cnvs = $id("svgcanvas");
|
||||
|
||||
let w = parseFloat(getComputedStyle(this.workarea, null).width.replace("px", "")), h = parseFloat(getComputedStyle(this.workarea, null).height.replace("px", ""));
|
||||
const wOrig = w, hOrig = h;
|
||||
let w = parseFloat(getComputedStyle(this.workarea, null).width.replace("px", "")); let h = parseFloat(getComputedStyle(this.workarea, null).height.replace("px", ""));
|
||||
const wOrig = w; const hOrig = h;
|
||||
const oldCtr = {
|
||||
x: wArea.scrollLeft + wOrig / 2,
|
||||
y: wArea.scrollTop + hOrig / 2
|
||||
@@ -700,12 +700,12 @@ class Editor extends EditorStartup {
|
||||
* @returns {void}
|
||||
*/
|
||||
zoomChanged(win, bbox, autoCenter) {
|
||||
const scrbar = 15,
|
||||
wArea = this.workarea;
|
||||
const scrbar = 15;
|
||||
const wArea = this.workarea;
|
||||
const zInfo = this.svgCanvas.setBBoxZoom(bbox, parseFloat(getComputedStyle(wArea, null).width.replace("px", "")) - scrbar, parseFloat(getComputedStyle(wArea, null).height.replace("px", "")) - scrbar);
|
||||
if (!zInfo) { return; }
|
||||
const zoomlevel = zInfo.zoom,
|
||||
bb = zInfo.bbox;
|
||||
const zoomlevel = zInfo.zoom;
|
||||
const bb = zInfo.bbox;
|
||||
|
||||
if (zoomlevel < 0.001) {
|
||||
this.changeZoom(0.1);
|
||||
|
||||
@@ -282,8 +282,8 @@ class EditorStartup {
|
||||
|
||||
const wArea = this.workarea;
|
||||
|
||||
let lastX = null, lastY = null,
|
||||
panning = false, keypan = false;
|
||||
let lastX = null; let lastY = null;
|
||||
let panning = false; let keypan = false;
|
||||
|
||||
$id('svgcanvas').addEventListener('mouseup', function(evt) {
|
||||
if (panning === false) { return true; }
|
||||
|
||||
@@ -168,7 +168,7 @@ class MainMenu {
|
||||
}
|
||||
this.editor.exportWindowName =
|
||||
this.editor.configObj.curConfig.canvasName + this.editor.exportWindowCt;
|
||||
let popHTML, popURL;
|
||||
let popHTML; let popURL;
|
||||
if (this.editor.loadingURL) {
|
||||
popURL = this.editor.loadingURL;
|
||||
} else {
|
||||
|
||||
@@ -40,7 +40,7 @@ class Rulers {
|
||||
if (!zoom) { zoom = this.svgCanvas.getZoom(); }
|
||||
if (!scanvas) { scanvas = document.getElementById('svgcanvas'); }
|
||||
|
||||
let d, i;
|
||||
let d; let i;
|
||||
const limit = 30000;
|
||||
const contentElem = this.svgCanvas.getContentElem();
|
||||
const units = getTypeMap();
|
||||
@@ -72,7 +72,7 @@ class Rulers {
|
||||
const totalLen = rulerLen;
|
||||
hcanv.parentNode.style[lentype] = totalLen + 'px';
|
||||
let ctx = hcanv.getContext('2d');
|
||||
let ctxArr, num, ctxArrNum;
|
||||
let ctxArr; let num; let ctxArrNum;
|
||||
|
||||
ctx.fillStyle = 'rgb(200,0,0)';
|
||||
ctx.fillRect(0, 0, hcanv.width, hcanv.height);
|
||||
|
||||
@@ -340,15 +340,15 @@ export default class ColorValuePicker {
|
||||
ahex = null;
|
||||
}
|
||||
let
|
||||
red = inputs[3],
|
||||
green = inputs[4],
|
||||
blue = inputs[5],
|
||||
alpha = inputs.length > 7 ? inputs[6] : null,
|
||||
hue = inputs[0],
|
||||
saturation = inputs[1],
|
||||
value = inputs[2],
|
||||
hex = inputs[(inputs.length > 7) ? 7 : 6],
|
||||
ahex = inputs.length > 7 ? inputs[8] : null;
|
||||
red = inputs[3];
|
||||
let green = inputs[4];
|
||||
let blue = inputs[5];
|
||||
let alpha = inputs.length > 7 ? inputs[6] : null;
|
||||
let hue = inputs[0];
|
||||
let saturation = inputs[1];
|
||||
let value = inputs[2];
|
||||
let hex = inputs[(inputs.length > 7) ? 7 : 6];
|
||||
let ahex = inputs.length > 7 ? inputs[8] : null;
|
||||
Object.assign(that, { destroy });
|
||||
red.addEventListener('keyup', keyUp);
|
||||
green.addEventListener('keyup', keyUp);
|
||||
|
||||
@@ -82,10 +82,10 @@ export default class Slider {
|
||||
* @returns {void}
|
||||
*/
|
||||
function setValuesFromMousePosition (e) {
|
||||
const barW = bar.w, // local copies for YUI compressor
|
||||
barH = bar.h;
|
||||
let locX = e.pageX - offset.l,
|
||||
locY = e.pageY - offset.t;
|
||||
const barW = bar.w; // local copies for YUI compressor
|
||||
const barH = bar.h;
|
||||
let locX = e.pageX - offset.l;
|
||||
let locY = e.pageY - offset.t;
|
||||
// keep the arrow within the bounds of the bar
|
||||
if (locX < 0) locX = 0;
|
||||
else if (locX > barW) locX = barW;
|
||||
@@ -102,12 +102,12 @@ export default class Slider {
|
||||
*/
|
||||
function draw () {
|
||||
const
|
||||
barW = bar.w,
|
||||
barH = bar.h,
|
||||
arrowW = arrow.w,
|
||||
arrowH = arrow.h;
|
||||
let arrowOffsetX = 0,
|
||||
arrowOffsetY = 0;
|
||||
barW = bar.w;
|
||||
const barH = bar.h;
|
||||
const arrowW = arrow.w;
|
||||
const arrowH = arrow.h;
|
||||
let arrowOffsetX = 0;
|
||||
let arrowOffsetY = 0;
|
||||
setTimeout(function () {
|
||||
if (rangeX > 0) { // range is greater than zero
|
||||
// constrain to bounds
|
||||
@@ -152,7 +152,7 @@ export default class Slider {
|
||||
if (!isNullish(context) && context === that) return undefined;
|
||||
let changed = false;
|
||||
|
||||
let newX, newY;
|
||||
let newX; let newY;
|
||||
if (isNullish(name)) name = 'xy';
|
||||
switch (name.toLowerCase()) {
|
||||
case 'x':
|
||||
@@ -225,10 +225,10 @@ export default class Slider {
|
||||
}
|
||||
}
|
||||
let // changed = false,
|
||||
newMinX,
|
||||
newMaxX,
|
||||
newMinY,
|
||||
newMaxY;
|
||||
newMinX;
|
||||
let newMaxX;
|
||||
let newMinY;
|
||||
let newMaxY;
|
||||
if (isNullish(name)) name = 'all';
|
||||
switch (name.toLowerCase()) {
|
||||
case 'minx':
|
||||
@@ -307,18 +307,18 @@ export default class Slider {
|
||||
arrow = null;
|
||||
changeEvents = null;
|
||||
}
|
||||
let offset,
|
||||
timeout,
|
||||
x = 0,
|
||||
y = 0,
|
||||
minX = 0,
|
||||
maxX = 100,
|
||||
rangeX = 100,
|
||||
minY = 0,
|
||||
maxY = 100,
|
||||
rangeY = 100,
|
||||
arrow = bar.querySelector('img'), // the arrow image to drag
|
||||
changeEvents = [];
|
||||
let offset;
|
||||
let timeout;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
let minX = 0;
|
||||
let maxX = 100;
|
||||
let rangeX = 100;
|
||||
let minY = 0;
|
||||
let maxY = 100;
|
||||
let rangeY = 100;
|
||||
let arrow = bar.querySelector('img'); // the arrow image to drag
|
||||
let changeEvents = [];
|
||||
Object.assign(that, {
|
||||
val,
|
||||
range,
|
||||
|
||||
@@ -46,7 +46,7 @@ export function mergeDeep(target, source) {
|
||||
export function getClosest(elem, selector) {
|
||||
const firstChar = selector.charAt(0);
|
||||
const supports = 'classList' in document.documentElement;
|
||||
let attribute, value;
|
||||
let attribute; let value;
|
||||
// If selector is a data attribute, split attribute from value
|
||||
if (firstChar === '[') {
|
||||
selector = selector.substr(1, selector.length - 2);
|
||||
|
||||
@@ -189,10 +189,10 @@ function mkElem (name, attrs, newparent) {
|
||||
* @returns {external:jQuery}
|
||||
*/
|
||||
export function jGraduateMethod (elem, options, okCallback, cancelCallback, i18next) {
|
||||
const $this = elem,
|
||||
$settings = Object.assign({}, jGraduateDefaults, options || {}),
|
||||
id = $this.getAttribute('id'),
|
||||
idref = '#' + $this.getAttribute('id') + ' ';
|
||||
const $this = elem;
|
||||
const $settings = Object.assign({}, jGraduateDefaults, options || {});
|
||||
const id = $this.getAttribute('id');
|
||||
const idref = '#' + $this.getAttribute('id') + ' ';
|
||||
|
||||
if (!idref) {
|
||||
// eslint-disable-next-line no-alert
|
||||
@@ -346,12 +346,12 @@ export function jGraduateMethod (elem, options, okCallback, cancelCallback, i18n
|
||||
/* eslint-enable max-len */
|
||||
// --------------
|
||||
// Set up all the SVG elements (the gradient, stops and rectangle)
|
||||
const MAX = 256,
|
||||
MARGINX = 0,
|
||||
MARGINY = 0,
|
||||
// STOP_RADIUS = 15 / 2,
|
||||
SIZEX = MAX - 2 * MARGINX,
|
||||
SIZEY = MAX - 2 * MARGINY;
|
||||
const MAX = 256;
|
||||
const MARGINX = 0;
|
||||
const MARGINY = 0;
|
||||
// STOP_RADIUS = 15 / 2,
|
||||
const SIZEX = MAX - 2 * MARGINX;
|
||||
const SIZEY = MAX - 2 * MARGINY;
|
||||
|
||||
const attrInput = {};
|
||||
|
||||
@@ -448,15 +448,15 @@ export function jGraduateMethod (elem, options, okCallback, cancelCallback, i18n
|
||||
}
|
||||
}
|
||||
|
||||
const x1 = Number.parseFloat(grad.getAttribute('x1') || 0.0),
|
||||
y1 = Number.parseFloat(grad.getAttribute('y1') || 0.0),
|
||||
x2 = Number.parseFloat(grad.getAttribute('x2') || 1.0),
|
||||
y2 = Number.parseFloat(grad.getAttribute('y2') || 0.0);
|
||||
const x1 = Number.parseFloat(grad.getAttribute('x1') || 0.0);
|
||||
const y1 = Number.parseFloat(grad.getAttribute('y1') || 0.0);
|
||||
const x2 = Number.parseFloat(grad.getAttribute('x2') || 1.0);
|
||||
const y2 = Number.parseFloat(grad.getAttribute('y2') || 0.0);
|
||||
|
||||
const cx = Number.parseFloat(grad.getAttribute('cx') || 0.5),
|
||||
cy = Number.parseFloat(grad.getAttribute('cy') || 0.5),
|
||||
fx = Number.parseFloat(grad.getAttribute('fx') || cx),
|
||||
fy = Number.parseFloat(grad.getAttribute('fy') || cy);
|
||||
const cx = Number.parseFloat(grad.getAttribute('cx') || 0.5);
|
||||
const cy = Number.parseFloat(grad.getAttribute('cy') || 0.5);
|
||||
const fx = Number.parseFloat(grad.getAttribute('fx') || cx);
|
||||
const fy = Number.parseFloat(grad.getAttribute('fy') || cy);
|
||||
|
||||
const previewRect = mkElem('rect', {
|
||||
id: id + '_jgraduate_rect',
|
||||
@@ -676,7 +676,7 @@ export function jGraduateMethod (elem, options, okCallback, cancelCallback, i18n
|
||||
|
||||
const stopMakerDiv = $this.querySelector('#' + id + '_jGraduate_StopSlider');
|
||||
|
||||
let stops, curStop, drag;
|
||||
let stops; let curStop; let drag;
|
||||
|
||||
const delStop = mkElem('path', {
|
||||
d: 'm9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5',
|
||||
@@ -710,7 +710,7 @@ export function jGraduateMethod (elem, options, okCallback, cancelCallback, i18n
|
||||
drag = null;
|
||||
}
|
||||
|
||||
let scaleX = 1, scaleY = 1, angle = 0;
|
||||
let scaleX = 1; let scaleY = 1; let angle = 0;
|
||||
|
||||
let cX = cx;
|
||||
let cY = cy;
|
||||
@@ -946,7 +946,7 @@ export function jGraduateMethod (elem, options, okCallback, cancelCallback, i18n
|
||||
|
||||
$this.querySelector('#' + id + '_jGraduate_match_ctr').checked = !showFocus;
|
||||
|
||||
let lastfx, lastfy;
|
||||
let lastfx; let lastfy;
|
||||
const onMatchCtrHandler = (e) => {
|
||||
showFocus = !e.target.checked;
|
||||
if (showFocus) {
|
||||
@@ -1034,7 +1034,7 @@ export function jGraduateMethod (elem, options, okCallback, cancelCallback, i18n
|
||||
slider.input.value = x;
|
||||
};
|
||||
|
||||
let ellipVal = 0, angleVal = 0;
|
||||
let ellipVal = 0; let angleVal = 0;
|
||||
|
||||
if (curType === 'radialGradient') {
|
||||
const tlist = curGradient.gradientTransform.baseVal;
|
||||
|
||||
@@ -227,7 +227,7 @@ export const jPicker = /** @lends external:jQuery.jPicker */ {
|
||||
return undefined;
|
||||
}
|
||||
const newV = {};
|
||||
let rgb = false, hsv = false;
|
||||
let rgb = false; let hsv = false;
|
||||
if (value.r !== undefined && !name.includes('r')) name += 'r';
|
||||
if (value.g !== undefined && !name.includes('g')) name += 'g';
|
||||
if (value.b !== undefined && !name.includes('b')) name += 'b';
|
||||
@@ -361,7 +361,7 @@ export const jPicker = /** @lends external:jQuery.jPicker */ {
|
||||
function destroy () {
|
||||
changeEvents = null;
|
||||
}
|
||||
let r, g, b, a, h, s, v, changeEvents = [];
|
||||
let r; let g; let b; let a; let h; let s; let v; let changeEvents = [];
|
||||
Object.assign(that, {
|
||||
// public properties and methods
|
||||
val,
|
||||
@@ -411,7 +411,7 @@ export const jPicker = /** @lends external:jQuery.jPicker */ {
|
||||
hexToRgba (hex) {
|
||||
if (hex === '' || hex === 'none') return { r: null, g: null, b: null, a: null };
|
||||
hex = this.validateHex(hex);
|
||||
let r = '00', g = '00', b = '00', a = '255';
|
||||
let r = '00'; let g = '00'; let b = '00'; let a = '255';
|
||||
if (hex.length === 6) hex += 'ff';
|
||||
if (hex.length > 6) {
|
||||
r = hex.substring(0, 2);
|
||||
@@ -477,8 +477,8 @@ export const jPicker = /** @lends external:jQuery.jPicker */ {
|
||||
* @returns {module:jPicker.HSV}
|
||||
*/
|
||||
rgbToHsv (rgb) {
|
||||
const r = rgb.r / 255, g = rgb.g / 255, b = rgb.b / 255, hsv = { h: 0, s: 0, v: 0 };
|
||||
let min = 0, max = 0;
|
||||
const r = rgb.r / 255; const g = rgb.g / 255; const b = rgb.b / 255; const hsv = { h: 0, s: 0, v: 0 };
|
||||
let min = 0; let max = 0;
|
||||
if (r >= g && r >= b) {
|
||||
max = r;
|
||||
min = g > b ? b : g;
|
||||
@@ -520,11 +520,11 @@ export const jPicker = /** @lends external:jQuery.jPicker */ {
|
||||
h /= 60;
|
||||
s /= 100;
|
||||
v /= 100;
|
||||
const i = h | 0,
|
||||
f = h - i,
|
||||
p = v * (1 - s),
|
||||
q = v * (1 - (s * f)),
|
||||
t = v * (1 - (s * (1 - f)));
|
||||
const i = h | 0;
|
||||
const f = h - i;
|
||||
const p = v * (1 - s);
|
||||
const q = v * (1 - (s * f));
|
||||
const t = v * (1 - (s * (1 - f)));
|
||||
switch (i) {
|
||||
case 0:
|
||||
rgb.r = v;
|
||||
@@ -607,8 +607,8 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||
let sets = mergeDeep({}, jPickerDefaults); // local copies for YUI compressor
|
||||
sets = mergeDeep(sets, options);
|
||||
|
||||
const that = elem,
|
||||
settings = sets;
|
||||
const that = elem;
|
||||
const settings = sets;
|
||||
if (that.nodeName.toLowerCase() === 'input') { // Add color picker icon if binding to an input element and bind the events to the input
|
||||
Object.assign(settings, {
|
||||
window: {
|
||||
@@ -648,10 +648,10 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||
* @returns {void}
|
||||
*/
|
||||
function setColorMode (colorMode) {
|
||||
const { active } = color, // local copies for YUI compressor
|
||||
// {clientPath} = images,
|
||||
hex = active.val('hex');
|
||||
let rgbMap, rgbBar;
|
||||
const { active } = color; // local copies for YUI compressor
|
||||
// {clientPath} = images,
|
||||
const hex = active.val('hex');
|
||||
let rgbMap; let rgbBar;
|
||||
settings.color.mode = colorMode;
|
||||
switch (colorMode) {
|
||||
case 'h':
|
||||
@@ -1000,15 +1000,15 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||
setAlpha.call(that, colorBarL5, toFixedNumeric(((255 - (a || 0)) * 100) / 255, 4));
|
||||
break;
|
||||
} case 's': {
|
||||
const hva = ui.val('hva'),
|
||||
saturatedColor = new Color({ h: (hva && hva.h) || 0, s: 100, v: !isNullish(hva) ? hva.v : 100 });
|
||||
const hva = ui.val('hva');
|
||||
const saturatedColor = new Color({ h: (hva && hva.h) || 0, s: 100, v: !isNullish(hva) ? hva.v : 100 });
|
||||
setBG.call(that, colorBarDiv, saturatedColor.val('hex'));
|
||||
setAlpha.call(that, colorBarL2, 100 - (!isNullish(hva) ? hva.v : 100));
|
||||
setAlpha.call(that, colorBarL5, toFixedNumeric(((255 - ((hva && hva.a) || 0)) * 100) / 255, 4));
|
||||
break;
|
||||
} case 'v': {
|
||||
const hsa = ui.val('hsa'),
|
||||
valueColor = new Color({ h: (hsa && hsa.h) || 0, s: !isNullish(hsa) ? hsa.s : 100, v: 100 });
|
||||
const hsa = ui.val('hsa');
|
||||
const valueColor = new Color({ h: (hsa && hsa.h) || 0, s: !isNullish(hsa) ? hsa.s : 100, v: 100 });
|
||||
setBG.call(that, colorBarDiv, valueColor.val('hex'));
|
||||
setAlpha.call(that, colorBarL5, toFixedNumeric(((255 - ((hsa && hsa.a) || 0)) * 100) / 255, 4));
|
||||
break;
|
||||
@@ -1016,7 +1016,7 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||
case 'g':
|
||||
case 'b': {
|
||||
const rgba = ui.val('rgba');
|
||||
let hValue = 0, vValue = 0;
|
||||
let hValue = 0; let vValue = 0;
|
||||
if (settings.color.mode === 'r') {
|
||||
hValue = (rgba && rgba.b) || 0;
|
||||
vValue = (rgba && rgba.g) || 0;
|
||||
@@ -1309,8 +1309,8 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||
*/
|
||||
function initialize () {
|
||||
const nexts = that.nextElementSibling;
|
||||
const win = settings.window,
|
||||
popup = win.expandable ? nexts.querySelector('#Container') : null;
|
||||
const win = settings.window;
|
||||
const popup = win.expandable ? nexts.querySelector('#Container') : null;
|
||||
container = win.expandable ? document.createElement('div') : that;
|
||||
container.classList.add('jPicker');
|
||||
container.classList.add('Container');
|
||||
@@ -1454,9 +1454,9 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||
win.expandable && win.bindToInput ? win.input : null,
|
||||
win.alphaPrecision
|
||||
);
|
||||
const hex = !isNullish(all) ? all.hex : null,
|
||||
preview = tbody.querySelector('#Preview'),
|
||||
button = tbody.querySelector('#Button');
|
||||
const hex = !isNullish(all) ? all.hex : null;
|
||||
const preview = tbody.querySelector('#Preview');
|
||||
const button = tbody.querySelector('#Button');
|
||||
activePreview = preview.querySelector('#Active');
|
||||
activePreview.style.backgroundColor = (hex) ? '#' + hex : 'transparent';
|
||||
currentPreview = preview.querySelector('#Current');
|
||||
@@ -1625,34 +1625,34 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||
cancelCallback = null;
|
||||
}
|
||||
|
||||
let elementStartX = null, // Used to record the starting css positions for dragging the control
|
||||
elementStartY = null,
|
||||
pageStartX = null, // Used to record the mousedown coordinates for dragging the control
|
||||
pageStartY = null,
|
||||
container = null,
|
||||
colorMapDiv = null,
|
||||
colorBarDiv = null,
|
||||
colorMapL1 = null, // different layers of colorMap and colorBar
|
||||
colorMapL2 = null,
|
||||
colorMapL3 = null,
|
||||
colorBarL1 = null,
|
||||
colorBarL2 = null,
|
||||
colorBarL3 = null,
|
||||
colorBarL4 = null,
|
||||
colorBarL5 = null,
|
||||
colorBarL6 = null,
|
||||
colorMap = null, // color maps
|
||||
colorBar = null,
|
||||
colorPicker = null,
|
||||
activePreview = null, // color boxes above the radio buttons
|
||||
currentPreview = null,
|
||||
okButton = null,
|
||||
cancelButton = null,
|
||||
grid = null, // preset colors grid
|
||||
iconColor = null, // iconColor for popup icon
|
||||
iconAlpha = null, // iconAlpha for popup icon
|
||||
iconImage = null, // iconImage popup icon
|
||||
moveBar = null; // drag bar
|
||||
let elementStartX = null; // Used to record the starting css positions for dragging the control
|
||||
let elementStartY = null;
|
||||
let pageStartX = null; // Used to record the mousedown coordinates for dragging the control
|
||||
let pageStartY = null;
|
||||
let container = null;
|
||||
let colorMapDiv = null;
|
||||
let colorBarDiv = null;
|
||||
let colorMapL1 = null; // different layers of colorMap and colorBar
|
||||
let colorMapL2 = null;
|
||||
let colorMapL3 = null;
|
||||
let colorBarL1 = null;
|
||||
let colorBarL2 = null;
|
||||
let colorBarL3 = null;
|
||||
let colorBarL4 = null;
|
||||
let colorBarL5 = null;
|
||||
let colorBarL6 = null;
|
||||
let colorMap = null; // color maps
|
||||
let colorBar = null;
|
||||
let colorPicker = null;
|
||||
let activePreview = null; // color boxes above the radio buttons
|
||||
let currentPreview = null;
|
||||
let okButton = null;
|
||||
let cancelButton = null;
|
||||
let grid = null; // preset colors grid
|
||||
let iconColor = null; // iconColor for popup icon
|
||||
let iconAlpha = null; // iconAlpha for popup icon
|
||||
let iconImage = null; // iconImage popup icon
|
||||
let moveBar = null; // drag bar
|
||||
Object.assign(that, {
|
||||
// public properties, methods, and callbacks
|
||||
commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK"
|
||||
|
||||
@@ -23,8 +23,8 @@ let cbid = 0;
|
||||
*/
|
||||
function getCallbackSetter (funcName) {
|
||||
return function (...args) {
|
||||
const that = this, // New callback
|
||||
callbackID = this.send(funcName, args, function () { /* empty fn */ }); // The callback (currently it's nothing, but will be set later)
|
||||
const that = this; // New callback
|
||||
const callbackID = this.send(funcName, args, function () { /* empty fn */ }); // The callback (currently it's nothing, but will be set later)
|
||||
|
||||
return function (newCallback) {
|
||||
that.callbacks[callbackID] = newCallback; // Set callback
|
||||
@@ -65,8 +65,8 @@ function messageListener (e) {
|
||||
if (!e.data || ![ 'string', 'object' ].includes(typeof e.data)) {
|
||||
return;
|
||||
}
|
||||
const { allowedOrigins } = this,
|
||||
data = typeof e.data === 'object' ? e.data : JSON.parse(e.data);
|
||||
const { allowedOrigins } = this;
|
||||
const data = typeof e.data === 'object' ? e.data : JSON.parse(e.data);
|
||||
if (!data || typeof data !== 'object' || data.namespace !== 'svg-edit' ||
|
||||
e.source !== this.frame.contentWindow ||
|
||||
(!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin))
|
||||
@@ -372,8 +372,8 @@ class EmbeddedSVGEdit {
|
||||
// of the current JSON-based communication API (e.g., not passing
|
||||
// callbacks). We might be able to address these shortcomings; see
|
||||
// the todo elsewhere in this file.
|
||||
const message = { id: callbackID },
|
||||
{ svgEditor: { canvas: svgCanvas } } = that.frame.contentWindow;
|
||||
const message = { id: callbackID };
|
||||
const { svgEditor: { canvas: svgCanvas } } = that.frame.contentWindow;
|
||||
try {
|
||||
message.result = svgCanvas[name](...args);
|
||||
} catch (err) {
|
||||
|
||||
@@ -29,11 +29,11 @@ export default {
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { $id } = svgCanvas;
|
||||
const
|
||||
addElem = svgCanvas.addSVGElementFromJson,
|
||||
{ nonce } = S,
|
||||
prefix = 'se_arrow_';
|
||||
addElem = svgCanvas.addSVGElementFromJson;
|
||||
const { nonce } = S;
|
||||
const prefix = 'se_arrow_';
|
||||
|
||||
let selElems, arrowprefix, randomizeIds = S.randomize_ids;
|
||||
let selElems; let arrowprefix; let randomizeIds = S.randomize_ids;
|
||||
|
||||
/**
|
||||
* @param {Window} win
|
||||
|
||||
@@ -31,10 +31,10 @@ export default {
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
let selElems;
|
||||
const updateButton = function (path) {
|
||||
const seglist = path.pathSegList,
|
||||
closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1,
|
||||
showbutton = closed ? 'tool_openpath' : 'tool_closepath',
|
||||
hidebutton = closed ? 'tool_closepath' : 'tool_openpath';
|
||||
const seglist = path.pathSegList;
|
||||
const closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1;
|
||||
const showbutton = closed ? 'tool_openpath' : 'tool_closepath';
|
||||
const hidebutton = closed ? 'tool_closepath' : 'tool_openpath';
|
||||
$id(hidebutton).style.display = 'none';
|
||||
$id(showbutton).style.display = 'block';
|
||||
};
|
||||
@@ -48,8 +48,8 @@ export default {
|
||||
const toggleClosed = function () {
|
||||
const path = selElems[0];
|
||||
if (path) {
|
||||
const seglist = path.pathSegList,
|
||||
last = seglist.numberOfItems - 1;
|
||||
const seglist = path.pathSegList;
|
||||
const last = seglist.numberOfItems - 1;
|
||||
// is closed
|
||||
if (seglist.getItem(last).pathSegType === 1) {
|
||||
seglist.removeItem(last);
|
||||
|
||||
@@ -30,9 +30,9 @@ export default {
|
||||
const svgEditor = this;
|
||||
const { svgCanvas } = svgEditor;
|
||||
const { getElem, $id, mergeDeep } = svgCanvas;
|
||||
const { svgroot } = S,
|
||||
addElem = svgCanvas.addSVGElementFromJson,
|
||||
selManager = S.selectorManager;
|
||||
const { svgroot } = S;
|
||||
const addElem = svgCanvas.addSVGElementFromJson;
|
||||
const selManager = S.selectorManager;
|
||||
await loadExtensionTranslation(svgEditor);
|
||||
|
||||
let startX;
|
||||
@@ -437,8 +437,8 @@ export default {
|
||||
const x = opts.mouse_x / zoom;
|
||||
const y = opts.mouse_y / zoom;
|
||||
|
||||
const diffX = x - startX,
|
||||
diffY = y - startY;
|
||||
const diffX = x - startX;
|
||||
const diffY = y - startY;
|
||||
|
||||
const mode = svgCanvas.getMode();
|
||||
|
||||
|
||||
@@ -30,18 +30,18 @@ export default {
|
||||
async init(S) {
|
||||
const svgEditor = this;
|
||||
await loadExtensionTranslation(svgEditor);
|
||||
const { ChangeElementCommand } = S, // , svgcontent,
|
||||
// svgdoc = S.svgroot.parentNode.ownerDocument,
|
||||
{ svgCanvas } = svgEditor,
|
||||
addToHistory = function (cmd) { svgCanvas.undoMgr.addCommandToHistory(cmd); },
|
||||
currentStyle = {
|
||||
fillPaint: 'red', fillOpacity: 1.0,
|
||||
strokePaint: 'black', strokeOpacity: 1.0,
|
||||
strokeWidth: 5, strokeDashArray: null,
|
||||
opacity: 1.0,
|
||||
strokeLinecap: 'butt',
|
||||
strokeLinejoin: 'miter'
|
||||
};
|
||||
const { ChangeElementCommand } = S; // , svgcontent,
|
||||
// svgdoc = S.svgroot.parentNode.ownerDocument,
|
||||
const { svgCanvas } = svgEditor;
|
||||
const addToHistory = function (cmd) { svgCanvas.undoMgr.addCommandToHistory(cmd); };
|
||||
const currentStyle = {
|
||||
fillPaint: 'red', fillOpacity: 1.0,
|
||||
strokePaint: 'black', strokeOpacity: 1.0,
|
||||
strokeWidth: 5, strokeDashArray: null,
|
||||
opacity: 1.0,
|
||||
strokeLinecap: 'butt',
|
||||
strokeLinejoin: 'miter'
|
||||
};
|
||||
const { $id } = svgCanvas;
|
||||
|
||||
/**
|
||||
|
||||
@@ -66,10 +66,10 @@ export default {
|
||||
$id('foreign_cancel').style.display = (on) ? 'block' : 'none';
|
||||
}
|
||||
|
||||
let selElems,
|
||||
started,
|
||||
newFO,
|
||||
editingforeign = false;
|
||||
let selElems;
|
||||
let started;
|
||||
let newFO;
|
||||
let editingforeign = false;
|
||||
|
||||
/**
|
||||
* This function sets the content of element elt to the input XML.
|
||||
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
let mode = 's';
|
||||
let multiArr = [];
|
||||
let transferStopped = false;
|
||||
let preview, submit;
|
||||
let preview; let submit;
|
||||
|
||||
/**
|
||||
* Contains the SVG to insert.
|
||||
@@ -190,7 +190,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
let entry, curMeta, svgStr, imgStr;
|
||||
let entry; let curMeta; let svgStr; let imgStr;
|
||||
switch (type) {
|
||||
case 'meta': {
|
||||
// Metadata
|
||||
|
||||
@@ -146,7 +146,7 @@ export default {
|
||||
if (on) {
|
||||
const el = selElems[0];
|
||||
|
||||
let val, ci;
|
||||
let val; let ci;
|
||||
$.each(mtypes, function (i, pos) {
|
||||
const m = getLinked(el, 'marker-' + pos);
|
||||
const txtbox = $id(pos + '_marker');
|
||||
|
||||
@@ -59,10 +59,10 @@ export default {
|
||||
// Obtained Text-AMS-MML_SVG.js from https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/config/TeX-AMS-MML_SVG.js
|
||||
{ uiStrings } = svgEditor;
|
||||
let
|
||||
math,
|
||||
locationX,
|
||||
locationY,
|
||||
mathjaxLoaded = false;
|
||||
math;
|
||||
let locationX;
|
||||
let locationY;
|
||||
let mathjaxLoaded = false;
|
||||
|
||||
// TODO: Implement language support. Move these uiStrings to the locale files and
|
||||
// the code to the langReady callback. Also i18nize alert and HTML below
|
||||
@@ -231,8 +231,8 @@ export default {
|
||||
return undefined;
|
||||
},
|
||||
callback () {
|
||||
const head = document.head || document.getElementsByTagName('head')[0],
|
||||
style = document.createElement('style');
|
||||
const head = document.head || document.getElementsByTagName('head')[0];
|
||||
const style = document.createElement('style');
|
||||
style.textContent = '#mathjax fieldset{' +
|
||||
'padding: 5px;' +
|
||||
'margin: 5px;' +
|
||||
|
||||
@@ -24,8 +24,8 @@ export const dragmove = function(target, handler, parent, onStart, onEnd, onDrag
|
||||
}
|
||||
|
||||
_loaded = true;
|
||||
let isMoving = false, hasStarted = false;
|
||||
let startX = 0, startY = 0, lastX = 0, lastY = 0;
|
||||
let isMoving = false; let hasStarted = false;
|
||||
let startX = 0; let startY = 0; let lastX = 0; let lastY = 0;
|
||||
|
||||
// On the first click and hold, record the offset of the pointer in relation
|
||||
// to the point of click inside the element.
|
||||
|
||||
@@ -27,15 +27,15 @@ export default {
|
||||
const { $id } = svgCanvas;
|
||||
const addElem = svgCanvas.addSVGElementFromJson;
|
||||
let
|
||||
selElems,
|
||||
selElems;
|
||||
// editingitex = false,
|
||||
// svgdoc = S.svgroot.parentNode.ownerDocument,
|
||||
started,
|
||||
newPM;
|
||||
// edg = 0,
|
||||
// newFOG, newFOGParent, newDef, newImageName, newMaskID,
|
||||
// undoCommand = 'Not image',
|
||||
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;
|
||||
let started;
|
||||
let newPM;
|
||||
// edg = 0,
|
||||
// newFOG, newFOGParent, newDef, newImageName, newMaskID,
|
||||
// undoCommand = 'Not image',
|
||||
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const markerTypes = {
|
||||
nomarker: {},
|
||||
@@ -372,7 +372,7 @@ export default {
|
||||
let font = $id('placemarkFont').value.split(' ');
|
||||
const fontSize = Number.parseInt(font.pop());
|
||||
font = font.join(' ');
|
||||
const x0 = opts.start_x + 10, y0 = opts.start_y + 10;
|
||||
const x0 = opts.start_x + 10; const y0 = opts.start_y + 10;
|
||||
let maxlen = 0;
|
||||
const children = [ {
|
||||
element: 'line',
|
||||
@@ -479,8 +479,8 @@ export default {
|
||||
const elements = newPM.children;
|
||||
Array.prototype.forEach.call(elements, function(i, _){
|
||||
const [ , , type, n ] = i.id.split('_');
|
||||
const y0 = y + (fontSize + 6) * n,
|
||||
x0 = x + maxlen * fontSize * 0.5 + fontSize;
|
||||
const y0 = y + (fontSize + 6) * n;
|
||||
const x0 = x + maxlen * fontSize * 0.5 + fontSize;
|
||||
const nx = (x + (x0 - x) / 2 < px) ? x0 : x;
|
||||
const ny = (y + ((fontSize + 6) * (lines - 1)) / 2 < py)
|
||||
? y + (fontSize + 6) * (lines - 1)
|
||||
|
||||
@@ -19,8 +19,8 @@ export default {
|
||||
const saveSvgAction = './savefile.php';
|
||||
svgEditor.setCustomHandlers({
|
||||
save (win, data) {
|
||||
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
|
||||
filename = getFileNameFromTitle();
|
||||
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data;
|
||||
const filename = getFileNameFromTitle();
|
||||
|
||||
// $.post(saveSvgAction, { output_svg: svg, filename });
|
||||
let postData = { output_svg: svg, filename };
|
||||
|
||||
@@ -79,9 +79,9 @@ export default {
|
||||
return false;
|
||||
}
|
||||
const
|
||||
saveSvgAction = './filesave.php',
|
||||
saveImgAction = './filesave.php';
|
||||
// Create upload target (hidden iframe)
|
||||
saveSvgAction = './filesave.php';
|
||||
const saveImgAction = './filesave.php';
|
||||
// Create upload target (hidden iframe)
|
||||
|
||||
let cancelled = false;
|
||||
|
||||
@@ -97,8 +97,8 @@ export default {
|
||||
svgEditor.setCustomHandlers({
|
||||
save (win, data) {
|
||||
// Firefox doesn't seem to know it is UTF-8 (no matter whether we use or skip the clientDownload code) despite the Content-Disposition header containing UTF-8, but adding the encoding works
|
||||
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
|
||||
filename = getFileNameFromTitle();
|
||||
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data;
|
||||
const filename = getFileNameFromTitle();
|
||||
|
||||
if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;charset=UTF-8;base64,' + encode64(svg))) {
|
||||
return;
|
||||
@@ -116,8 +116,8 @@ export default {
|
||||
form.remove();
|
||||
},
|
||||
exportPDF (win, data) {
|
||||
const filename = getFileNameFromTitle(),
|
||||
datauri = data.output;
|
||||
const filename = getFileNameFromTitle();
|
||||
const datauri = data.output;
|
||||
if (clientDownloadSupport(filename, '.pdf', datauri)) {
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ export default {
|
||||
const datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType);
|
||||
|
||||
// Check if there are issues
|
||||
let pre, note = '';
|
||||
let pre; let note = '';
|
||||
if (issues.length) {
|
||||
pre = '\n \u2022 '; // Bullet
|
||||
note += ('\n\n' + pre + issues.join(pre));
|
||||
|
||||
@@ -110,9 +110,9 @@ export default {
|
||||
const x = opts.mouse_x / zoom;
|
||||
const y = opts.mouse_y / zoom;
|
||||
|
||||
const tlist = canv.getTransformList(curShape),
|
||||
box = curShape.getBBox(),
|
||||
left = box.x, top = box.y;
|
||||
const tlist = canv.getTransformList(curShape);
|
||||
const box = curShape.getBBox();
|
||||
const left = box.x; const top = box.y;
|
||||
|
||||
const newbox = {
|
||||
x: Math.min(startX, x),
|
||||
@@ -135,9 +135,9 @@ export default {
|
||||
}
|
||||
|
||||
// update the transform list with translate,scale,translate
|
||||
const translateOrigin = svgroot.createSVGTransform(),
|
||||
scale = svgroot.createSVGTransform(),
|
||||
translateBack = svgroot.createSVGTransform();
|
||||
const translateOrigin = svgroot.createSVGTransform();
|
||||
const scale = svgroot.createSVGTransform();
|
||||
const translateBack = svgroot.createSVGTransform();
|
||||
|
||||
translateOrigin.setTranslate(-(left + tx), -(top + ty));
|
||||
if (!evt.shiftKey) {
|
||||
|
||||
@@ -24,9 +24,9 @@ export default {
|
||||
async init () {
|
||||
const svgEditor = this;
|
||||
const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang'));
|
||||
const saveMessage = 'save',
|
||||
readMessage = 'read',
|
||||
excludedMessages = [ readMessage, saveMessage ];
|
||||
const saveMessage = 'save';
|
||||
const readMessage = 'read';
|
||||
const excludedMessages = [ readMessage, saveMessage ];
|
||||
|
||||
let pathID;
|
||||
this.canvas.bind(
|
||||
@@ -38,7 +38,7 @@ export default {
|
||||
* @returns {void}
|
||||
*/
|
||||
(win, { data, origin }) => {
|
||||
let type, content;
|
||||
let type; let content;
|
||||
try {
|
||||
({ type, pathID, content } = data.webappfind); // May throw if data is not an object
|
||||
if (origin !== location.origin || // We are only interested in a message sent as though within this URL by our browser add-on
|
||||
|
||||
@@ -350,8 +350,8 @@ class LayersPanel {
|
||||
*/
|
||||
toggleHighlightLayer(layerNameToHighlight) {
|
||||
let i;
|
||||
const curNames = [],
|
||||
numLayers = this.editor.svgCanvas.getCurrentDrawing().getNumLayers();
|
||||
const curNames = [];
|
||||
const numLayers = this.editor.svgCanvas.getCurrentDrawing().getNumLayers();
|
||||
for (i = 0; i < numLayers; i++) {
|
||||
curNames[i] = this.editor.svgCanvas.getCurrentDrawing().getLayerName(i);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class TopPanel {
|
||||
* @returns {void}
|
||||
*/
|
||||
update() {
|
||||
let i, len;
|
||||
let i; let len;
|
||||
if (!isNullish(this.selectedElement)) {
|
||||
switch (this.selectedElement.tagName) {
|
||||
case "use":
|
||||
@@ -208,7 +208,7 @@ class TopPanel {
|
||||
if ([ "line", "circle", "ellipse" ].includes(elname)) {
|
||||
$id("xy_panel").style.display = 'none';
|
||||
} else {
|
||||
let x, y;
|
||||
let x; let y;
|
||||
|
||||
// Get BBox vals for g, polyline and path
|
||||
if ([ "g", "polyline", "path" ].includes(elname)) {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* @returns {void}
|
||||
*/
|
||||
function touchHandler (ev) {
|
||||
const { changedTouches } = ev,
|
||||
first = changedTouches[0];
|
||||
const { changedTouches } = ev;
|
||||
const first = changedTouches[0];
|
||||
|
||||
let type = '';
|
||||
switch (ev.type) {
|
||||
|
||||
Reference in New Issue
Block a user