Fix bug where IDs could not be changed. Moved cleanupElement into svgutils.js. Corrected MIME type of two new test files.

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1990 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2011-02-10 04:10:03 +00:00
parent ca671f90d2
commit 45a26c1602
4 changed files with 51 additions and 48 deletions

View File

@@ -9,8 +9,8 @@
// Dependencies:
// 1) jQuery
// 2) browser.js: for getBBox(), getElem(), assignAttributes()
// 3) svgtransformlist.js: only for getRotationAngle()
// 2) browser.js
// 3) svgtransformlist.js
var svgedit = svgedit || {};
@@ -610,4 +610,36 @@ svgedit.utilities.assignAttributes = function(node, attrs, suspendLength, unitCh
if (!svgedit.browser.isOpera()) svgroot_.unsuspendRedraw(handle);
};
// Function: cleanupElement
// Remove unneeded (default) attributes, makes resulting SVG smaller
//
// Parameters:
// element - DOM element to clean up
svgedit.utilities.cleanupElement = function(element) {
var handle = svgroot_.suspendRedraw(60);
var defaults = {
'fill-opacity':1,
'stop-opacity':1,
'opacity':1,
'stroke':'none',
'stroke-dasharray':'none',
'stroke-linejoin':'miter',
'stroke-linecap':'butt',
'stroke-opacity':1,
'stroke-width':1,
'rx':0,
'ry':0
}
for(var attr in defaults) {
var val = defaults[attr];
if(element.getAttribute(attr) == val) {
element.removeAttribute(attr);
}
}
svgroot_.unsuspendRedraw(handle);
};
})();