JSLint
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2641 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
afa427a4a2
commit
0df050aeb4
|
@ -1,3 +1,5 @@
|
|||
/*globals $*/
|
||||
/*jslint vars: true, eqeq: true */
|
||||
/*
|
||||
* svgcanvas.js
|
||||
*
|
||||
|
@ -310,9 +312,9 @@ canvas.undoMgr = new svgedit.history.UndoManager({
|
|||
canvas.identifyLayers();
|
||||
}
|
||||
if (cmdType == InsertElementCommand.type()) {
|
||||
if (isApply) restoreRefElems(cmd.elem);
|
||||
if (isApply) {restoreRefElems(cmd.elem);}
|
||||
} else {
|
||||
if (!isApply) restoreRefElems(cmd.elem);
|
||||
if (!isApply) {restoreRefElems(cmd.elem);}
|
||||
}
|
||||
if (cmd.elem.tagName === 'use') {
|
||||
setUseData(cmd.elem);
|
||||
|
@ -390,8 +392,9 @@ $(opac_ani).attr({
|
|||
|
||||
var restoreRefElems = function(elem) {
|
||||
// Look for missing reference elements, restore any found
|
||||
var attrs = $(elem).attr(ref_attrs);
|
||||
for (var o in attrs) {
|
||||
var o, i,
|
||||
attrs = $(elem).attr(ref_attrs);
|
||||
for (o in attrs) {
|
||||
var val = attrs[o];
|
||||
if (val && val.indexOf('url(') === 0) {
|
||||
var id = svgedit.utilities.getUrlFromAttr(val).substr(1);
|
||||
|
@ -406,7 +409,7 @@ var restoreRefElems = function(elem) {
|
|||
var childs = elem.getElementsByTagName('*');
|
||||
|
||||
if (childs.length) {
|
||||
for (var i = 0, l = childs.length; i < l; i++) {
|
||||
for (i = 0, l = childs.length; i < l; i++) {
|
||||
restoreRefElems(childs[i]);
|
||||
}
|
||||
}
|
||||
|
@ -554,9 +557,10 @@ var getIntersectionList = this.getIntersectionList = function(rect) {
|
|||
|
||||
if (!rect) {
|
||||
var rubberBBox = rubberBox.getBBox();
|
||||
var bb = {};
|
||||
var o,
|
||||
bb = {};
|
||||
|
||||
for (var o in rubberBBox) {
|
||||
for (o in rubberBBox) {
|
||||
bb[o] = rubberBBox[o] / current_zoom;
|
||||
}
|
||||
rubberBBox = bb;
|
||||
|
@ -566,7 +570,7 @@ var getIntersectionList = this.getIntersectionList = function(rect) {
|
|||
}
|
||||
var i = curBBoxes.length;
|
||||
while (i--) {
|
||||
if (!rubberBBox.width || !rubberBBox.width) continue;
|
||||
if (!rubberBBox.width || !rubberBBox.width) {continue;}
|
||||
if (svgedit.math.rectsIntersect(rubberBBox, curBBoxes[i].bbox)) {
|
||||
resultList.push(curBBoxes[i].elem);
|
||||
}
|
||||
|
@ -588,8 +592,8 @@ var getIntersectionList = this.getIntersectionList = function(rect) {
|
|||
// Returns:
|
||||
// A single bounding box object
|
||||
getStrokedBBox = this.getStrokedBBox = function(elems) {
|
||||
if (!elems) elems = getVisibleElements();
|
||||
if (!elems.length) return false;
|
||||
if (!elems) {elems = getVisibleElements();}
|
||||
if (!elems.length) {return false;}
|
||||
// Make sure the expected BBox is returned if the element is a group
|
||||
var getCheckedBBox = function(elem) {
|
||||
|
||||
|
@ -672,13 +676,13 @@ getStrokedBBox = this.getStrokedBBox = function(elems) {
|
|||
|
||||
var full_bb;
|
||||
$.each(elems, function() {
|
||||
if (full_bb) return;
|
||||
if (!this.parentNode) return;
|
||||
if (full_bb) {return;}
|
||||
if (!this.parentNode) {return;}
|
||||
full_bb = getCheckedBBox(this);
|
||||
});
|
||||
|
||||
// This shouldn't ever happen...
|
||||
if (full_bb == null) return null;
|
||||
if (full_bb == null) {return null;}
|
||||
|
||||
// full_bb doesn't include the stoke, so this does no good!
|
||||
// if (elems.length == 1) return full_bb;
|
||||
|
@ -737,7 +741,9 @@ getStrokedBBox = this.getStrokedBBox = function(elems) {
|
|||
// Returns:
|
||||
// An array with all "visible" elements.
|
||||
var getVisibleElements = this.getVisibleElements = function(parent) {
|
||||
if (!parent) parent = $(svgcontent).children(); // Prevent layers from being included
|
||||
if (!parent) {
|
||||
parent = $(svgcontent).children(); // Prevent layers from being included
|
||||
}
|
||||
|
||||
var contentElems = [];
|
||||
$(parent).children().each(function(i, elem) {
|
||||
|
@ -763,8 +769,9 @@ var getVisibleElements = this.getVisibleElements = function(parent) {
|
|||
// * elem - The element
|
||||
// * bbox - The element's BBox as retrieved from getStrokedBBox
|
||||
var getVisibleElementsAndBBoxes = this.getVisibleElementsAndBBoxes = function(parent) {
|
||||
if (!parent) parent = $(svgcontent).children(); // Prevent layers from being included
|
||||
|
||||
if (!parent) {
|
||||
parent = $(svgcontent).children(); // Prevent layers from being included
|
||||
}
|
||||
var contentElems = [];
|
||||
$(parent).children().each(function(i, elem) {
|
||||
try {
|
||||
|
@ -887,9 +894,10 @@ this.prepareSvg = function(newDoc) {
|
|||
this.sanitizeSvg(newDoc.documentElement);
|
||||
|
||||
// convert paths into absolute commands
|
||||
var paths = newDoc.getElementsByTagNameNS(NS.SVG, "path");
|
||||
for (var i = 0, len = paths.length; i < len; ++i) {
|
||||
var path = paths[i];
|
||||
var i, path,
|
||||
paths = newDoc.getElementsByTagNameNS(NS.SVG, "path");
|
||||
for (i = 0, len = paths.length; i < len; ++i) {
|
||||
path = paths[i];
|
||||
path.setAttribute('d', pathActions.convertPath(path));
|
||||
pathActions.fixEnd(path);
|
||||
}
|
||||
|
@ -905,7 +913,7 @@ this.prepareSvg = function(newDoc) {
|
|||
// Parameters:
|
||||
// elem - The (text) DOM element to clone
|
||||
var ffClone = function(elem) {
|
||||
if (!svgedit.browser.isGecko()) return elem;
|
||||
if (!svgedit.browser.isGecko()) {return elem;}
|
||||
var clone = elem.cloneNode(true);
|
||||
elem.parentNode.insertBefore(clone, elem);
|
||||
elem.parentNode.removeChild(elem);
|
||||
|
@ -1021,16 +1029,17 @@ var root_sctm = null;
|
|||
// noCall - Optional boolean that when true does not call the "selected" handler
|
||||
var clearSelection = this.clearSelection = function(noCall) {
|
||||
if (selectedElements[0] != null) {
|
||||
var len = selectedElements.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var elem = selectedElements[i];
|
||||
if (elem == null) break;
|
||||
var i, elem,
|
||||
len = selectedElements.length;
|
||||
for (i = 0; i < len; ++i) {
|
||||
elem = selectedElements[i];
|
||||
if (elem == null) {break;}
|
||||
selectorManager.releaseSelector(elem);
|
||||
selectedElements[i] = null;
|
||||
}
|
||||
// selectedBBoxes[0] = null;
|
||||
}
|
||||
if (!noCall) call("selected", selectedElements);
|
||||
if (!noCall) {call("selected", selectedElements);}
|
||||
};
|
||||
|
||||
// TODO: do we need to worry about selectedBBoxes here?
|
||||
|
@ -1058,7 +1067,7 @@ var addToSelection = this.addToSelection = function(elemsToAdd, showGrips) {
|
|||
var i = elemsToAdd.length;
|
||||
while (i--) {
|
||||
var elem = elemsToAdd[i];
|
||||
if (!elem || !svgedit.utilities.getBBox(elem)) continue;
|
||||
if (!elem || !svgedit.utilities.getBBox(elem)) {continue;}
|
||||
|
||||
if (elem.tagName === 'a' && elem.childNodes.length === 1) {
|
||||
// Make "a" element's child be the selected element
|
||||
|
|
Loading…
Reference in New Issue