From 4358bc52fd63c29029439960f6b9a5910c4b6e23 Mon Sep 17 00:00:00 2001 From: Chet Harrison Date: Fri, 30 Oct 2015 13:57:21 -0700 Subject: [PATCH 1/2] Added UMD wrapper --- src/backbonefire.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/backbonefire.js b/src/backbonefire.js index 0e208b5..b84c0b6 100644 --- a/src/backbonefire.js +++ b/src/backbonefire.js @@ -8,7 +8,26 @@ * License: MIT */ -(function(_, Backbone) { + (function(factory) { + var root = (typeof self == 'object' && self.self == self && self) || + (typeof global == 'object' && global.global == global && global); + + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['underscore', 'backbone'], function(_, Backbone) { + factory(_, Backbone); + }); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + var _ = require('underscore'); + var Backbone = require('backbone'); + module.exports = factory(_, Backbone); + } else { + // Browser globals + factory(root._, root.Backbone); + } + + }(function factory(_, Backbone) { 'use strict'; Backbone.Firebase = {}; @@ -864,4 +883,4 @@ }); -})(window._, window.Backbone); +})); From 17a334c480a35d58e4dc360a44dbd8ca7674ad35 Mon Sep 17 00:00:00 2001 From: Chet Harrison Date: Mon, 2 Nov 2015 09:27:20 -0800 Subject: [PATCH 2/2] Added globals to jshint list --- src/backbonefire.js | 46 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/backbonefire.js b/src/backbonefire.js index b84c0b6..491dd31 100644 --- a/src/backbonefire.js +++ b/src/backbonefire.js @@ -8,26 +8,7 @@ * License: MIT */ - (function(factory) { - var root = (typeof self == 'object' && self.self == self && self) || - (typeof global == 'object' && global.global == global && global); - - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['underscore', 'backbone'], function(_, Backbone) { - factory(_, Backbone); - }); - } else if (typeof module === 'object' && module.exports) { - // Node/CommonJS - var _ = require('underscore'); - var Backbone = require('backbone'); - module.exports = factory(_, Backbone); - } else { - // Browser globals - factory(root._, root.Backbone); - } - - }(function factory(_, Backbone) { +var backbonefire = function(_, Backbone) { 'use strict'; Backbone.Firebase = {}; @@ -883,4 +864,27 @@ }); -})); +}; + +/*globals self, global, define, require, module */ +(function(backbonefire) { + 'use strict'; + var root = (typeof self == 'object' && self.self == self && self) || + (typeof global == 'object' && global.global == global && global); + + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['underscore', 'backbone'], function(_, Backbone) { + backbonefire(_, Backbone); + }); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + var _ = require('underscore'); + var Backbone = require('backbone'); + module.exports = backbonefire(_, Backbone); + } else { + // Browser globals + backbonefire(root._, root.Backbone); + } + +})(backbonefire);