JSDoc
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2733 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
5439b4dc73
commit
6e1393f2ea
100
editor/draw.js
100
editor/draw.js
|
@ -314,15 +314,13 @@ svgedit.draw.Drawing.prototype.getCurrentLayerName = function () {
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: setCurrentLayer
|
/**
|
||||||
// Sets the current layer. If the name is not a valid layer name, then this function returns
|
* Sets the current layer. If the name is not a valid layer name, then this
|
||||||
// false. Otherwise it returns true. This is not an undo-able action.
|
* function returns false. Otherwise it returns true. This is not an
|
||||||
//
|
* undo-able action.
|
||||||
// Parameters:
|
* @param {string} name - The name of the layer you want to switch to.
|
||||||
// name - the name of the layer you want to switch to.
|
* @returns {boolean} true if the current layer was switched, otherwise false
|
||||||
//
|
*/
|
||||||
// Returns:
|
|
||||||
// true if the current layer was switched, otherwise false
|
|
||||||
svgedit.draw.Drawing.prototype.setCurrentLayer = function(name) {
|
svgedit.draw.Drawing.prototype.setCurrentLayer = function(name) {
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < this.getNumLayers(); ++i) {
|
for (i = 0; i < this.getNumLayers(); ++i) {
|
||||||
|
@ -339,11 +337,11 @@ svgedit.draw.Drawing.prototype.setCurrentLayer = function(name) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Function: svgedit.draw.Drawing.deleteCurrentLayer
|
/**
|
||||||
// Deletes the current layer from the drawing and then clears the selection. This function
|
* Deletes the current layer from the drawing and then clears the selection.
|
||||||
// then calls the 'changed' handler. This is an undoable action.
|
* This function then calls the 'changed' handler. This is an undoable action.
|
||||||
// Returns:
|
* @returns {SVGGElement} The SVGGElement of the layer removed or null.
|
||||||
// The SVGGElement of the layer removed or null.
|
*/
|
||||||
svgedit.draw.Drawing.prototype.deleteCurrentLayer = function() {
|
svgedit.draw.Drawing.prototype.deleteCurrentLayer = function() {
|
||||||
if (this.current_layer && this.getNumLayers() > 1) {
|
if (this.current_layer && this.getNumLayers() > 1) {
|
||||||
// actually delete from the DOM and return it
|
// actually delete from the DOM and return it
|
||||||
|
@ -356,9 +354,10 @@ svgedit.draw.Drawing.prototype.deleteCurrentLayer = function() {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: svgedit.draw.Drawing.identifyLayers
|
/**
|
||||||
// Updates layer system and sets the current layer to the
|
* Updates layer system and sets the current layer to the
|
||||||
// top-most layer (last <g> child of this drawing).
|
* top-most layer (last <g> child of this drawing).
|
||||||
|
*/
|
||||||
svgedit.draw.Drawing.prototype.identifyLayers = function() {
|
svgedit.draw.Drawing.prototype.identifyLayers = function() {
|
||||||
this.all_layers = [];
|
this.all_layers = [];
|
||||||
var numchildren = this.svgElem_.childNodes.length;
|
var numchildren = this.svgElem_.childNodes.length;
|
||||||
|
@ -424,16 +423,13 @@ svgedit.draw.Drawing.prototype.identifyLayers = function() {
|
||||||
this.current_layer.setAttribute("style", "pointer-events:all");
|
this.current_layer.setAttribute("style", "pointer-events:all");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: svgedit.draw.Drawing.createLayer
|
/**
|
||||||
// Creates a new top-level layer in the drawing with the given name and
|
* Creates a new top-level layer in the drawing with the given name and
|
||||||
// sets the current layer to it.
|
* sets the current layer to it.
|
||||||
//
|
* @param {string} name - The given name
|
||||||
// Parameters:
|
* @returns {SVGGElement} The SVGGElement of the new layer, which is
|
||||||
// name - The given name
|
* also the current layer of this drawing.
|
||||||
//
|
*/
|
||||||
// Returns:
|
|
||||||
// The SVGGElement of the new layer, which is also the current layer
|
|
||||||
// of this drawing.
|
|
||||||
svgedit.draw.Drawing.prototype.createLayer = function(name) {
|
svgedit.draw.Drawing.prototype.createLayer = function(name) {
|
||||||
var svgdoc = this.svgElem_.ownerDocument;
|
var svgdoc = this.svgElem_.ownerDocument;
|
||||||
var new_layer = svgdoc.createElementNS(NS.SVG, "g");
|
var new_layer = svgdoc.createElementNS(NS.SVG, "g");
|
||||||
|
@ -445,15 +441,12 @@ svgedit.draw.Drawing.prototype.createLayer = function(name) {
|
||||||
return new_layer;
|
return new_layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: svgedit.draw.Drawing.getLayerVisibility
|
/**
|
||||||
// Returns whether the layer is visible. If the layer name is not valid, then this function
|
* Returns whether the layer is visible. If the layer name is not valid,
|
||||||
// returns false.
|
* then this function returns false.
|
||||||
//
|
* @param {string} layername - The name of the layer which you want to query.
|
||||||
// Parameters:
|
* @returns {boolean} The visibility state of the layer, or false if the layer name was invalid.
|
||||||
// layername - the name of the layer which you want to query.
|
*/
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// The visibility state of the layer, or false if the layer name was invalid.
|
|
||||||
svgedit.draw.Drawing.prototype.getLayerVisibility = function(layername) {
|
svgedit.draw.Drawing.prototype.getLayerVisibility = function(layername) {
|
||||||
// find the layer
|
// find the layer
|
||||||
var layer = null;
|
var layer = null;
|
||||||
|
@ -465,19 +458,18 @@ svgedit.draw.Drawing.prototype.getLayerVisibility = function(layername) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!layer) {return false;}
|
if (!layer) {return false;}
|
||||||
return (layer.getAttribute('display') != 'none');
|
return (layer.getAttribute('display') !== 'none');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: svgedit.draw.Drawing.setLayerVisibility
|
/**
|
||||||
// Sets the visibility of the layer. If the layer name is not valid, this function return
|
* Sets the visibility of the layer. If the layer name is not valid, this
|
||||||
// false, otherwise it returns true. This is an undo-able action.
|
* function returns false, otherwise it returns true. This is an
|
||||||
//
|
* undo-able action.
|
||||||
// Parameters:
|
* @param {string} layername - The name of the layer to change the visibility
|
||||||
// layername - the name of the layer to change the visibility
|
* @param {boolean} bVisible - Whether the layer should be visible
|
||||||
// bVisible - true/false, whether the layer should be visible
|
* @returns {?SVGGElement} The SVGGElement representing the layer if the
|
||||||
//
|
* layername was valid, otherwise null.
|
||||||
// Returns:
|
*/
|
||||||
// The SVGGElement representing the layer if the layername was valid, otherwise null.
|
|
||||||
svgedit.draw.Drawing.prototype.setLayerVisibility = function(layername, bVisible) {
|
svgedit.draw.Drawing.prototype.setLayerVisibility = function(layername, bVisible) {
|
||||||
if (typeof bVisible !== 'boolean') {
|
if (typeof bVisible !== 'boolean') {
|
||||||
return null;
|
return null;
|
||||||
|
@ -521,13 +513,13 @@ svgedit.draw.Drawing.prototype.getLayerOpacity = function(layername) {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function: svgedit.draw.Drawing.setLayerOpacity
|
/**
|
||||||
// Sets the opacity of the given layer. If the input name is not a layer, nothing happens.
|
* Sets the opacity of the given layer. If the input name is not a layer,
|
||||||
// If opacity is not a value between 0.0 and 1.0, then nothing happens.
|
* nothing happens. If opacity is not a value between 0.0 and 1.0, then
|
||||||
//
|
* nothing happens.
|
||||||
// Parameters:
|
* @param {string} layername - Name of the layer on which to set the opacity
|
||||||
// layername - name of the layer on which to set the opacity
|
* @param {number} opacity - A float value in the range 0.0-1.0
|
||||||
// opacity - a float value in the range 0.0-1.0
|
*/
|
||||||
svgedit.draw.Drawing.prototype.setLayerOpacity = function(layername, opacity) {
|
svgedit.draw.Drawing.prototype.setLayerOpacity = function(layername, opacity) {
|
||||||
if (typeof opacity !== 'number' || opacity < 0.0 || opacity > 1.0) {
|
if (typeof opacity !== 'number' || opacity < 0.0 || opacity > 1.0) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue