Commit 035a938d by Timmy Willison

Added recommended UMD syntax to raphael for AMD support. Fixes gh-407.

Related: https://github.com/umdjs/umd
parent c3ed3740
...@@ -8,10 +8,30 @@ Visit the library website for more information: [http://raphaeljs.com](http://ra ...@@ -8,10 +8,30 @@ Visit the library website for more information: [http://raphaeljs.com](http://ra
* `git submodule init && git submodule update && npm install` * `git submodule init && git submodule update && npm install`
(thank you [Wes Tood](https://github.com/wesleytodd)) (thank you [Wes Tood](https://github.com/wesleytodd))
### Dependencies ## Dependencies
* [uglifyjs](https://github.com/mishoo/UglifyJS) * [uglifyjs](https://github.com/mishoo/UglifyJS)
* [eve](https://github.com/adobe-webplatform/eve) * [eve](https://github.com/adobe-webplatform/eve)
## Loading
Raphael can be loaded in a script tag or with AMD:
```js
define([ "raphael" ], function( Raphael ) {
console.log( Raphael );
});
```
To place raphael in a directory that is not your AMD's loader's base URL, adjust the path to raphael.
```js
// requirejs syntax
require.config({
paths: {
raphael: "libs/raphael"
}
});
```
## Development ## Development
At the moment we have 4 milestones: At the moment we have 4 milestones:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,7 +5,19 @@ ...@@ -5,7 +5,19 @@
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
// └─────────────────────────────────────────────────────────────────────┘ \\ // └─────────────────────────────────────────────────────────────────────┘ \\
(function () { (function (glob, factory) {
// AMD support
if (typeof define === "function" && define.amd) {
// Define as named module for the sake of raphael.svg.js and raphael.vml.js
// Adjust AMD paths if needed
// example:
// require.config({ paths: { raphael: "libs/raphael" } });
define("raphael", ["eve"], factory);
} else {
// Browser globals (glob is window)
glob.Raphael = factory(glob.eve);
}
}(this, function (eve) {
/*\ /*\
* Raphael * Raphael
[ method ] [ method ]
...@@ -5244,4 +5256,6 @@ ...@@ -5244,4 +5256,6 @@
eve.on("raphael.DOMload", function () { eve.on("raphael.DOMload", function () {
loaded = true; loaded = true;
}); });
})();
return R;
}));
...@@ -385,7 +385,19 @@ ...@@ -385,7 +385,19 @@
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
// └─────────────────────────────────────────────────────────────────────┘ \\ // └─────────────────────────────────────────────────────────────────────┘ \\
(function () { (function (glob, factory) {
// AMD support
if (typeof define === "function" && define.amd) {
// Define as named module for the sake of raphael.svg.js and raphael.vml.js
// Adjust AMD paths if needed
// example:
// require.config({ paths: { raphael: "libs/raphael" } });
define("raphael", ["eve"], factory);
} else {
// Browser globals (glob is window)
glob.Raphael = factory(glob.eve);
}
}(this, function (eve) {
/*\ /*\
* Raphael * Raphael
[ method ] [ method ]
...@@ -5624,7 +5636,9 @@ ...@@ -5624,7 +5636,9 @@
eve.on("raphael.DOMload", function () { eve.on("raphael.DOMload", function () {
loaded = true; loaded = true;
}); });
})();
return R;
}));
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël - JavaScript Vector Library │ \\ // │ Raphaël - JavaScript Vector Library │ \\
...@@ -5635,7 +5649,19 @@ ...@@ -5635,7 +5649,19 @@
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
// └─────────────────────────────────────────────────────────────────────┘ \\ // └─────────────────────────────────────────────────────────────────────┘ \\
window.Raphael && window.Raphael.svg && function (R) { (function (glob, factory) {
// AMD support
if (typeof define === "function" && define.amd && require) {
// Require Raphael
require(["raphael"], factory);
} else if ( glob.Raphael ) {
// Browser globals (glob is window)
factory( glob.Raphael );
}
}(this, function (R) {
if ( !R.svg ) {
return;
}
var has = "hasOwnProperty", var has = "hasOwnProperty",
Str = String, Str = String,
toFloat = parseFloat, toFloat = parseFloat,
...@@ -6985,7 +7011,8 @@ window.Raphael && window.Raphael.svg && function (R) { ...@@ -6985,7 +7011,8 @@ window.Raphael && window.Raphael.svg && function (R) {
}; };
})(method); })(method);
} }
}(window.Raphael); }));
// ┌─────────────────────────────────────────────────────────────────────┐ \\ // ┌─────────────────────────────────────────────────────────────────────┐ \\
// │ Raphaël - JavaScript Vector Library │ \\ // │ Raphaël - JavaScript Vector Library │ \\
// ├─────────────────────────────────────────────────────────────────────┤ \\ // ├─────────────────────────────────────────────────────────────────────┤ \\
...@@ -6995,7 +7022,19 @@ window.Raphael && window.Raphael.svg && function (R) { ...@@ -6995,7 +7022,19 @@ window.Raphael && window.Raphael.svg && function (R) {
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
// └─────────────────────────────────────────────────────────────────────┘ \\ // └─────────────────────────────────────────────────────────────────────┘ \\
window.Raphael && window.Raphael.vml && function (R) { (function (glob, factory) {
// AMD support
if (typeof define === "function" && define.amd && require) {
// Require Raphael
require(["raphael"], factory);
} else if ( glob.Raphael ) {
// Browser globals (glob is window)
factory( glob.Raphael );
}
}(this, function (R) {
if ( !R.vml ) {
return;
}
var has = "hasOwnProperty", var has = "hasOwnProperty",
Str = String, Str = String,
toFloat = parseFloat, toFloat = parseFloat,
...@@ -7958,4 +7997,4 @@ window.Raphael && window.Raphael.vml && function (R) { ...@@ -7958,4 +7997,4 @@ window.Raphael && window.Raphael.vml && function (R) {
}; };
})(method); })(method);
} }
}(window.Raphael); }));
...@@ -7,7 +7,19 @@ ...@@ -7,7 +7,19 @@
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
// └─────────────────────────────────────────────────────────────────────┘ \\ // └─────────────────────────────────────────────────────────────────────┘ \\
window.Raphael && window.Raphael.svg && function (R) { (function (glob, factory) {
// AMD support
if (typeof define === "function" && define.amd && require) {
// Require Raphael
require(["raphael"], factory);
} else if ( glob.Raphael ) {
// Browser globals (glob is window)
factory( glob.Raphael );
}
}(this, function (R) {
if ( !R.svg ) {
return;
}
var has = "hasOwnProperty", var has = "hasOwnProperty",
Str = String, Str = String,
toFloat = parseFloat, toFloat = parseFloat,
...@@ -1357,4 +1369,4 @@ window.Raphael && window.Raphael.svg && function (R) { ...@@ -1357,4 +1369,4 @@ window.Raphael && window.Raphael.svg && function (R) {
}; };
})(method); })(method);
} }
}(window.Raphael); }));
\ No newline at end of file
...@@ -7,7 +7,19 @@ ...@@ -7,7 +7,19 @@
// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ // │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\
// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\
// └─────────────────────────────────────────────────────────────────────┘ \\ // └─────────────────────────────────────────────────────────────────────┘ \\
window.Raphael && window.Raphael.vml && function (R) { (function (glob, factory) {
// AMD support
if (typeof define === "function" && define.amd && require) {
// Require Raphael
require(["raphael"], factory);
} else if ( glob.Raphael ) {
// Browser globals (glob is window)
factory( glob.Raphael );
}
}(this, function (R) {
if ( !R.vml ) {
return;
}
var has = "hasOwnProperty", var has = "hasOwnProperty",
Str = String, Str = String,
toFloat = parseFloat, toFloat = parseFloat,
...@@ -970,4 +982,4 @@ window.Raphael && window.Raphael.vml && function (R) { ...@@ -970,4 +982,4 @@ window.Raphael && window.Raphael.vml && function (R) {
}; };
})(method); })(method);
} }
}(window.Raphael); }));
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment