- Docs (JSDoc): Further on preferring void
This commit is contained in:
112
editor/path.js
112
editor/path.js
@@ -49,7 +49,7 @@ const uiStrings = {};
|
||||
/**
|
||||
* @function module:path.setUiStrings
|
||||
* @param {module:path.uiStrings} strs
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const setUiStrings = function (strs) {
|
||||
Object.assign(uiStrings, strs.ui);
|
||||
@@ -66,7 +66,7 @@ let pathData = {};
|
||||
/**
|
||||
* @function module:path.setLinkControlPoints
|
||||
* @param {boolean} lcp
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const setLinkControlPoints = function (lcp) {
|
||||
linkControlPts = lcp;
|
||||
@@ -103,12 +103,12 @@ let editorContext_ = null;
|
||||
* @function module:path.EditorContext#call
|
||||
* @param {"selected"|"changed"} ev - String with the event name
|
||||
* @param {module:svgcanvas.SvgCanvas#event:selected|module:svgcanvas.SvgCanvas#event:changed} arg - Argument to pass through to the callback function. If the event is "changed", an array of `Element`s is passed; if "selected", a single-item array of `Element` is passed.
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
/**
|
||||
* @function module:path.EditorContext#resetD
|
||||
* @param {SVGPathElement} p
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
/**
|
||||
* Note: This doesn't round to an integer necessarily
|
||||
@@ -163,7 +163,7 @@ let editorContext_ = null;
|
||||
/**
|
||||
* @function module:path.EditorContext#setStarted
|
||||
* @param {boolean} s
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
/**
|
||||
* @function module:path.EditorContext#getRubberBox
|
||||
@@ -179,14 +179,14 @@ let editorContext_ = null;
|
||||
* @param {PlainObject} cfg
|
||||
* @param {boolean} cfg.closedSubpath
|
||||
* @param {SVGCircleElement[]} cfg.grips
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
/**
|
||||
* @function module:path.EditorContext#endChanges
|
||||
* @param {PlainObject} cfg
|
||||
* @param {string} cfg.cmd
|
||||
* @param {Element} cfg.elem
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
/**
|
||||
* @function module:path.EditorContext#getCurrentZoom
|
||||
@@ -234,7 +234,7 @@ let editorContext_ = null;
|
||||
/**
|
||||
* @function module:path.init
|
||||
* @param {module:path.EditorContext} editorContext
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const init = function (editorContext) {
|
||||
editorContext_ = editorContext;
|
||||
@@ -255,7 +255,7 @@ export const init = function (editorContext) {
|
||||
* @param {Element} elem
|
||||
* @param {Segment} newseg
|
||||
* @param {Integer} index
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const insertItemBefore = function (elem, newseg, index) {
|
||||
// Support insertItemBefore on paths for FF2
|
||||
@@ -535,7 +535,7 @@ export const getControlPoints = function (seg) {
|
||||
* @param {Integer} index
|
||||
* @param {ArgumentsArray} pts
|
||||
* @param {SVGPathElement} elem
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const replacePathSeg = function (type, index, pts, elem) {
|
||||
const pth = elem || path.elem;
|
||||
@@ -689,7 +689,7 @@ export class Segment {
|
||||
|
||||
/**
|
||||
* @param {boolean} y
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
showCtrlPts (y) {
|
||||
for (const i in this.ctrlpts) {
|
||||
@@ -701,7 +701,7 @@ export class Segment {
|
||||
|
||||
/**
|
||||
* @param {boolean} y
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
selectCtrls (y) {
|
||||
$('#ctrlpointgrip_' + this.index + 'c1, #ctrlpointgrip_' + this.index + 'c2')
|
||||
@@ -710,7 +710,7 @@ export class Segment {
|
||||
|
||||
/**
|
||||
* @param {boolean} y
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
show (y) {
|
||||
if (this.ptgrip) {
|
||||
@@ -723,7 +723,7 @@ export class Segment {
|
||||
|
||||
/**
|
||||
* @param {boolean} y
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
select (y) {
|
||||
if (this.ptgrip) {
|
||||
@@ -737,7 +737,7 @@ export class Segment {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
addGrip () {
|
||||
this.ptgrip = getPointGrip(this, true);
|
||||
@@ -747,7 +747,7 @@ export class Segment {
|
||||
|
||||
/**
|
||||
* @param {boolean} full
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
update (full) {
|
||||
if (this.ptgrip) {
|
||||
@@ -773,7 +773,7 @@ export class Segment {
|
||||
/**
|
||||
* @param {Integer} dx
|
||||
* @param {Integer} dy
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
move (dx, dy) {
|
||||
const {item} = this;
|
||||
@@ -816,7 +816,7 @@ export class Segment {
|
||||
|
||||
/**
|
||||
* @param {Integer} num
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
setLinked (num) {
|
||||
let seg, anum, pt;
|
||||
@@ -850,7 +850,7 @@ export class Segment {
|
||||
* @param {Integer} num
|
||||
* @param {Integer} dx
|
||||
* @param {Integer} dy
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
moveCtrl (num, dx, dy) {
|
||||
const {item} = this;
|
||||
@@ -869,7 +869,7 @@ export class Segment {
|
||||
/**
|
||||
* @param {Integer} newType Possible values set during {@link module:path.init}
|
||||
* @param {ArgumentsArray} pts
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
setType (newType, pts) {
|
||||
replacePathSeg(newType, this.index, pts);
|
||||
@@ -991,11 +991,11 @@ export class Path {
|
||||
* @callback module:path.PathEachSegCallback
|
||||
* @this module:path.Segment
|
||||
* @param {Integer} i The index of the seg being iterated
|
||||
* @returns {boolean|undefined} Will stop execution of `eachSeg` if returns `false`
|
||||
* @returns {boolean|void} Will stop execution of `eachSeg` if returns `false`
|
||||
*/
|
||||
/**
|
||||
* @param {module:path.PathEachSegCallback} fn
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
eachSeg (fn) {
|
||||
const len = this.segs.length;
|
||||
@@ -1007,7 +1007,7 @@ export class Path {
|
||||
|
||||
/**
|
||||
* @param {Integer} index
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
addSeg (index) {
|
||||
// Adds a new segment
|
||||
@@ -1048,7 +1048,7 @@ export class Path {
|
||||
|
||||
/**
|
||||
* @param {Integer} index
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
deleteSeg (index) {
|
||||
const seg = this.segs[index];
|
||||
@@ -1078,7 +1078,7 @@ export class Path {
|
||||
|
||||
/**
|
||||
* @param {Integer} index
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
removePtFromSelection (index) {
|
||||
const pos = this.selected_pts.indexOf(index);
|
||||
@@ -1090,7 +1090,7 @@ export class Path {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
clearSelection () {
|
||||
this.eachSeg(function () {
|
||||
@@ -1101,7 +1101,7 @@ export class Path {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
storeD () {
|
||||
this.last_d = this.elem.getAttribute('d');
|
||||
@@ -1109,7 +1109,7 @@ export class Path {
|
||||
|
||||
/**
|
||||
* @param {Integer} y
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
show (y) {
|
||||
// Shows this path's segment grips
|
||||
@@ -1127,7 +1127,7 @@ export class Path {
|
||||
* Move selected points.
|
||||
* @param {Integer} dx
|
||||
* @param {Integer} dy
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
movePts (dx, dy) {
|
||||
let i = this.selected_pts.length;
|
||||
@@ -1140,7 +1140,7 @@ export class Path {
|
||||
/**
|
||||
* @param {Integer} dx
|
||||
* @param {Integer} dy
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
moveCtrl (dx, dy) {
|
||||
const seg = this.segs[this.selected_pts[0]];
|
||||
@@ -1152,7 +1152,7 @@ export class Path {
|
||||
|
||||
/**
|
||||
* @param {?Integer} newType See {@link https://www.w3.org/TR/SVG/single-page.html#paths-InterfaceSVGPathSeg}
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
setSegType (newType) {
|
||||
this.storeD();
|
||||
@@ -1222,7 +1222,7 @@ export class Path {
|
||||
/**
|
||||
* @param {Integer} pt
|
||||
* @param {Integer} ctrlNum
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
selectPt (pt, ctrlNum) {
|
||||
this.clearSelection();
|
||||
@@ -1268,7 +1268,7 @@ export class Path {
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
endChanges (text) {
|
||||
if (isWebkit()) { editorContext_.resetD(this.elem); }
|
||||
@@ -1278,7 +1278,7 @@ export class Path {
|
||||
|
||||
/**
|
||||
* @param {Integer|Integer[]} indexes
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
addPtsToSelection (indexes) {
|
||||
if (!Array.isArray(indexes)) { indexes = [indexes]; }
|
||||
@@ -1347,7 +1347,7 @@ export const getPath_ = function (elem) {
|
||||
/**
|
||||
* @function module:path.removePath_
|
||||
* @param {string} id
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const removePath_ = function (id) {
|
||||
if (id in pathData) { delete pathData[id]; }
|
||||
@@ -1388,7 +1388,7 @@ const getRotVals = function (x, y) {
|
||||
* @function module:path.recalcRotatedPath
|
||||
* @todo This is still using ye olde transform methods, can probably
|
||||
* be optimized or even taken care of by `recalculateDimensions`
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const recalcRotatedPath = function () {
|
||||
const currentPath = path.elem;
|
||||
@@ -1446,7 +1446,7 @@ export const recalcRotatedPath = function () {
|
||||
|
||||
/**
|
||||
* @function module:path.clearData
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const clearData = function () {
|
||||
pathData = {};
|
||||
@@ -1457,7 +1457,7 @@ export const clearData = function () {
|
||||
* @function module:path.reorientGrads
|
||||
* @param {Element} elem
|
||||
* @param {SVGMatrix} m
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
export const reorientGrads = function (elem, m) {
|
||||
const bb = utilsGetBBox(elem);
|
||||
@@ -1792,7 +1792,7 @@ export const pathActions = (function () {
|
||||
* @param {Element} mouseTarget
|
||||
* @param {Float} startX
|
||||
* @param {Float} startY
|
||||
* @returns {boolean|undefined}
|
||||
* @returns {boolean|void}
|
||||
*/
|
||||
mouseDown (evt, mouseTarget, startX, startY) {
|
||||
let id;
|
||||
@@ -2042,7 +2042,7 @@ export const pathActions = (function () {
|
||||
/**
|
||||
* @param {Float} mouseX
|
||||
* @param {Float} mouseY
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
mouseMove (mouseX, mouseY) {
|
||||
const currentZoom = editorContext_.getCurrentZoom();
|
||||
@@ -2178,7 +2178,7 @@ export const pathActions = (function () {
|
||||
* @param {Element} element
|
||||
* @param {Float} mouseX
|
||||
* @param {Float} mouseY
|
||||
* @returns {module:path.keepElement|undefined}
|
||||
* @returns {module:path.keepElement|void}
|
||||
*/
|
||||
mouseUp (evt, element, mouseX, mouseY) {
|
||||
const drawnPath = editorContext_.getDrawnPath();
|
||||
@@ -2230,7 +2230,7 @@ export const pathActions = (function () {
|
||||
},
|
||||
/**
|
||||
* @param {Element} element
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
toEditMode (element) {
|
||||
path = getPath_(element);
|
||||
@@ -2243,7 +2243,7 @@ export const pathActions = (function () {
|
||||
/**
|
||||
* @param {Element} elem
|
||||
* @fires module:svgcanvas.SvgCanvas#event:selected
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
toSelectMode (elem) {
|
||||
const selPath = (elem === path.elem);
|
||||
@@ -2264,7 +2264,7 @@ export const pathActions = (function () {
|
||||
},
|
||||
/**
|
||||
* @param {boolean} on
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
addSubPath (on) {
|
||||
if (on) {
|
||||
@@ -2279,7 +2279,7 @@ export const pathActions = (function () {
|
||||
},
|
||||
/**
|
||||
* @param {Element} target
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
select (target) {
|
||||
if (currentPath === target) {
|
||||
@@ -2292,7 +2292,7 @@ export const pathActions = (function () {
|
||||
},
|
||||
/**
|
||||
* @fires module:svgcanvas.SvgCanvas#event:changed
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
reorient () {
|
||||
const elem = editorContext_.getSelectedElements()[0];
|
||||
@@ -2322,7 +2322,7 @@ export const pathActions = (function () {
|
||||
|
||||
/**
|
||||
* @param {boolean} remove Not in use
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
clear (remove) {
|
||||
const drawnPath = editorContext_.getDrawnPath();
|
||||
@@ -2342,7 +2342,7 @@ export const pathActions = (function () {
|
||||
},
|
||||
/**
|
||||
* @param {?(Element|SVGPathElement)} pth
|
||||
* @returns {false|undefined}
|
||||
* @returns {false|void}
|
||||
*/
|
||||
resetOrientation (pth) {
|
||||
if (isNullish(pth) || pth.nodeName !== 'path') { return false; }
|
||||
@@ -2384,7 +2384,7 @@ export const pathActions = (function () {
|
||||
return undefined;
|
||||
},
|
||||
/**
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
zoomChange () {
|
||||
if (editorContext_.getCurrentMode() === 'pathedit') {
|
||||
@@ -2412,13 +2412,13 @@ export const pathActions = (function () {
|
||||
},
|
||||
/**
|
||||
* @param {boolean} linkPoints
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
linkControlPoints (linkPoints) {
|
||||
setLinkControlPoints(linkPoints);
|
||||
},
|
||||
/**
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
clonePathNode () {
|
||||
path.storeD();
|
||||
@@ -2441,7 +2441,7 @@ export const pathActions = (function () {
|
||||
path.endChanges('Clone path node(s)');
|
||||
},
|
||||
/**
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
opencloseSubPath () {
|
||||
const selPts = path.selected_pts;
|
||||
@@ -2553,7 +2553,7 @@ export const pathActions = (function () {
|
||||
path.init().selectPt(0);
|
||||
},
|
||||
/**
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
deletePathNode () {
|
||||
if (!pathActions.canDeleteNodes) { return; }
|
||||
@@ -2643,7 +2643,7 @@ export const pathActions = (function () {
|
||||
smoothPolylineIntoPath,
|
||||
/**
|
||||
* @param {?Integer} v See {@link https://www.w3.org/TR/SVG/single-page.html#paths-InterfaceSVGPathSeg}
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
setSegType (v) {
|
||||
path.setSegType(v);
|
||||
@@ -2651,7 +2651,7 @@ export const pathActions = (function () {
|
||||
/**
|
||||
* @param {string} attr
|
||||
* @param {Float} newValue
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
moveNode (attr, newValue) {
|
||||
const selPts = path.selected_pts;
|
||||
@@ -2669,7 +2669,7 @@ export const pathActions = (function () {
|
||||
},
|
||||
/**
|
||||
* @param {Element} elem
|
||||
* @returns {undefined}
|
||||
* @returns {void}
|
||||
*/
|
||||
fixEnd (elem) {
|
||||
// Adds an extra segment if the last seg before a Z doesn't end
|
||||
|
||||
Reference in New Issue
Block a user