Add deleteCurrentLayer() to Drawing

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1953 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2011-01-30 17:11:56 +00:00
parent cd00087f2a
commit d85a7bc8a2
5 changed files with 79 additions and 28 deletions

View File

@@ -276,6 +276,24 @@ svgedit.draw.Drawing.prototype.setCurrentLayer = function(name) {
return false;
};
// Function: svgedit.draw.Drawing.deleteCurrentLayer
// Deletes the current layer from the drawing and then clears the selection. This function
// then calls the 'changed' handler. This is an undoable action.
// Returns:
// The SVGGElement of the layer removed or null.
svgedit.draw.Drawing.prototype.deleteCurrentLayer = function() {
if (this.current_layer && this.getNumLayers() > 1) {
// actually delete from the DOM and return it
var parent = this.current_layer.parentNode;
var nextSibling = this.current_layer.nextSibling;
var oldLayerGroup = parent.removeChild(this.current_layer);
this.identifyLayers();
return oldLayerGroup;
}
return null;
};
// Function: svgedit.draw.Drawing.identifyLayers
// Updates layer system and sets the current layer to the
// top-most layer (last <g> child of this drawing).