diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 58dc8ffc..402da330 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -90,7 +90,7 @@ var svgroot = svgdoc.importNode(svgedit.utilities.text2xml( container.appendChild(svgroot); // The actual element that represents the final output SVG element -var svgcontent = svgdoc.createElementNS(NS.SVG, "svg"); +var svgcontent = svgdoc.createElementNS(NS.SVG, 'svg'); // This function resets the svgcontent element while keeping it in the DOM. var clearSvgContentElement = canvas.clearSvgContentElement = function() { @@ -105,8 +105,8 @@ var clearSvgContentElement = canvas.clearSvgContentElement = function() { y: dimensions[1], overflow: curConfig.show_outside_canvas ? 'visible' : 'hidden', xmlns: NS.SVG, - "xmlns:se": NS.SE, - "xmlns:xlink": NS.XLINK + 'xmlns:se': NS.SE, + 'xmlns:xlink': NS.XLINK }).appendTo(svgroot); // TODO: make this string optional and set by the client @@ -116,7 +116,7 @@ var clearSvgContentElement = canvas.clearSvgContentElement = function() { clearSvgContentElement(); // Prefix string for element IDs -var idprefix = "svg_"; +var idprefix = 'svg_'; // Function: setIdPrefix // Changes the ID prefix to the given value @@ -150,7 +150,7 @@ var all_properties = { fill: (curConfig.initFill.color == 'none' ? '' : '#') + curConfig.initFill.color, fill_paint: null, fill_opacity: curConfig.initFill.opacity, - stroke: "#" + curConfig.initStroke.color, + stroke: '#' + curConfig.initStroke.color, stroke_paint: null, stroke_opacity: curConfig.initStroke.opacity, stroke_width: curConfig.initStroke.width, @@ -163,7 +163,7 @@ var all_properties = { all_properties.text = $.extend(true, {}, all_properties.shape); $.extend(all_properties.text, { - fill: "#000000", + fill: '#000000', stroke_width: 0, font_size: 24, font_family: 'serif' @@ -203,16 +203,16 @@ var addSvgElementFromJson = this.addSvgElementFromJson = function(data) { } if (data.curStyles) { svgedit.utilities.assignAttributes(shape, { - "fill": cur_shape.fill, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_dasharray, - "stroke-linejoin": cur_shape.stroke_linejoin, - "stroke-linecap": cur_shape.stroke_linecap, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - "opacity": cur_shape.opacity / 2, - "style": "pointer-events:inherit" + 'fill': cur_shape.fill, + 'stroke': cur_shape.stroke, + 'stroke-width': cur_shape.stroke_width, + 'stroke-dasharray': cur_shape.stroke_dasharray, + 'stroke-linejoin': cur_shape.stroke_linejoin, + 'stroke-linecap': cur_shape.stroke_linecap, + 'stroke-opacity': cur_shape.stroke_opacity, + 'fill-opacity': cur_shape.fill_opacity, + 'opacity': cur_shape.opacity / 2, + 'style': 'pointer-events:inherit' }, 100); } svgedit.utilities.assignAttributes(shape, data.attr, 100); @@ -236,8 +236,8 @@ var getMatrix = svgedit.math.getMatrix; svgedit.units.init({ getBaseUnit: function() { return curConfig.baseUnit; }, getElement: svgedit.utilities.getElem, - getHeight: function() { return svgcontent.getAttribute("height")/current_zoom; }, - getWidth: function() { return svgcontent.getAttribute("width")/current_zoom; }, + getHeight: function() { return svgcontent.getAttribute('height')/current_zoom; }, + getWidth: function() { return svgcontent.getAttribute('width')/current_zoom; }, getRoundDigits: function() { return save_options.round_digits; } }); // import from units.js @@ -301,7 +301,7 @@ canvas.undoMgr = new svgedit.history.UndoManager({ } else if (eventType == EventTypes.AFTER_APPLY || eventType == EventTypes.AFTER_UNAPPLY) { var elems = cmd.elements(); canvas.pathActions.clear(); - call("changed", elems); + call('changed', elems); var cmdType = cmd.type(); var isApply = (eventType == EventTypes.AFTER_APPLY); if (cmdType == MoveElementCommand.type()) { @@ -324,7 +324,7 @@ canvas.undoMgr = new svgedit.history.UndoManager({ } } else if (cmdType == ChangeElementCommand.type()) { // if we are changing layer names, re-identify all layers - if (cmd.elem.tagName == "title" && cmd.elem.parentNode.parentNode == svgcontent) { + if (cmd.elem.tagName == 'title' && cmd.elem.parentNode.parentNode == svgcontent) { canvas.identifyLayers(); } var values = isApply ? cmd.newValues : cmd.oldValues; @@ -373,14 +373,14 @@ svgedit.path.init({ // Interface strings, usually for title elements var uiStrings = { - "exportNoBlur": "Blurred elements will appear as un-blurred", - "exportNoforeignObject": "foreignObject elements will not appear", - "exportNoDashArray": "Strokes will appear filled", - "exportNoText": "Text may not appear as expected" + exportNoBlur: "Blurred elements will appear as un-blurred", + exportNoforeignObject: "foreignObject elements will not appear", + exportNoDashArray: "Strokes will appear filled", + exportNoText: "Text may not appear as expected" }; var visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use'; -var ref_attrs = ["clip-path", "fill", "filter", "marker-end", "marker-mid", "marker-start", "mask", "stroke"]; +var ref_attrs = ['clip-path', 'fill', 'filter', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'stroke']; var elData = $.data; @@ -420,7 +420,7 @@ var restoreRefElems = function(elem) { (function() { // TODO For Issue 208: this is a start on a thumbnail - // var svgthumb = svgdoc.createElementNS(NS.SVG, "use"); + // var svgthumb = svgdoc.createElementNS(NS.SVG, 'use'); // svgthumb.setAttribute('width', '100'); // svgthumb.setAttribute('height', '100'); // svgedit.utilities.setHref(svgthumb, '#svgcontent'); @@ -447,10 +447,10 @@ var encodableImages = {}, startTransform = null, // String indicating the current editor mode - current_mode = "select", + current_mode = 'select', // String with the current direction in which an element is being resized - current_resize_mode = "none", + current_resize_mode = 'none', // Object with IDs for imported files, to see if one was already added import_ids = {}, @@ -521,9 +521,9 @@ this.addExtension = function(name, ext_func) { ext = ext_func; } extensions[name] = ext; - call("extension_added", ext); + call('extension_added', ext); } else { - console.log('Cannot add extension "' + name + '", an extension by that name already exists"'); + console.log('Cannot add extension "' + name + '", an extension by that name already exists.'); } }; @@ -556,7 +556,7 @@ var getIntersectionList = this.getIntersectionList = function(rect) { resultList = parent.getIntersectionList(rect, null); } catch(e) { } - if (resultList == null || typeof(resultList.item) != "function") { + if (resultList == null || typeof(resultList.item) != 'function') { resultList = []; var rubberBBox; if (!rect) { @@ -630,7 +630,7 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { if (!good_bb) { // Must use clone else FF freaks out var clone = elem.cloneNode(true); - var g = document.createElementNS(NS.SVG, "g"); + var g = document.createElementNS(NS.SVG, 'g'); var parent = elem.parentNode; parent.appendChild(g); g.appendChild(clone); @@ -698,9 +698,9 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { // FIXME: same re-creation problem with this function as getCheckedBBox() above var getOffset = function(elem) { - var sw = elem.getAttribute("stroke-width"); + var sw = elem.getAttribute('stroke-width'); var offset = 0; - if (elem.getAttribute("stroke") != "none" && !isNaN(sw)) { + if (elem.getAttribute('stroke') != 'none' && !isNaN(sw)) { offset += sw/2; } return offset; @@ -793,7 +793,7 @@ var getVisibleElementsAndBBoxes = this.getVisibleElementsAndBBoxes = function(pa // Parameters: // elem - SVG element to wrap var groupSvgElem = this.groupSvgElem = function(elem) { - var g = document.createElementNS(NS.SVG, "g"); + var g = document.createElementNS(NS.SVG, 'g'); elem.parentNode.replaceChild(g, elem); $(g).append(elem).data('gsvg', elem)[0].id = getNextId(); }; @@ -814,7 +814,7 @@ var copyElem = function(el) { } }); // set the copied element's new id - new_el.removeAttribute("id"); + new_el.removeAttribute('id'); new_el.id = getNextId(); // Opera's "d" value needs to be reset for Opera/Win/non-EN @@ -900,7 +900,7 @@ this.prepareSvg = function(newDoc) { // convert paths into absolute commands var i, path, len, - paths = newDoc.getElementsByTagNameNS(NS.SVG, "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)); @@ -948,7 +948,7 @@ this.setRotationAngle = function(val, preventUndo) { // ensure val is the proper type val = parseFloat(val); var elem = selectedElements[0]; - var oldTransform = elem.getAttribute("transform"); + var oldTransform = elem.getAttribute('transform'); var bbox = svgedit.utilities.getBBox(elem); var cx = bbox.x+bbox.width/2, cy = bbox.y+bbox.height/2; var tlist = svgedit.transformlist.getTransformList(elem); @@ -971,20 +971,20 @@ this.setRotationAngle = function(val, preventUndo) { tlist.appendItem(R_nc); } } else if (tlist.numberOfItems == 0) { - elem.removeAttribute("transform"); + elem.removeAttribute('transform'); } if (!preventUndo) { // we need to undo it, then redo it so it can be undo-able! :) // TODO: figure out how to make changes to transform list undo-able cross-browser? - var newTransform = elem.getAttribute("transform"); - elem.setAttribute("transform", oldTransform); - changeSelectedAttribute("transform", newTransform, selectedElements); - call("changed", selectedElements); + var newTransform = elem.getAttribute('transform'); + elem.setAttribute('transform', oldTransform); + changeSelectedAttribute('transform', newTransform, selectedElements); + call('changed', selectedElements); } - var pointGripContainer = svgedit.utilities.getElem("pathpointgrip_container"); -// if (elem.nodeName == "path" && pointGripContainer) { -// pathActions.setPointContainerTransform(elem.getAttribute("transform")); + var pointGripContainer = svgedit.utilities.getElem('pathpointgrip_container'); +// if (elem.nodeName == 'path' && pointGripContainer) { +// pathActions.setPointContainerTransform(elem.getAttribute('transform')); // } var selector = selectorManager.requestSelector(selectedElements[0]); selector.resize(); @@ -995,7 +995,7 @@ this.setRotationAngle = function(val, preventUndo) { // Runs recalculateDimensions on the selected elements, // adding the changes to a single batch command var recalculateAllSelectedDimensions = this.recalculateAllSelectedDimensions = function() { - var text = (current_resize_mode == "none" ? "position" : "size"); + var text = (current_resize_mode == 'none' ? 'position' : 'size'); var batchCmd = new svgedit.history.BatchCommand(text); var i = selectedElements.length; @@ -1010,7 +1010,7 @@ var recalculateAllSelectedDimensions = this.recalculateAllSelectedDimensions = f if (!batchCmd.isEmpty()) { addCommandToHistory(batchCmd); - call("changed", selectedElements); + call('changed', selectedElements); } }; @@ -1044,7 +1044,7 @@ var clearSelection = this.clearSelection = function(noCall) { } // selectedBBoxes[0] = null; } - if (!noCall) {call("selected", selectedElements);} + if (!noCall) {call('selected', selectedElements);} }; // TODO: do we need to worry about selectedBBoxes here? @@ -1094,7 +1094,7 @@ var addToSelection = this.addToSelection = function(elemsToAdd, showGrips) { } } } - call("selected", selectedElements); + call('selected', selectedElements); if (showGrips || selectedElements.length == 1) { selectorManager.requestSelector(selectedElements[0]).showGrips(true); @@ -1169,7 +1169,7 @@ var removeFromSelection = this.removeFromSelection = function(elemsToRemove) { this.selectAllInCurrentLayer = function() { var current_layer = getCurrentDrawing().getCurrentLayer(); if (current_layer) { - current_mode = "select"; + current_mode = 'select'; selectOnly($(current_group || current_layer).children()); } }; @@ -1194,9 +1194,9 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // for foreign content, go up until we find the foreignObject // WebKit browsers set the mouse target to the svgcanvas div if ([NS.MATH, NS.HTML].indexOf(mouse_target.namespaceURI) >= 0 && - mouse_target.id != "svgcanvas") + mouse_target.id != 'svgcanvas') { - while (mouse_target.nodeName != "foreignObject") { + while (mouse_target.nodeName != 'foreignObject') { mouse_target = mouse_target.parentNode; if (!mouse_target) {return svgroot;} } @@ -1229,7 +1229,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // } // Webkit bubbles the mouse event all the way up to the div, so we // set the mouse_target to the svgroot like the other browsers -// if (mouse_target.nodeName.toLowerCase() == "div") { +// if (mouse_target.nodeName.toLowerCase() == 'div') { // mouse_target = svgroot; // } @@ -1319,7 +1319,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { evt.preventDefault(); if (right_click) { - current_mode = "select"; + current_mode = 'select'; lastClickPoint = pt; } @@ -1354,26 +1354,26 @@ var getMouseTarget = this.getMouseTarget = function(evt) { if (mouse_target == selectorManager.selectorParentGroup && selectedElements[0] != null) { var grip = evt.target; - var griptype = elData(grip, "type"); + var griptype = elData(grip, 'type'); // rotating - if (griptype == "rotate") { - current_mode = "rotate"; + if (griptype == 'rotate') { + current_mode = 'rotate'; } // resizing - else if (griptype == "resize") { - current_mode = "resize"; - current_resize_mode = elData(grip, "dir"); + else if (griptype == 'resize') { + current_mode = 'resize'; + current_resize_mode = elData(grip, 'dir'); } mouse_target = selectedElements[0]; } - startTransform = mouse_target.getAttribute("transform"); + startTransform = mouse_target.getAttribute('transform'); var i, stroke_w, tlist = svgedit.transformlist.getTransformList(mouse_target); switch (current_mode) { - case "select": + case 'select': started = true; - current_resize_mode = "none"; + current_resize_mode = 'none'; if (right_click) {started = false;} if (mouse_target != svgroot) { @@ -1406,7 +1406,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { } } else if (!right_click){ clearSelection(); - current_mode = "multiselect"; + current_mode = 'multiselect'; if (rubberBox == null) { rubberBox = selectorManager.getRubberBandBox(); } @@ -1426,7 +1426,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { }, 100); } break; - case "zoom": + case 'zoom': started = true; if (rubberBox == null) { rubberBox = selectorManager.getRubberBandBox(); @@ -1439,7 +1439,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { 'display': 'inline' }, 100); break; - case "resize": + case 'resize': started = true; start_x = x; start_y = y; @@ -1493,24 +1493,24 @@ var getMouseTarget = this.getMouseTarget = function(evt) { } } break; - case "fhellipse": - case "fhrect": - case "fhpath": + case 'fhellipse': + case 'fhrect': + case 'fhpath': start.x = real_x; start.y = real_y; started = true; - d_attr = real_x + "," + real_y + " "; + d_attr = real_x + ',' + real_y + ' '; stroke_w = cur_shape.stroke_width == 0 ? 1 : cur_shape.stroke_width; addSvgElementFromJson({ - "element": "polyline", - "curStyles": true, - "attr": { - "points": d_attr, - "id": getNextId(), - "fill": "none", - "opacity": cur_shape.opacity / 2, - "stroke-linecap": "round", - "style": "pointer-events:none" + element: 'polyline', + curStyles: true, + attr: { + points: d_attr, + id: getNextId(), + fill: 'none', + opacity: cur_shape.opacity / 2, + 'stroke-linecap': 'round', + style: 'pointer-events:none' } }); freehand.minx = real_x; @@ -1518,141 +1518,141 @@ var getMouseTarget = this.getMouseTarget = function(evt) { freehand.miny = real_y; freehand.maxy = real_y; break; - case "image": + case 'image': started = true; var newImage = addSvgElementFromJson({ - "element": "image", - "attr": { - "x": x, - "y": y, - "width": 0, - "height": 0, - "id": getNextId(), - "opacity": cur_shape.opacity / 2, - "style": "pointer-events:inherit" + element: 'image', + attr: { + x: x, + y: y, + width: 0, + height: 0, + id: getNextId(), + opacity: cur_shape.opacity / 2, + style: 'pointer-events:inherit' } }); setHref(newImage, last_good_img_url); preventClickDefault(newImage); break; - case "square": + case 'square': // FIXME: once we create the rect, we lose information that this was a square // (for resizing purposes this could be important) - case "rect": + case 'rect': started = true; start_x = x; start_y = y; addSvgElementFromJson({ - "element": "rect", - "curStyles": true, - "attr": { - "x": x, - "y": y, - "width": 0, - "height": 0, - "id": getNextId(), - "opacity": cur_shape.opacity / 2 + element: 'rect', + curStyles: true, + attr: { + x: x, + y: y, + width: 0, + height: 0, + id: getNextId(), + opacity: cur_shape.opacity / 2 } }); break; - case "line": + case 'line': started = true; stroke_w = cur_shape.stroke_width == 0 ? 1 : cur_shape.stroke_width; addSvgElementFromJson({ - "element": "line", - "curStyles": true, - "attr": { - "x1": x, - "y1": y, - "x2": x, - "y2": y, - "id": getNextId(), - "stroke": cur_shape.stroke, - "stroke-width": stroke_w, - "stroke-dasharray": cur_shape.stroke_dasharray, - "stroke-linejoin": cur_shape.stroke_linejoin, - "stroke-linecap": cur_shape.stroke_linecap, - "stroke-opacity": cur_shape.stroke_opacity, - "fill": "none", - "opacity": cur_shape.opacity / 2, - "style": "pointer-events:none" + element: 'line', + curStyles: true, + attr: { + x1: x, + y1: y, + x2: x, + y2: y, + id: getNextId(), + stroke: cur_shape.stroke, + 'stroke-width': stroke_w, + 'stroke-dasharray': cur_shape.stroke_dasharray, + 'stroke-linejoin': cur_shape.stroke_linejoin, + 'stroke-linecap': cur_shape.stroke_linecap, + 'stroke-opacity': cur_shape.stroke_opacity, + fill: 'none', + opacity: cur_shape.opacity / 2, + style: 'pointer-events:none' } }); break; - case "circle": + case 'circle': started = true; addSvgElementFromJson({ - "element": "circle", - "curStyles": true, - "attr": { - "cx": x, - "cy": y, - "r": 0, - "id": getNextId(), - "opacity": cur_shape.opacity / 2 + element: 'circle', + curStyles: true, + attr: { + cx: x, + cy: y, + r: 0, + id: getNextId(), + opacity: cur_shape.opacity / 2 } }); break; - case "ellipse": + case 'ellipse': started = true; addSvgElementFromJson({ - "element": "ellipse", - "curStyles": true, - "attr": { - "cx": x, - "cy": y, - "rx": 0, - "ry": 0, - "id": getNextId(), - "opacity": cur_shape.opacity / 2 + element: 'ellipse', + curStyles: true, + attr: { + cx: x, + cy: y, + rx: 0, + ry: 0, + id: getNextId(), + opacity: cur_shape.opacity / 2 } }); break; - case "text": + case 'text': started = true; var newText = addSvgElementFromJson({ - "element": "text", - "curStyles": true, - "attr": { - "x": x, - "y": y, - "id": getNextId(), - "fill": cur_text.fill, - "stroke-width": cur_text.stroke_width, - "font-size": cur_text.font_size, - "font-family": cur_text.font_family, - "text-anchor": "middle", - "xml:space": "preserve", - "opacity": cur_shape.opacity + element: 'text', + curStyles: true, + attr: { + x: x, + y: y, + id: getNextId(), + fill: cur_text.fill, + 'stroke-width': cur_text.stroke_width, + 'font-size': cur_text.font_size, + 'font-family': cur_text.font_family, + 'text-anchor': 'middle', + 'xml:space': 'preserve', + opacity: cur_shape.opacity } }); -// newText.textContent = "text"; +// newText.textContent = 'text'; break; - case "path": + case 'path': // Fall through - case "pathedit": + case 'pathedit': start_x *= current_zoom; start_y *= current_zoom; pathActions.mouseDown(evt, mouse_target, start_x, start_y); started = true; break; - case "textedit": + case 'textedit': start_x *= current_zoom; start_y *= current_zoom; textActions.mouseDown(evt, mouse_target, start_x, start_y); started = true; break; - case "rotate": + case 'rotate': started = true; // we are starting an undoable change (a drag-rotation) - canvas.undoMgr.beginUndoableChange("transform", selectedElements); + canvas.undoMgr.beginUndoableChange('transform', selectedElements); break; default: // This could occur in an extension break; } - var ext_result = runExtensions("mouseDown", { + var ext_result = runExtensions('mouseDown', { event: evt, start_x: start_x, start_y: start_y, @@ -1692,7 +1692,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { evt.preventDefault(); var tlist; switch (current_mode) { - case "select": + case 'select': // we temporarily use a translate on the element(s) being dragged // this transform is removed upon mousing up and the element is // relocated to the new location @@ -1741,11 +1741,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) { selectorManager.requestSelector(selected).resize(); } - call("transition", selectedElements); + call('transition', selectedElements); } } break; - case "multiselect": + case 'multiselect': real_x *= current_zoom; real_y *= current_zoom; svgedit.utilities.assignAttributes(rubberBox, { @@ -1786,7 +1786,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { } break; - case "resize": + case 'resize': // we track the resize bounding box and translate/scale the selected element // while the mouse is down, when mouse goes up, we use this to recalculate // the shape's coordinates @@ -1816,10 +1816,10 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // if not stretching in y direction, set dy to 0 // if not stretching in x direction, set dx to 0 - if (current_resize_mode.indexOf("n")==-1 && current_resize_mode.indexOf("s")==-1) { + if (current_resize_mode.indexOf('n')==-1 && current_resize_mode.indexOf('s')==-1) { dy = 0; } - if (current_resize_mode.indexOf("e")==-1 && current_resize_mode.indexOf("w")==-1) { + if (current_resize_mode.indexOf('e')==-1 && current_resize_mode.indexOf('w')==-1) { dx = 0; } @@ -1828,13 +1828,13 @@ var getMouseTarget = this.getMouseTarget = function(evt) { sy = height ? (height+dy)/height : 1, sx = width ? (width+dx)/width : 1; // if we are dragging on the north side, then adjust the scale factor and ty - if (current_resize_mode.indexOf("n") >= 0) { + if (current_resize_mode.indexOf('n') >= 0) { sy = height ? (height-dy)/height : 1; ty = height; } // if we dragging on the east side, then adjust the scale factor and tx - if (current_resize_mode.indexOf("w") >= 0) { + if (current_resize_mode.indexOf('w') >= 0) { sx = width ? (width-dx)/width : 1; tx = width; } @@ -1873,10 +1873,10 @@ var getMouseTarget = this.getMouseTarget = function(evt) { selectorManager.requestSelector(selected).resize(); - call("transition", selectedElements); + call('transition', selectedElements); break; - case "zoom": + case 'zoom': real_x *= current_zoom; real_y *= current_zoom; svgedit.utilities.assignAttributes(rubberBox, { @@ -1886,13 +1886,13 @@ var getMouseTarget = this.getMouseTarget = function(evt) { 'height': Math.abs(real_y - r_start_y*current_zoom) }, 100); break; - case "text": + case 'text': svgedit.utilities.assignAttributes(shape,{ 'x': x, 'y': y }, 1000); break; - case "line": + case 'line': // Opera has a problem with suspendRedraw() apparently var handle = null; if (!window.opera) {svgroot.suspendRedraw(1000);} @@ -1911,17 +1911,17 @@ var getMouseTarget = this.getMouseTarget = function(evt) { y2 = xya.y; } - shape.setAttributeNS(null, "x2", x2); - shape.setAttributeNS(null, "y2", y2); + shape.setAttributeNS(null, 'x2', x2); + shape.setAttributeNS(null, 'y2', y2); if (!window.opera) {svgroot.unsuspendRedraw(handle);} break; - case "foreignObject": + case 'foreignObject': // fall through - case "square": + case 'square': // fall through - case "rect": + case 'rect': // fall through - case "image": + case 'image': var square = (current_mode == 'square') || evt.shiftKey, w = Math.abs(x - start_x), h = Math.abs(y - start_y), @@ -1950,18 +1950,18 @@ var getMouseTarget = this.getMouseTarget = function(evt) { },1000); break; - case "circle": - c = $(shape).attr(["cx", "cy"]); + case 'circle': + c = $(shape).attr(['cx', 'cy']); cx = c.cx; cy = c.cy; var rad = Math.sqrt( (x-cx)*(x-cx) + (y-cy)*(y-cy) ); if (curConfig.gridSnapping) { rad = svgedit.utilities.snapToGrid(rad); } - shape.setAttributeNS(null, "r", rad); + shape.setAttributeNS(null, 'r', rad); break; - case "ellipse": - c = $(shape).attr(["cx", "cy"]); + case 'ellipse': + c = $(shape).attr(['cx', 'cy']); cx = c.cx; cy = c.cy; // Opera has a problem with suspendRedraw() apparently @@ -1973,21 +1973,21 @@ var getMouseTarget = this.getMouseTarget = function(evt) { y = svgedit.utilities.snapToGrid(y); cy = svgedit.utilities.snapToGrid(cy); } - shape.setAttributeNS(null, "rx", Math.abs(x - cx) ); + shape.setAttributeNS(null, 'rx', Math.abs(x - cx) ); var ry = Math.abs(evt.shiftKey?(x - cx):(y - cy)); - shape.setAttributeNS(null, "ry", ry ); + shape.setAttributeNS(null, 'ry', ry ); if (!window.opera) {svgroot.unsuspendRedraw(handle);} break; - case "fhellipse": - case "fhrect": + case 'fhellipse': + case 'fhrect': freehand.minx = Math.min(real_x, freehand.minx); freehand.maxx = Math.max(real_x, freehand.maxx); freehand.miny = Math.min(real_y, freehand.miny); freehand.maxy = Math.max(real_y, freehand.maxy); // break; missing on purpose - case "fhpath": -// d_attr += + real_x + "," + real_y + " "; -// shape.setAttributeNS(null, "points", d_attr); + case 'fhpath': +// d_attr += + real_x + ',' + real_y + ' '; +// shape.setAttributeNS(null, 'points', d_attr); end.x = real_x; end.y = real_y; if (controllPoint2.x && controllPoint2.y) { for (i = 0; i < STEP_COUNT - 1; i++) { @@ -1998,8 +1998,8 @@ var getMouseTarget = this.getMouseTarget = function(evt) { bSpline = getBsplinePoint(parameter); sumDistance += Math.sqrt((nextPos.x - bSpline.x) * (nextPos.x - bSpline.x) + (nextPos.y - bSpline.y) * (nextPos.y - bSpline.y)); if (sumDistance > THRESHOLD_DIST) { - d_attr += + bSpline.x + "," + bSpline.y + " "; - shape.setAttributeNS(null, "points", d_attr); + d_attr += + bSpline.x + ',' + bSpline.y + ' '; + shape.setAttributeNS(null, 'points', d_attr); sumDistance -= THRESHOLD_DIST; } } @@ -2009,9 +2009,9 @@ var getMouseTarget = this.getMouseTarget = function(evt) { start = {x:end.x, y:end.y}; break; // update path stretch line coordinates - case "path": + case 'path': // fall through - case "pathedit": + case 'pathedit': x *= current_zoom; y *= current_zoom; @@ -2049,7 +2049,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { pathActions.mouseMove(x, y); break; - case "textedit": + case 'textedit': x *= current_zoom; y *= current_zoom; // if (rubberBox && rubberBox.getAttribute('display') != 'none') { @@ -2064,7 +2064,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { textActions.mouseMove(mouse_x, mouse_y); break; - case "rotate": + case 'rotate': box = svgedit.utilities.getBBox(selected); cx = box.x + box.width/2; cy = box.y + box.height/2; @@ -2082,13 +2082,13 @@ var getMouseTarget = this.getMouseTarget = function(evt) { } canvas.setRotationAngle(angle<-180?(360+angle):angle, true); - call("transition", selectedElements); + call('transition', selectedElements); break; default: break; } - runExtensions("mouseMove", { + runExtensions('mouseMove', { event: evt, mouse_x: mouse_x, mouse_y: mouse_y, @@ -2124,44 +2124,44 @@ var getMouseTarget = this.getMouseTarget = function(evt) { var attrs, t; switch (current_mode) { // intentionally fall-through to select here - case "resize": - case "multiselect": + case 'resize': + case 'multiselect': if (rubberBox != null) { - rubberBox.setAttribute("display", "none"); + rubberBox.setAttribute('display', 'none'); curBBoxes = []; } - current_mode = "select"; - case "select": + current_mode = 'select'; + case 'select': if (selectedElements[0] != null) { // if we only have one selected element if (selectedElements[1] == null) { // set our current stroke/fill properties to the element's var selected = selectedElements[0]; switch ( selected.tagName ) { - case "g": - case "use": - case "image": - case "foreignObject": + case 'g': + case 'use': + case 'image': + case 'foreignObject': break; default: - cur_properties.fill = selected.getAttribute("fill"); - cur_properties.fill_opacity = selected.getAttribute("fill-opacity"); - cur_properties.stroke = selected.getAttribute("stroke"); - cur_properties.stroke_opacity = selected.getAttribute("stroke-opacity"); - cur_properties.stroke_width = selected.getAttribute("stroke-width"); - cur_properties.stroke_dasharray = selected.getAttribute("stroke-dasharray"); - cur_properties.stroke_linejoin = selected.getAttribute("stroke-linejoin"); - cur_properties.stroke_linecap = selected.getAttribute("stroke-linecap"); + cur_properties.fill = selected.getAttribute('fill'); + cur_properties.fill_opacity = selected.getAttribute('fill-opacity'); + cur_properties.stroke = selected.getAttribute('stroke'); + cur_properties.stroke_opacity = selected.getAttribute('stroke-opacity'); + cur_properties.stroke_width = selected.getAttribute('stroke-width'); + cur_properties.stroke_dasharray = selected.getAttribute('stroke-dasharray'); + cur_properties.stroke_linejoin = selected.getAttribute('stroke-linejoin'); + cur_properties.stroke_linecap = selected.getAttribute('stroke-linecap'); } - if (selected.tagName == "text") { - cur_text.font_size = selected.getAttribute("font-size"); - cur_text.font_family = selected.getAttribute("font-family"); + if (selected.tagName == 'text') { + cur_text.font_size = selected.getAttribute('font-size'); + cur_text.font_family = selected.getAttribute('font-family'); } selectorManager.requestSelector(selected).showGrips(true); // This shouldn't be necessary as it was done on mouseDown... -// call("selected", [selected]); +// call('selected', [selected]); } // always recalculate dimensions to strip off stray identity transforms recalculateAllSelectedDimensions(); @@ -2179,7 +2179,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // no change in position/size, so maybe we should move to pathedit else { t = evt.target; - if (selectedElements[0].nodeName === "path" && selectedElements[1] == null) { + if (selectedElements[0].nodeName === 'path' && selectedElements[1] == null) { pathActions.select(selectedElements[0]); } // if it was a path // else, if it was selected and this is a shift-click, remove it from selection @@ -2203,12 +2203,12 @@ var getMouseTarget = this.getMouseTarget = function(evt) { } return; - case "zoom": + case 'zoom': if (rubberBox != null) { - rubberBox.setAttribute("display", "none"); + rubberBox.setAttribute('display', 'none'); } var factor = evt.shiftKey ? 0.5 : 2; - call("zoomed", { + call('zoomed', { 'x': Math.min(r_start_x, real_x), 'y': Math.min(r_start_y, real_y), 'width': Math.abs(real_x - r_start_x), @@ -2216,7 +2216,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { 'factor': factor }); return; - case "fhpath": + case 'fhpath': // Check that the path contains at least 2 points; a degenerate one-point path // causes problems. // Webkit ignores how we set the points attribute with commas and uses space @@ -2237,67 +2237,67 @@ var getMouseTarget = this.getMouseTarget = function(evt) { element = pathActions.smoothPolylineIntoPath(element); } break; - case "line": - attrs = $(element).attr(["x1", "x2", "y1", "y2"]); + case 'line': + attrs = $(element).attr(['x1', 'x2', 'y1', 'y2']); keep = (attrs.x1 != attrs.x2 || attrs.y1 != attrs.y2); break; - case "foreignObject": - case "square": - case "rect": - case "image": - attrs = $(element).attr(["width", "height"]); + case 'foreignObject': + case 'square': + case 'rect': + case 'image': + attrs = $(element).attr(['width', 'height']); // Image should be kept regardless of size (use inherit dimensions later) - keep = (attrs.width != 0 || attrs.height != 0) || current_mode === "image"; + keep = (attrs.width != 0 || attrs.height != 0) || current_mode === 'image'; break; - case "circle": + case 'circle': keep = (element.getAttribute('r') != 0); break; - case "ellipse": - attrs = $(element).attr(["rx", "ry"]); + case 'ellipse': + attrs = $(element).attr(['rx', 'ry']); keep = (attrs.rx != null || attrs.ry != null); break; - case "fhellipse": + case 'fhellipse': if ((freehand.maxx - freehand.minx) > 0 && (freehand.maxy - freehand.miny) > 0) { element = addSvgElementFromJson({ - "element": "ellipse", - "curStyles": true, - "attr": { - "cx": (freehand.minx + freehand.maxx) / 2, - "cy": (freehand.miny + freehand.maxy) / 2, - "rx": (freehand.maxx - freehand.minx) / 2, - "ry": (freehand.maxy - freehand.miny) / 2, - "id": getId() + element: 'ellipse', + curStyles: true, + attr: { + cx: (freehand.minx + freehand.maxx) / 2, + cy: (freehand.miny + freehand.maxy) / 2, + rx: (freehand.maxx - freehand.minx) / 2, + ry: (freehand.maxy - freehand.miny) / 2, + id: getId() } }); - call("changed",[element]); + call('changed',[element]); keep = true; } break; - case "fhrect": + case 'fhrect': if ((freehand.maxx - freehand.minx) > 0 && (freehand.maxy - freehand.miny) > 0) { element = addSvgElementFromJson({ - "element": "rect", - "curStyles": true, - "attr": { - "x": freehand.minx, - "y": freehand.miny, - "width": (freehand.maxx - freehand.minx), - "height": (freehand.maxy - freehand.miny), - "id": getId() + element: 'rect', + curStyles: true, + attr: { + x: freehand.minx, + y: freehand.miny, + width: (freehand.maxx - freehand.minx), + height: (freehand.maxy - freehand.miny), + id: getId() } }); - call("changed",[element]); + call('changed',[element]); keep = true; } break; - case "text": + case 'text': keep = true; selectOnly([element]); textActions.start(element); break; - case "path": + case 'path': // set element to null here so that it is not removed nor finalized element = null; // continue to be set to true so that mouseMove happens @@ -2307,34 +2307,34 @@ var getMouseTarget = this.getMouseTarget = function(evt) { element = res.element; keep = res.keep; break; - case "pathedit": + case 'pathedit': keep = true; element = null; pathActions.mouseUp(evt); break; - case "textedit": + case 'textedit': keep = false; element = null; textActions.mouseUp(evt, mouse_x, mouse_y); break; - case "rotate": + case 'rotate': keep = true; element = null; - current_mode = "select"; + current_mode = 'select'; var batchCmd = canvas.undoMgr.finishUndoableChange(); if (!batchCmd.isEmpty()) { addCommandToHistory(batchCmd); } // perform recalculation to weed out any stray identity transforms that might get stuck recalculateAllSelectedDimensions(); - call("changed", selectedElements); + call('changed', selectedElements); break; default: // This could occur in an extension break; } - var ext_result = runExtensions("mouseUp", { + var ext_result = runExtensions('mouseUp', { event: evt, mouse_x: mouse_x, mouse_y: mouse_y @@ -2358,18 +2358,18 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // if this element is in a group, go up until we reach the top-level group // just below the layer groups // TODO: once we implement links, we also would have to check for elements - while (t.parentNode.parentNode.tagName == "g") { + while (t.parentNode.parentNode.tagName == 'g') { t = t.parentNode; } // if we are not in the middle of creating a path, and we've clicked on some shape, // then go to Select mode. // WebKit returns
when the canvas is clicked, Firefox/Opera return - if ( (current_mode != "path" || !drawn_path) && - t.parentNode.id != "selectorParentGroup" && - t.id != "svgcanvas" && t.id != "svgroot") + if ( (current_mode != 'path' || !drawn_path) && + t.parentNode.id != 'selectorParentGroup' && + t.id != 'svgcanvas' && t.id != 'svgroot') { // switch into "select" mode if we've clicked on an element - canvas.setMode("select"); + canvas.setMode('select'); selectOnly([t], true); } @@ -2396,10 +2396,10 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // but that doesn't seem to be supported in Webkit setTimeout(function() { if (c_ani) {c_ani.remove();} - element.setAttribute("opacity", cur_shape.opacity); - element.setAttribute("style", "pointer-events:inherit"); + element.setAttribute('opacity', cur_shape.opacity); + element.setAttribute('style', 'pointer-events:inherit'); cleanupElement(element); - if (current_mode === "path") { + if (current_mode === 'path') { pathActions.toEditMode(element); } else if (curConfig.selectNew) { selectOnly([element], true); @@ -2408,7 +2408,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // undo means to call cmd.unapply(), redo means to call cmd.apply() addCommandToHistory(new svgedit.history.InsertElementCommand(element)); - call("changed",[element]); + call('changed',[element]); }, ani_dur * 1000); } @@ -2430,7 +2430,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { textActions.select(mouse_target, pt.x, pt.y); } - if ((tagName === "g" || tagName === "a") && svgedit.utilities.getRotationAngle(mouse_target)) { + if ((tagName === 'g' || tagName === 'a') && svgedit.utilities.getRotationAngle(mouse_target)) { // TODO: Allow method of in-group editing without having to do // this (similar to editing rotated paths) @@ -2466,7 +2466,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { // $(window).mouseup(mouseUp); //TODO(rafaelcastrocouto): User preference for shift key and zoom factor - $(container).bind("mousewheel DOMMouseScroll", function(e){ + $(container).bind('mousewheel DOMMouseScroll', function(e){ //if (!e.shiftKey) {return;} e.preventDefault(); var evt = e.originalEvent; @@ -2486,7 +2486,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) { bbox.factor = Math.max(3/4, Math.min(4/3, (delta))); - call("zoomed", bbox); + call('zoomed', bbox); }); }()); @@ -2515,7 +2515,7 @@ textActions = canvas.textActions = (function() { var allow_dbl; function setCursor(index) { - var empty = (textinput.value === ""); + var empty = (textinput.value === ''); $(textinput).focus(); if (!arguments.length) { @@ -2532,15 +2532,15 @@ textActions = canvas.textActions = (function() { if (!empty) { textinput.setSelectionRange(index, index); } - cursor = svgedit.utilities.getElem("text_cursor"); + cursor = svgedit.utilities.getElem('text_cursor'); if (!cursor) { - cursor = document.createElementNS(NS.SVG, "line"); + cursor = document.createElementNS(NS.SVG, 'line'); svgedit.utilities.assignAttributes(cursor, { - 'id': "text_cursor", - 'stroke': "#333", + id: 'text_cursor', + stroke: '#333', 'stroke-width': 1 }); - cursor = svgedit.utilities.getElem("selectorParentGroup").appendChild(cursor); + cursor = svgedit.utilities.getElem('selectorParentGroup').appendChild(cursor); } if (!blinker) { @@ -2575,17 +2575,17 @@ textActions = canvas.textActions = (function() { textinput.setSelectionRange(start, end); } - selblock = svgedit.utilities.getElem("text_selectblock"); + selblock = svgedit.utilities.getElem('text_selectblock'); if (!selblock) { - selblock = document.createElementNS(NS.SVG, "path"); + selblock = document.createElementNS(NS.SVG, 'path'); svgedit.utilities.assignAttributes(selblock, { - 'id': "text_selectblock", - 'fill': "green", - 'opacity': 0.5, - 'style': "pointer-events:none" + id: 'text_selectblock', + fill: 'green', + opacity: 0.5, + style: 'pointer-events:none' }); - svgedit.utilities.getElem("selectorParentGroup").appendChild(selblock); + svgedit.utilities.getElem('selectorParentGroup').appendChild(selblock); } var startbb = chardata[start]; @@ -2598,10 +2598,10 @@ textActions = canvas.textActions = (function() { bl = ptToScreen(startbb.x, textbb.y + textbb.height), br = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y + textbb.height); - var dstr = "M" + tl.x + "," + tl.y - + " L" + tr.x + "," + tr.y - + " " + br.x + "," + br.y - + " " + bl.x + "," + bl.y + "z"; + var dstr = 'M' + tl.x + ',' + tl.y + + ' L' + tr.x + ',' + tr.y + + ' ' + br.x + ',' + br.y + + ' ' + bl.x + ',' + bl.y + 'z'; svgedit.utilities.assignAttributes(selblock, { d: dstr, @@ -2767,7 +2767,7 @@ textActions = canvas.textActions = (function() { setCursor: setCursor, toEditMode: function(x, y) { allow_dbl = false; - current_mode = "textedit"; + current_mode = 'textedit'; selectorManager.requestSelector(curtext).showGrips(false); // Make selector group accept clicks var sel = selectorManager.requestSelector(curtext).selectorRect; @@ -2793,7 +2793,7 @@ textActions = canvas.textActions = (function() { }, 300); }, toSelectMode: function(selectElem) { - current_mode = "select"; + current_mode = 'select'; clearInterval(blinker); blinker = null; if (selblock) {$(selblock).attr('display', 'none');} @@ -2804,7 +2804,7 @@ textActions = canvas.textActions = (function() { clearSelection(); $(curtext).css('cursor', 'move'); - call("selected", [curtext]); + call('selected', [curtext]); addToSelection([curtext], true); } if (curtext && !curtext.textContent.length) { @@ -2825,7 +2825,7 @@ textActions = canvas.textActions = (function() { // $(textinput).blur(hideCursor); }, clear: function() { - if (current_mode == "textedit") { + if (current_mode == 'textedit') { textActions.toSelectMode(); } }, @@ -2906,7 +2906,7 @@ pathActions = canvas.pathActions = function() { var newPoint, firstCtrl; function resetD(p) { - p.setAttribute("d", pathActions.convertPath(p)); + p.setAttribute('d', pathActions.convertPath(p)); } // TODO: Move into path.js @@ -2914,7 +2914,7 @@ pathActions = canvas.pathActions = function() { if (svgedit.browser.isWebkit()) {resetD(this.elem);} var cmd = new svgedit.history.ChangeElementCommand(this.elem, {d: this.last_d}, text); addCommandToHistory(cmd); - call("changed", [this.elem]); + call('changed', [this.elem]); }; svgedit.path.Path.prototype.addPtsToSelection = function(indexes) { @@ -2944,7 +2944,7 @@ pathActions = canvas.pathActions = function() { pathActions.closed_subpath = this.subpathIsClosed(this.selected_pts[0]); - call("selected", grips); + call('selected', grips); }; current_path = null; @@ -2973,7 +2973,7 @@ pathActions = canvas.pathActions = function() { // - http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-der.html var curpos = points.getItem(0), prevCtlPt = null; var d = []; - d.push(["M", curpos.x, ",", curpos.y, " C"].join("")); + d.push(['M', curpos.x, ',', curpos.y, ' C'].join('')); for (i = 1; i <= (N-4); i += 3) { var ct1 = points.getItem(i); var ct2 = points.getItem(i+1); @@ -2998,22 +2998,22 @@ pathActions = canvas.pathActions = function() { prevCtlPt = ct2; } // handle remaining line segments - d.push("L"); + d.push('L'); while (i < N) { var pt = points.getItem(i); - d.push([pt.x, pt.y].join(",")); + d.push([pt.x, pt.y].join(',')); i++; } - d = d.join(" "); + d = d.join(' '); // create new path element element = addSvgElementFromJson({ - "element": "path", - "curStyles": true, - "attr": { - "id": getId(), - "d": d, - "fill": "none" + element: 'path', + curStyles: true, + attr: { + id: getId(), + d: d, + fill: 'none' } }); // No need to call "changed", as this is already done under mouseUp @@ -3024,13 +3024,13 @@ pathActions = canvas.pathActions = function() { return { mouseDown: function(evt, mouse_target, start_x, start_y) { var id; - if (current_mode === "path") { + if (current_mode === 'path') { mouse_x = start_x; mouse_y = start_y; var x = mouse_x/current_zoom, y = mouse_y/current_zoom, - stretchy = svgedit.utilities.getElem("path_stretch_line"); + stretchy = svgedit.utilities.getElem('path_stretch_line'); newPoint = [x, y]; if (curConfig.gridSnapping){ @@ -3041,29 +3041,29 @@ pathActions = canvas.pathActions = function() { } if (!stretchy) { - stretchy = document.createElementNS(NS.SVG, "path"); + stretchy = document.createElementNS(NS.SVG, 'path'); svgedit.utilities.assignAttributes(stretchy, { - 'id': "path_stretch_line", - 'stroke': "#22C", - 'stroke-width': "0.5", - 'fill': 'none' + id: 'path_stretch_line', + stroke: '#22C', + 'stroke-width': '0.5', + fill: 'none' }); - stretchy = svgedit.utilities.getElem("selectorParentGroup").appendChild(stretchy); + stretchy = svgedit.utilities.getElem('selectorParentGroup').appendChild(stretchy); } - stretchy.setAttribute("display", "inline"); + stretchy.setAttribute('display', 'inline'); var keep = null; var index; // if pts array is empty, create path element with M at current point if (!drawn_path) { - d_attr = "M" + x + "," + y + " "; + d_attr = 'M' + x + ',' + y + ' '; drawn_path = addSvgElementFromJson({ - "element": "path", - "curStyles": true, - "attr": { - "d": d_attr, - "id": getNextId(), - "opacity": cur_shape.opacity / 2 + element: 'path', + curStyles: true, + attr: { + d: d_attr, + id: getNextId(), + opacity: cur_shape.opacity / 2 } }); // set stretchy line to first point @@ -3143,9 +3143,9 @@ pathActions = canvas.pathActions = function() { svgedit.coords.remapElement(newpath, {}, svgedit.path.path.matrix.inverse()); } - var new_d = newpath.getAttribute("d"); - var orig_d = $(svgedit.path.path.elem).attr("d"); - $(svgedit.path.path.elem).attr("d", orig_d + new_d); + var new_d = newpath.getAttribute('d'); + var orig_d = $(svgedit.path.path.elem).attr('d'); + $(svgedit.path.path.elem).attr('d', orig_d + new_d); $(newpath).remove(); if (svgedit.path.path.matrix) { svgedit.path.recalcRotatedPath(); @@ -3161,7 +3161,7 @@ pathActions = canvas.pathActions = function() { // Checks if current target or parents are #svgcontent if (!$.contains(container, getMouseTarget(evt))) { // Clicked outside canvas, so don't make point - console.log("Clicked outside canvas"); + console.log('Clicked outside canvas'); return false; } @@ -3214,7 +3214,7 @@ pathActions = canvas.pathActions = function() { id = evt.target.id; var cur_pt; - if (id.substr(0,14) == "pathpointgrip_") { + if (id.substr(0,14) == 'pathpointgrip_') { // Select this point cur_pt = svgedit.path.path.cur_pt = parseInt(id.substr(14)); svgedit.path.path.dragging = [start_x, start_y]; @@ -3232,7 +3232,7 @@ pathActions = canvas.pathActions = function() { } else { svgedit.path.path.addPtsToSelection(cur_pt); } - } else if (id.indexOf("ctrlpointgrip_") == 0) { + } else if (id.indexOf('ctrlpointgrip_') == 0) { svgedit.path.path.dragging = [start_x, start_y]; var parts = id.split('_')[1].split('c'); @@ -3257,7 +3257,7 @@ pathActions = canvas.pathActions = function() { }, mouseMove: function(mouse_x, mouse_y) { hasMoved = true; - if (current_mode === "path") { + if (current_mode === 'path') { if (!drawn_path) {return;} var seglist = drawn_path.pathSegList; var index = seglist.numberOfItems - 1; @@ -3315,7 +3315,7 @@ pathActions = canvas.pathActions = function() { svgedit.path.replacePathSeg(6, index, [pt_x, pt_y, last_x, last_y, alt_x, alt_y], drawn_path); } } else { - var stretchy = svgedit.utilities.getElem("path_stretch_line"); + var stretchy = svgedit.utilities.getElem('path_stretch_line'); if (stretchy) { var prev = seglist.getItem(index); if (prev.pathSegType === 6) { @@ -3379,7 +3379,7 @@ pathActions = canvas.pathActions = function() { mouseUp: function(evt, element, mouse_x, mouse_y) { // Create mode - if (current_mode === "path") { + if (current_mode === 'path') { newPoint = null; if (!drawn_path) { element = svgedit.utilities.getElem(getId()); @@ -3403,7 +3403,7 @@ pathActions = canvas.pathActions = function() { svgedit.path.path.update(); if (hasMoved) { - svgedit.path.path.endChanges("Move path point(s)"); + svgedit.path.path.endChanges('Move path point(s)'); } if (!evt.shiftKey && !hasMoved) { @@ -3411,7 +3411,7 @@ pathActions = canvas.pathActions = function() { } } else if (rubberBox && rubberBox.getAttribute('display') != 'none') { // Done with multi-node-select - rubberBox.setAttribute("display", "none"); + rubberBox.setAttribute('display', 'none'); if (rubberBox.getAttribute('width') <= 2 && rubberBox.getAttribute('height') <= 2) { pathActions.toSelectMode(evt.target); @@ -3425,7 +3425,7 @@ pathActions = canvas.pathActions = function() { }, toEditMode: function(element) { svgedit.path.path = svgedit.path.getPath_(element); - current_mode = "pathedit"; + current_mode = 'pathedit'; clearSelection(); svgedit.path.path.show(true).update(); svgedit.path.path.oldbbox = svgedit.utilities.getBBox(svgedit.path.path.elem); @@ -3433,7 +3433,7 @@ pathActions = canvas.pathActions = function() { }, toSelectMode: function(elem) { var selPath = (elem == svgedit.path.path.elem); - current_mode = "select"; + current_mode = 'select'; svgedit.path.path.show(false); current_path = false; clearSelection(); @@ -3444,7 +3444,7 @@ pathActions = canvas.pathActions = function() { } if (selPath) { - call("selected", [elem]); + call('selected', [elem]); addToSelection([elem], true); } }, @@ -3452,7 +3452,7 @@ pathActions = canvas.pathActions = function() { if (on) { // Internally we go into "path" mode, but in the UI it will // still appear as if in "pathedit" mode. - current_mode = "path"; + current_mode = 'path'; subpath = true; } else { pathActions.clear(true); @@ -3462,7 +3462,7 @@ pathActions = canvas.pathActions = function() { select: function(target) { if (current_path === target) { pathActions.toEditMode(target); - current_mode = "pathedit"; + current_mode = 'pathedit'; } // going into pathedit mode else { current_path = target; @@ -3474,7 +3474,7 @@ pathActions = canvas.pathActions = function() { var angle = svgedit.utilities.getRotationAngle(elem); if (angle == 0) {return;} - var batchCmd = new svgedit.history.BatchCommand("Reorient path"); + var batchCmd = new svgedit.history.BatchCommand('Reorient path'); var changes = { d: elem.getAttribute('d'), transform: elem.getAttribute('transform') @@ -3491,19 +3491,19 @@ pathActions = canvas.pathActions = function() { this.clear(); addToSelection([elem], true); - call("changed", selectedElements); + call('changed', selectedElements); }, clear: function(remove) { current_path = null; if (drawn_path) { var elem = svgedit.utilities.getElem(getId()); - $(svgedit.utilities.getElem("path_stretch_line")).remove(); + $(svgedit.utilities.getElem('path_stretch_line')).remove(); $(elem).remove(); - $(svgedit.utilities.getElem("pathpointgrip_container")).find('*').attr('display', 'none'); + $(svgedit.utilities.getElem('pathpointgrip_container')).find('*').attr('display', 'none'); drawn_path = firstCtrl = null; started = false; - } else if (current_mode == "pathedit") { + } else if (current_mode == 'pathedit') { this.toSelectMode(); } if (svgedit.path.path) {svgedit.path.path.init().show(false);} @@ -3513,7 +3513,7 @@ pathActions = canvas.pathActions = function() { var tlist = svgedit.transformlist.getTransformList(path); var m = svgedit.math.transformListToTransform(tlist).matrix; tlist.clear(); - path.removeAttribute("transform"); + path.removeAttribute('transform'); var segList = path.pathSegList; // Opera/win/non-EN throws an error here. @@ -3548,7 +3548,7 @@ pathActions = canvas.pathActions = function() { reorientGrads(path, m); }, zoomChange: function() { - if (current_mode == "pathedit") { + if (current_mode == 'pathedit') { svgedit.path.path.update(); } }, @@ -3583,7 +3583,7 @@ pathActions = canvas.pathActions = function() { } svgedit.path.path.init().addPtsToSelection(nums); - svgedit.path.path.endChanges("Clone path node(s)"); + svgedit.path.path.endChanges('Clone path node(s)'); }, opencloseSubPath: function() { var sel_pts = svgedit.path.path.selected_pts; @@ -3771,7 +3771,7 @@ pathActions = canvas.pathActions = function() { var cp = $(svgedit.path.path.elem); cp.attr('d', cp.attr('d')); } - svgedit.path.path.endChanges("Delete path node(s)"); + svgedit.path.path.endChanges('Delete path node(s)'); }, smoothPolylineIntoPath: smoothPolylineIntoPath, setSegType: function(v) { @@ -3789,7 +3789,7 @@ pathActions = canvas.pathActions = function() { diff[attr] = newValue - seg.item[attr]; seg.move(diff.x, diff.y); - svgedit.path.path.endChanges("Move path point"); + svgedit.path.path.endChanges('Move path point'); }, fixEnd: function(elem) { // Adds an extra segment if the last seg before a Z doesn't end @@ -3825,7 +3825,7 @@ pathActions = canvas.pathActions = function() { var segList = path.pathSegList; var len = segList.numberOfItems; var curx = 0, cury = 0; - var d = ""; + var d = ''; var last_m = null; for (i = 0; i < len; ++i) { @@ -3853,7 +3853,7 @@ pathActions = canvas.pathActions = function() { switch (type) { case 1: // z,Z closepath (Z/z) - d += "z"; + d += 'z'; break; case 12: // absolute horizontal line (H) x -= curx; @@ -3992,7 +3992,7 @@ pathActions = canvas.pathActions = function() { // Returns: // The amount of elements that were removed var removeUnusedDefElems = this.removeUnusedDefElems = function() { - var defs = svgcontent.getElementsByTagNameNS(NS.SVG, "defs"); + var defs = svgcontent.getElementsByTagNameNS(NS.SVG, 'defs'); if (!defs || !defs.length) {return 0;} // if (!defs.firstChild) {return;} @@ -4022,7 +4022,7 @@ var removeUnusedDefElems = this.removeUnusedDefElems = function() { } } - var defelems = $(defs).find("linearGradient, radialGradient, filter, marker, svg, symbol"); + var defelems = $(defs).find('linearGradient, radialGradient, filter, marker, svg, symbol'); i = defelems.length; while (i--) { var defelem = defelems[i]; @@ -4116,15 +4116,15 @@ this.svgToString = function(elem, indent) { childs = elem.childNodes; for (i = 0; i < indent; i++) {out.push(' ');} - out.push("<"); out.push(elem.nodeName); + out.push('<'); out.push(elem.nodeName); if (elem.id === 'svgcontent') { // Process root element separately var res = getResolution(); - var vb = ""; + var vb = ''; // TODO: Allow this by dividing all values by current baseVal // Note that this also means we should properly deal with this on import -// if (curConfig.baseUnit !== "px") { +// if (curConfig.baseUnit !== 'px') { // var unit = curConfig.baseUnit; // var unit_m = svgedit.units.getTypeMap()[unit]; // res.w = svgedit.units.shortFloat(res.w / unit_m) @@ -4134,7 +4134,7 @@ this.svgToString = function(elem, indent) { // res.h += unit; // } - if (unit !== "px") { + if (unit !== 'px') { res.w = svgedit.units.convertUnit(res.w, unit) + unit; res.h = svgedit.units.convertUnit(res.h, unit) + unit; } @@ -4150,14 +4150,14 @@ this.svgToString = function(elem, indent) { var uri = this.namespaceURI; if(uri && !nsuris[uri] && nsMap[uri] && nsMap[uri] !== 'xmlns' && nsMap[uri] !== 'xml' ) { nsuris[uri] = true; - out.push(" xmlns:" + nsMap[uri] + '="' + uri +'"'); + out.push(' xmlns:' + nsMap[uri] + '="' + uri +'"'); } $.each(this.attributes, function(i, attr) { var uri = attr.namespaceURI; if (uri && !nsuris[uri] && nsMap[uri] !== 'xmlns' && nsMap[uri] !== 'xml' ) { nsuris[uri] = true; - out.push(" xmlns:" + nsMap[uri] + '="' + uri +'"'); + out.push(' xmlns:' + nsMap[uri] + '="' + uri +'"'); } }); }); @@ -4172,12 +4172,12 @@ this.svgToString = function(elem, indent) { if (attr.nodeName.indexOf('xmlns:') === 0) {continue;} // only serialize attributes we don't use internally - if (attrVal != "" && attr_names.indexOf(attr.localName) == -1) { + if (attrVal != '' && attr_names.indexOf(attr.localName) == -1) { if (!attr.namespaceURI || nsMap[attr.namespaceURI]) { out.push(' '); - out.push(attr.nodeName); out.push("=\""); - out.push(attrVal); out.push("\""); + out.push(attr.nodeName); out.push('="'); + out.push(attrVal); out.push('"'); } } } @@ -4191,10 +4191,10 @@ this.svgToString = function(elem, indent) { var attrVal = toXml(attr.nodeValue); //remove bogus attributes added by Gecko if (moz_attrs.indexOf(attr.localName) >= 0) {continue;} - if (attrVal != "") { + if (attrVal != '') { if (attrVal.indexOf('pointer-events') === 0) {continue;} - if (attr.localName === "class" && attrVal.indexOf('se_') === 0) {continue;} - out.push(" "); + if (attr.localName === 'class' && attrVal.indexOf('se_') === 0) {continue;} + out.push(' '); if (attr.localName === 'd') {attrVal = pathActions.convertPath(elem, true);} if (!isNaN(attrVal)) { attrVal = svgedit.units.shortFloat(attrVal); @@ -4216,15 +4216,15 @@ this.svgToString = function(elem, indent) { // map various namespaces to our fixed namespace prefixes // (the default xmlns attribute itself does not get a prefix) if (!attr.namespaceURI || attr.namespaceURI == NS.SVG || nsMap[attr.namespaceURI]) { - out.push(attr.nodeName); out.push("=\""); - out.push(attrVal); out.push("\""); + out.push(attr.nodeName); out.push('="'); + out.push(attrVal); out.push('"'); } } } } if (elem.hasChildNodes()) { - out.push(">"); + out.push('>'); indent++; var bOneLine = false; @@ -4232,40 +4232,40 @@ this.svgToString = function(elem, indent) { var child = childs.item(i); switch(child.nodeType) { case 1: // element node - out.push("\n"); + out.push('\n'); out.push(this.svgToString(childs.item(i), indent)); break; case 3: // text node - var str = child.nodeValue.replace(/^\s+|\s+$/g, ""); - if (str != "") { + var str = child.nodeValue.replace(/^\s+|\s+$/g, ''); + if (str != '') { bOneLine = true; out.push(String(toXml(str))); } break; case 4: // cdata node - out.push("\n"); - out.push(new Array(indent+1).join(" ")); - out.push(""); + out.push('\n'); + out.push(new Array(indent+1).join(' ')); + out.push('<![CDATA['); out.push(child.nodeValue); - out.push(""); + out.push(']]>'); break; case 8: // comment - out.push("\n"); - out.push(new Array(indent+1).join(" ")); - out.push(""); + out.push('-->'); break; } // switch on node type } indent--; if (!bOneLine) { - out.push("\n"); + out.push('\n'); for (i = 0; i < indent; i++) {out.push(' ');} } - out.push(""); + out.push(''); } else { - out.push("/>"); + out.push('/>'); } } return out.join(''); @@ -4282,11 +4282,11 @@ this.embedImage = function(val, callback) { // load in the image and once it's loaded, get the dimensions $(new Image()).load(function() { // create a canvas the same size as the raster image - var canvas = document.createElement("canvas"); + var canvas = document.createElement('canvas'); canvas.width = this.width; canvas.height = this.height; // load the raster image into the canvas - canvas.getContext("2d").drawImage(this, 0, 0); + canvas.getContext('2d').drawImage(this, 0, 0); // retrieve the data: URL try { var urldata = ';svgedit_url=' + encodeURIComponent(val); @@ -4326,7 +4326,7 @@ this.save = function(opts) { // no need for doctype, see http://jwatt.org/svg/authoring/#doctype-declaration var str = this.svgCanvasToString(); - call("saved", str); + call('saved', str); }; // Function: rasterExport @@ -4350,7 +4350,7 @@ this.rasterExport = function(imgType, quality) { var content = $(svgcontent); // Add font/text check if Canvas Text API is not implemented - if (!("font" in $('')[0].getContext('2d'))) { + if (!('font' in $('')[0].getContext('2d'))) { issue_list.text = uiStrings.exportNoText; } @@ -4361,7 +4361,7 @@ this.rasterExport = function(imgType, quality) { }); var str = this.svgCanvasToString(); - call("exported", {svg: str, issues: issues, type: imgType, mimeType: mimeType, quality: quality}); + call('exported', {svg: str, issues: issues, type: imgType, mimeType: mimeType, quality: quality}); }; // Function: getSvgString @@ -4408,7 +4408,7 @@ var uniquifyElems = this.uniquifyElems = function(g) { // // Problem #1: if svg_1 gets renamed, we do not update the polyline's se:connector attribute // Problem #2: if the polyline svg_7 gets renamed, we do not update the marker id nor the polyline's marker-end attribute - var ref_elems = ["filter", "linearGradient", "pattern", "radialGradient", "symbol", "textPath", "use"]; + var ref_elems = ['filter', 'linearGradient', 'pattern', 'radialGradient', 'symbol', 'textPath', 'use']; svgedit.utilities.walkTree(g, function(n) { // if it's an element node @@ -4473,7 +4473,7 @@ var uniquifyElems = this.uniquifyElems = function(g) { var j = attrs.length; while (j--) { var attr = attrs[j]; - attr.ownerElement.setAttribute(attr.name, "url(#" + newid + ")"); + attr.ownerElement.setAttribute(attr.name, 'url(#' + newid + ')'); } // remap all href attributes @@ -4481,7 +4481,7 @@ var uniquifyElems = this.uniquifyElems = function(g) { var k = hreffers.length; while (k--) { var hreffer = hreffers[k]; - svgedit.utilities.setHref(hreffer, "#"+newid); + svgedit.utilities.setHref(hreffer, '#' + newid); } } } @@ -4604,7 +4604,7 @@ var convertToGroup = this.convertToGroup = function(elem) { xform.setTranslate(pt.x, pt.y); tlist.appendItem(xform); svgedit.recalculate.recalculateDimensions(elem); - call("selected", [elem]); + call('selected', [elem]); } else if ($elem.data('symbol')) { elem = $elem.data('symbol'); @@ -4620,7 +4620,7 @@ var convertToGroup = this.convertToGroup = function(elem) { } // Not ideal, but works - ts += " translate(" + (pos.x || 0) + "," + (pos.y || 0) + ")"; + ts += ' translate(' + (pos.x || 0) + ',' + (pos.y || 0) + ')'; var prev = $elem.prev(); @@ -4631,7 +4631,7 @@ var convertToGroup = this.convertToGroup = function(elem) { // See if other elements reference this symbol var has_more = $(svgcontent).find('use:data(symbol)').length; - var g = svgdoc.createElementNS(NS.SVG, "g"); + var g = svgdoc.createElementNS(NS.SVG, 'g'); var childs = elem.childNodes; var i; @@ -4646,7 +4646,7 @@ var convertToGroup = this.convertToGroup = function(elem) { } if (ts) { - g.setAttribute("transform", ts); + g.setAttribute('transform', ts); } var parent = elem.parentNode; @@ -4726,7 +4726,7 @@ this.setSvgString = function(xmlString) { this.prepareSvg(newDoc); - var batchCmd = new svgedit.history.BatchCommand("Change Source"); + var batchCmd = new svgedit.history.BatchCommand('Change Source'); // remove old svg document var nextSibling = svgcontent.nextSibling; @@ -4750,9 +4750,9 @@ this.setSvgString = function(xmlString) { // retrieve or set the nonce var nonce = getCurrentDrawing().getNonce(); if (nonce) { - call("setnonce", nonce); + call('setnonce', nonce); } else { - call("unsetnonce"); + call('unsetnonce'); } // change image href vals if possible @@ -4823,8 +4823,8 @@ this.setSvgString = function(xmlString) { var percs = false; // determine proper size - if (content.attr("viewBox")) { - var vb = content.attr("viewBox").split(' '); + if (content.attr('viewBox')) { + var vb = content.attr('viewBox').split(' '); attrs.width = vb[2]; attrs.height = vb[3]; } @@ -4836,7 +4836,7 @@ this.setSvgString = function(xmlString) { if (!val) {val = '100%';} - if (String(val).substr(-1) === "%") { + if (String(val).substr(-1) === '%') { // Use user units if percentage given percs = true; } else { @@ -4871,7 +4871,7 @@ this.setSvgString = function(xmlString) { batchCmd.addSubCommand(new svgedit.history.InsertElementCommand(svgcontent)); // update root to the correct size - var changes = content.attr(["width", "height"]); + var changes = content.attr(['width', 'height']); batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(svgroot, changes)); // reset zoom @@ -4884,7 +4884,7 @@ this.setSvgString = function(xmlString) { svgroot.appendChild(selectorManager.selectorParentGroup); addCommandToHistory(batchCmd); - call("changed", [svgcontent]); + call('changed', [svgcontent]); } catch(e) { console.log(e); return false; @@ -4924,7 +4924,7 @@ this.importSvgString = function(xmlString) { } } - var batchCmd = new svgedit.history.BatchCommand("Import SVG"); + var batchCmd = new svgedit.history.BatchCommand('Import SVG'); var symbol; if (useExisting) { symbol = import_ids[uid].symbol; @@ -4946,30 +4946,30 @@ this.importSvgString = function(xmlString) { uniquifyElems(svg); - var innerw = svgedit.units.convertToNum('width', svg.getAttribute("width")), - innerh = svgedit.units.convertToNum('height', svg.getAttribute("height")), - innervb = svg.getAttribute("viewBox"), + var innerw = svgedit.units.convertToNum('width', svg.getAttribute('width')), + innerh = svgedit.units.convertToNum('height', svg.getAttribute('height')), + innervb = svg.getAttribute('viewBox'), // if no explicit viewbox, create one out of the width and height - vb = innervb ? innervb.split(" ") : [0, 0, innerw, innerh]; + vb = innervb ? innervb.split(' ') : [0, 0, innerw, innerh]; for (j = 0; j < 4; ++j) { vb[j] = +(vb[j]); } // TODO: properly handle preserveAspectRatio - var canvasw = +svgcontent.getAttribute("width"), - canvash = +svgcontent.getAttribute("height"); + var canvasw = +svgcontent.getAttribute('width'), + canvash = +svgcontent.getAttribute('height'); // imported content should be 1/3 of the canvas on its largest dimension if (innerh > innerw) { - ts = "scale(" + (canvash/3)/vb[3] + ")"; + ts = 'scale(' + (canvash/3)/vb[3] + ')'; } else { - ts = "scale(" + (canvash/3)/vb[2] + ")"; + ts = 'scale(' + (canvash/3)/vb[2] + ')'; } // Hack to make recalculateDimensions understand how to scale - ts = "translate(0) " + ts + " translate(0)"; + ts = 'translate(0) ' + ts + ' translate(0)'; - symbol = svgdoc.createElementNS(NS.SVG, "symbol"); + symbol = svgdoc.createElementNS(NS.SVG, 'symbol'); var defs = svgedit.utilities.findDefs(); if (svgedit.browser.isGecko()) { @@ -5001,24 +5001,24 @@ this.importSvgString = function(xmlString) { batchCmd.addSubCommand(new svgedit.history.InsertElementCommand(symbol)); } - var use_el = svgdoc.createElementNS(NS.SVG, "use"); + var use_el = svgdoc.createElementNS(NS.SVG, 'use'); use_el.id = getNextId(); - setHref(use_el, "#" + symbol.id); + setHref(use_el, '#' + symbol.id); (current_group || getCurrentDrawing().getCurrentLayer()).appendChild(use_el); batchCmd.addSubCommand(new svgedit.history.InsertElementCommand(use_el)); clearSelection(); - use_el.setAttribute("transform", ts); + use_el.setAttribute('transform', ts); svgedit.recalculate.recalculateDimensions(use_el); $(use_el).data('symbol', symbol).data('ref', symbol); addToSelection([use_el]); // TODO: Find way to add this in a recalculateDimensions-parsable way // if (vb[0] != 0 || vb[1] != 0) -// ts = "translate(" + (-vb[0]) + "," + (-vb[1]) + ") " + ts; +// ts = 'translate(' + (-vb[0]) + ',' + (-vb[1]) + ') ' + ts; addCommandToHistory(batchCmd); - call("changed", [svgcontent]); + call('changed', [svgcontent]); } catch(e) { console.log(e); @@ -5048,12 +5048,12 @@ var identifyLayers = canvas.identifyLayers = function() { // Parameters: // name - The given name this.createLayer = function(name) { - var batchCmd = new svgedit.history.BatchCommand("Create Layer"); + var batchCmd = new svgedit.history.BatchCommand('Create Layer'); var new_layer = getCurrentDrawing().createLayer(name); batchCmd.addSubCommand(new svgedit.history.InsertElementCommand(new_layer)); addCommandToHistory(batchCmd); clearSelection(); - call("changed", [new_layer]); + call('changed', [new_layer]); }; // Function: cloneLayer @@ -5064,9 +5064,9 @@ this.createLayer = function(name) { // Parameters: // name - The given name this.cloneLayer = function(name) { - var batchCmd = new svgedit.history.BatchCommand("Duplicate Layer"); - var new_layer = svgdoc.createElementNS(NS.SVG, "g"); - var layer_title = svgdoc.createElementNS(NS.SVG, "title"); + var batchCmd = new svgedit.history.BatchCommand('Duplicate Layer'); + var new_layer = svgdoc.createElementNS(NS.SVG, 'g'); + var layer_title = svgdoc.createElementNS(NS.SVG, 'title'); layer_title.textContent = name; new_layer.appendChild(layer_title); var current_layer = getCurrentDrawing().getCurrentLayer(); @@ -5085,7 +5085,7 @@ this.cloneLayer = function(name) { batchCmd.addSubCommand(new svgedit.history.InsertElementCommand(new_layer)); addCommandToHistory(batchCmd); canvas.setCurrentLayer(name); - call("changed", [new_layer]); + call('changed', [new_layer]); }; // Function: deleteCurrentLayer @@ -5097,12 +5097,12 @@ this.deleteCurrentLayer = function() { var parent = current_layer.parentNode; current_layer = getCurrentDrawing().deleteCurrentLayer(); if (current_layer) { - var batchCmd = new svgedit.history.BatchCommand("Delete Layer"); + var batchCmd = new svgedit.history.BatchCommand('Delete Layer'); // store in our Undo History batchCmd.addSubCommand(new svgedit.history.RemoveElementCommand(current_layer, nextSibling, parent)); addCommandToHistory(batchCmd); clearSelection(); - call("changed", [parent]); + call('changed', [parent]); return true; } return false; @@ -5143,7 +5143,7 @@ this.renameCurrentLayer = function(newname) { // setCurrentLayer will return false if the name doesn't already exist // this means we are free to rename our oldLayer if (!canvas.setCurrentLayer(newname)) { - var batchCmd = new svgedit.history.BatchCommand("Rename Layer"); + var batchCmd = new svgedit.history.BatchCommand('Rename Layer'); // find the index of the layer for (i = 0; i < drawing.getNumLayers(); ++i) { if (drawing.all_layers[i][1] == oldLayer) {break;} @@ -5156,14 +5156,14 @@ this.renameCurrentLayer = function(newname) { for (i = 0; i < len; ++i) { var child = oldLayer.childNodes.item(i); // found the element, now append all the - if (child && child.tagName == "title") { + if (child && child.tagName == 'title') { // wipe out old name while (child.firstChild) { child.removeChild(child.firstChild); } child.textContent = newname; - batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(child, {"#text":oldname})); + batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(child, {'#text':oldname})); addCommandToHistory(batchCmd); - call("changed", [oldLayer]); + call('changed', [oldLayer]); return true; } } @@ -5244,7 +5244,7 @@ this.setLayerVisibility = function(layername, bVisible) { clearSelection(); pathActions.clear(); } -// call("changed", [selected]); +// call('changed', [selected]); return true; }; @@ -5270,7 +5270,7 @@ this.moveSelectedToLayer = function(layername) { } if (!layer) {return false;} - var batchCmd = new svgedit.history.BatchCommand("Move Elements to Layer"); + var batchCmd = new svgedit.history.BatchCommand('Move Elements to Layer'); // loop for each selected element and move it var selElems = selectedElements; @@ -5291,7 +5291,7 @@ this.moveSelectedToLayer = function(layername) { }; this.mergeLayer = function(skipHistory) { - var batchCmd = new svgedit.history.BatchCommand("Merge Layer"); + var batchCmd = new svgedit.history.BatchCommand('Merge Layer'); var drawing = getCurrentDrawing(); var prev = $(drawing.current_layer).prev()[0]; if (!prev) {return;} @@ -5320,7 +5320,7 @@ this.mergeLayer = function(skipHistory) { clearSelection(); identifyLayers(); - call("changed", [svgcontent]); + call('changed', [svgcontent]); addCommandToHistory(batchCmd); } @@ -5330,7 +5330,7 @@ this.mergeLayer = function(skipHistory) { }; this.mergeAllLayers = function() { - var batchCmd = new svgedit.history.BatchCommand("Merge all Layers"); + var batchCmd = new svgedit.history.BatchCommand('Merge all Layers'); var drawing = getCurrentDrawing(); drawing.current_layer = drawing.all_layers[drawing.getNumLayers()-1][1]; while ($(svgcontent).children('g').length > 1) { @@ -5339,7 +5339,7 @@ this.mergeAllLayers = function() { clearSelection(); identifyLayers(); - call("changed", [svgcontent]); + call('changed', [svgcontent]); addCommandToHistory(batchCmd); }; @@ -5361,7 +5361,7 @@ var leaveContext = this.leaveContext = function() { } disabled_elems = []; clearSelection(true); - call("contextset", null); + call('contextset', null); } current_group = null; }; @@ -5388,7 +5388,7 @@ var setContext = this.setContext = function(elem) { }); clearSelection(); - call("contextset", current_group); + call('contextset', current_group); }; // Group: Document functions @@ -5407,7 +5407,7 @@ this.clear = function() { canvas.current_drawing_ = new svgedit.draw.Drawing(svgcontent); // create empty first layer - canvas.createLayer("Layer 1"); + canvas.createLayer('Layer 1'); // clear the undo stack canvas.undoMgr.resetUndoStack(); @@ -5418,7 +5418,7 @@ this.clear = function() { // reset the rubber band box rubberBox = selectorManager.getRubberBandBox(); - call("cleared"); + call('cleared'); }; // Function: linkControlPoints @@ -5440,11 +5440,11 @@ this.getSelectedElems = function() { return selectedElements; }; // Function: getResolution // Returns the current dimensions and zoom level in an object var getResolution = this.getResolution = function() { -// var vb = svgcontent.getAttribute("viewBox").split(' '); +// var vb = svgcontent.getAttribute('viewBox').split(' '); // return {'w':vb[2], 'h':vb[3], 'zoom': current_zoom}; - var width = svgcontent.getAttribute("width")/current_zoom; - var height = svgcontent.getAttribute("height")/current_zoom; + var width = svgcontent.getAttribute('width')/current_zoom; + var height = svgcontent.getAttribute('height')/current_zoom; return { 'w': width, @@ -5460,7 +5460,7 @@ this.getZoom = function(){return current_zoom;}; // Function: getVersion // Returns a string which describes the revision number of SvgCanvas. this.getVersion = function() { - return "svgcanvas.js ($Rev$)"; + return 'svgcanvas.js ($Rev$)'; }; // Function: setUiStrings @@ -5506,7 +5506,7 @@ this.setGroupTitle = function(val) { var ts = $(elem).children('title'); - var batchCmd = new svgedit.history.BatchCommand("Set Label"); + var batchCmd = new svgedit.history.BatchCommand('Set Label'); if (!val.length) { // Remove title element @@ -5520,7 +5520,7 @@ this.setGroupTitle = function(val) { title.textContent = val; } else { // Add title element - title = svgdoc.createElementNS(NS.SVG, "title"); + title = svgdoc.createElementNS(NS.SVG, 'title'); title.textContent = val; $(elem).prepend(title); batchCmd.addSubCommand(new svgedit.history.InsertElementCommand(title)); @@ -5545,7 +5545,7 @@ this.setDocumentTitle = function(newtitle) { var i; var childs = svgcontent.childNodes, doc_title = false, old_title = ''; - var batchCmd = new svgedit.history.BatchCommand("Change Image Title"); + var batchCmd = new svgedit.history.BatchCommand('Change Image Title'); for (i = 0; i < childs.length; i++) { if (childs[i].nodeName == 'title') { @@ -5555,7 +5555,7 @@ this.setDocumentTitle = function(newtitle) { } } if (!doc_title) { - doc_title = svgdoc.createElementNS(NS.SVG, "title"); + doc_title = svgdoc.createElementNS(NS.SVG, 'title'); svgcontent.insertBefore(doc_title, svgcontent.firstChild); } @@ -5602,7 +5602,7 @@ this.setResolution = function(x, y) { var bbox = getStrokedBBox(); if (bbox) { - batchCmd = new svgedit.history.BatchCommand("Fit Canvas to Content"); + batchCmd = new svgedit.history.BatchCommand('Fit Canvas to Content'); var visEls = getVisibleElements(); addToSelection(visEls); var dx = [], dy = []; @@ -5624,7 +5624,7 @@ this.setResolution = function(x, y) { if (x != w || y != h) { var handle = svgroot.suspendRedraw(1000); if (!batchCmd) { - batchCmd = new svgedit.history.BatchCommand("Change Image Dimensions"); + batchCmd = new svgedit.history.BatchCommand('Change Image Dimensions'); } x = svgedit.units.convertToNum('width', x); @@ -5635,14 +5635,14 @@ this.setResolution = function(x, y) { this.contentW = x; this.contentH = y; - batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(svgcontent, {"width":w, "height":h})); + batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(svgcontent, {'width':w, 'height':h})); - svgcontent.setAttribute("viewBox", [0, 0, x/current_zoom, y/current_zoom].join(' ')); - batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(svgcontent, {"viewBox": ["0 0", w, h].join(' ')})); + svgcontent.setAttribute('viewBox', [0, 0, x/current_zoom, y/current_zoom].join(' ')); + batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(svgcontent, {'viewBox': ['0 0', w, h].join(' ')})); addCommandToHistory(batchCmd); svgroot.unsuspendRedraw(handle); - call("changed", [svgcontent]); + call('changed', [svgcontent]); } return true; }; @@ -5713,14 +5713,14 @@ this.setBBoxZoom = function(val, editor_w, editor_h) { // zoomlevel - Float indicating the zoom level to change to this.setZoom = function(zoomlevel) { var res = getResolution(); - svgcontent.setAttribute("viewBox", "0 0 " + res.w/zoomlevel + " " + res.h/zoomlevel); + svgcontent.setAttribute('viewBox', '0 0 ' + res.w/zoomlevel + ' ' + res.h/zoomlevel); current_zoom = zoomlevel; $.each(selectedElements, function(i, elem) { if (!elem) {return;} selectorManager.requestSelector(elem).resize(); }); pathActions.zoomChange(); - runExtensions("zoomChanged", zoomlevel); + runExtensions('zoomChanged', zoomlevel); }; // Function: getMode @@ -5758,10 +5758,10 @@ this.getColor = function(type) { // preventUndo - Boolean indicating whether or not this should be and undoable option this.setColor = function(type, val, preventUndo) { cur_shape[type] = val; - cur_properties[type + '_paint'] = {type:"solidColor"}; + cur_properties[type + '_paint'] = {type:'solidColor'}; var elems = []; function addNonG (e) { - if (e.nodeName != "g") { + if (e.nodeName != 'g') { elems.push(e); } } @@ -5769,11 +5769,11 @@ this.setColor = function(type, val, preventUndo) { while (i--) { var elem = selectedElements[i]; if (elem) { - if (elem.tagName == "g") { + if (elem.tagName == 'g') { svgedit.utilities.walkTree(elem, addNonG); } else { if (type == 'fill') { - if (elem.tagName != "polyline" && elem.tagName != "line") { + if (elem.tagName != 'polyline' && elem.tagName != 'line') { elems.push(elem); } } else { @@ -5785,7 +5785,7 @@ this.setColor = function(type, val, preventUndo) { if (elems.length > 0) { if (!preventUndo) { changeSelectedAttribute(type, val, elems); - call("changed", elems); + call('changed', elems); } else { changeSelectedAttributeNoUndo(type, val, elems); } @@ -5798,7 +5798,7 @@ this.setColor = function(type, val, preventUndo) { // Parameters // type - String indicating "fill" or "stroke" to apply to an element var setGradient = this.setGradient = function(type) { - if (!cur_properties[type + '_paint'] || cur_properties[type + '_paint'].type == "solidColor") {return;} + if (!cur_properties[type + '_paint'] || cur_properties[type + '_paint'].type == 'solidColor') {return;} var grad = canvas[type + 'Grad']; // find out if there is a duplicate gradient already in the defs var duplicate_grad = findDuplicateGradient(grad); @@ -5812,7 +5812,7 @@ var setGradient = this.setGradient = function(type) { } else { // use existing gradient grad = duplicate_grad; } - canvas.setColor(type, "url(#" + grad.id + ")"); + canvas.setColor(type, 'url(#' + grad.id + ')'); }; // Function: findDuplicateGradient @@ -5825,12 +5825,12 @@ var setGradient = this.setGradient = function(type) { // The existing gradient if found, null if not var findDuplicateGradient = function(grad) { var defs = svgedit.utilities.findDefs(); - var existing_grads = $(defs).find("linearGradient, radialGradient"); + var existing_grads = $(defs).find('linearGradient, radialGradient'); var i = existing_grads.length; var rad_attrs = ['r', 'cx', 'cy', 'fx', 'fy']; while (i--) { var og = existing_grads[i]; - if (grad.tagName == "linearGradient") { + if (grad.tagName == 'linearGradient') { if (grad.getAttribute('x1') != og.getAttribute('x1') || grad.getAttribute('y1') != og.getAttribute('y1') || grad.getAttribute('x2') != og.getAttribute('x2') || @@ -5851,8 +5851,8 @@ var findDuplicateGradient = function(grad) { } // else could be a duplicate, iterate through stops - var stops = grad.getElementsByTagNameNS(NS.SVG, "stop"); - var ostops = og.getElementsByTagNameNS(NS.SVG, "stop"); + var stops = grad.getElementsByTagNameNS(NS.SVG, 'stop'); + var ostops = og.getElementsByTagNameNS(NS.SVG, 'stop'); if (stops.length != ostops.length) { continue; @@ -5985,7 +5985,7 @@ this.setStrokeWidth = function(val) { while (i--) { var elem = selectedElements[i]; if (elem) { - if (elem.tagName == "g") { + if (elem.tagName == 'g') { svgedit.utilities.walkTree(elem, addNonG); } else { @@ -5994,8 +5994,8 @@ this.setStrokeWidth = function(val) { } } if (elems.length > 0) { - changeSelectedAttribute("stroke-width", val, elems); - call("changed", selectedElements); + changeSelectedAttribute('stroke-width', val, elems); + call('changed', selectedElements); } }; @@ -6017,8 +6017,8 @@ this.setStrokeAttr = function(attr, val) { while (i--) { var elem = selectedElements[i]; if (elem) { - if (elem.tagName == "g") { - svgedit.utilities.walkTree(elem, function(e){if (e.nodeName!="g") {elems.push(e);}}); + if (elem.tagName == 'g') { + svgedit.utilities.walkTree(elem, function(e){if (e.nodeName!='g') {elems.push(e);}}); } else { elems.push(elem); @@ -6027,7 +6027,7 @@ this.setStrokeAttr = function(attr, val) { } if (elems.length > 0) { changeSelectedAttribute(attr, val, elems); - call("changed", selectedElements); + call('changed', selectedElements); } }; @@ -6047,7 +6047,7 @@ this.getOpacity = function() { // Sets the given opacity to the current selected elements this.setOpacity = function(val) { cur_shape.opacity = val; - changeSelectedAttribute("opacity", val); + changeSelectedAttribute('opacity', val); }; // Function: getOpacity @@ -6072,10 +6072,10 @@ this.getStrokeOpacity = function() { this.setPaintOpacity = function(type, val, preventUndo) { cur_shape[type + '_opacity'] = val; if (!preventUndo) { - changeSelectedAttribute(type + "-opacity", val); + changeSelectedAttribute(type + '-opacity', val); } else { - changeSelectedAttributeNoUndo(type + "-opacity", val); + changeSelectedAttributeNoUndo(type + '-opacity', val); } }; @@ -6127,19 +6127,19 @@ this.getBlur = function(elem) { if (val === 0) { // Don't change the StdDev, as that will hide the element. // Instead, just remove the value for "filter" - changeSelectedAttributeNoUndo("filter", ""); + changeSelectedAttributeNoUndo('filter', ''); filterHidden = true; } else { var elem = selectedElements[0]; if (filterHidden) { - changeSelectedAttributeNoUndo("filter", 'url(#' + elem.id + '_blur)'); + changeSelectedAttributeNoUndo('filter', 'url(#' + elem.id + '_blur)'); } if (svgedit.browser.isWebkit()) { console.log('e', elem); elem.removeAttribute('filter'); elem.setAttribute('filter', 'url(#' + elem.id + '_blur)'); } - changeSelectedAttributeNoUndo("stdDeviation", val, [filter.firstChild]); + changeSelectedAttributeNoUndo('stdDeviation', val, [filter.firstChild]); canvas.setBlurOffsets(filter, val); } }; @@ -6207,16 +6207,16 @@ this.getBlur = function(elem) { } } else { // Not found, so create - var newblur = addSvgElementFromJson({ "element": "feGaussianBlur", - "attr": { - "in": 'SourceGraphic', - "stdDeviation": val + var newblur = addSvgElementFromJson({ 'element': 'feGaussianBlur', + 'attr': { + 'in': 'SourceGraphic', + 'stdDeviation': val } }); - filter = addSvgElementFromJson({ "element": "filter", - "attr": { - "id": elem_id + '_blur' + filter = addSvgElementFromJson({ 'element': 'filter', + 'attr': { + 'id': elem_id + '_blur' } }); @@ -6229,17 +6229,17 @@ this.getBlur = function(elem) { var changes = {filter: elem.getAttribute('filter')}; if (val === 0) { - elem.removeAttribute("filter"); + elem.removeAttribute('filter'); batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(elem, changes)); return; } - changeSelectedAttribute("filter", 'url(#' + elem_id + '_blur)'); + changeSelectedAttribute('filter', 'url(#' + elem_id + '_blur)'); batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(elem, changes)); canvas.setBlurOffsets(filter, val); cur_command = batchCmd; - canvas.undoMgr.beginUndoableChange("stdDeviation", [filter?filter.firstChild:null]); + canvas.undoMgr.beginUndoableChange('stdDeviation', [filter?filter.firstChild:null]); if (complete) { canvas.setBlurNoUndo(val); finishChange(); @@ -6255,10 +6255,10 @@ this.getBlur = function(elem) { this.getBold = function() { // should only have one element selected var selected = selectedElements[0]; - if (selected != null && selected.tagName == "text" && + if (selected != null && selected.tagName == 'text' && selectedElements[1] == null) { - return (selected.getAttribute("font-weight") == "bold"); + return (selected.getAttribute('font-weight') == 'bold'); } return false; }; @@ -6270,10 +6270,10 @@ this.getBold = function() { // b - Boolean indicating bold (true) or normal (false) this.setBold = function(b) { var selected = selectedElements[0]; - if (selected != null && selected.tagName == "text" && + if (selected != null && selected.tagName == 'text' && selectedElements[1] == null) { - changeSelectedAttribute("font-weight", b ? "bold" : "normal"); + changeSelectedAttribute('font-weight', b ? 'bold' : 'normal'); } if (!selectedElements[0].textContent) { textActions.setCursor(); @@ -6287,10 +6287,10 @@ this.setBold = function(b) { // Boolean indicating whether or not element is italic this.getItalic = function() { var selected = selectedElements[0]; - if (selected != null && selected.tagName == "text" && + if (selected != null && selected.tagName == 'text' && selectedElements[1] == null) { - return (selected.getAttribute("font-style") == "italic"); + return (selected.getAttribute('font-style') == 'italic'); } return false; }; @@ -6302,10 +6302,10 @@ this.getItalic = function() { // b - Boolean indicating italic (true) or normal (false) this.setItalic = function(i) { var selected = selectedElements[0]; - if (selected != null && selected.tagName == "text" && + if (selected != null && selected.tagName == 'text' && selectedElements[1] == null) { - changeSelectedAttribute("font-style", i ? "italic" : "normal"); + changeSelectedAttribute('font-style', i ? 'italic' : 'normal'); } if (!selectedElements[0].textContent) { textActions.setCursor(); @@ -6325,7 +6325,7 @@ this.getFontFamily = function() { // val - String with the new font family this.setFontFamily = function(val) { cur_text.font_family = val; - changeSelectedAttribute("font-family", val); + changeSelectedAttribute('font-family', val); if (selectedElements[0] && !selectedElements[0].textContent) { textActions.setCursor(); } @@ -6339,7 +6339,7 @@ this.setFontFamily = function(val) { // val - String with the new font color this.setFontColor = function(val) { cur_text.fill = val; - changeSelectedAttribute("fill", val); + changeSelectedAttribute('fill', val); }; // Function: getFontColor @@ -6361,7 +6361,7 @@ this.getFontSize = function() { // val - Float with the new font size this.setFontSize = function(val) { cur_text.font_size = val; - changeSelectedAttribute("font-size", val); + changeSelectedAttribute('font-size', val); if (!selectedElements[0].textContent) { textActions.setCursor(); } @@ -6371,7 +6371,7 @@ this.setFontSize = function(val) { // Returns the current text (textContent) of the selected element this.getText = function() { var selected = selectedElements[0]; - if (selected == null) { return ""; } + if (selected == null) { return ''; } return selected.textContent; }; @@ -6381,7 +6381,7 @@ this.getText = function() { // Parameters: // val - String with the new text this.setTextContent = function(val) { - changeSelectedAttribute("#text", val); + changeSelectedAttribute('#text', val); textActions.init(val); textActions.setCursor(); }; @@ -6406,11 +6406,11 @@ this.setImageURL = function(val) { setsize = true; } else if (!setsize) {return;} - var batchCmd = new svgedit.history.BatchCommand("Change Image URL"); + var batchCmd = new svgedit.history.BatchCommand('Change Image URL'); setHref(elem, val); batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(elem, { - "#href": cur_href + '#href': cur_href })); if (setsize) { @@ -6426,7 +6426,7 @@ this.setImageURL = function(val) { batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(elem, changes)); addCommandToHistory(batchCmd); - call("changed", [elem]); + call('changed', [elem]); }).attr('src', val); } else { addCommandToHistory(batchCmd); @@ -6455,11 +6455,11 @@ this.setLinkURL = function(val) { if (cur_href === val) {return;} - var batchCmd = new svgedit.history.BatchCommand("Change Link URL"); + var batchCmd = new svgedit.history.BatchCommand('Change Link URL'); setHref(elem, val); batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(elem, { - "#href": cur_href + '#href': cur_href })); addCommandToHistory(batchCmd); @@ -6473,13 +6473,13 @@ this.setLinkURL = function(val) { // val - The new radius this.setRectRadius = function(val) { var selected = selectedElements[0]; - if (selected != null && selected.tagName == "rect") { - var r = selected.getAttribute("rx"); + if (selected != null && selected.tagName == 'rect') { + var r = selected.getAttribute('rx'); if (r != val) { - selected.setAttribute("rx", val); - selected.setAttribute("ry", val); - addCommandToHistory(new svgedit.history.ChangeElementCommand(selected, {"rx":r, "ry":r}, "Radius")); - call("changed", [selected]); + selected.setAttribute('rx', val); + selected.setAttribute('ry', val); + addCommandToHistory(new svgedit.history.ChangeElementCommand(selected, {'rx':r, 'ry':r}, 'Radius')); + call('changed', [selected]); } } }; @@ -6532,20 +6532,20 @@ this.convertToPath = function(elem, getBBox) { } if (!getBBox) { - var batchCmd = new svgedit.history.BatchCommand("Convert element to Path"); + var batchCmd = new svgedit.history.BatchCommand('Convert element to Path'); } var attrs = getBBox?{}:{ - "fill": cur_shape.fill, - "fill-opacity": cur_shape.fill_opacity, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_dasharray, - "stroke-linejoin": cur_shape.stroke_linejoin, - "stroke-linecap": cur_shape.stroke_linecap, - "stroke-opacity": cur_shape.stroke_opacity, - "opacity": cur_shape.opacity, - "visibility":"hidden" + 'fill': cur_shape.fill, + 'fill-opacity': cur_shape.fill_opacity, + 'stroke': cur_shape.stroke, + 'stroke-width': cur_shape.stroke_width, + 'stroke-dasharray': cur_shape.stroke_dasharray, + 'stroke-linejoin': cur_shape.stroke_linejoin, + 'stroke-linecap': cur_shape.stroke_linecap, + 'stroke-opacity': cur_shape.stroke_opacity, + 'opacity': cur_shape.opacity, + 'visibility':'hidden' }; // any attribute on the element not covered by the above @@ -6558,13 +6558,13 @@ this.convertToPath = function(elem, getBBox) { }); var path = addSvgElementFromJson({ - "element": "path", - "attr": attrs + 'element': 'path', + 'attr': attrs }); - var eltrans = elem.getAttribute("transform"); + var eltrans = elem.getAttribute('transform'); if (eltrans) { - path.setAttribute("transform", eltrans); + path.setAttribute('transform', eltrans); } var id = elem.id; @@ -6615,12 +6615,12 @@ this.convertToPath = function(elem, getBBox) { d = elem.getAttribute('d'); break; case 'line': - a = $(elem).attr(["x1", "y1", "x2", "y2"]); - d = "M"+a.x1+","+a.y1+"L"+a.x2+","+a.y2; + a = $(elem).attr(['x1', 'y1', 'x2', 'y2']); + d = 'M'+a.x1+','+a.y1+'L'+a.x2+','+a.y2; break; case 'polyline': case 'polygon': - d = "M" + elem.getAttribute('points'); + d = 'M' + elem.getAttribute('points'); break; case 'rect': var r = $(elem).attr(['rx', 'ry']); @@ -6682,7 +6682,7 @@ this.convertToPath = function(elem, getBBox) { clearSelection(); elem.parentNode.removeChild(elem); path.setAttribute('id', id); - path.removeAttribute("visibility"); + path.removeAttribute('visibility'); addToSelection([path], true); addCommandToHistory(batchCmd); @@ -6736,11 +6736,11 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) { // only allow the transform/opacity/filter attribute to change on elements, slightly hacky // TODO: FIXME: This doesn't seem right. Where's the body of this if statement? - if (elem.tagName === "g" && good_g_attrs.indexOf(attr) >= 0) {} - var oldval = attr === "#text" ? elem.textContent : elem.getAttribute(attr); - if (oldval == null) {oldval = "";} + if (elem.tagName === 'g' && good_g_attrs.indexOf(attr) >= 0) {} + var oldval = attr === '#text' ? elem.textContent : elem.getAttribute(attr); + if (oldval == null) {oldval = '';} if (oldval !== String(newValue)) { - if (attr == "#text") { + if (attr == '#text') { var old_w = svgedit.utilities.getBBox(elem).width; elem.textContent = newValue; @@ -6765,7 +6765,7 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) { // elem.setAttribute('y', elem.getAttribute('y')-dy); // } - } else if (attr == "#href") { + } else if (attr == '#href') { setHref(elem, newValue); } else {elem.setAttribute(attr, newValue);} @@ -6774,7 +6774,7 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) { // NOTE: Important that this happens AFTER elem.setAttribute() or else attributes like // font-size can get reset to their old value, ultimately by svgEditor.updateContextPanel(), // after calling textActions.toSelectMode() below - if (current_mode === "textedit" && attr !== "#text" && elem.textContent.length) { + if (current_mode === 'textedit' && attr !== '#text' && elem.textContent.length) { textActions.toSelectMode(elem); } @@ -6802,7 +6802,7 @@ var changeSelectedAttributeNoUndo = function(attr, newValue, elems) { // if this element was rotated, and we changed the position of this element // we need to update the rotational transform attribute var angle = svgedit.utilities.getRotationAngle(elem); - if (angle != 0 && attr != "transform") { + if (angle != 0 && attr != 'transform') { var tlist = svgedit.transformlist.getTransformList(elem); var n = tlist.numberOfItems; while (n--) { @@ -6855,7 +6855,7 @@ var changeSelectedAttribute = this.changeSelectedAttribute = function(attr, val, // history stack this.deleteSelectedElements = function() { var i; - var batchCmd = new svgedit.history.BatchCommand("Delete Elements"); + var batchCmd = new svgedit.history.BatchCommand('Delete Elements'); var len = selectedElements.length; var selectedCopy = []; //selectedElements is being deleted for (i = 0; i < len; ++i) { @@ -6884,7 +6884,7 @@ this.deleteSelectedElements = function() { batchCmd.addSubCommand(new RemoveElementCommand(elem, nextSibling, parent)); } if (!batchCmd.isEmpty()) {addCommandToHistory(batchCmd);} - call("changed", selectedCopy); + call('changed', selectedCopy); clearSelection(); }; @@ -6895,7 +6895,7 @@ this.deleteSelectedElements = function() { // TODO: Combine similar code with deleteSelectedElements this.cutSelectedElements = function() { var i; - var batchCmd = new svgedit.history.BatchCommand("Cut Elements"); + var batchCmd = new svgedit.history.BatchCommand('Cut Elements'); var len = selectedElements.length; var selectedCopy = []; //selectedElements is being deleted for (i = 0; i < len; ++i) { @@ -6918,7 +6918,7 @@ this.cutSelectedElements = function() { batchCmd.addSubCommand(new RemoveElementCommand(elem, nextSibling, parent)); } if (!batchCmd.isEmpty()) {addCommandToHistory(batchCmd);} - call("changed", selectedCopy); + call('changed', selectedCopy); clearSelection(); canvas.clipBoard = selectedCopy; @@ -6983,7 +6983,7 @@ this.pasteElements = function(type, x, y) { } addCommandToHistory(batchCmd); - call("changed", pasted); + call('changed', pasted); }; // Function: groupSelectedElements @@ -6996,8 +6996,8 @@ this.groupSelectedElements = function(type, urlArg) { var cmd_str = ''; switch (type) { - case "a": - cmd_str = "Make hyperlink"; + case 'a': + cmd_str = 'Make hyperlink'; var url = ''; if (arguments.length > 1) { url = urlArg; @@ -7005,7 +7005,7 @@ this.groupSelectedElements = function(type, urlArg) { break; default: type = 'g'; - cmd_str = "Group Elements"; + cmd_str = 'Group Elements'; break; } @@ -7013,9 +7013,9 @@ this.groupSelectedElements = function(type, urlArg) { // create and insert the group element var g = addSvgElementFromJson({ - "element": type, - "attr": { - "id": getNextId() + 'element': type, + 'attr': { + 'id': getNextId() } }); if (type === 'a') { @@ -7052,12 +7052,12 @@ var pushGroupProperties = this.pushGroupProperties = function(g, undoable) { var children = g.childNodes; var len = children.length; - var xform = g.getAttribute("transform"); + var xform = g.getAttribute('transform'); var glist = svgedit.transformlist.getTransformList(g); var m = svgedit.math.transformListToTransform(glist).matrix; - var batchCmd = new svgedit.history.BatchCommand("Push group properties"); + var batchCmd = new svgedit.history.BatchCommand('Push group properties'); // TODO: get all fill/stroke properties from the group that we are about to destroy // "fill", "fill-opacity", "fill-rule", "stroke", "stroke-dasharray", "stroke-dashoffset", @@ -7196,7 +7196,7 @@ var pushGroupProperties = this.pushGroupProperties = function(g, undoable) { // transfer the group's transform down to each child and then // call svgedit.recalculate.recalculateDimensions() - var oldxform = elem.getAttribute("transform"); + var oldxform = elem.getAttribute('transform'); changes = {}; changes.transform = oldxform || ''; @@ -7219,9 +7219,9 @@ var pushGroupProperties = this.pushGroupProperties = function(g, undoable) { // remove transform and make it undo-able if (xform) { changes = {}; - changes["transform"] = xform; - g.setAttribute("transform", ""); - g.removeAttribute("transform"); + changes.transform = xform; + g.setAttribute('transform', ''); + g.removeAttribute('transform'); batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(g, changes)); } @@ -7254,9 +7254,9 @@ this.ungroupSelectedElement = function() { } // Look for parent "a" - if (g.tagName === "g" || g.tagName === "a") { + if (g.tagName === 'g' || g.tagName === 'a') { - var batchCmd = new svgedit.history.BatchCommand("Ungroup Elements"); + var batchCmd = new svgedit.history.BatchCommand('Ungroup Elements'); var cmd = pushGroupProperties(g, true); if (cmd) {batchCmd.addSubCommand(cmd);} @@ -7311,8 +7311,8 @@ this.moveToTopSelectedElement = function() { // If the element actually moved position, add the command and fire the changed // event handler. if (oldNextSibling != t.nextSibling) { - addCommandToHistory(new svgedit.history.MoveElementCommand(t, oldNextSibling, oldParent, "top")); - call("changed", [t]); + addCommandToHistory(new svgedit.history.MoveElementCommand(t, oldNextSibling, oldParent, 'top')); + call('changed', [t]); } } }; @@ -7339,8 +7339,8 @@ this.moveToBottomSelectedElement = function() { // If the element actually moved position, add the command and fire the changed // event handler. if (oldNextSibling != t.nextSibling) { - addCommandToHistory(new svgedit.history.MoveElementCommand(t, oldNextSibling, oldParent, "bottom")); - call("changed", [t]); + addCommandToHistory(new svgedit.history.MoveElementCommand(t, oldNextSibling, oldParent, 'bottom')); + call('changed', [t]); } } }; @@ -7380,8 +7380,8 @@ this.moveUpDownSelected = function(dir) { // If the element actually moved position, add the command and fire the changed // event handler. if (oldNextSibling != t.nextSibling) { - addCommandToHistory(new svgedit.history.MoveElementCommand(t, oldNextSibling, oldParent, "Move " + dir)); - call("changed", [t]); + addCommandToHistory(new svgedit.history.MoveElementCommand(t, oldNextSibling, oldParent, 'Move ' + dir)); + call('changed', [t]); } }; @@ -7403,7 +7403,7 @@ this.moveSelectedElements = function(dx, dy, undoable) { dy /= current_zoom; } undoable = undoable || true; - var batchCmd = new svgedit.history.BatchCommand("position"); + var batchCmd = new svgedit.history.BatchCommand('position'); var i = selectedElements.length; while (i--) { var selected = selectedElements[i]; @@ -7451,7 +7451,7 @@ this.moveSelectedElements = function(dx, dy, undoable) { if (undoable) { addCommandToHistory(batchCmd); } - call("changed", selectedElements); + call('changed', selectedElements); return batchCmd; } }; @@ -7461,7 +7461,7 @@ this.moveSelectedElements = function(dx, dy, undoable) { // from their originals this.cloneSelectedElements = function(x, y) { var i, elem; - var batchCmd = new svgedit.history.BatchCommand("Clone Elements"); + var batchCmd = new svgedit.history.BatchCommand('Clone Elements'); // find all the elements selected (stop at first null) var len = selectedElements.length; function sortfunction(a, b){ @@ -7604,8 +7604,8 @@ this.contentH = getResolution().h; // * d_x - The x position difference // * d_y - The y position difference this.updateCanvas = function(w, h) { - svgroot.setAttribute("width", w); - svgroot.setAttribute("height", h); + svgroot.setAttribute('width', w); + svgroot.setAttribute('height', h); var bg = $('#canvasBackground')[0]; var old_x = svgcontent.getAttribute('x'); var old_y = svgcontent.getAttribute('y'); @@ -7617,7 +7617,7 @@ this.updateCanvas = function(w, h) { height: this.contentH*current_zoom, 'x': x, 'y': y, - "viewBox" : "0 0 " + this.contentW + " " + this.contentH + 'viewBox' : '0 0 ' + this.contentW + ' ' + this.contentH }); svgedit.utilities.assignAttributes(bg, { @@ -7635,8 +7635,8 @@ this.updateCanvas = function(w, h) { }); } - selectorManager.selectorParentGroup.setAttribute("transform", "translate(" + x + "," + y + ")"); - runExtensions("canvasUpdated",{new_x:x, new_y:y, old_x:old_x, old_y:old_y, d_x:x - old_x, d_y:y - old_y}); + selectorManager.selectorParentGroup.setAttribute('transform', 'translate(' + x + ',' + y + ')'); + runExtensions('canvasUpdated',{new_x:x, new_y:y, old_x:old_x, old_y:old_y, d_x:x - old_x, d_y:y - old_y}); return {x:x, y:y, old_x:old_x, old_y:old_y, d_x:x - old_x, d_y:y - old_y}; }; @@ -7653,7 +7653,7 @@ this.setBackground = function(color, url) { border.setAttribute('fill', color); if (url) { if (!bg_img) { - bg_img = svgdoc.createElementNS(NS.SVG, "image"); + bg_img = svgdoc.createElementNS(NS.SVG, 'image'); svgedit.utilities.assignAttributes(bg_img, { 'id': 'background_image', 'width': '100%', @@ -7699,7 +7699,7 @@ this.cycleElement = function(next) { } } selectOnly([elem], true); - call("selected", selectedElements); + call('selected', selectedElements); }; this.clear();