- Linting (ESLint): As per latest ash-nazg

This commit is contained in:
Brett Zamir
2020-03-27 20:39:51 +08:00
parent 1f1452f4fa
commit 7914f26e02
20 changed files with 113 additions and 101 deletions

View File

@@ -61,7 +61,10 @@ module.exports = {
polyfills: [
'document.querySelector',
'history.pushState',
'history.replaceState'
'history.replaceState',
'Number.parseFloat',
'Number.parseInt',
'Number.isNaN'
]
},
rules: {
@@ -136,6 +139,9 @@ module.exports = {
'JSON',
'location.href',
'MutationObserver',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'Object.assign',
'Object.defineProperty',
'Object.defineProperties',
@@ -170,6 +176,9 @@ module.exports = {
'console',
'fetch',
'location.origin',
'Number.isNaN',
'Number.parseFloat',
'Number.parseInt',
'window.postMessage'
]
},
@@ -231,6 +240,8 @@ module.exports = {
files: ['canvg/rgbcolor.js'],
settings: {
polyfills: [
'Number.isNaN',
'Number.parseInt',
'Object.assign',
'Object.keys'
]
@@ -266,6 +277,7 @@ module.exports = {
'document.body',
'document.head',
'DOMParser',
'Number.isNaN',
'Object.keys',
'Object.entries',
'Promise'

View File

@@ -224,7 +224,7 @@ function build (opts) {
numValue () {
if (!this.hasValue()) return 0;
let n = parseFloat(this.value);
let n = Number.parseFloat(this.value);
if (String(this.value).endsWith('%')) {
n /= 100.0;
}
@@ -414,7 +414,7 @@ function build (opts) {
// points and paths
svg.ToNumberArray = function (s) {
const a = svg.trim(svg.compressSpaces((s || '').replace(/,/g, ' '))).split(' ');
return a.map((_a) => parseFloat(_a));
return a.map((_a) => Number.parseFloat(_a));
};
svg.Point = class {
constructor (x, y) {
@@ -1308,7 +1308,7 @@ function build (opts) {
},
getScalar () {
return parseFloat(this.getToken());
return Number.parseFloat(this.getToken());
},
nextCommand () {
@@ -1908,8 +1908,8 @@ function build (opts) {
if (this.values.hasValue()) {
const p = ret.progress * (this.values.value.length - 1);
const lb = Math.floor(p), ub = Math.ceil(p);
ret.from = new svg.Property('from', parseFloat(this.values.value[lb]));
ret.to = new svg.Property('to', parseFloat(this.values.value[ub]));
ret.from = new svg.Property('from', Number.parseFloat(this.values.value[lb]));
ret.to = new svg.Property('to', Number.parseFloat(this.values.value[ub]));
ret.progress = (p - lb) / (ub - lb);
} else {
ret.from = this.from;
@@ -1942,7 +1942,7 @@ function build (opts) {
const r = from.r + (to.r - from.r) * p.progress;
const g = from.g + (to.g - from.g) * p.progress;
const b = from.b + (to.b - from.b) * p.progress;
return 'rgb(' + parseInt(r) + ',' + parseInt(g) + ',' + parseInt(b) + ')';
return 'rgb(' + Number.parseInt(r) + ',' + Number.parseInt(g) + ',' + Number.parseInt(b) + ')';
}
return this.attribute('from').value;
}

View File

@@ -158,7 +158,7 @@ const colorDefs = [
// re: /^rgb\((?<r>\d{1,3}),\s*(?<g>\d{1,3}),\s*(?<b>\d{1,3})\)$/,
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
process (_, ...bits) {
return bits.map((b) => parseInt(b));
return bits.map((b) => Number.parseInt(b));
}
},
{
@@ -166,7 +166,7 @@ const colorDefs = [
// re: /^(?<r>\w{2})(?<g>\w{2})(?<b>\w{2})$/,
example: ['#00ff00', '336699'],
process (_, ...bits) {
return bits.map((b) => parseInt(b, 16));
return bits.map((b) => Number.parseInt(b, 16));
}
},
{
@@ -174,7 +174,7 @@ const colorDefs = [
// re: /^(?<r>\w{1})(?<g>\w{1})(?<b>\w{1})$/,
example: ['#fb0', 'f0f'],
process (_, ...bits) {
return bits.map((b) => parseInt(b + b, 16));
return bits.map((b) => Number.parseInt(b + b, 16));
}
}
];

View File

@@ -111,8 +111,8 @@ export const remapElement = function (selected, changes, m) {
// therefore [T'] = [M_inv][T][M]
const existing = transformListToTransform(selected).matrix,
tNew = matrixMultiply(existing.inverse(), m, existing);
changes.x = parseFloat(changes.x) + tNew.e;
changes.y = parseFloat(changes.y) + tNew.f;
changes.x = Number.parseFloat(changes.x) + tNew.e;
changes.y = Number.parseFloat(changes.y) + tNew.f;
} else {
// we just absorb all matrices into the element and don't do any remapping
const chlist = getTransformList(selected);

View File

@@ -253,7 +253,7 @@ export class Drawing {
return false;
}
// extract the obj_num of this id
const num = parseInt(id.substr(front.length));
const num = Number.parseInt(id.substr(front.length));
// if we didn't get a positive number or we already released this number
// then return false.

View File

@@ -14,7 +14,7 @@ export default {
// https://code.google.com/p/chromium/issues/detail?id=565120.
if (isChrome()) {
const verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
const chromeVersion = parseInt(navigator.userAgent.substring(verIndex));
const chromeVersion = Number.parseInt(navigator.userAgent.substring(verIndex));
if (chromeVersion < 49) {
return undefined;
}
@@ -37,12 +37,12 @@ export default {
// Define dynamic animation of the view box.
const updateViewBox = function () {
const portHeight = parseFloat($('#workarea').css('height'));
const portWidth = parseFloat($('#workarea').css('width'));
const portHeight = Number.parseFloat($('#workarea').css('height'));
const portWidth = Number.parseFloat($('#workarea').css('width'));
const portX = $('#workarea').scrollLeft();
const portY = $('#workarea').scrollTop();
const windowWidth = parseFloat($('#svgcanvas').css('width'));
const windowHeight = parseFloat($('#svgcanvas').css('height'));
const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height');
@@ -93,12 +93,12 @@ export default {
// Set up the overview window as a controller for the view port.
overviewWindowGlobals.viewBoxDragging = false;
const updateViewPortFromViewBox = function () {
const windowWidth = parseFloat($('#svgcanvas').css('width'));
const windowHeight = parseFloat($('#svgcanvas').css('height'));
const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxX = parseFloat($('#overview_window_view_box').css('left'));
const viewBoxY = parseFloat($('#overview_window_view_box').css('top'));
const viewBoxX = Number.parseFloat($('#overview_window_view_box').css('left'));
const viewBoxY = Number.parseFloat($('#overview_window_view_box').css('top'));
const portX = viewBoxX / overviewWidth * windowWidth;
const portY = viewBoxY / overviewHeight * windowHeight;
@@ -118,8 +118,8 @@ export default {
const mouseY = (evt.offsetY || evt.originalEvent.layerY);
const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxWidth = parseFloat($('#overview_window_view_box').css('min-width'));
const viewBoxHeight = parseFloat($('#overview_window_view_box').css('min-height'));
const viewBoxWidth = Number.parseFloat($('#overview_window_view_box').css('min-width'));
const viewBoxHeight = Number.parseFloat($('#overview_window_view_box').css('min-height'));
let viewBoxX = mouseX - 0.5 * viewBoxWidth;
let viewBoxY = mouseY - 0.5 * viewBoxHeight;

View File

@@ -106,7 +106,7 @@ export default {
*/
function updateFont (font) {
font = font.split(' ');
const fontSize = parseInt(font.pop());
const fontSize = Number.parseInt(font.pop());
font = font.join(' ');
selElems.forEach((elem) => {
if (elem && elem.getAttribute('class').includes('placemark')) {
@@ -356,7 +356,7 @@ export default {
const id = svgCanvas.getNextId();
const items = $('#placemarkText').val().split(';');
let font = $('#placemarkFont').val().split(' ');
const fontSize = parseInt(font.pop());
const fontSize = Number.parseInt(font.pop());
font = font.join(' ');
const x0 = opts.start_x + 10, y0 = opts.start_y + 10;
let maxlen = 0;

View File

@@ -515,7 +515,7 @@ export default function jQueryPluginJGraduate ($) {
let inverted = '';
for (let i = 0; i < 6; i += 2) {
// const ch = color.substr(i, 2);
let inv = (255 - parseInt(color.substr(i, 2), 16)).toString(16);
let inv = (255 - Number.parseInt(color.substr(i, 2), 16)).toString(16);
if (inv.length < 2) inv = 0 + inv;
inverted += inv;
}
@@ -535,15 +535,15 @@ export default function jQueryPluginJGraduate ($) {
}
}
const x1 = parseFloat(grad.getAttribute('x1') || 0.0),
y1 = parseFloat(grad.getAttribute('y1') || 0.0),
x2 = parseFloat(grad.getAttribute('x2') || 1.0),
y2 = parseFloat(grad.getAttribute('y2') || 0.0);
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 cx = parseFloat(grad.getAttribute('cx') || 0.5),
cy = parseFloat(grad.getAttribute('cy') || 0.5),
fx = parseFloat(grad.getAttribute('fx') || cx),
fy = parseFloat(grad.getAttribute('fy') || cy);
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 previewRect = mkElem('rect', {
id: id + '_jgraduate_rect',
@@ -617,7 +617,7 @@ export default function jQueryPluginJGraduate ($) {
.val(attrval)
.change(function () {
// TODO: Support values < 0 and > 1 (zoomable preview?)
if (isNaN(parseFloat(this.value)) || this.value < 0) {
if (isNaN(Number.parseFloat(this.value)) || this.value < 0) {
this.value = 0.0;
} else if (this.value > 1) {
this.value = 1.0;
@@ -692,7 +692,7 @@ export default function jQueryPluginJGraduate ($) {
const colorhandle = this; // eslint-disable-line consistent-this
let stopOpacity = Number(stop.getAttribute('stop-opacity')) || 1;
let stopColor = stop.getAttribute('stop-color') || 1;
let thisAlpha = (parseFloat(stopOpacity) * 255).toString(16);
let thisAlpha = (Number.parseFloat(stopOpacity) * 255).toString(16);
while (thisAlpha.length < 2) { thisAlpha = '0' + thisAlpha; }
colr = stopColor.substr(1) + thisAlpha;
$('#' + id + '_jGraduate_stopPicker').css({left: 100, bottom: 15}).jPicker({
@@ -1052,7 +1052,7 @@ export default function jQueryPluginJGraduate ($) {
const setSlider = function (e) {
const {offset: {left}} = slider;
const div = slider.parent;
let x = (e.pageX - left - parseInt(div.css('border-left-width')));
let x = (e.pageX - left - Number.parseInt(div.css('border-left-width')));
if (x > SLIDERW) x = SLIDERW;
if (x <= 0) x = 0;
const posx = x - 5;
@@ -1066,7 +1066,7 @@ export default function jQueryPluginJGraduate ($) {
curGradient.setAttribute('r', x);
break;
case 'opacity':
$this.paint.alpha = parseInt(x * 100);
$this.paint.alpha = Number.parseInt(x * 100);
previewRect.setAttribute('fill-opacity', x);
break;
case 'ellip':

View File

@@ -463,11 +463,11 @@ const jPicker = function ($) {
case alpha && alpha.get(0):
switch (e.keyCode) {
case 38:
alpha.val(setValueInRange.call(that, parseFloat(alpha.val()) + 1, 0, 100));
alpha.val(setValueInRange.call(that, Number.parseFloat(alpha.val()) + 1, 0, 100));
color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target);
return false;
case 40:
alpha.val(setValueInRange.call(that, parseFloat(alpha.val()) - 1, 0, 100));
alpha.val(setValueInRange.call(that, Number.parseFloat(alpha.val()) - 1, 0, 100));
color.val('a', toFixedNumeric((alpha.val() * 255) / 100, alphaPrecision), e.target);
return false;
}
@@ -563,7 +563,7 @@ const jPicker = function ($) {
break;
case ahex && ahex.get(0):
ahex.val(ahex.val().replace(/[^a-fA-F\d]/g, '').toLowerCase().substring(0, 2));
color.val('a', !isNullish(ahex.val()) ? parseInt(ahex.val(), 16) : null, e.target);
color.val('a', !isNullish(ahex.val()) ? Number.parseInt(ahex.val(), 16) : null, e.target);
break;
}
return undefined;
@@ -1086,7 +1086,7 @@ const jPicker = function ($) {
* @returns {Integer}
*/
hexToInt (hex) {
return parseInt(hex, 16);
return Number.parseInt(hex, 16);
},
/**
* @typedef {PlainObject} module:jPicker.HSV
@@ -1120,7 +1120,7 @@ const jPicker = function ($) {
if (r === max) hsv.h = (g - b) / delta;
else if (g === max) hsv.h = 2 + (b - r) / delta;
else hsv.h = 4 + (r - g) / delta;
hsv.h = parseInt(hsv.h * 60);
hsv.h = Number.parseInt(hsv.h * 60);
if (hsv.h < 0) hsv.h += 360;
}
hsv.s = (hsv.s * 100) | 0;
@@ -1251,7 +1251,7 @@ const jPicker = function ($) {
} else {
settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results
}
const isLessThanIE7 = parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters; // needed to run the AlphaImageLoader function for IE6
const isLessThanIE7 = Number.parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters; // needed to run the AlphaImageLoader function for IE6
// set color mode and update visuals for the new color mode
/**
*
@@ -1802,8 +1802,8 @@ const jPicker = function ($) {
function moveBarMouseDown (e) {
// const {element} = settings.window, // local copies for YUI compressor
// {page} = settings.window;
elementStartX = parseInt(container.css('left'));
elementStartY = parseInt(container.css('top'));
elementStartX = Number.parseInt(container.css('left'));
elementStartY = Number.parseInt(container.css('top'));
pageStartX = e.pageX;
pageStartY = e.pageY;
// bind events to document to move window - we will unbind these on mouseup
@@ -2000,7 +2000,7 @@ const jPicker = function ($) {
? (popup.offset().left - 10 + (win.position.y === 'center' ? 25 : 0)) + 'px'
: win.position.x === 'screenCenter'
? (($(document).width() >> 1) - 260) + 'px'
: (popup.offset().left + parseInt(win.position.x)) + 'px',
: (popup.offset().left + Number.parseInt(win.position.x)) + 'px',
position: 'absolute',
top: win.position.y === 'top'
? (popup.offset().top - 312) + 'px'
@@ -2008,7 +2008,7 @@ const jPicker = function ($) {
? (popup.offset().top - 156) + 'px'
: win.position.y === 'bottom'
? (popup.offset().top + 25) + 'px'
: (popup.offset().top + parseInt(win.position.y)) + 'px'
: (popup.offset().top + Number.parseInt(win.position.y)) + 'px'
}
);
} else {

View File

@@ -263,7 +263,7 @@ const svgElementToPdf = function (element, pdf, options) {
pdf.setFillColor(fillRGB.r, fillRGB.g, fillRGB.b);
}
if (attributeIsNotEmpty(node, 'stroke-width')) {
pdf.setLineWidth(k * parseInt(node.getAttribute('stroke-width')));
pdf.setLineWidth(k * Number.parseInt(node.getAttribute('stroke-width')));
}
const strokeColor = node.getAttribute('stroke');
if (attributeIsNotEmpty(strokeColor) && node.getAttribute('stroke-width') !== '0' && node.getAttribute('stroke-opacity') !== '0') {
@@ -291,38 +291,38 @@ const svgElementToPdf = function (element, pdf, options) {
break;
case 'line':
pdf.line(
k * parseInt(node.getAttribute('x1')),
k * parseInt(node.getAttribute('y1')),
k * parseInt(node.getAttribute('x2')),
k * parseInt(node.getAttribute('y2'))
k * Number.parseInt(node.getAttribute('x1')),
k * Number.parseInt(node.getAttribute('y1')),
k * Number.parseInt(node.getAttribute('x2')),
k * Number.parseInt(node.getAttribute('y2'))
);
removeAttributes(node, pdfSvgAttr.line);
break;
case 'rect':
pdf.rect(
k * parseInt(node.getAttribute('x')),
k * parseInt(node.getAttribute('y')),
k * parseInt(node.getAttribute('width')),
k * parseInt(node.getAttribute('height')),
k * Number.parseInt(node.getAttribute('x')),
k * Number.parseInt(node.getAttribute('y')),
k * Number.parseInt(node.getAttribute('width')),
k * Number.parseInt(node.getAttribute('height')),
colorMode
);
removeAttributes(node, pdfSvgAttr.rect);
break;
case 'ellipse':
pdf.ellipse(
k * parseInt(node.getAttribute('cx')),
k * parseInt(node.getAttribute('cy')),
k * parseInt(node.getAttribute('rx')),
k * parseInt(node.getAttribute('ry')),
k * Number.parseInt(node.getAttribute('cx')),
k * Number.parseInt(node.getAttribute('cy')),
k * Number.parseInt(node.getAttribute('rx')),
k * Number.parseInt(node.getAttribute('ry')),
colorMode
);
removeAttributes(node, pdfSvgAttr.ellipse);
break;
case 'circle':
pdf.circle(
k * parseInt(node.getAttribute('cx')),
k * parseInt(node.getAttribute('cy')),
k * parseInt(node.getAttribute('r')),
k * Number.parseInt(node.getAttribute('cx')),
k * Number.parseInt(node.getAttribute('cy')),
k * Number.parseInt(node.getAttribute('r')),
colorMode
);
removeAttributes(node, pdfSvgAttr.circle);
@@ -405,7 +405,7 @@ const svgElementToPdf = function (element, pdf, options) {
}
pdf.setFontType(fontType);
const pdfFontSize = node.hasAttribute('font-size')
? parseInt(node.getAttribute('font-size'))
? Number.parseInt(node.getAttribute('font-size'))
: 16;
/**
@@ -441,8 +441,8 @@ const svgElementToPdf = function (element, pdf, options) {
case 'start': break;
case 'default': node.setAttribute('text-anchor', 'start'); break;
}
x = parseInt(node.getAttribute('x')) - xOffset;
y = parseInt(node.getAttribute('y'));
x = Number.parseInt(node.getAttribute('x')) - xOffset;
y = Number.parseInt(node.getAttribute('y'));
}
// console.log('fontSize:', pdfFontSize, 'text:', node.textContent);
pdf.setFontSize(pdfFontSize).text(

View File

@@ -120,7 +120,7 @@ class Layer {
if (isNullish(opacity)) {
return 1;
}
return parseFloat(opacity);
return Number.parseFloat(opacity);
}
/**

View File

@@ -158,8 +158,8 @@ export const transformListToTransform = function (tlist, min, max) {
}
min = min || 0;
max = max || (tlist.numberOfItems - 1);
min = parseInt(min);
max = parseInt(max);
min = Number.parseInt(min);
max = Number.parseInt(max);
if (min > max) { const temp = max; max = min; min = temp; }
let m = svg.createSVGMatrix();
for (let i = min; i <= max; ++i) {

View File

@@ -2003,7 +2003,7 @@ export const pathActions = (function () {
let curPt;
if (id.substr(0, 14) === 'pathpointgrip_') {
// Select this point
curPt = path.cur_pt = parseInt(id.substr(14));
curPt = path.cur_pt = Number.parseInt(id.substr(14));
path.dragging = [startX, startY];
const seg = path.segs[curPt];

View File

@@ -146,8 +146,8 @@ export default function jQueryPluginSpinButton ($) {
this.spinCfg = {
// min: cfg.min ? Number(cfg.min) : null,
// max: cfg.max ? Number(cfg.max) : null,
min: !isNaN(parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0
max: !isNaN(parseFloat(cfg.max)) ? Number(cfg.max) : null,
min: !isNaN(Number.parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0
max: !isNaN(Number.parseFloat(cfg.max)) ? Number(cfg.max) : null,
step: cfg.step ? Number(cfg.step) : 1,
stepfunc: cfg.stepfunc || false,
page: cfg.page ? Number(cfg.page) : 10,

View File

@@ -969,7 +969,7 @@ editor.init = function () {
const s = sides[i];
let cur = el.data('orig_margin-' + s);
if (Utils.isNullish(cur)) {
cur = parseInt(el.css('margin-' + s));
cur = Number.parseInt(el.css('margin-' + s));
// Cache the original margin
el.data('orig_margin-' + s, cur);
}
@@ -1986,7 +1986,7 @@ editor.init = function () {
// Create multiple canvases when necessary (due to browser limits)
if (rulerLen >= limit) {
ctxArrNum = parseInt(rulerLen / limit) + 1;
ctxArrNum = Number.parseInt(rulerLen / limit) + 1;
ctxArr = [];
ctxArr[0] = ctx;
let copy;
@@ -2903,7 +2903,7 @@ editor.init = function () {
options = tool;
} else {
// If flyout is selected, allow shift key to iterate through subitems
j = parseInt(j);
j = Number.parseInt(j);
// Use `allHolders` to include both extension `includeWith` and toolbarButtons
options = allHolders[opts.parent][j + 1] ||
holders[opts.parent][0];
@@ -3639,7 +3639,7 @@ editor.init = function () {
*/
const changeRotationAngle = function (ctl) {
svgCanvas.setRotationAngle(ctl.value);
$('#tool_reorient').toggleClass('disabled', parseInt(ctl.value) === 0);
$('#tool_reorient').toggleClass('disabled', Number.parseInt(ctl.value) === 0);
};
/**
@@ -4019,7 +4019,7 @@ editor.init = function () {
editor.addDropDown('#opacity_dropdown', function () {
if ($(this).find('div').length) { return; }
const perc = parseInt($(this).text().split('%')[0]);
const perc = Number.parseInt($(this).text().split('%')[0]);
changeOpacity(false, perc);
}, true);
@@ -4063,7 +4063,7 @@ editor.init = function () {
if (val) {
zoomChanged(window, val);
} else {
changeZoom({value: parseFloat(item.text())});
changeZoom({value: Number.parseFloat(item.text())});
}
}, true);
@@ -4462,7 +4462,7 @@ editor.init = function () {
const rotateSelected = function (cw, step) {
if (Utils.isNullish(selectedElement) || multiselected) { return; }
if (!cw) { step *= -1; }
const angle = parseFloat($('#angle').val()) + step;
const angle = Number.parseFloat($('#angle').val()) + step;
svgCanvas.setRotationAngle(angle);
updateContextPanel();
};
@@ -4592,7 +4592,7 @@ editor.init = function () {
if (!customExportImage) {
openExportWindow();
}
const quality = parseInt($('#image-slider').val()) / 100;
const quality = Number.parseInt($('#image-slider').val()) / 100;
/* const results = */ await svgCanvas.rasterExport(imgType, quality, exportWindowName);
}
};
@@ -5184,7 +5184,7 @@ editor.init = function () {
this._paintOpacity = 1;
break;
} default: {
this._paintOpacity = parseFloat(selectedElement.getAttribute(type + '-opacity'));
this._paintOpacity = Number.parseFloat(selectedElement.getAttribute(type + '-opacity'));
if (isNaN(this._paintOpacity)) {
this._paintOpacity = 1.0;
}
@@ -5432,8 +5432,8 @@ editor.init = function () {
const rulerX = $('#ruler_x');
$('#sidepanels').width('+=' + delta);
$('#layerpanel').width('+=' + delta);
rulerX.css('right', parseInt(rulerX.css('right')) + delta);
workarea.css('right', parseInt(workarea.css('right')) + delta);
rulerX.css('right', Number.parseInt(rulerX.css('right')) + delta);
workarea.css('right', Number.parseInt(workarea.css('right')) + delta);
svgCanvas.runExtensions('workareaResized');
};

View File

@@ -572,7 +572,7 @@ const getCurrentZoom = this.getZoom = function () { return currentZoom; };
* @type {module:path.EditorContext#round}
*/
const round = this.round = function (val) {
return parseInt(val * currentZoom) / currentZoom;
return Number.parseInt(val * currentZoom) / currentZoom;
};
selectInit(
@@ -1231,8 +1231,8 @@ const getIntersectionList = this.getIntersectionList = function (rect) {
if (!isIE()) {
if (typeof svgroot.getIntersectionList === 'function') {
// Offset the bbox of the rubber box by the offset of the svgcontent element.
rubberBBox.x += parseInt(svgcontent.getAttribute('x'));
rubberBBox.y += parseInt(svgcontent.getAttribute('y'));
rubberBBox.x += Number.parseInt(svgcontent.getAttribute('x'));
rubberBBox.y += Number.parseInt(svgcontent.getAttribute('y'));
resultList = svgroot.getIntersectionList(rubberBBox, parent);
}
@@ -1498,7 +1498,7 @@ const ffClone = function (elem) {
*/
this.setRotationAngle = function (val, preventUndo) {
// ensure val is the proper type
val = parseFloat(val);
val = Number.parseFloat(val);
const elem = selectedElements[0];
const oldTransform = elem.getAttribute('transform');
const bbox = utilsGetBBox(elem);
@@ -2849,7 +2849,7 @@ const mouseUp = function (evt) {
let aniDur = 0.2;
let cAni;
if (opacAni.beginElement && parseFloat(element.getAttribute('opacity')) !== curShape.opacity) {
if (opacAni.beginElement && Number.parseFloat(element.getAttribute('opacity')) !== curShape.opacity) {
cAni = $(opacAni).clone().attr({
to: curShape.opacity,
dur: aniDur

View File

@@ -172,7 +172,7 @@ export class SVGTransformList { // eslint-disable-line no-shadow
*/
const mtx = svgroot.createSVGMatrix();
Object.values(valArr).forEach(function (item, i) {
valArr[i] = parseFloat(item);
valArr[i] = Number.parseFloat(item);
if (name === 'matrix') {
mtx[letters[i]] = valArr[i];
}

View File

@@ -140,7 +140,7 @@ export const shortFloat = function (val) {
if (Array.isArray(val)) {
return shortFloat(val[0]) + ',' + shortFloat(val[1]);
}
return parseFloat(val).toFixed(digits) - 0;
return Number.parseFloat(val).toFixed(digits) - 0;
};
/**

View File

@@ -661,8 +661,8 @@ export const getBBox = function (elem) {
const bb = {
width,
height,
x: x + parseFloat(selected.getAttribute('x') || 0),
y: y + parseFloat(selected.getAttribute('y') || 0)
x: x + Number.parseFloat(selected.getAttribute('x') || 0),
y: y + Number.parseFloat(selected.getAttribute('y') || 0)
};
ret = bb;
}

View File

@@ -33,12 +33,12 @@ const query = function (qry, root) {
};
const ua = navigator.userAgent;
const isFF = parseFloat(ua.split('Firefox/')[1]) || undefined;
const isWK = parseFloat(ua.split('WebKit/')[1]) || undefined;
const isOpera = parseFloat(ua.split('Opera/')[1]) || undefined;
const isFF = Number.parseFloat(ua.split('Firefox/')[1]) || undefined;
const isWK = Number.parseFloat(ua.split('WebKit/')[1]) || undefined;
const isOpera = Number.parseFloat(ua.split('Opera/')[1]) || undefined;
const canTransition = (function () {
const ver = parseFloat(ua.split('Version/')[1]) || undefined;
const ver = Number.parseFloat(ua.split('Version/')[1]) || undefined;
// test to determine if this browser can handle CSS transitions.
const cachedCanTransition =
(isWK || (isFF && isFF > 3.6) || (isOpera && ver >= 10.5));
@@ -158,9 +158,9 @@ const SlideShow = function (slides) {
const h = window.location.hash;
try {
this.current = parseInt(h.split('#slide')[1]);
} catch (e) { /* squeltch */ }
this.current = isNaN(this.current) ? 1 : this.current;
this.current = Number.parseInt(h.split('#slide')[1]);
} catch (e) { /* squelch */ }
this.current = Number.isNaN(this.current) ? 1 : this.current;
const that = this;
doc.addEventListener('keydown',
function (e) { that.handleKeys(e); });