Merge pull request #300 from Klowner/dev-browserify-support

Add Browserify / CommonJS support (dev branch rebased)
master
Dmitry Baranovskiy 2014-09-17 16:23:47 +10:00
commit c0b0b5805e
3 changed files with 12 additions and 6 deletions

View File

@ -9,6 +9,9 @@
},
"author": "Dmitry Baranovskiy",
"license": "Apache License v2",
"dependencies": {
"eve": "~0.4.2"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.0",
@ -16,7 +19,6 @@
"grunt-exec": "~0.4.2",
"mocha": "*",
"expect.js": "*",
"eve": "~0.4.2",
"dr.js": "~0.1.0"
}
}

View File

@ -5,9 +5,13 @@
define(["eve"], function( eve ) {
return factory(glob, eve);
});
} else if (typeof exports !== 'undefined') {
// Next for Node.js or CommonJS
var eve = require('eve');
module.exports = factory(glob, eve);
} else {
// Browser globals (glob is window)
// Snap adds itself to window
factory(glob, glob.eve);
}
}(this, function (window, eve) {
}(window || this, function (window, eve) {

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
var Snap = (function() {
var Snap = (function(root) {
Snap.version = "0.3.0";
/*\
* Snap
@ -55,8 +55,8 @@ Snap.toString = function () {
};
Snap._ = {};
var glob = {
win: window,
doc: window.document
win: root.window,
doc: root.window.document
};
Snap._.glob = glob;
var has = "hasOwnProperty",
@ -1612,4 +1612,4 @@ Snap.plugin = function (f) {
};
glob.win.Snap = Snap;
return Snap;
}());
}(window || this));