-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.svg.compat-1.0.1.js
69 lines (62 loc) · 2.58 KB
/
jquery.svg.compat-1.0.1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* http://keith-wood.name/svg.html
SVG for jQuery compatibility from v1.0.1 to v1.4.0.
Written by Keith Wood (kbwood{at}iinet.com.au) May 2008.
Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
Please attribute the author if you use it. */
var svgManager = null;
var svgGraphing = null;
(function($) { // Hide scope, no $ conflict
svgManager = $.svg;
svgGraphing = $.svg.graphing;
$.svg._rootClass = $.svg._wrapperClass;
$.extend($.svg, {
/* Retrieve the SVG wrapper for a given division.
@param input element - division to look for or
jQuery - jQuery collection containing the division or
string - jQuery selector for the division
@return SVGRoot - the associated SVG wrapper */
getSVGFor: function(input) {
input = (input.jquery ? input : $(input));
return $.svg._getSVG(input);
}
});
$.extend($.svg._rootClass.prototype, {
/* Draw a rounded rectangle.
@param parent element - the parent node for the new shape
@param x number - the x-coordinate for the left edge of the rectangle
@param y number - the y-coordinate for the top edge of the rectangle
@param width number - the width of the rectangle
@param height number - the height of the rectangle
@param rx number - the x-radius of the ellipse for the rounded corners
@param ry number - the y-radius of the ellipse for the rounded corners
@param settings object - additional settings for the shape (optional)
@return the new shape node */
roundrect: function(parent, x, y, width, height, rx, ry, settings) {
return this.rect(parent, x, y, width, height, rx, ry, settings);
},
});
/* Attach the SVG functionality to a jQuery selection.
@param loadURL string - the URL of the initial document to load (optional)
@param onLoad function - a callback functional invoked following loading (optional)
@param settings object - the new settings to use for this SVG instance (optional)
@return jQuery object - for chaining further calls */
$.fn.svg = function(loadURL, onLoad, settings) {
if (typeof loadURL == 'function') {
settings = onLoad;
onLoad = loadURL;
loadURL = null;
}
if (loadURL && typeof loadURL == 'object') {
settings = loadURL;
loadURL = onLoad = null;
}
if (onLoad && typeof onLoad == 'object') {
settings = onLoad;
onLoad = null;
}
return this.each(function() {
$.svg._attachSVG(this, {loadURL: loadURL, onLoad: onLoad, settings: settings});
});
};
})(jQuery);