-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
76 lines (58 loc) · 2.48 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Vertebrae.js 1.1.2
// (c) 2015 Lari Hoppula
// (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
var Events = require('./events');
var History = require('./history');
var utils = require('./utils');
module.exports = function(root, _, $) {
// Save the previous value of the `Backbone` variable, so that it can be
// restored later on, if `noConflict` is used.
var previousBackbone = root.Backbone;
var Backbone = {};
// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
// the `$` variable.
Backbone.$ = $;
// Use provided underscore implementation or fallback to utils
Backbone._ = _ || utils;
// Set the default implementation of `Backbone.ajax` to proxy through to `$`.
// Override this if you'd like to use a different library.
Backbone.ajax = function() {
return Backbone.$.ajax.apply(Backbone.$, arguments);
};
Backbone.sync = require('./sync')(Backbone);
// Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
// to its previous owner. Returns a reference to this Backbone object.
Backbone.noConflict = function() {
root.Backbone = previousBackbone;
return this;
};
// Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
// will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and
// set a `X-Http-Method-Override` header.
Backbone.emulateHTTP = false;
// Turn on `emulateJSON` to support legacy servers that can't deal with direct
// `application/json` requests ... this will encode the body as
// `application/x-www-form-urlencoded` instead and will send the model in a
// form param named `model`.
Backbone.emulateJSON = false;
var Model = require('./model')(Backbone);
var Collection = require('./collection')(Backbone, Model);
var View = require('./view')(Backbone);
var Router = require('./router')(Backbone);
// extend Backbone with Events module
_.extend(Backbone, Events);
// Current version of the library. Keep in sync with `package.json`.
Backbone.VERSION = '1.1.2';
// Create the default Backbone.history.
Backbone.history = new History;
Backbone.Collection = Collection;
Backbone.Events = Events;
Backbone.History = History;
Backbone.Model = Model;
Backbone.Router = Router;
Backbone.View = View;
return Backbone;
};