- Refactoring: Use static keyword for classes

This commit is contained in:
Brett Zamir
2019-05-08 09:58:18 +08:00
parent fc0c53f61a
commit 597644999d
22 changed files with 615 additions and 557 deletions

54
dist/canvg.js vendored
View File

@@ -521,35 +521,41 @@ var canvg = (function (exports) {
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$1(obj) {

View File

@@ -521,35 +521,41 @@ var svgEditorExtension_server_moinsave = (function () {
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$1(obj) {

View File

@@ -521,35 +521,41 @@ var svgEditorExtension_server_opensave = (function () {
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$1(obj) {

143
dist/index-es.js vendored
View File

@@ -2559,6 +2559,22 @@ var getReverseNS = function getReverseNS() {
}
return builder.pathSegList;
} // STATIC
}], [{
key: "_pathSegArrayAsString",
value: function _pathSegArrayAsString(pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}
}]);
@@ -2573,24 +2589,9 @@ var getReverseNS = function getReverseNS() {
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@@ -6316,46 +6317,48 @@ function () {
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@@ -13160,39 +13163,41 @@ function () {
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

143
dist/index-umd.js vendored
View File

@@ -2565,6 +2565,22 @@
}
return builder.pathSegList;
} // STATIC
}], [{
key: "_pathSegArrayAsString",
value: function _pathSegArrayAsString(pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}
}]);
@@ -2579,24 +2595,9 @@
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@@ -6322,46 +6323,48 @@
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@@ -13166,39 +13169,41 @@
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -364,35 +364,41 @@
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
var jsPDFAPI = jsPDF.API;
var pdfSvgAttr = {
// allowed attributes. all others are removed from the preview.

View File

@@ -2343,6 +2343,22 @@
}
return builder.pathSegList;
} // STATIC
}], [{
key: "_pathSegArrayAsString",
value: function _pathSegArrayAsString(pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}
}]);
@@ -2357,24 +2373,9 @@
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {

143
dist/svgcanvas-iife.js vendored
View File

@@ -2437,6 +2437,22 @@ var SvgCanvas = (function () {
}
return builder.pathSegList;
} // STATIC
}], [{
key: "_pathSegArrayAsString",
value: function _pathSegArrayAsString(pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}
}]);
@@ -2451,24 +2467,9 @@ var SvgCanvas = (function () {
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@@ -6388,46 +6389,48 @@ var SvgCanvas = (function () {
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@@ -12938,39 +12941,41 @@ var SvgCanvas = (function () {
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long