- Linting (ESLint): Finish extensions and most files in editor/; unfinished: editor/svg-editor.js, editor/svgcanvas.js

- Linting (ESLint): Fix ignore file paths
- History `elem` fix
This commit is contained in:
Brett Zamir
2018-05-16 08:53:27 +08:00
parent 5bcbb948eb
commit 340915be4e
51 changed files with 12031 additions and 12108 deletions

View File

@@ -1,5 +1,5 @@
/*globals svgEditor, svgedit, svgCanvas, $*/
/*jslint vars: true, eqeq: true*/
/* eslint-disable no-var */
/* globals svgEditor, svgCanvas, $ */
/*
* ext-star.js
*
@@ -9,7 +9,8 @@
*
*/
svgEditor.addExtension('star', function(S){'use strict';
svgEditor.addExtension('star', function (S) {
'use strict';
var // NS = svgedit.NS,
// svgcontent = S.svgcontent,
@@ -17,19 +18,18 @@ svgEditor.addExtension('star', function(S){'use strict';
// editingitex = false,
// svgdoc = S.svgroot.parentNode.ownerDocument,
started,
newFO,
newFO;
// edg = 0,
// newFOG, newFOGParent, newDef, newImageName, newMaskID,
// undoCommand = 'Not image',
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH,
shape;
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;
function showPanel(on){
var fc_rules = $('#fc_rules');
if (!fc_rules.length) {
fc_rules = $('<style id="fc_rules"></style>').appendTo('head');
function showPanel (on) {
var fcRules = $('#fc_rules');
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
fc_rules.text(!on ? '' : ' #tool_topath { display: none !important; }');
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#star_panel').toggle(on);
}
@@ -39,7 +39,7 @@ svgEditor.addExtension('star', function(S){'use strict';
}
*/
function setAttr(attr, val){
function setAttr (attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
S.call('changed', selElems);
}
@@ -63,7 +63,7 @@ svgEditor.addExtension('star', function(S){'use strict';
title: 'Star Tool',
position: 12,
events: {
click: function(){
click: function () {
showPanel(true);
svgCanvas.setMode('star');
}
@@ -79,7 +79,7 @@ svgEditor.addExtension('star', function(S){'use strict';
size: 3,
defval: 5,
events: {
change: function(){
change: function () {
setAttr('point', this.value);
}
}
@@ -100,23 +100,23 @@ svgEditor.addExtension('star', function(S){'use strict';
size: 3,
defval: 0,
events: {
change: function(){
change: function () {
setAttr('radialshift', this.value);
}
}
}],
callback: function(){
callback: function () {
$('#star_panel').hide();
// var endChanges = function(){};
},
mouseDown: function(opts){
mouseDown: function (opts) {
var rgb = svgCanvas.getColor('fill');
// var ccRgbEl = rgb.substring(1, rgb.length);
var sRgb = svgCanvas.getColor('stroke');
// var ccSRgbEl = sRgb.substring(1, rgb.length);
var sWidth = svgCanvas.getStrokeWidth();
if (svgCanvas.getMode() == 'star') {
if (svgCanvas.getMode() === 'star') {
started = true;
newFO = S.addSvgElementFromJson({
@@ -141,11 +141,11 @@ svgEditor.addExtension('star', function(S){'use strict';
};
}
},
mouseMove: function(opts){
mouseMove: function (opts) {
if (!started) {
return;
}
if (svgCanvas.getMode() == 'star') {
if (svgCanvas.getMode() === 'star') {
var x = opts.mouse_x;
var y = opts.mouse_y;
var c = $(newFO).attr(['cx', 'cy', 'point', 'orient', 'fill', 'strokecolor', 'strokeWidth', 'radialshift']);
@@ -158,9 +158,9 @@ svgEditor.addExtension('star', function(S){'use strict';
var s;
for (s = 0; point >= s; s++) {
var angle = 2.0 * Math.PI * (s / point);
if ('point' == orient) {
if (orient === 'point') {
angle -= (Math.PI / 2);
} else if ('edge' == orient) {
} else if (orient === 'edge') {
angle = (angle + (Math.PI / point)) - (Math.PI / 2);
}
@@ -169,11 +169,11 @@ svgEditor.addExtension('star', function(S){'use strict';
polyPoints += x + ',' + y + ' ';
if (null != inradius) {
if (inradius != null) {
angle = (2.0 * Math.PI * (s / point)) + (Math.PI / point);
if ('point' == orient) {
if (orient === 'point') {
angle -= (Math.PI / 2);
} else if ('edge' == orient) {
} else if (orient === 'edge') {
angle = (angle + (Math.PI / point)) - (Math.PI / 2);
}
angle += radialShift;
@@ -188,25 +188,24 @@ svgEditor.addExtension('star', function(S){'use strict';
newFO.setAttributeNS(null, 'fill', fill);
newFO.setAttributeNS(null, 'stroke', strokecolor);
newFO.setAttributeNS(null, 'stroke-width', strokewidth);
shape = newFO.getAttributeNS(null, 'shape');
/* var shape = */ newFO.getAttributeNS(null, 'shape');
return {
started: true
};
}
},
mouseUp: function(){
if (svgCanvas.getMode() == 'star') {
mouseUp: function () {
if (svgCanvas.getMode() === 'star') {
var attrs = $(newFO).attr(['r']);
// svgCanvas.addToSelection([newFO], true);
return {
keep: (attrs.r != 0),
keep: (attrs.r !== '0'),
element: newFO
};
}
},
selectedChanged: function(opts){
selectedChanged: function (opts) {
// Use this to update the current selected elements
selElems = opts.elems;
@@ -220,8 +219,7 @@ svgEditor.addExtension('star', function(S){'use strict';
$('#starNumPoints').val(elem.getAttribute('point'));
$('#radialShift').val(elem.getAttribute('radialshift'));
showPanel(true);
}
else {
} else {
showPanel(false);
}
} else {
@@ -229,7 +227,7 @@ svgEditor.addExtension('star', function(S){'use strict';
}
}
},
elementChanged: function(opts){
elementChanged: function (opts) {
// var elem = opts.elems[0];
}
};