|
9 | 9 |
|
10 | 10 | // Establish the root object, `window` (`self`) in the browser, or `global` on the server.
|
11 | 11 | // We use `self` instead of `window` for `WebWorker` support.
|
12 |
| - var root = (typeof self == 'object' && self.self === self && self) || |
13 |
| - (typeof global == 'object' && global.global === global && global); |
| 12 | + var root = typeof self == 'object' && self.self === self && self || |
| 13 | + typeof global == 'object' && global.global === global && global; |
14 | 14 |
|
15 | 15 | // Set up Backbone appropriately for the environment. Start with AMD.
|
16 | 16 | if (typeof define === 'function' && define.amd) {
|
|
28 | 28 |
|
29 | 29 | // Finally, as a browser global.
|
30 | 30 | } else {
|
31 |
| - root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$)); |
| 31 | + root.Backbone = factory(root, {}, root._, root.jQuery || root.Zepto || root.ender || root.$); |
32 | 32 | }
|
33 | 33 |
|
34 | 34 | })(function(root, Backbone, _, $) {
|
|
654 | 654 | // Set temporary attributes if `{wait: true}` to properly find new ids.
|
655 | 655 | if (attrs && wait) this.attributes = _.extend({}, attributes, attrs);
|
656 | 656 |
|
657 |
| - var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); |
| 657 | + var method = this.isNew() ? 'create' : options.patch ? 'patch' : 'update'; |
658 | 658 | if (method === 'patch' && !options.attrs) options.attrs = attrs;
|
659 | 659 | var xhr = this.sync(method, this, options);
|
660 | 660 |
|
|
1500 | 1500 | // 90% of the core usefulness of Backbone Collections is actually implemented
|
1501 | 1501 | // right here:
|
1502 | 1502 | var collectionMethods = {forEach: 3, each: 3, map: 3, collect: 3, reduce: 0,
|
1503 |
| - foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3, |
1504 |
| - select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3, |
1505 |
| - contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3, |
1506 |
| - head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3, |
1507 |
| - without: 0, difference: 0, indexOf: 3, shuffle: 1, lastIndexOf: 3, |
1508 |
| - isEmpty: 1, chain: 1, sample: 3, partition: 3, groupBy: 3, countBy: 3, |
1509 |
| - sortBy: 3, indexBy: 3, findIndex: 3, findLastIndex: 3}; |
| 1503 | + foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3, |
| 1504 | + select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3, |
| 1505 | + contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3, |
| 1506 | + head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3, |
| 1507 | + without: 0, difference: 0, indexOf: 3, shuffle: 1, lastIndexOf: 3, |
| 1508 | + isEmpty: 1, chain: 1, sample: 3, partition: 3, groupBy: 3, countBy: 3, |
| 1509 | + sortBy: 3, indexBy: 3, findIndex: 3, findLastIndex: 3}; |
1510 | 1510 |
|
1511 | 1511 |
|
1512 | 1512 | // Underscore methods that we want to implement on the Model, mapped to the
|
1513 | 1513 | // number of arguments they take.
|
1514 | 1514 | var modelMethods = {keys: 1, values: 1, pairs: 1, invert: 1, pick: 0,
|
1515 |
| - omit: 0, chain: 1, isEmpty: 1}; |
| 1515 | + omit: 0, chain: 1, isEmpty: 1}; |
1516 | 1516 |
|
1517 | 1517 | // Mix in each Underscore method as a proxy to `Collection#models`.
|
1518 | 1518 |
|
|
1615 | 1615 |
|
1616 | 1616 | // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
|
1617 | 1617 | var methodMap = {
|
1618 |
| - 'create': 'POST', |
1619 |
| - 'update': 'PUT', |
1620 |
| - 'patch': 'PATCH', |
1621 |
| - 'delete': 'DELETE', |
1622 |
| - 'read': 'GET' |
| 1618 | + create: 'POST', |
| 1619 | + update: 'PUT', |
| 1620 | + patch: 'PATCH', |
| 1621 | + delete: 'DELETE', |
| 1622 | + read: 'GET' |
1623 | 1623 | };
|
1624 | 1624 |
|
1625 | 1625 | // Set the default implementation of `Backbone.ajax` to proxy through to `$`.
|
|
1712 | 1712 | // against the current location hash.
|
1713 | 1713 | _routeToRegExp: function(route) {
|
1714 | 1714 | route = route.replace(escapeRegExp, '\\$&')
|
1715 |
| - .replace(optionalParam, '(?:$1)?') |
1716 |
| - .replace(namedParam, function(match, optional) { |
1717 |
| - return optional ? match : '([^/?]+)'; |
1718 |
| - }) |
1719 |
| - .replace(splatParam, '([^?]*?)'); |
| 1715 | + .replace(optionalParam, '(?:$1)?') |
| 1716 | + .replace(namedParam, function(match, optional) { |
| 1717 | + return optional ? match : '([^/?]+)'; |
| 1718 | + }) |
| 1719 | + .replace(splatParam, '([^?]*?)'); |
1720 | 1720 | return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
|
1721 | 1721 | },
|
1722 | 1722 |
|
|
0 commit comments