Reduce Mootools components.
This commit is contained in:
@@ -21,9 +21,9 @@
|
||||
*/
|
||||
web2d.Group = new Class({
|
||||
Extends: web2d.Element,
|
||||
initialize : function(attributes) {
|
||||
initialize: function (attributes) {
|
||||
var peer = web2d.peer.Toolkit.createGroup();
|
||||
var defaultAttributes = {width:50, height:50, x:50, y:50,coordOrigin:'0 0',coordSize:'50 50'};
|
||||
var defaultAttributes = {width: 50, height: 50, x: 50, y: 50, coordOrigin: '0 0', coordSize: '50 50'};
|
||||
for (var key in attributes) {
|
||||
defaultAttributes[key] = attributes[key];
|
||||
}
|
||||
@@ -33,7 +33,7 @@ web2d.Group = new Class({
|
||||
/**
|
||||
* Remove an element as a child to the object.
|
||||
*/
|
||||
removeChild : function(element) {
|
||||
removeChild: function (element) {
|
||||
if (!$defined(element)) {
|
||||
throw "Child element can not be null";
|
||||
}
|
||||
@@ -53,7 +53,7 @@ web2d.Group = new Class({
|
||||
/**
|
||||
* Appends an element as a child to the object.
|
||||
*/
|
||||
appendChild : function(element) {
|
||||
append: function (element) {
|
||||
if (!$defined(element)) {
|
||||
throw "Child element can not be null";
|
||||
}
|
||||
@@ -71,11 +71,11 @@ web2d.Group = new Class({
|
||||
throw "A group can not have a workspace as a child";
|
||||
}
|
||||
|
||||
this._peer.appendChild(element._peer);
|
||||
this._peer.append(element._peer);
|
||||
},
|
||||
|
||||
|
||||
getType : function() {
|
||||
getType: function () {
|
||||
return "Group";
|
||||
},
|
||||
|
||||
@@ -86,34 +86,34 @@ web2d.Group = new Class({
|
||||
* Consequently CSS2 position attributes (left, top, width, height and so on) have no unit specifier -
|
||||
* they are simple numbers, not CSS length quantities.
|
||||
*/
|
||||
setCoordSize : function(width, height) {
|
||||
setCoordSize: function (width, height) {
|
||||
this._peer.setCoordSize(width, height);
|
||||
},
|
||||
|
||||
setCoordOrigin : function(x, y) {
|
||||
setCoordOrigin: function (x, y) {
|
||||
this._peer.setCoordOrigin(x, y);
|
||||
},
|
||||
|
||||
getCoordOrigin : function() {
|
||||
getCoordOrigin: function () {
|
||||
return this._peer.getCoordOrigin();
|
||||
},
|
||||
getSize : function() {
|
||||
getSize: function () {
|
||||
return this._peer.getSize();
|
||||
},
|
||||
|
||||
setFill : function(color, opacity) {
|
||||
setFill: function (color, opacity) {
|
||||
throw "Unsupported operation. Fill can not be set to a group";
|
||||
},
|
||||
|
||||
setStroke : function(width, style, color, opacity) {
|
||||
setStroke: function (width, style, color, opacity) {
|
||||
throw "Unsupported operation. Stroke can not be set to a group";
|
||||
},
|
||||
|
||||
getCoordSize : function() {
|
||||
getCoordSize: function () {
|
||||
return this._peer.getCoordSize();
|
||||
},
|
||||
|
||||
appendDomChild : function(DomElement) {
|
||||
appendDomChild: function (DomElement) {
|
||||
if (!$defined(DomElement)) {
|
||||
throw "Child element can not be null";
|
||||
}
|
||||
@@ -122,11 +122,11 @@ web2d.Group = new Class({
|
||||
throw "It's not possible to add the group as a child of itself";
|
||||
}
|
||||
|
||||
this._peer._native.appendChild(DomElement);
|
||||
this._peer._native.append(DomElement);
|
||||
},
|
||||
|
||||
setOpacity:function(value){
|
||||
this._peer.setOpacity(value);
|
||||
setOpacity: function (value) {
|
||||
this._peer.setOpacity(value);
|
||||
}
|
||||
|
||||
});
|
@@ -17,27 +17,27 @@
|
||||
*/
|
||||
|
||||
web2d.Workspace = new Class({
|
||||
Extends:web2d.Element,
|
||||
initialize:function(attributes) {
|
||||
Extends: web2d.Element,
|
||||
initialize: function (attributes) {
|
||||
this._htmlContainer = this._createDivContainer();
|
||||
|
||||
var peer = web2d.peer.Toolkit.createWorkspace(this._htmlContainer);
|
||||
var defaultAttributes = {width:'200px',height:'200px',stroke:'1px solid #edf1be',
|
||||
fillColor:"white",coordOrigin:'0 0',coordSize:'200 200' };
|
||||
var defaultAttributes = {width: '200px', height: '200px', stroke: '1px solid #edf1be',
|
||||
fillColor: "white", coordOrigin: '0 0', coordSize: '200 200' };
|
||||
for (var key in attributes) {
|
||||
defaultAttributes[key] = attributes[key];
|
||||
}
|
||||
this.parent(peer, defaultAttributes);
|
||||
this._htmlContainer.appendChild(this._peer._native);
|
||||
this._htmlContainer.append(this._peer._native);
|
||||
},
|
||||
|
||||
getType : function() {
|
||||
getType: function () {
|
||||
return "Workspace";
|
||||
},
|
||||
/**
|
||||
* Appends an element as a child to the object.
|
||||
*/
|
||||
appendChild : function(element) {
|
||||
append: function (element) {
|
||||
if (!$defined(element)) {
|
||||
throw "Child element can not be null";
|
||||
}
|
||||
@@ -50,20 +50,20 @@ web2d.Workspace = new Class({
|
||||
throw "A workspace can not have a workspace as a child";
|
||||
}
|
||||
|
||||
this._peer.appendChild(element._peer);
|
||||
this._peer.append(element._peer);
|
||||
},
|
||||
|
||||
addItAsChildTo : function(element) {
|
||||
addItAsChildTo: function (element) {
|
||||
if (!$defined(element)) {
|
||||
throw "Workspace div container can not be null";
|
||||
}
|
||||
element.appendChild(this._htmlContainer);
|
||||
element.append(this._htmlContainer);
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a new div element that will be responsible for containing the workspace elements.
|
||||
*/
|
||||
_createDivContainer : function(domElement) {
|
||||
_createDivContainer: function () {
|
||||
var container = window.document.createElement("div");
|
||||
container.id = "workspaceContainer";
|
||||
// container.style.overflow = "hidden";
|
||||
@@ -73,7 +73,7 @@ web2d.Workspace = new Class({
|
||||
container.style.height = "688px";
|
||||
container.style.border = '1px solid red';
|
||||
|
||||
return container;
|
||||
return $(container);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -84,15 +84,15 @@ web2d.Workspace = new Class({
|
||||
* pt (points; 1pt=1/72in)
|
||||
* pc (picas; 1pc=12pt)
|
||||
*/
|
||||
setSize : function(width, height) {
|
||||
setSize: function (width, height) {
|
||||
// HTML container must have the size of the group element.
|
||||
if ($defined(width)) {
|
||||
this._htmlContainer.style.width = width;
|
||||
this._htmlContainer.css('width', width);
|
||||
|
||||
}
|
||||
|
||||
if ($defined(height)) {
|
||||
this._htmlContainer.style.height = height;
|
||||
this._htmlContainer.css('height', height);
|
||||
}
|
||||
this._peer.setSize(width, height);
|
||||
},
|
||||
@@ -104,21 +104,21 @@ web2d.Workspace = new Class({
|
||||
* Consequently CSS2 position attributes (left, top, width, height and so on) have no unit specifier -
|
||||
* they are simple numbers, not CSS length quantities.
|
||||
*/
|
||||
setCoordSize : function(width, height) {
|
||||
setCoordSize: function (width, height) {
|
||||
this._peer.setCoordSize(width, height);
|
||||
},
|
||||
|
||||
/**
|
||||
* @Todo: Complete Doc
|
||||
*/
|
||||
setCoordOrigin : function(x, y) {
|
||||
setCoordOrigin: function (x, y) {
|
||||
this._peer.setCoordOrigin(x, y);
|
||||
},
|
||||
|
||||
/**
|
||||
* @Todo: Complete Doc
|
||||
*/
|
||||
getCoordOrigin : function() {
|
||||
getCoordOrigin: function () {
|
||||
return this._peer.getCoordOrigin();
|
||||
},
|
||||
|
||||
@@ -127,34 +127,34 @@ web2d.Workspace = new Class({
|
||||
/**
|
||||
* All the SVG elements will be children of this HTML element.
|
||||
*/
|
||||
_getHtmlContainer : function() {
|
||||
_getHtmlContainer: function () {
|
||||
return this._htmlContainer;
|
||||
},
|
||||
|
||||
setFill : function(color, opacity) {
|
||||
this._htmlContainer.style.backgroundColor = color;
|
||||
setFill: function (color, opacity) {
|
||||
this._htmlContainer.css('background-color', color);
|
||||
if (opacity || opacity === 0) {
|
||||
throw "Unsupported operation. Opacity not supported.";
|
||||
}
|
||||
},
|
||||
|
||||
getFill : function() {
|
||||
var color = this._htmlContainer.style.backgroundColor;
|
||||
return {color:color};
|
||||
getFill: function () {
|
||||
var color = this._htmlContainer.css('background-color');
|
||||
return {color: color};
|
||||
},
|
||||
|
||||
|
||||
getSize : function() {
|
||||
var width = this._htmlContainer.style.width;
|
||||
var height = this._htmlContainer.style.height;
|
||||
return {width:width,height:height};
|
||||
getSize: function () {
|
||||
var width = this._htmlContainer.css('width');
|
||||
var height = this._htmlContainer.css('height');
|
||||
return {width: width, height: height};
|
||||
},
|
||||
|
||||
setStroke : function(width, style, color, opacity) {
|
||||
setStroke: function (width, style, color, opacity) {
|
||||
if (style != 'solid') {
|
||||
throw 'Not supported style stroke style:' + style;
|
||||
}
|
||||
this._htmlContainer.style.border = width + ' ' + style + ' ' + color;
|
||||
this._htmlContainer.css('border',width + ' ' + style + ' ' + color);
|
||||
|
||||
if (opacity || opacity === 0) {
|
||||
throw "Unsupported operation. Opacity not supported.";
|
||||
@@ -162,14 +162,14 @@ web2d.Workspace = new Class({
|
||||
},
|
||||
|
||||
|
||||
getCoordSize : function() {
|
||||
getCoordSize: function () {
|
||||
return this._peer.getCoordSize();
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove an element as a child to the object.
|
||||
*/
|
||||
removeChild : function(element) {
|
||||
removeChild: function (element) {
|
||||
if (!$defined(element)) {
|
||||
throw "Child element can not be null";
|
||||
}
|
||||
@@ -186,7 +186,7 @@ web2d.Workspace = new Class({
|
||||
this._peer.removeChild(element._peer);
|
||||
},
|
||||
|
||||
dumpNativeChart : function() {
|
||||
dumpNativeChart: function () {
|
||||
var elem = this._htmlContainer
|
||||
return elem.innerHTML;
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ web2d.peer.svg.ElementPeer = new Class({
|
||||
this._parent = parent;
|
||||
},
|
||||
|
||||
appendChild:function (elementPeer) {
|
||||
append:function (elementPeer) {
|
||||
// Store parent and child relationship.
|
||||
elementPeer.setParent(this);
|
||||
var children = this.getChildren();
|
||||
@@ -86,7 +86,7 @@ web2d.peer.svg.ElementPeer = new Class({
|
||||
* http://developer.mozilla.org/en/docs/addEvent
|
||||
*/
|
||||
addEvent:function (type, listener) {
|
||||
this._native.addEvent(type, listener);
|
||||
$(this._native).bind(type, listener);
|
||||
},
|
||||
|
||||
fireEvent:function (type, event) {
|
||||
@@ -98,7 +98,7 @@ web2d.peer.svg.ElementPeer = new Class({
|
||||
},
|
||||
|
||||
removeEvent:function (type, listener) {
|
||||
this._native.removeEvent(type, listener);
|
||||
$(this._native).unbind(type, listener);
|
||||
},
|
||||
|
||||
setSize:function (width, height) {
|
||||
@@ -214,12 +214,12 @@ web2d.peer.svg.ElementPeer = new Class({
|
||||
return listeners;
|
||||
},
|
||||
|
||||
positionRelativeTo:function (elem, options) {
|
||||
options = !$defined(options) ? {} : options;
|
||||
options['relativeTo'] = document.id(this._native);
|
||||
elem.position(options);
|
||||
},
|
||||
|
||||
// positionRelativeTo:function (elem, options) {
|
||||
// options = !$defined(options) ? {} : options;
|
||||
// options['relativeTo'] = document.id(this._native);
|
||||
// elem.position(options);
|
||||
// },
|
||||
//
|
||||
|
||||
/**
|
||||
* Move element to the front
|
||||
|
@@ -18,17 +18,17 @@
|
||||
|
||||
web2d.peer.svg.GroupPeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
initialize: function () {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'g');
|
||||
this.parent(svgElement);
|
||||
this._native.setAttribute("preserveAspectRatio", "none");
|
||||
this._coordSize = {width:1,height:1};
|
||||
this._coordSize = {width: 1, height: 1};
|
||||
this._native.setAttribute("focusable", "true");
|
||||
this._position = {x:0,y:0};
|
||||
this._coordOrigin = {x:0,y:0};
|
||||
this._position = {x: 0, y: 0};
|
||||
this._coordOrigin = {x: 0, y: 0};
|
||||
},
|
||||
|
||||
setCoordSize : function(width, height) {
|
||||
setCoordSize: function (width, height) {
|
||||
var change = this._coordSize.width != width || this._coordSize.height != height;
|
||||
this._coordSize.width = width;
|
||||
this._coordSize.height = height;
|
||||
@@ -38,8 +38,8 @@ web2d.peer.svg.GroupPeer = new Class({
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
},
|
||||
|
||||
getCoordSize : function() {
|
||||
return {width:this._coordSize.width,height:this._coordSize.height};
|
||||
getCoordSize: function () {
|
||||
return {width: this._coordSize.width, height: this._coordSize.height};
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ web2d.peer.svg.GroupPeer = new Class({
|
||||
* * skewY(<skew-angle>), which specifies a skew transformation along the y-axis.
|
||||
**/
|
||||
|
||||
updateTransform : function() {
|
||||
updateTransform: function () {
|
||||
var sx = this._size.width / this._coordSize.width;
|
||||
var sy = this._size.height / this._coordSize.height;
|
||||
|
||||
@@ -73,11 +73,11 @@ web2d.peer.svg.GroupPeer = new Class({
|
||||
this._native.setAttribute("transform", "translate(" + cx + "," + cy + ") scale(" + sx + "," + sy + ")");
|
||||
},
|
||||
|
||||
setOpacity : function(value) {
|
||||
setOpacity: function (value) {
|
||||
this._native.setAttribute("opacity", value);
|
||||
},
|
||||
|
||||
setCoordOrigin : function(x, y) {
|
||||
setCoordOrigin: function (x, y) {
|
||||
var change = x != this._coordOrigin.x || y != this._coordOrigin.y;
|
||||
if ($defined(x)) {
|
||||
this._coordOrigin.x = x;
|
||||
@@ -90,14 +90,14 @@ web2d.peer.svg.GroupPeer = new Class({
|
||||
this.updateTransform();
|
||||
},
|
||||
|
||||
setSize : function(width, height) {
|
||||
setSize: function (width, height) {
|
||||
var change = width != this._size.width || height != this._size.height;
|
||||
this.parent(width, height);
|
||||
if (change)
|
||||
this.updateTransform();
|
||||
},
|
||||
|
||||
setPosition : function(x, y) {
|
||||
setPosition: function (x, y) {
|
||||
var change = x != this._position.x || y != this._position.y;
|
||||
if ($defined(x)) {
|
||||
this._position.x = parseInt(x);
|
||||
@@ -110,16 +110,16 @@ web2d.peer.svg.GroupPeer = new Class({
|
||||
this.updateTransform();
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
return {x:this._position.x,y:this._position.y};
|
||||
getPosition: function () {
|
||||
return {x: this._position.x, y: this._position.y};
|
||||
},
|
||||
|
||||
appendChild : function(child) {
|
||||
append: function (child) {
|
||||
this.parent(child);
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
|
||||
},
|
||||
|
||||
getCoordOrigin : function () {
|
||||
return {x:this._coordOrigin.x, y:this._coordOrigin.y};
|
||||
getCoordOrigin: function () {
|
||||
return {x: this._coordOrigin.x, y: this._coordOrigin.y};
|
||||
}
|
||||
});
|
@@ -19,27 +19,27 @@
|
||||
|
||||
web2d.peer.svg.TextPeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function() {
|
||||
initialize: function () {
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'text');
|
||||
this.parent(svgElement);
|
||||
this._position = {x:0,y:0};
|
||||
this._position = {x: 0, y: 0};
|
||||
this._font = new web2d.Font("Arial", this);
|
||||
},
|
||||
|
||||
appendChild : function(element) {
|
||||
this._native.appendChild(element._native);
|
||||
append: function (element) {
|
||||
this._native.append(element._native);
|
||||
},
|
||||
|
||||
setTextAlignment : function(align) {
|
||||
setTextAlignment: function (align) {
|
||||
this._textAlign = align;
|
||||
},
|
||||
|
||||
|
||||
getTextAlignment : function() {
|
||||
getTextAlignment: function () {
|
||||
return $defined(this._textAlign) ? this._textAlign : 'left';
|
||||
},
|
||||
|
||||
setText : function(text) {
|
||||
setText: function (text) {
|
||||
// Remove all previous nodes ...
|
||||
while (this._native.firstChild) {
|
||||
this._native.removeChild(this._native.firstChild);
|
||||
@@ -48,38 +48,38 @@ web2d.peer.svg.TextPeer = new Class({
|
||||
this._text = text;
|
||||
if (text) {
|
||||
var lines = text.split('\n');
|
||||
lines.forEach(function(line) {
|
||||
lines.forEach(function (line) {
|
||||
var tspan = window.document.createElementNS(this.svgNamespace, 'tspan');
|
||||
tspan.setAttribute('dy', '1em');
|
||||
tspan.setAttribute('x', this.getPosition().x);
|
||||
|
||||
tspan.textContent = line.length == 0 ? " " : line;
|
||||
this._native.appendChild(tspan);
|
||||
this._native.append(tspan);
|
||||
}.bind(this));
|
||||
}
|
||||
},
|
||||
|
||||
getText : function() {
|
||||
getText: function () {
|
||||
return this._text;
|
||||
},
|
||||
|
||||
setPosition : function(x, y) {
|
||||
this._position = {x:x, y:y};
|
||||
setPosition: function (x, y) {
|
||||
this._position = {x: x, y: y};
|
||||
this._native.setAttribute('y', y);
|
||||
this._native.setAttribute('x', x);
|
||||
|
||||
// tspan must be positioned manually.
|
||||
this._native.getElements('tspan').forEach(function(span) {
|
||||
this._native.getElements('tspan').forEach(function (span) {
|
||||
span.setAttribute('x', x);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
getPosition: function () {
|
||||
return this._position;
|
||||
},
|
||||
|
||||
setFont : function(font, size, style, weight) {
|
||||
setFont: function (font, size, style, weight) {
|
||||
if ($defined(font)) {
|
||||
this._font = new web2d.Font(font, this);
|
||||
}
|
||||
@@ -95,41 +95,41 @@ web2d.peer.svg.TextPeer = new Class({
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
_updateFontStyle : function() {
|
||||
_updateFontStyle: function () {
|
||||
this._native.setAttribute('font-family', this._font.getFontFamily());
|
||||
this._native.setAttribute('font-size', this._font.getGraphSize());
|
||||
this._native.setAttribute('font-style', this._font.getStyle());
|
||||
this._native.setAttribute('font-weight', this._font.getWeight());
|
||||
},
|
||||
|
||||
setColor : function(color) {
|
||||
setColor: function (color) {
|
||||
this._native.setAttribute('fill', color);
|
||||
},
|
||||
|
||||
getColor : function() {
|
||||
getColor: function () {
|
||||
return this._native.getAttribute('fill');
|
||||
},
|
||||
|
||||
setTextSize : function (size) {
|
||||
setTextSize: function (size) {
|
||||
this._font.setSize(size);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
setContentSize : function(width, height) {
|
||||
setContentSize: function (width, height) {
|
||||
this._native.xTextSize = width.toFixed(1) + "," + height.toFixed(1);
|
||||
},
|
||||
|
||||
setStyle : function (style) {
|
||||
setStyle: function (style) {
|
||||
this._font.setStyle(style);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
setWeight : function (weight) {
|
||||
setWeight: function (weight) {
|
||||
this._font.setWeight(weight);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
setFontFamily : function (family) {
|
||||
setFontFamily: function (family) {
|
||||
var oldFont = this._font;
|
||||
this._font = new web2d.Font(family, this);
|
||||
this._font.setSize(oldFont.getSize());
|
||||
@@ -138,21 +138,21 @@ web2d.peer.svg.TextPeer = new Class({
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
getFont : function () {
|
||||
getFont: function () {
|
||||
return {
|
||||
font:this._font.getFont(),
|
||||
size:parseInt(this._font.getSize()),
|
||||
style:this._font.getStyle(),
|
||||
weight:this._font.getWeight()
|
||||
font: this._font.getFont(),
|
||||
size: parseInt(this._font.getSize()),
|
||||
style: this._font.getStyle(),
|
||||
weight: this._font.getWeight()
|
||||
};
|
||||
},
|
||||
|
||||
setSize : function (size) {
|
||||
setSize: function (size) {
|
||||
this._font.setSize(size);
|
||||
this._updateFontStyle();
|
||||
},
|
||||
|
||||
getWidth : function () {
|
||||
getWidth: function () {
|
||||
var computedWidth;
|
||||
// Firefox hack for this issue:http://stackoverflow.com/questions/6390065/doing-ajax-updates-in-svg-breaks-getbbox-is-there-a-workaround
|
||||
try {
|
||||
@@ -160,12 +160,12 @@ web2d.peer.svg.TextPeer = new Class({
|
||||
computedWidth = this._native.getBBox().width;
|
||||
// Chrome bug is producing this error, oly during page loading. Remove the hack if it works. The issue seems to be
|
||||
// caused when the element is hidden. I don't know why, but it works ...
|
||||
if(computedWidth==0){
|
||||
if (computedWidth == 0) {
|
||||
var bbox = this._native.getBBox();
|
||||
computedWidth = bbox.width;
|
||||
}
|
||||
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
computedWidth = 10;
|
||||
|
||||
}
|
||||
@@ -175,17 +175,17 @@ web2d.peer.svg.TextPeer = new Class({
|
||||
return width;
|
||||
},
|
||||
|
||||
getHeight : function () {
|
||||
getHeight: function () {
|
||||
// Firefox hack for this issue:http://stackoverflow.com/questions/6390065/doing-ajax-updates-in-svg-breaks-getbbox-is-there-a-workaround
|
||||
try {
|
||||
var computedHeight = this._native.getBBox().height;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
computedHeight = 10;
|
||||
}
|
||||
return parseInt(computedHeight);
|
||||
},
|
||||
|
||||
getHtmlFontSize : function () {
|
||||
getHtmlFontSize: function () {
|
||||
return this._font.getHtmlSize();
|
||||
}
|
||||
});
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
web2d.peer.svg.WorkspacePeer = new Class({
|
||||
Extends: web2d.peer.svg.ElementPeer,
|
||||
initialize : function(element) {
|
||||
initialize: function (element) {
|
||||
this._element = element;
|
||||
var svgElement = window.document.createElementNS(this.svgNamespace, 'svg');
|
||||
this.parent(svgElement);
|
||||
@@ -38,9 +38,9 @@ web2d.peer.svg.WorkspacePeer = new Class({
|
||||
*
|
||||
*/
|
||||
|
||||
setCoordSize : function (width, height) {
|
||||
setCoordSize: function (width, height) {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [0,0,0,0];
|
||||
var coords = [0, 0, 0, 0];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
@@ -57,20 +57,20 @@ web2d.peer.svg.WorkspacePeer = new Class({
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(this, "strokeStyle");
|
||||
},
|
||||
|
||||
getCoordSize : function () {
|
||||
getCoordSize: function () {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [1,1,1,1];
|
||||
var coords = [1, 1, 1, 1];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
return {width:coords[2],height:coords[3]};
|
||||
return {width: coords[2], height: coords[3]};
|
||||
},
|
||||
|
||||
setCoordOrigin : function (x, y) {
|
||||
setCoordOrigin: function (x, y) {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
|
||||
// ViewBox min-x ,min-y by default initializated with 0 and 0.
|
||||
var coords = [0,0,0,0];
|
||||
var coords = [0, 0, 0, 0];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
@@ -86,23 +86,23 @@ web2d.peer.svg.WorkspacePeer = new Class({
|
||||
this._native.setAttribute('viewBox', coords.join(" "));
|
||||
},
|
||||
|
||||
appendChild : function (child) {
|
||||
append: function (child) {
|
||||
this.parent(child);
|
||||
web2d.peer.utils.EventUtils.broadcastChangeEvent(child, "onChangeCoordSize");
|
||||
},
|
||||
|
||||
getCoordOrigin : function (child) {
|
||||
getCoordOrigin: function (child) {
|
||||
var viewBox = this._native.getAttribute('viewBox');
|
||||
var coords = [1,1,1,1];
|
||||
var coords = [1, 1, 1, 1];
|
||||
if (viewBox != null) {
|
||||
coords = viewBox.split(/ /);
|
||||
}
|
||||
var x = parseFloat(coords[0]);
|
||||
var y = parseFloat(coords[1]);
|
||||
return {x:x,y:y};
|
||||
return {x: x, y: y};
|
||||
},
|
||||
|
||||
getPosition : function () {
|
||||
return {x:0,y:0};
|
||||
getPosition: function () {
|
||||
return {x: 0, y: 0};
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user