mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-26 08:04:56 +01:00
Fix lint issues.
This commit is contained in:
parent
181ca7b34e
commit
c89d40758a
@ -7,5 +7,7 @@
|
|||||||
"airbnb-base"
|
"airbnb-base"
|
||||||
],
|
],
|
||||||
"plugins": ["only-warn"],
|
"plugins": ["only-warn"],
|
||||||
"rules": {}
|
"rules": {
|
||||||
|
"no-underscore-dangle": "off"
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,6 +6,12 @@
|
|||||||
"extends": [
|
"extends": [
|
||||||
"airbnb-base"
|
"airbnb-base"
|
||||||
],
|
],
|
||||||
"plugins": ["only-warn"],
|
"plugins": [
|
||||||
"rules": {}
|
"only-warn"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"no-underscore-dangle": "off",
|
||||||
|
"no-restricted-syntax": "off",
|
||||||
|
"max-len": [1,250]
|
||||||
|
}
|
||||||
}
|
}
|
@ -30,8 +30,10 @@ const Arrow = new Class({
|
|||||||
strokeOpacity: 1,
|
strokeOpacity: 1,
|
||||||
};
|
};
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -26,8 +26,10 @@ const CurvedLine = new Class({
|
|||||||
strokeColor: 'blue', strokeWidth: 1, strokeStyle: 'solid', strokeOpacity: 1,
|
strokeColor: 'blue', strokeWidth: 1, strokeStyle: 'solid', strokeOpacity: 1,
|
||||||
};
|
};
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -36,15 +38,15 @@ const CurvedLine = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setFrom(x, y) {
|
setFrom(x, y) {
|
||||||
$assert(!isNaN(x), 'x must be defined');
|
$assert(!Number.isNaN(x), 'x must be defined');
|
||||||
$assert(!isNaN(y), 'y must be defined');
|
$assert(!Number.isNaN(y), 'y must be defined');
|
||||||
|
|
||||||
this.peer.setFrom(x, y);
|
this.peer.setFrom(x, y);
|
||||||
},
|
},
|
||||||
|
|
||||||
setTo(x, y) {
|
setTo(x, y) {
|
||||||
$assert(!isNaN(x), 'x must be defined');
|
$assert(!Number.isNaN(x), 'x must be defined');
|
||||||
$assert(!isNaN(y), 'y must be defined');
|
$assert(!Number.isNaN(y), 'y must be defined');
|
||||||
|
|
||||||
this.peer.setTo(x, y);
|
this.peer.setTo(x, y);
|
||||||
},
|
},
|
||||||
|
@ -23,7 +23,7 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
throw new Error('Element peer can not be null');
|
throw new Error('Element peer can not be null');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($defined(attributes)) { // eslint-disable-line no-undef
|
if ($defined(attributes)) {
|
||||||
this._initialize(attributes);
|
this._initialize(attributes);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -32,31 +32,40 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
const batchExecute = {};
|
const batchExecute = {};
|
||||||
|
|
||||||
// Collect arguments ...
|
// Collect arguments ...
|
||||||
for (var key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
|
|
||||||
const funcName = this._attributeNameToFuncName(key, 'set');
|
const funcName = this._attributeNameToFuncName(key, 'set');
|
||||||
let funcArgs = batchExecute[funcName];
|
let funcArgs = batchExecute[funcName];
|
||||||
if (!$defined(funcArgs)) { // eslint-disable-line no-undef
|
|
||||||
|
if (!$defined(funcArgs)) {
|
||||||
funcArgs = [];
|
funcArgs = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const signature = Element._propertyNameToSignature[key];
|
const signature = Element._propertyNameToSignature[key];
|
||||||
const argPositions = signature[1];
|
const argPositions = signature[1];
|
||||||
if (argPositions != Element._SIGNATURE_MULTIPLE_ARGUMENTS) {
|
|
||||||
|
if (argPositions !== Element._SIGNATURE_MULTIPLE_ARGUMENTS) {
|
||||||
funcArgs[argPositions] = attributes[key];
|
funcArgs[argPositions] = attributes[key];
|
||||||
} else {
|
} else {
|
||||||
funcArgs = attributes[key].split(' ');
|
funcArgs = attributes[key].split(' ');
|
||||||
}
|
}
|
||||||
batchExecute[funcName] = funcArgs;
|
batchExecute[funcName] = funcArgs;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call functions ...
|
// Call functions ...
|
||||||
for (var key in batchExecute) { // eslint-disable-line no-redeclare
|
for (const key in batchExecute) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(batchExecute, key)) {
|
||||||
|
|
||||||
const func = this[key];
|
const func = this[key];
|
||||||
if (!$defined(func)) { // eslint-disable-line no-undef
|
if (!$defined(func)) {
|
||||||
throw new Error(`Could not find function: ${key}`);
|
throw new Error(`Could not find function: ${key}`);
|
||||||
}
|
}
|
||||||
func.apply(this, batchExecute[key]);
|
func.apply(this, batchExecute[key]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setSize(width, height) {
|
setSize(width, height) {
|
||||||
@ -72,7 +81,8 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
* type
|
* type
|
||||||
* A string representing the event type to listen for.
|
* A string representing the event type to listen for.
|
||||||
* listener
|
* listener
|
||||||
* The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a function in JavaScript.
|
* The object that receives a notification when an event of the specified type occurs. This must be an object
|
||||||
|
* implementing the EventListener interface, or simply a function in JavaScript.
|
||||||
*
|
*
|
||||||
* The following events types are supported:
|
* The following events types are supported:
|
||||||
*
|
*
|
||||||
@ -146,13 +156,13 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
*/
|
*/
|
||||||
setStroke(width, style, color, opacity) {
|
setStroke(width, style, color, opacity) {
|
||||||
if (
|
if (
|
||||||
style != null
|
style !== null
|
||||||
&& style != undefined
|
&& style !== undefined
|
||||||
&& style != 'dash'
|
&& style !== 'dash'
|
||||||
&& style != 'dot'
|
&& style !== 'dot'
|
||||||
&& style != 'solid'
|
&& style !== 'solid'
|
||||||
&& style != 'longdash'
|
&& style !== 'longdash'
|
||||||
&& style != 'dashdot'
|
&& style !== 'dashdot'
|
||||||
) {
|
) {
|
||||||
throw new Error(`Unsupported stroke style: '${style}'`);
|
throw new Error(`Unsupported stroke style: '${style}'`);
|
||||||
}
|
}
|
||||||
@ -161,8 +171,8 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
|
|
||||||
_attributeNameToFuncName(attributeKey, prefix) {
|
_attributeNameToFuncName(attributeKey, prefix) {
|
||||||
const signature = Element._propertyNameToSignature[attributeKey];
|
const signature = Element._propertyNameToSignature[attributeKey];
|
||||||
if (!$defined(signature)) { // eslint-disable-line no-undef
|
if (!$defined(signature)) {
|
||||||
throw `Unsupported attribute: ${attributeKey}`;
|
throw new Error(`Unsupported attribute: ${attributeKey}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const firstLetter = signature[0].charAt(0);
|
const firstLetter = signature[0].charAt(0);
|
||||||
@ -175,11 +185,12 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
* fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight, coordOrigin, coordOriginX, coordOrigiY
|
* fill, fillColor, fillOpacity, coordSize, coordSizeWidth, coordSizeHeight, coordOrigin, coordOriginX, coordOrigiY
|
||||||
*/
|
*/
|
||||||
setAttribute(key, value) {
|
setAttribute(key, value) {
|
||||||
|
|
||||||
const funcName = this._attributeNameToFuncName(key, 'set');
|
const funcName = this._attributeNameToFuncName(key, 'set');
|
||||||
|
|
||||||
const signature = Element._propertyNameToSignature[key];
|
const signature = Element._propertyNameToSignature[key];
|
||||||
if (signature == null) {
|
if (signature == null) {
|
||||||
throw `Could not find the signature for:${key}`;
|
throw new Error(`Could not find the signature for:${key}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse arguments ..
|
// Parse arguments ..
|
||||||
@ -187,7 +198,7 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
let args = [];
|
let args = [];
|
||||||
if (argPositions !== this._SIGNATURE_MULTIPLE_ARGUMENTS) {
|
if (argPositions !== this._SIGNATURE_MULTIPLE_ARGUMENTS) {
|
||||||
args[argPositions] = value;
|
args[argPositions] = value;
|
||||||
} else if (typeof value === 'array') { // eslint-disable-line valid-typeof
|
} else if (Array.isArray(value)) {
|
||||||
args = value;
|
args = value;
|
||||||
} else {
|
} else {
|
||||||
const strValue = String(value);
|
const strValue = String(value);
|
||||||
@ -197,7 +208,7 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
// Look up method ...
|
// Look up method ...
|
||||||
const setter = this[funcName];
|
const setter = this[funcName];
|
||||||
if (setter == null) {
|
if (setter == null) {
|
||||||
throw `Could not find the function name:${funcName}`;
|
throw new Error(`Could not find the function name:${funcName}`);
|
||||||
}
|
}
|
||||||
setter.apply(this, args);
|
setter.apply(this, args);
|
||||||
},
|
},
|
||||||
@ -207,23 +218,23 @@ const Element = new Class({ // eslint-disable-line no-undef
|
|||||||
|
|
||||||
const signature = Element._propertyNameToSignature[key];
|
const signature = Element._propertyNameToSignature[key];
|
||||||
if (signature == null) {
|
if (signature == null) {
|
||||||
throw `Could not find the signature for:${key}`;
|
throw new Error(`Could not find the signature for:${key}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getter = this[funcName];
|
const getter = this[funcName];
|
||||||
if (getter == null) {
|
if (getter == null) {
|
||||||
throw `Could not find the function name:${funcName}`;
|
throw new Error(`Could not find the function name:${funcName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getterResult = getter.apply(this, []);
|
const getterResult = getter.apply(this, []);
|
||||||
const attibuteName = signature[2];
|
const attibuteName = signature[2];
|
||||||
if (!$defined(attibuteName)) { // eslint-disable-line no-undef
|
if (!$defined(attibuteName)) {
|
||||||
throw `Could not find attribute mapping for:${key}`;
|
throw new Error(`Could not find attribute mapping for:${key}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = getterResult[attibuteName];
|
const result = getterResult[attibuteName];
|
||||||
if (!$defined(result)) { // eslint-disable-line no-undef
|
if (!$defined(result)) {
|
||||||
throw `Could not find attribute with name:${attibuteName}`;
|
throw new Error(`Could not find attribute with name:${attibuteName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -26,8 +26,10 @@ const Elipse = new Class({
|
|||||||
width: 40, height: 40, x: 5, y: 5, stroke: '1 solid black', fillColor: 'blue',
|
width: 40, height: 40, x: 5, y: 5, stroke: '1 solid black', fillColor: 'blue',
|
||||||
};
|
};
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
const Toolkit = require('./Toolkit');
|
|
||||||
const TransformUtil = require('./peer/utils/TransformUtils').default;
|
const TransformUtil = require('./peer/utils/TransformUtils').default;
|
||||||
|
|
||||||
const Font = new Class({
|
const Font = new Class({
|
||||||
|
@ -29,8 +29,10 @@ const Group = new Class({
|
|||||||
width: 50, height: 50, x: 50, y: 50, coordOrigin: '0 0', coordSize: '50 50',
|
width: 50, height: 50, x: 50, y: 50, coordOrigin: '0 0', coordSize: '50 50',
|
||||||
};
|
};
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ const Group = new Class({
|
|||||||
throw Error('Child element can not be null');
|
throw Error('Child element can not be null');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element == this) {
|
if (element === this) {
|
||||||
throw new Error("It's not posible to add the group as a child of itself");
|
throw new Error("It's not posible to add the group as a child of itself");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ const Group = new Class({
|
|||||||
throw new Error(`It seems not to be an element ->${element}`);
|
throw new Error(`It seems not to be an element ->${element}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementType == 'Workspace') {
|
if (elementType === 'Workspace') {
|
||||||
throw new Error('A group can not have a workspace as a child');
|
throw new Error('A group can not have a workspace as a child');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,10 @@ const Line = new Class({
|
|||||||
const peer = Toolkit.createLine();
|
const peer = Toolkit.createLine();
|
||||||
const defaultAttributes = { strokeColor: '#495879', strokeWidth: 1, strokeOpacity: 1 };
|
const defaultAttributes = { strokeColor: '#495879', strokeWidth: 1, strokeOpacity: 1 };
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -26,8 +26,10 @@ const PolyLine = new Class({
|
|||||||
strokeColor: 'blue', strokeWidth: 1, strokeStyle: 'solid', strokeOpacity: 1,
|
strokeColor: 'blue', strokeWidth: 1, strokeStyle: 'solid', strokeOpacity: 1,
|
||||||
};
|
};
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -28,20 +28,18 @@ const Rect = new Class({
|
|||||||
Extends: Element,
|
Extends: Element,
|
||||||
initialize(arc, attributes) {
|
initialize(arc, attributes) {
|
||||||
if (arc && arc > 1) {
|
if (arc && arc > 1) {
|
||||||
throw 'Arc must be 0<=arc<=1';
|
throw new Error('Arc must be 0<=arc<=1');
|
||||||
}
|
}
|
||||||
if (arguments.length <= 0) {
|
|
||||||
const rx = 0;
|
|
||||||
const ry = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const peer = Toolkit.createRect(arc);
|
const peer = Toolkit.createRect(arc);
|
||||||
const defaultAttributes = {
|
const defaultAttributes = {
|
||||||
width: 40, height: 40, x: 5, y: 5, stroke: '1 solid black', fillColor: 'green',
|
width: 40, height: 40, x: 5, y: 5, stroke: '1 solid black', fillColor: 'green',
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ const Text = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getHeight() {
|
getHeight() {
|
||||||
return parseInt(this.peer.getHeight());
|
return parseInt(this.peer.getHeight(), 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
getFontHeight() {
|
getFontHeight() {
|
||||||
|
@ -33,8 +33,10 @@ const Workspace = new Class({
|
|||||||
coordSize: '200 200',
|
coordSize: '200 200',
|
||||||
};
|
};
|
||||||
for (const key in attributes) {
|
for (const key in attributes) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(attributes, key)) {
|
||||||
defaultAttributes[key] = attributes[key];
|
defaultAttributes[key] = attributes[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.parent(peer, defaultAttributes);
|
this.parent(peer, defaultAttributes);
|
||||||
this._htmlContainer.append(this.peer._native);
|
this._htmlContainer.append(this.peer._native);
|
||||||
},
|
},
|
||||||
@ -48,15 +50,15 @@ const Workspace = new Class({
|
|||||||
*/
|
*/
|
||||||
append(element) {
|
append(element) {
|
||||||
if (!$defined(element)) {
|
if (!$defined(element)) {
|
||||||
throw 'Child element can not be null';
|
throw new Error('Child element can not be null');
|
||||||
}
|
}
|
||||||
const elementType = element.getType();
|
const elementType = element.getType();
|
||||||
if (elementType == null) {
|
if (elementType == null) {
|
||||||
throw `It seems not to be an element ->${element}`;
|
throw new Error(`It seems not to be an element ->${element}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementType == 'Workspace') {
|
if (elementType === 'Workspace') {
|
||||||
throw 'A workspace can not have a workspace as a child';
|
throw new Error('A workspace can not have a workspace as a child');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.peer.append(element.peer);
|
this.peer.append(element.peer);
|
||||||
@ -64,7 +66,7 @@ const Workspace = new Class({
|
|||||||
|
|
||||||
addItAsChildTo(element) {
|
addItAsChildTo(element) {
|
||||||
if (!$defined(element)) {
|
if (!$defined(element)) {
|
||||||
throw 'Workspace div container can not be null';
|
throw new Error('Workspace div container can not be null');
|
||||||
}
|
}
|
||||||
element.append(this._htmlContainer);
|
element.append(this._htmlContainer);
|
||||||
},
|
},
|
||||||
@ -157,13 +159,13 @@ const Workspace = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setStroke(width, style, color, opacity) {
|
setStroke(width, style, color, opacity) {
|
||||||
if (style != 'solid') {
|
if (style !== 'solid') {
|
||||||
throw `Not supported style stroke style:${style}`;
|
throw new Error(`Not supported style stroke style:${style}`);
|
||||||
}
|
}
|
||||||
this._htmlContainer.css('border', `${width} ${style} ${color}`);
|
this._htmlContainer.css('border', `${width} ${style} ${color}`);
|
||||||
|
|
||||||
if (opacity || opacity === 0) {
|
if (opacity || opacity === 0) {
|
||||||
throw 'Unsupported operation. Opacity not supported.';
|
throw new Error('Unsupported operation. Opacity not supported.');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -176,16 +178,16 @@ const Workspace = new Class({
|
|||||||
*/
|
*/
|
||||||
removeChild(element) {
|
removeChild(element) {
|
||||||
if (!$defined(element)) {
|
if (!$defined(element)) {
|
||||||
throw 'Child element can not be null';
|
throw new Error('Child element can not be null');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element == this) {
|
if (element === this) {
|
||||||
throw "It's not possible to add the group as a child of itself";
|
throw new Error("It's not possible to add the group as a child of itself");
|
||||||
}
|
}
|
||||||
|
|
||||||
const elementType = element.getType();
|
const elementType = element.getType();
|
||||||
if (elementType == null) {
|
if (elementType == null) {
|
||||||
throw `It seems not to be an element ->${element}`;
|
throw new Error(`It seems not to be an element ->${element}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.peer.removeChild(element.peer);
|
this.peer.removeChild(element.peer);
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2015] [wisemapping]
|
|
||||||
*
|
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the license at
|
|
||||||
*
|
|
||||||
* http://www.wisemapping.org/license
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const web2d = {};
|
|
||||||
web2d.peer = {
|
|
||||||
svg: {},
|
|
||||||
};
|
|
||||||
web2d.peer.utils = {};
|
|
@ -48,8 +48,8 @@ const CurvedLinePeer = new Class({
|
|||||||
const change = this._control2.x != control.x || this._control2.y != control.y;
|
const change = this._control2.x != control.x || this._control2.y != control.y;
|
||||||
if ($defined(control.x)) {
|
if ($defined(control.x)) {
|
||||||
this._control2 = control;
|
this._control2 = control;
|
||||||
this._control2.x = parseInt(this._control2.x);
|
this._control2.x = parseInt(this._control2.x, 10);
|
||||||
this._control2.y = parseInt(this._control2.y);
|
this._control2.y = parseInt(this._control2.y, 10);
|
||||||
}
|
}
|
||||||
if (change) this._updatePath();
|
if (change) this._updatePath();
|
||||||
},
|
},
|
||||||
@ -75,16 +75,16 @@ const CurvedLinePeer = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setFrom(x1, y1) {
|
setFrom(x1, y1) {
|
||||||
const change = this._x1 != parseInt(x1) || this._y1 != parseInt(y1);
|
const change = this._x1 != parseInt(x1, 10) || this._y1 != parseInt(y1, 10);
|
||||||
this._x1 = parseInt(x1);
|
this._x1 = parseInt(x1, 10);
|
||||||
this._y1 = parseInt(y1);
|
this._y1 = parseInt(y1, 10);
|
||||||
if (change) this._updatePath();
|
if (change) this._updatePath();
|
||||||
},
|
},
|
||||||
|
|
||||||
setTo(x2, y2) {
|
setTo(x2, y2) {
|
||||||
const change = this._x2 != parseInt(x2) || this._y2 != parseInt(y2);
|
const change = this._x2 !== parseInt(x2, 10) || this._y2 !== parseInt(y2, 10);
|
||||||
this._x2 = parseInt(x2);
|
this._x2 = parseInt(x2, 10);
|
||||||
this._y2 = parseInt(y2);
|
this._y2 = parseInt(y2, 10);
|
||||||
if (change) this._updatePath();
|
if (change) this._updatePath();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -149,13 +149,8 @@ const CurvedLinePeer = new Class({
|
|||||||
if ($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2)) {
|
if ($defined(this._x1) && $defined(this._y1) && $defined(this._x2) && $defined(this._y2)) {
|
||||||
this._calculateAutoControlPoints(avoidControlPointFix);
|
this._calculateAutoControlPoints(avoidControlPointFix);
|
||||||
const path = `M${this._x1},${this._y1
|
const path = `M${this._x1},${this._y1
|
||||||
} C${this._control1.x + this._x1},${this._control1.y + this._y1} ${
|
} C${this._control1.x + this._x1},${this._control1.y + this._y1} ${this._control2.x + this._x2},${this._control2.y + this._y2} ${this._x2},${this._y2
|
||||||
this._control2.x + this._x2},${this._control2.y + this._y2} ${
|
}${this._lineStyle ? ` ${this._control2.x + this._x2},${this._control2.y + this._y2 + 3} ${this._control1.x + this._x1},${this._control1.y + this._y1 + 5} ${this._x1},${this._y1 + 7} Z`
|
||||||
this._x2},${this._y2
|
|
||||||
}${this._lineStyle ? ` ${
|
|
||||||
this._control2.x + this._x2},${this._control2.y + this._y2 + 3} ${
|
|
||||||
this._control1.x + this._x1},${this._control1.y + this._y1 + 5} ${
|
|
||||||
this._x1},${this._y1 + 7} Z`
|
|
||||||
: ''}`;
|
: ''}`;
|
||||||
this._native.setAttribute('d', path);
|
this._native.setAttribute('d', path);
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ const TransformUtil = {
|
|||||||
const coordSize = current.getCoordSize();
|
const coordSize = current.getCoordSize();
|
||||||
const size = current.getSize();
|
const size = current.getSize();
|
||||||
|
|
||||||
width *= (parseInt(size.width) / coordSize.width);
|
width *= (parseInt(size.width,10) / coordSize.width);
|
||||||
height *= (parseInt(size.height) / coordSize.height);
|
height *= (parseInt(size.height,10) / coordSize.height);
|
||||||
current = current.getParent();
|
current = current.getParent();
|
||||||
}
|
}
|
||||||
return { width, height };
|
return { width, height };
|
||||||
|
Loading…
Reference in New Issue
Block a user