Add plug-ins functionality.
authorDmitry Baranovskiy <dbaranovskiy@Fresh-Air.sydney.atlassian.com>
Fri, 6 Feb 2009 06:18:21 +0000 (17:18 +1100)
committerDmitry Baranovskiy <dbaranovskiy@Fresh-Air.sydney.atlassian.com>
Fri, 6 Feb 2009 06:18:21 +0000 (17:18 +1100)
raphael-svg.js
raphael-vml.js
raphael.js

index 47d0f33..22f6292 100644 (file)
                 container[prop] = R._.paper[prop];
             }
         }
+        for (var prop in R.fn) {
+            if (!container[prop]) {
+                container[prop] = R.fn[prop];
+            }
+        }
         container.clear();
         return container;
     };
index fc1e16c..7701acb 100644 (file)
         return res;
     };
     R._.theGroup = function (vml) {
-        var el = document.createElement("rvml:group"), els = el.style;
-        els.position = "absolute";
-        els.left = 0;
-        els.top = 0;
-        els.width = vml.width;
-        els.height = vml.height;
-        if (vml.canvas) {
-            vml.canvas.appendChild(el);
-        }
-        var res = new Element(el, el, vml);
-        for (var f in vml) {
-            if (f.charAt(0) != "_" && typeof vml[f] == "function") {
-                res[f] = (function (f) {
-                    return function () {
-                        var e = vml[f].apply(vml, arguments);
-                        el.appendChild(e[0].parentNode);
-                        return e;
-                    };
-                })(f);
-            }
-        }
-        res.type = "group";
-        return res;
+        return this;
     };
     R._create = function () {
         // container, width, height
         for (var prop in R._.paper) {
             container[prop] = R._.paper[prop];
         }
+        for (var prop in R.fn) {
+            if (!container[prop]) {
+                container[prop] = R.fn[prop];
+            }
+        }
         container.clear = function () {
             var todel = [];
             for (var i = 0, ii = r.childNodes.length; i < ii; i++) {
index 0ce39b7..e3b1b06 100644 (file)
@@ -16,6 +16,7 @@ function Raphael() {
         paper: {},
         element: {}
     };
+    R.fn = {};
     var availableAttrs = {cx: 0, cy: 0, fill: "#fff", "fill-opacity": 1, font: '16px "Arial"', "font-family": '"Arial"', "font-size": "16", gradient: 0, height: 0, opacity: 1, path: "M0,0", r: 0, rotation: 0, rx: 0, ry: 0, scale: "1 1", stroke: "#000", "stroke-dasharray": "", "stroke-linecap": "butt", "stroke-linejoin": "butt", "stroke-miterlimit": 0, "stroke-opacity": 1, "stroke-width": 1, translation: "0 0", width: 0, x: 0, y: 0},
         availableAnimAttrs = {cx: "number", cy: "number", fill: "colour", "fill-opacity": "number", "font-size": "number", height: "number", opacity: "number", path: "path", r: "number", rotation: "number", rx: "number", ry: "number", scale: "csv", stroke: "colour", "stroke-opacity": "number", "stroke-width": "number", translation: "csv", width: "number", x: "number", y: "number"};
     R._.paper.circle = function (x, y, r) {
@@ -738,7 +739,9 @@ function Raphael() {
     var script = document.getElementsByTagName("script"),
         newscript = document.createElement("script");
     script = script[script.length - 1];
+    var path = script.src.match(/.*\//);
+    path = path ? path[0] : "";
     newscript.type = "text/javascript";
-    newscript.src = window.SVGAngle ? "raphael-svg.js" : "raphael-vml.js";
+    newscript.src = path + (window.SVGAngle ? "raphael-svg.js" : "raphael-vml.js");
     script.parentNode.appendChild(newscript);
 })(Raphael);