diff --git a/editor/path.js b/editor/path.js index c21cb186..4a4be421 100644 --- a/editor/path.js +++ b/editor/path.js @@ -356,7 +356,7 @@ svgedit.path.getSegSelector = function(seg, update) { // // Returns: // Array of two "smoothed" point objects -svgedit.path.smoothControlPoints = this.smoothControlPoints = function(ct1, ct2, pt) { +svgedit.path.smoothControlPoints = function(ct1, ct2, pt) { // each point must not be the origin var x1 = ct1.x - pt.x, y1 = ct1.y - pt.y, diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 5f7bcf85..b19eb08d 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -723,7 +723,7 @@ // Call when part of element is in process of changing, generally // on mousemove actions like rotate, move, etc. - var elementTransition = function(window,elems) { + var elementTransition = function(window, elems) { var mode = svgCanvas.getMode(); var elem = elems[0]; @@ -970,7 +970,7 @@ flyout_funcs[opt](); } }); - // $('#tools_rect').mouseleave(function(){$('#tools_rect').fadeOut();}); + // $('#tools_rect').mouseleave(function(){$('#tools_rect').fadeOut();}); }); setFlyoutTitles(); }; @@ -1728,7 +1728,7 @@ // Set up editor background functionality // TODO add checkerboard as "pattern" - var color_blocks = ['#FFF','#888','#000']; // ,'url(data:image/gif;base64,R0lGODlhEAAQAIAAAP%2F%2F%2F9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG%2Bgq4jM3IFLJgpswNly%2FXkcBpIiVaInlLJr9FZWAQA7)']; + var color_blocks = ['#FFF', '#888', '#000']; // ,'url(data:image/gif;base64,R0lGODlhEAAQAIAAAP%2F%2F%2F9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG%2Bgq4jM3IFLJgpswNly%2FXkcBpIiVaInlLJr9FZWAQA7)']; var str = ''; $.each(color_blocks, function() { str += '
'; @@ -1842,7 +1842,7 @@ var promptMoveLayerOnce = false; $('#selLayerNames').change(function(){ var destLayer = this.options[this.selectedIndex].value; - var confirm_str = uiStrings.notification.QmoveElemsToLayer.replace('%s',destLayer); + var confirmStr = uiStrings.notification.QmoveElemsToLayer.replace('%s', destLayer); var moveToLayer = function(ok) { if (!ok) return; promptMoveLayerOnce = true; @@ -1854,7 +1854,7 @@ if (promptMoveLayerOnce) { moveToLayer(true); } else { - $.confirm(confirm_str, moveToLayer); + $.confirm(confirmStr, moveToLayer); } } }); diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index e7ffa698..3d4b855a 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -39,7 +39,7 @@ if (window.opera) { // See http://api.jquery.com/attr/ for basic documentation of .attr() - // Additional functionality: + // Additional functionality: // - When getting attributes, a string that's a number is return as type number. // - If an array is supplied as first parameter, multiple values are returned // as an object with values for each given attributes @@ -71,7 +71,6 @@ if (window.opera) { obj[aname] = attr; } return obj; - } else if (typeof key === "object") { // Setting attributes form object for (var v in key) { @@ -91,7 +90,6 @@ if (window.opera) { } return this; }; - }()); // Class: SvgCanvas @@ -345,7 +343,6 @@ canvas.undoMgr = new svgedit.history.UndoManager({ var elems = cmd.elements(); canvas.pathActions.clear(); call("changed", elems); - var cmdType = cmd.type(); var isApply = (eventType == EventTypes.AFTER_APPLY); if (cmdType == MoveElementCommand.type()) { @@ -363,7 +360,6 @@ canvas.undoMgr = new svgedit.history.UndoManager({ } else { if (!isApply) restoreRefElems(cmd.elem); } - if (cmd.elem.tagName === 'use') { setUseData(cmd.elem); } @@ -655,12 +651,12 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { if (!elems.length) return false; // Make sure the expected BBox is returned if the element is a group var getCheckedBBox = function(elem) { - + try { // TODO: Fix issue with rotated groups. Currently they work // fine in FF, but not in other browsers (same problem mentioned // in Issue 339 comment #2). - + var bb = svgedit.utilities.getBBox(elem); var angle = svgedit.utilities.getRotationAngle(elem); @@ -668,9 +664,7 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { svgedit.math.hasMatrixTransform(svgedit.transformlist.getTransformList(elem))) { // Accurate way to get BBox of rotated element in Firefox: // Put element in group and get its BBox - var good_bb = false; - // Get the BBox from the raw path for these elements var elemNames = ['ellipse', 'path', 'line', 'polyline', 'polygon']; if (elemNames.indexOf(elem.tagName) >= 0) { @@ -683,10 +677,10 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { bb = good_bb = canvas.convertToPath(elem, true); } } - + if (!good_bb) { // Must use clone else FF freaks out - var clone = elem.cloneNode(true); + var clone = elem.cloneNode(true); var g = document.createElementNS(svgns, "g"); var parent = elem.parentNode; parent.appendChild(g); @@ -694,7 +688,7 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { bb = svgedit.utilities.bboxToObj(g.getBBox()); parent.removeChild(g); } - + // Old method: Works by giving the rotated BBox, // this is (unfortunately) what Opera and Safari do // natively when getting the BBox of the parent group @@ -729,10 +723,10 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { // bb.height = rmaxy - rminy; } return bb; - } catch(e) { + } catch(e) { console.log(elem, e); return null; - } + } }; var full_bb; @@ -741,18 +735,18 @@ getStrokedBBox = this.getStrokedBBox = function(elems) { if (!this.parentNode) return; full_bb = getCheckedBBox(this); }); - + // This shouldn't ever happen... if (full_bb == null) return null; - + // full_bb doesn't include the stoke, so this does no good! // if (elems.length == 1) return full_bb; - + var max_x = full_bb.x + full_bb.width; var max_y = full_bb.y + full_bb.height; var min_x = full_bb.x; var min_y = full_bb.y; - + // FIXME: same re-creation problem with this function as getCheckedBBox() above var getOffset = function(elem) { var sw = elem.getAttribute("stroke-width"); @@ -913,7 +907,7 @@ var getId, getNextId, call; getId = c.getId = function() { return getCurrentDrawing().getId(); }; getNextId = c.getNextId = function() { return getCurrentDrawing().getNextId(); }; - + // Function: call // Run the callback function associated with the given event // @@ -925,14 +919,14 @@ var getId, getNextId, call; return events[event](this, arg); } }; - + // Function: bind // Attaches a callback function to an event // // Parameters: // event - String indicating the name of the event // f - The callback function to bind to the event - // + // // Return: // The previous event c.bind = function(event, f) { @@ -940,7 +934,7 @@ var getId, getNextId, call; events[event] = f; return old; }; - + }(canvas)); // Function: canvas.prepareSvg @@ -1093,7 +1087,7 @@ var remapElement = this.remapElement = function(selected, changes, m) { assignAttributes(selected, changes, 1000, true); } box = svgedit.utilities.getBBox(selected); - + for (var i = 0; i < 2; i++) { var type = i === 0 ? 'fill' : 'stroke'; var attrVal = selected.getAttribute(type); @@ -1101,15 +1095,15 @@ var remapElement = this.remapElement = function(selected, changes, m) { if (m.a < 0 || m.d < 0) { var grad = svgedit.utilities.getRefElem(attrVal); var newgrad = grad.cloneNode(true); - + if (m.a < 0) { //flip x var x1 = newgrad.getAttribute('x1'); var x2 = newgrad.getAttribute('x2'); newgrad.setAttribute('x1', -(x1 - 1)); newgrad.setAttribute('x2', -(x2 - 1)); - } - + } + if (m.d < 0) { //flip y var y1 = newgrad.getAttribute('y1'); @@ -1369,14 +1363,12 @@ var remapElement = this.remapElement = function(selected, changes, m) { // ty - The translation's y value var updateClipPath = function(attr, tx, ty) { var path = getRefElem(attr).firstChild; - var cp_xform = svgedit.transformlist.getTransformList(path); - var newxlate = svgroot.createSVGTransform(); newxlate.setTranslate(tx, ty); cp_xform.appendItem(newxlate); - + // Update clipPath's dimensions recalculateDimensions(path); }; diff --git a/editor/svgutils.js b/editor/svgutils.js index 4a5fdf63..f3677436 100644 --- a/editor/svgutils.js +++ b/editor/svgutils.js @@ -58,15 +58,15 @@ svgedit.utilities.init = function(editorContext) { svgedit.utilities.toXml = function(str) { return $('').text(str).html(); }; - + // Function: svgedit.utilities.fromXml -// Converts XML entities in a string to single characters. +// Converts XML entities in a string to single characters. // Example: '&' becomes '&' // // Parameters: // str - The string to be converted // -// Returns: +// Returns: // The converted string svgedit.utilities.fromXml = function(str) { return $('').html(str).text(); @@ -168,7 +168,7 @@ svgedit.utilities.decode64 = function(input) { // else if (c > 127) { // if (c < 2048){ // output += String.fromCharCode((c >> 6) | 192); -// } +// } // else { // output += String.fromCharCode((c >> 12) | 224) + String.fromCharCode((c >> 6) & 63 | 128); // } @@ -178,7 +178,7 @@ svgedit.utilities.decode64 = function(input) { // return output; // }, -// Function: svgedit.utilities.convertToXMLReferences +// Function: svgedit.utilities.convertToXMLReferences // Converts a string to use XML references svgedit.utilities.convertToXMLReferences = function(input) { var output = ''; @@ -205,8 +205,8 @@ svgedit.utilities.text2xml = function(sXML) { try{ var dXML = (window.DOMParser)?new DOMParser():new ActiveXObject('Microsoft.XMLDOM'); dXML.async = false; - } catch(e){ - throw new Error('XML Parser could not be instantiated'); + } catch(e){ + throw new Error('XML Parser could not be instantiated'); }; try{ if(dXML.loadXML) out = (dXML.loadXML(sXML))?dXML:false; @@ -267,7 +267,7 @@ svgedit.utilities.walkTreePost = function(elem, cbFn) { }; // Function: svgedit.utilities.getUrlFromAttr -// Extracts the URL from the url(...) syntax of some attributes. +// Extracts the URL from the url(...) syntax of some attributes. // Three variants: // *