Code formatting updated.
parent
26b7ac05a1
commit
7b4f7d0ae9
|
@ -113,10 +113,10 @@ Layer.prototype.deactivate = function() {
|
||||||
* Set this layer visible or hidden based on 'visible' parameter.
|
* Set this layer visible or hidden based on 'visible' parameter.
|
||||||
* @param {boolean} visible - If true, make visible; otherwise, hide it.
|
* @param {boolean} visible - If true, make visible; otherwise, hide it.
|
||||||
*/
|
*/
|
||||||
Layer.prototype.setVisible = function( visible) {
|
Layer.prototype.setVisible = function(visible) {
|
||||||
var expected = visible === undefined || visible ? "inline" : "none";
|
var expected = visible === undefined || visible ? "inline" : "none";
|
||||||
var oldDisplay = this.group_.getAttribute("display");
|
var oldDisplay = this.group_.getAttribute("display");
|
||||||
if( oldDisplay !== expected) {
|
if (oldDisplay !== expected) {
|
||||||
this.group_.setAttribute("display", expected);
|
this.group_.setAttribute("display", expected);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -135,7 +135,7 @@ Layer.prototype.isVisible = function() {
|
||||||
*/
|
*/
|
||||||
Layer.prototype.getOpacity = function() {
|
Layer.prototype.getOpacity = function() {
|
||||||
var opacity = this.group_.getAttribute('opacity');
|
var opacity = this.group_.getAttribute('opacity');
|
||||||
if( opacity === null || opacity === undefined) {
|
if (opacity === null || opacity === undefined) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return parseFloat(opacity);
|
return parseFloat(opacity);
|
||||||
|
@ -146,7 +146,7 @@ Layer.prototype.getOpacity = function() {
|
||||||
* nothing happens.
|
* nothing happens.
|
||||||
* @param {number} opacity - A float value in the range 0.0-1.0
|
* @param {number} opacity - A float value in the range 0.0-1.0
|
||||||
*/
|
*/
|
||||||
Layer.prototype.setOpacity = function( opacity) {
|
Layer.prototype.setOpacity = function(opacity) {
|
||||||
if (typeof opacity === 'number' && opacity >= 0.0 && opacity <= 1.0) {
|
if (typeof opacity === 'number' && opacity >= 0.0 && opacity <= 1.0) {
|
||||||
this.group_.setAttribute('opacity', opacity);
|
this.group_.setAttribute('opacity', opacity);
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ Layer.prototype.setOpacity = function( opacity) {
|
||||||
* Append children to this layer.
|
* Append children to this layer.
|
||||||
* @param {SVGGElement} children - The children to append to this layer.
|
* @param {SVGGElement} children - The children to append to this layer.
|
||||||
*/
|
*/
|
||||||
Layer.prototype.appendChildren = function( children) {
|
Layer.prototype.appendChildren = function(children) {
|
||||||
for (var i = 0; i < children.length; ++i) {
|
for (var i = 0; i < children.length; ++i) {
|
||||||
this.group_.appendChild(children[i]);
|
this.group_.appendChild(children[i]);
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ function findLayerNameInGroup(group) {
|
||||||
var name = $("title", group).text();
|
var name = $("title", group).text();
|
||||||
|
|
||||||
// Hack for Opera 10.60
|
// Hack for Opera 10.60
|
||||||
if(!name && svgedit.browser.isOpera() && group.querySelectorAll) {
|
if (!name && svgedit.browser.isOpera() && group.querySelectorAll) {
|
||||||
name = $(group.querySelectorAll('title')).text();
|
name = $(group.querySelectorAll('title')).text();
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
|
@ -481,7 +481,7 @@ function findLayerNameInGroup(group) {
|
||||||
* @param {string[]} existingLayerNames - Existing layer names.
|
* @param {string[]} existingLayerNames - Existing layer names.
|
||||||
* @returns {string} - The new name.
|
* @returns {string} - The new name.
|
||||||
*/
|
*/
|
||||||
function getNewLayerName( existingLayerNames) {
|
function getNewLayerName(existingLayerNames) {
|
||||||
var i = 1;
|
var i = 1;
|
||||||
// TODO(codedread): What about internationalization of "Layer"?
|
// TODO(codedread): What about internationalization of "Layer"?
|
||||||
while (existingLayerNames.indexOf(("Layer " + i)) >= 0) { i++; }
|
while (existingLayerNames.indexOf(("Layer " + i)) >= 0) { i++; }
|
||||||
|
@ -509,14 +509,14 @@ svgedit.draw.Drawing.prototype.identifyLayers = function() {
|
||||||
var name = findLayerNameInGroup(child);
|
var name = findLayerNameInGroup(child);
|
||||||
if (name) {
|
if (name) {
|
||||||
layernames.push(name);
|
layernames.push(name);
|
||||||
layer = new Layer( name, child);
|
layer = new Layer(name, child);
|
||||||
this.all_layers.push(layer);
|
this.all_layers.push(layer);
|
||||||
this.layer_map[ name] = layer;
|
this.layer_map[ name] = layer;
|
||||||
} else {
|
} else {
|
||||||
// if group did not have a name, it is an orphan
|
// if group did not have a name, it is an orphan
|
||||||
orphans.push(child);
|
orphans.push(child);
|
||||||
}
|
}
|
||||||
} else if(~visElems.indexOf(child.nodeName)) {
|
} else if (~visElems.indexOf(child.nodeName)) {
|
||||||
// Child is "visible" (i.e. not a <title> or <defs> element), so it is an orphan
|
// Child is "visible" (i.e. not a <title> or <defs> element), so it is an orphan
|
||||||
orphans.push(child);
|
orphans.push(child);
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ svgedit.draw.Drawing.prototype.identifyLayers = function() {
|
||||||
|
|
||||||
// If orphans or no layers found, create a new layer and add all the orphans to it
|
// If orphans or no layers found, create a new layer and add all the orphans to it
|
||||||
if (orphans.length > 0 || !childgroups) {
|
if (orphans.length > 0 || !childgroups) {
|
||||||
layer = new Layer( getNewLayerName(layernames), null, this.svgElem_);
|
layer = new Layer(getNewLayerName(layernames), null, this.svgElem_);
|
||||||
layer.appendChildren(orphans);
|
layer.appendChildren(orphans);
|
||||||
this.all_layers.push(layer);
|
this.all_layers.push(layer);
|
||||||
this.layer_map[ name] = layer;
|
this.layer_map[ name] = layer;
|
||||||
|
@ -543,14 +543,14 @@ svgedit.draw.Drawing.prototype.identifyLayers = function() {
|
||||||
* also the current layer of this drawing.
|
* also the current layer of this drawing.
|
||||||
*/
|
*/
|
||||||
svgedit.draw.Drawing.prototype.createLayer = function(name) {
|
svgedit.draw.Drawing.prototype.createLayer = function(name) {
|
||||||
if( this.current_layer) {
|
if (this.current_layer) {
|
||||||
this.current_layer.deactivate();
|
this.current_layer.deactivate();
|
||||||
}
|
}
|
||||||
// Check for duplicate name.
|
// Check for duplicate name.
|
||||||
if( name === undefined || name === null || name === '' || this.layer_map[name]) {
|
if (name === undefined || name === null || name === '' || this.layer_map[name]) {
|
||||||
name = getNewLayerName(Object.keys(this.layer_map));
|
name = getNewLayerName(Object.keys(this.layer_map));
|
||||||
}
|
}
|
||||||
var layer = new Layer( name, null, this.svgElem_);
|
var layer = new Layer(name, null, this.svgElem_);
|
||||||
this.all_layers.push(layer);
|
this.all_layers.push(layer);
|
||||||
this.layer_map[ name] = layer;
|
this.layer_map[ name] = layer;
|
||||||
this.current_layer = layer;
|
this.current_layer = layer;
|
||||||
|
|
Loading…
Reference in New Issue