JSLint
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2645 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
75bd787023
commit
326a517074
|
@ -1,3 +1,5 @@
|
||||||
|
/*globals $, svgedit*/
|
||||||
|
/*jslint vars: true, eqeq: true*/
|
||||||
/**
|
/**
|
||||||
* Package: svgedit.browser
|
* Package: svgedit.browser
|
||||||
*
|
*
|
||||||
|
@ -10,7 +12,7 @@
|
||||||
// Dependencies:
|
// Dependencies:
|
||||||
// 1) jQuery (for $.alert())
|
// 1) jQuery (for $.alert())
|
||||||
|
|
||||||
(function() {
|
(function() {'use strict';
|
||||||
|
|
||||||
if (!svgedit.browser) {
|
if (!svgedit.browser) {
|
||||||
svgedit.browser = {};
|
svgedit.browser = {};
|
||||||
|
@ -21,7 +23,7 @@ var NS = svgedit.NS;
|
||||||
|
|
||||||
var supportsSvg_ = (function() {
|
var supportsSvg_ = (function() {
|
||||||
return !!document.createElementNS && !!document.createElementNS(NS.SVG, 'svg').createSVGRect;
|
return !!document.createElementNS && !!document.createElementNS(NS.SVG, 'svg').createSVGRect;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
svgedit.browser.supportsSvg = function() { return supportsSvg_; };
|
svgedit.browser.supportsSvg = function() { return supportsSvg_; };
|
||||||
if(!svgedit.browser.supportsSvg()) {
|
if(!svgedit.browser.supportsSvg()) {
|
||||||
|
@ -44,11 +46,11 @@ var isTouch_ = 'ontouchstart' in window;
|
||||||
|
|
||||||
var supportsSelectors_ = (function() {
|
var supportsSelectors_ = (function() {
|
||||||
return !!svg.querySelector;
|
return !!svg.querySelector;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
var supportsXpath_ = (function() {
|
var supportsXpath_ = (function() {
|
||||||
return !!document.evaluate;
|
return !!document.evaluate;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
// segList functions (for FF1.5 and 2.0)
|
// segList functions (for FF1.5 and 2.0)
|
||||||
var supportsPathReplaceItem_ = (function() {
|
var supportsPathReplaceItem_ = (function() {
|
||||||
|
@ -61,7 +63,7 @@ var supportsPathReplaceItem_ = (function() {
|
||||||
return true;
|
return true;
|
||||||
} catch(err) {}
|
} catch(err) {}
|
||||||
return false;
|
return false;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
var supportsPathInsertItemBefore_ = (function() {
|
var supportsPathInsertItemBefore_ = (function() {
|
||||||
var path = document.createElementNS(NS.SVG, 'path');
|
var path = document.createElementNS(NS.SVG, 'path');
|
||||||
|
@ -73,7 +75,7 @@ var supportsPathInsertItemBefore_ = (function() {
|
||||||
return true;
|
return true;
|
||||||
} catch(err) {}
|
} catch(err) {}
|
||||||
return false;
|
return false;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
// text character positioning (for IE9)
|
// text character positioning (for IE9)
|
||||||
var supportsGoodTextCharPos_ = (function() {
|
var supportsGoodTextCharPos_ = (function() {
|
||||||
|
@ -88,7 +90,7 @@ var supportsGoodTextCharPos_ = (function() {
|
||||||
var pos = text.getStartPositionOfChar(0).x;
|
var pos = text.getStartPositionOfChar(0).x;
|
||||||
document.documentElement.removeChild(svgroot);
|
document.documentElement.removeChild(svgroot);
|
||||||
return (pos === 0);
|
return (pos === 0);
|
||||||
})();
|
}());
|
||||||
|
|
||||||
var supportsPathBBox_ = (function() {
|
var supportsPathBBox_ = (function() {
|
||||||
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
var svgcontent = document.createElementNS(NS.SVG, 'svg');
|
||||||
|
@ -99,7 +101,7 @@ var supportsPathBBox_ = (function() {
|
||||||
var bbox = path.getBBox();
|
var bbox = path.getBBox();
|
||||||
document.documentElement.removeChild(svgcontent);
|
document.documentElement.removeChild(svgcontent);
|
||||||
return (bbox.height > 4 && bbox.height < 5);
|
return (bbox.height > 4 && bbox.height < 5);
|
||||||
})();
|
}());
|
||||||
|
|
||||||
// Support for correct bbox sizing on groups with horizontal/vertical lines
|
// Support for correct bbox sizing on groups with horizontal/vertical lines
|
||||||
var supportsHVLineContainerBBox_ = (function() {
|
var supportsHVLineContainerBBox_ = (function() {
|
||||||
|
@ -117,12 +119,12 @@ var supportsHVLineContainerBBox_ = (function() {
|
||||||
document.documentElement.removeChild(svgcontent);
|
document.documentElement.removeChild(svgcontent);
|
||||||
// Webkit gives 0, FF gives 10, Opera (correctly) gives 15
|
// Webkit gives 0, FF gives 10, Opera (correctly) gives 15
|
||||||
return (bbox.width == 15);
|
return (bbox.width == 15);
|
||||||
})();
|
}());
|
||||||
|
|
||||||
var supportsEditableText_ = (function() {
|
var supportsEditableText_ = (function() {
|
||||||
// TODO: Find better way to check support for this
|
// TODO: Find better way to check support for this
|
||||||
return isOpera_;
|
return isOpera_;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
var supportsGoodDecimals_ = (function() {
|
var supportsGoodDecimals_ = (function() {
|
||||||
// Correct decimals on clone attributes (Opera < 10.5/win/non-en)
|
// Correct decimals on clone attributes (Opera < 10.5/win/non-en)
|
||||||
|
@ -131,17 +133,17 @@ var supportsGoodDecimals_ = (function() {
|
||||||
var crect = rect.cloneNode(false);
|
var crect = rect.cloneNode(false);
|
||||||
var retValue = (crect.getAttribute('x').indexOf(',') == -1);
|
var retValue = (crect.getAttribute('x').indexOf(',') == -1);
|
||||||
if(!retValue) {
|
if(!retValue) {
|
||||||
$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\n\
|
$.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\n'+
|
||||||
Please upgrade to the <a href="http://opera.com">latest version</a> in which the problems have been fixed.');
|
'Please upgrade to the <a href="http://opera.com">latest version</a> in which the problems have been fixed.');
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
var supportsNonScalingStroke_ = (function() {
|
var supportsNonScalingStroke_ = (function() {
|
||||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||||
rect.setAttribute('style', 'vector-effect:non-scaling-stroke');
|
rect.setAttribute('style', 'vector-effect:non-scaling-stroke');
|
||||||
return rect.style.vectorEffect === 'non-scaling-stroke';
|
return rect.style.vectorEffect === 'non-scaling-stroke';
|
||||||
})();
|
}());
|
||||||
|
|
||||||
var supportsNativeSVGTransformLists_ = (function() {
|
var supportsNativeSVGTransformLists_ = (function() {
|
||||||
var rect = document.createElementNS(NS.SVG, 'rect');
|
var rect = document.createElementNS(NS.SVG, 'rect');
|
||||||
|
@ -149,7 +151,7 @@ var supportsNativeSVGTransformLists_ = (function() {
|
||||||
var t1 = svg.createSVGTransform();
|
var t1 = svg.createSVGTransform();
|
||||||
rxform.appendItem(t1);
|
rxform.appendItem(t1);
|
||||||
return rxform.getItem(0) == t1;
|
return rxform.getItem(0) == t1;
|
||||||
})();
|
}());
|
||||||
|
|
||||||
// Public API
|
// Public API
|
||||||
|
|
||||||
|
@ -175,4 +177,4 @@ svgedit.browser.supportsGoodDecimals = function() { return supportsGoodDecimals_
|
||||||
svgedit.browser.supportsNonScalingStroke = function() { return supportsNonScalingStroke_; };
|
svgedit.browser.supportsNonScalingStroke = function() { return supportsNonScalingStroke_; };
|
||||||
svgedit.browser.supportsNativeTransformLists = function() { return supportsNativeSVGTransformLists_; };
|
svgedit.browser.supportsNativeTransformLists = function() { return supportsNativeSVGTransformLists_; };
|
||||||
|
|
||||||
})();
|
}());
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/*globals $, svgEditor*/
|
||||||
|
/*jslint vars: true, eqeq: true*/
|
||||||
/**
|
/**
|
||||||
* Package: svgedit.contextmenu
|
* Package: svgedit.contextmenu
|
||||||
*
|
*
|
||||||
|
@ -52,7 +54,8 @@ var svgedit = svgedit || {};
|
||||||
// Defer injection to wait out initial menu processing. This probably goes away once all context
|
// Defer injection to wait out initial menu processing. This probably goes away once all context
|
||||||
// menu behavior is brought here.
|
// menu behavior is brought here.
|
||||||
svgEditor.ready(function() {
|
svgEditor.ready(function() {
|
||||||
for (var menuItem in contextMenuExtensions) {
|
var menuItem;
|
||||||
|
for (menuItem in contextMenuExtensions) {
|
||||||
injectExtendedContextMenuItemIntoDom(contextMenuExtensions[menuItem]);
|
injectExtendedContextMenuItemIntoDom(contextMenuExtensions[menuItem]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -60,4 +63,4 @@ var svgedit = svgedit || {};
|
||||||
svgedit.contextmenu.add = addContextMenuItem;
|
svgedit.contextmenu.add = addContextMenuItem;
|
||||||
svgedit.contextmenu.hasCustomHandler = hasCustomHandler;
|
svgedit.contextmenu.hasCustomHandler = hasCustomHandler;
|
||||||
svgedit.contextmenu.getCustomHandler = getCustomHandler;
|
svgedit.contextmenu.getCustomHandler = getCustomHandler;
|
||||||
})();
|
}());
|
||||||
|
|
Loading…
Reference in New Issue