Permalink
Browse files

switch back to normal (non-AMD) Backbone for now, too many problems w…

…ith dependencies in tests.
  • Loading branch information...
1 parent cdaedb3 commit 56cf4dd2d569a26b900861702b0f9b6b8535ad20 @shioyama shioyama committed Dec 5, 2012
Showing with 27 additions and 21 deletions.
  1. +3 −0 config/requirejs.yml
  2. +24 −21 vendor/assets/javascripts/backbone.js
View
@@ -1,6 +1,9 @@
shim:
'i18n':
exports: 'I18n'
+ 'backbone':
+ exports: 'Backbone'
+ deps: [ 'jquery', 'underscore']
'backbone-support':
exports: 'Support'
deps: [ 'jquery', 'underscore', 'backbone' ]
@@ -5,27 +5,15 @@
// For all details and documentation:
// http://backbonejs.org
-(function(root, factory) {
- // Set up Backbone appropriately for the environment.
- if (typeof exports !== 'undefined') {
- // Node/CommonJS, no need for jQuery in that case.
- factory(root, exports, require('underscore'));
- } else if (typeof define === 'function' && define.amd) {
- // AMD
- define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
- // Export global even in AMD case in case this script is loaded with
- // others that may still expect a global Backbone.
- root.Backbone = factory(root, exports, _, $);
- });
- } else {
- // Browser globals
- root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender));
- }
-}(this, function(root, Backbone, _, $) {
+(function(){
// Initial Setup
// -------------
+ // Save a reference to the global object (`window` in the browser, `global`
+ // on the server).
+ var root = this;
+
// Save the previous value of the `Backbone` variable, so that it can be
// restored later on, if `noConflict` is used.
var previousBackbone = root.Backbone;
@@ -34,9 +22,25 @@
var slice = Array.prototype.slice;
var splice = Array.prototype.splice;
+ // The top-level namespace. All public Backbone classes and modules will
+ // be attached to this. Exported for both CommonJS and the browser.
+ var Backbone;
+ if (typeof exports !== 'undefined') {
+ Backbone = exports;
+ } else {
+ Backbone = root.Backbone = {};
+ }
+
// Current version of the library. Keep in sync with `package.json`.
Backbone.VERSION = '0.9.2';
+ // Require Underscore, if we're on the server, and it's not already present.
+ var _ = root._;
+ if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
+
+ // For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable.
+ var $ = root.jQuery || root.Zepto || root.ender;
+
// Set the JavaScript library that will be used for DOM manipulation and
// Ajax calls (a.k.a. the `$` variable). By default Backbone will use: jQuery,
// Zepto, or Ender; but the `setDomLibrary()` method lets you inject an
@@ -50,7 +54,7 @@
// to its previous owner. Returns a reference to this Backbone object.
Backbone.noConflict = function() {
root.Backbone = previousBackbone;
- return Backbone;
+ return this;
};
// Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
@@ -1188,7 +1192,7 @@
make: function(tagName, attributes, content) {
var el = document.createElement(tagName);
if (attributes) $(el).attr(attributes);
- if (content != null) $(el).html(content);
+ if (content) $(el).html(content);
return el;
},
@@ -1424,5 +1428,4 @@
throw new Error('A "url" property or function must be specified');
};
- return Backbone;
-}));
+}).call(this);

0 comments on commit 56cf4dd

Please sign in to comment.