Make WordPress Core

Ticket #27182: 27182-01.patch

File 27182-01.patch, 36.0 KB (added by gcorne, 11 years ago)
  • src/wp-includes/js/backbone.js

    diff --git src/wp-includes/js/backbone.js src/wp-includes/js/backbone.js
    index f7783c2..24a550a 100644
     
    1 //     Backbone.js 1.1.0
     1//     Backbone.js 1.1.2
    22
    3 //     (c) 2010-2011 Jeremy Ashkenas, DocumentCloud Inc.
    4 //     (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
     3//     (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
    54//     Backbone may be freely distributed under the MIT license.
    65//     For all details and documentation:
    76//     http://backbonejs.org
    87
    9 (function(){
     8(function(root, factory) {
     9
     10  // Set up Backbone appropriately for the environment. Start with AMD.
     11  if (typeof define === 'function' && define.amd) {
     12    define(['underscore', 'jquery', 'exports'], function(_, $, exports) {
     13      // Export global even in AMD case in case this script is loaded with
     14      // others that may still expect a global Backbone.
     15      root.Backbone = factory(root, exports, _, $);
     16    });
     17
     18  // Next for Node.js or CommonJS. jQuery may not be needed as a module.
     19  } else if (typeof exports !== 'undefined') {
     20    var _ = require('underscore');
     21    factory(root, exports, _);
     22
     23  // Finally, as a browser global.
     24  } else {
     25    root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
     26  }
     27
     28}(this, function(root, Backbone, _, $) {
    1029
    1130  // Initial Setup
    1231  // -------------
    1332
    14   // Save a reference to the global object (`window` in the browser, `exports`
    15   // on the server).
    16   var root = this;
    17 
    1833  // Save the previous value of the `Backbone` variable, so that it can be
    1934  // restored later on, if `noConflict` is used.
    2035  var previousBackbone = root.Backbone;
     
    2540  var slice = array.slice;
    2641  var splice = array.splice;
    2742
    28   // The top-level namespace. All public Backbone classes and modules will
    29   // be attached to this. Exported for both the browser and the server.
    30   var Backbone;
    31   if (typeof exports !== 'undefined') {
    32     Backbone = exports;
    33   } else {
    34     Backbone = root.Backbone = {};
    35   }
    36 
    3743  // Current version of the library. Keep in sync with `package.json`.
    38   Backbone.VERSION = '1.1.0';
    39 
    40   // Require Underscore, if we're on the server, and it's not already present.
    41   var _ = root._;
    42   if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
     44  Backbone.VERSION = '1.1.2';
    4345
    4446  // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
    4547  // the `$` variable.
    46   Backbone.$ = root.jQuery || root.Zepto || root.ender || root.$;
     48  Backbone.$ = $;
    4749
    4850  // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
    4951  // to its previous owner. Returns a reference to this Backbone object.
     
    109111      var retain, ev, events, names, i, l, j, k;
    110112      if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
    111113      if (!name && !callback && !context) {
    112         this._events = {};
     114        this._events = void 0;
    113115        return this;
    114116      }
    115117      names = name ? [name] : _.keys(this._events);
     
    205207      case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
    206208      case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
    207209      case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
    208       default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
     210      default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
    209211    }
    210212  };
    211213
     
    350352
    351353      // Trigger all relevant attribute changes.
    352354      if (!silent) {
    353         if (changes.length) this._pending = true;
     355        if (changes.length) this._pending = options;
    354356        for (var i = 0, l = changes.length; i < l; i++) {
    355357          this.trigger('change:' + changes[i], this, current[changes[i]], options);
    356358        }
     
    361363      if (changing) return this;
    362364      if (!silent) {
    363365        while (this._pending) {
     366          options = this._pending;
    364367          this._pending = false;
    365368          this.trigger('change', this, options);
    366369        }
     
    528531    // using Backbone's restful methods, override this to change the endpoint
    529532    // that will be called.
    530533    url: function() {
    531       var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError();
     534      var base =
     535        _.result(this, 'urlRoot') ||
     536        _.result(this.collection, 'url') ||
     537        urlError();
    532538      if (this.isNew()) return base;
    533       return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
     539      return base.replace(/([^\/])$/, '$1/') + encodeURIComponent(this.id);
    534540    },
    535541
    536542    // **parse** converts a response into the hash of attributes to be `set` on
     
    546552
    547553    // A model is new if it has never been saved to the server, and lacks an id.
    548554    isNew: function() {
    549       return this.id == null;
     555      return !this.has(this.idAttribute);
    550556    },
    551557
    552558    // Check if the model is currently in a valid state.
     
    650656          options.index = index;
    651657          model.trigger('remove', model, this, options);
    652658        }
    653         this._removeReference(model);
     659        this._removeReference(model, options);
    654660      }
    655661      return singular ? models[0] : models;
    656662    },
     
    676682      // Turn bare objects into model references, and prevent invalid models
    677683      // from being added.
    678684      for (i = 0, l = models.length; i < l; i++) {
    679         attrs = models[i];
     685        attrs = models[i] || {};
    680686        if (attrs instanceof Model) {
    681687          id = model = attrs;
    682688        } else {
    683           id = attrs[targetModel.prototype.idAttribute];
     689          id = attrs[targetModel.prototype.idAttribute || 'id'];
    684690        }
    685691
    686692        // If a duplicate is found, prevent it from being added and
     
    700706          model = models[i] = this._prepareModel(attrs, options);
    701707          if (!model) continue;
    702708          toAdd.push(model);
    703 
    704           // Listen to added models' events, and index models for lookup by
    705           // `id` and by `cid`.
    706           model.on('all', this._onModelEvent, this);
    707           this._byId[model.cid] = model;
    708           if (model.id != null) this._byId[model.id] = model;
     709          this._addReference(model, options);
    709710        }
    710         if (order) order.push(existing || model);
     711
     712        // Do not add multiple models with the same `id`.
     713        model = existing || model;
     714        if (order && (model.isNew() || !modelMap[model.id])) order.push(model);
     715        modelMap[model.id] = true;
    711716      }
    712717
    713718      // Remove nonexistent models if appropriate.
     
    745750        }
    746751        if (sort || (order && order.length)) this.trigger('sort', this, options);
    747752      }
    748      
     753
    749754      // Return the added (or merged) model (or models).
    750755      return singular ? models[0] : models;
    751756    },
     
    757762    reset: function(models, options) {
    758763      options || (options = {});
    759764      for (var i = 0, l = this.models.length; i < l; i++) {
    760         this._removeReference(this.models[i]);
     765        this._removeReference(this.models[i], options);
    761766      }
    762767      options.previousModels = this.models;
    763768      this._reset();
     
    798803    // Get a model from the set by id.
    799804    get: function(obj) {
    800805      if (obj == null) return void 0;
    801       return this._byId[obj.id] || this._byId[obj.cid] || this._byId[obj];
     806      return this._byId[obj] || this._byId[obj.id] || this._byId[obj.cid];
    802807    },
    803808
    804809    // Get the model at the given index.
     
    874879      if (!options.wait) this.add(model, options);
    875880      var collection = this;
    876881      var success = options.success;
    877       options.success = function(model, resp, options) {
     882      options.success = function(model, resp) {
    878883        if (options.wait) collection.add(model, options);
    879884        if (success) success(model, resp, options);
    880885      };
     
    904909    // Prepare a hash of attributes (or other model) to be added to this
    905910    // collection.
    906911    _prepareModel: function(attrs, options) {
    907       if (attrs instanceof Model) {
    908         if (!attrs.collection) attrs.collection = this;
    909         return attrs;
    910       }
     912      if (attrs instanceof Model) return attrs;
    911913      options = options ? _.clone(options) : {};
    912914      options.collection = this;
    913915      var model = new this.model(attrs, options);
     
    916918      return false;
    917919    },
    918920
     921    // Internal method to create a model's ties to a collection.
     922    _addReference: function(model, options) {
     923      this._byId[model.cid] = model;
     924      if (model.id != null) this._byId[model.id] = model;
     925      if (!model.collection) model.collection = this;
     926      model.on('all', this._onModelEvent, this);
     927    },
     928
    919929    // Internal method to sever a model's ties to a collection.
    920     _removeReference: function(model) {
     930    _removeReference: function(model, options) {
    921931      if (this === model.collection) delete model.collection;
    922932      model.off('all', this._onModelEvent, this);
    923933    },
     
    946956    'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
    947957    'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest',
    948958    'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle',
    949     'lastIndexOf', 'isEmpty', 'chain'];
     959    'lastIndexOf', 'isEmpty', 'chain', 'sample'];
    950960
    951961  // Mix in each Underscore method as a proxy to `Collection#models`.
    952962  _.each(methods, function(method) {
     
    958968  });
    959969
    960970  // Underscore methods that take a property name as an argument.
    961   var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
     971  var attributeMethods = ['groupBy', 'countBy', 'sortBy', 'indexBy'];
    962972
    963973  // Use attributes instead of properties.
    964974  _.each(attributeMethods, function(method) {
     
    11801190    return xhr;
    11811191  };
    11821192
    1183   var noXhrPatch = typeof window !== 'undefined' && !!window.ActiveXObject && !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent);
     1193  var noXhrPatch =
     1194    typeof window !== 'undefined' && !!window.ActiveXObject &&
     1195      !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent);
    11841196
    11851197  // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
    11861198  var methodMap = {
     
    12391251      var router = this;
    12401252      Backbone.history.route(route, function(fragment) {
    12411253        var args = router._extractParameters(route, fragment);
    1242         callback && callback.apply(router, args);
     1254        router.execute(callback, args);
    12431255        router.trigger.apply(router, ['route:' + name].concat(args));
    12441256        router.trigger('route', name, args);
    12451257        Backbone.history.trigger('route', router, name, args);
     
    12471259      return this;
    12481260    },
    12491261
     1262    // Execute a route handler with the provided parameters.  This is an
     1263    // excellent place to do pre-route setup or post-route cleanup.
     1264    execute: function(callback, args) {
     1265      if (callback) callback.apply(this, args);
     1266    },
     1267
    12501268    // Simple proxy to `Backbone.history` to save a fragment into the history.
    12511269    navigate: function(fragment, options) {
    12521270      Backbone.history.navigate(fragment, options);
     
    12711289      route = route.replace(escapeRegExp, '\\$&')
    12721290                   .replace(optionalParam, '(?:$1)?')
    12731291                   .replace(namedParam, function(match, optional) {
    1274                      return optional ? match : '([^\/]+)';
     1292                     return optional ? match : '([^/?]+)';
    12751293                   })
    1276                    .replace(splatParam, '(.*?)');
    1277       return new RegExp('^' + route + '$');
     1294                   .replace(splatParam, '([^?]*?)');
     1295      return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
    12781296    },
    12791297
    12801298    // Given a route, and a URL fragment that it matches, return the array of
     
    12821300    // treated as `null` to normalize cross-browser behavior.
    12831301    _extractParameters: function(route, fragment) {
    12841302      var params = route.exec(fragment).slice(1);
    1285       return _.map(params, function(param) {
     1303      return _.map(params, function(param, i) {
     1304        // Don't decode the search params.
     1305        if (i === params.length - 1) return param || null;
    12861306        return param ? decodeURIComponent(param) : null;
    12871307      });
    12881308    }
     
    13201340  // Cached regex for removing a trailing slash.
    13211341  var trailingSlash = /\/$/;
    13221342
    1323   // Cached regex for stripping urls of hash and query.
    1324   var pathStripper = /[?#].*$/;
     1343  // Cached regex for stripping urls of hash.
     1344  var pathStripper = /#.*$/;
    13251345
    13261346  // Has the history handling already been started?
    13271347  History.started = false;
     
    13331353    // twenty times a second.
    13341354    interval: 50,
    13351355
     1356    // Are we at the app root?
     1357    atRoot: function() {
     1358      return this.location.pathname.replace(/[^\/]$/, '$&/') === this.root;
     1359    },
     1360
    13361361    // Gets the true hash value. Cannot use location.hash directly due to bug
    13371362    // in Firefox where location.hash will always be decoded.
    13381363    getHash: function(window) {
     
    13451370    getFragment: function(fragment, forcePushState) {
    13461371      if (fragment == null) {
    13471372        if (this._hasPushState || !this._wantsHashChange || forcePushState) {
    1348           fragment = this.location.pathname;
     1373          fragment = decodeURI(this.location.pathname + this.location.search);
    13491374          var root = this.root.replace(trailingSlash, '');
    13501375          if (!fragment.indexOf(root)) fragment = fragment.slice(root.length);
    13511376        } else {
     
    13761401      this.root = ('/' + this.root + '/').replace(rootStripper, '/');
    13771402
    13781403      if (oldIE && this._wantsHashChange) {
    1379         this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
     1404        var frame = Backbone.$('<iframe src="javascript:0" tabindex="-1">');
     1405        this.iframe = frame.hide().appendTo('body')[0].contentWindow;
    13801406        this.navigate(fragment);
    13811407      }
    13821408
     
    13941420      // opened by a non-pushState browser.
    13951421      this.fragment = fragment;
    13961422      var loc = this.location;
    1397       var atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root;
    13981423
    13991424      // Transition from hashChange to pushState or vice versa if both are
    14001425      // requested.
     
    14021427
    14031428        // If we've started off with a route from a `pushState`-enabled
    14041429        // browser, but we're currently in a browser that doesn't support it...
    1405         if (!this._hasPushState && !atRoot) {
     1430        if (!this._hasPushState && !this.atRoot()) {
    14061431          this.fragment = this.getFragment(null, true);
    1407           this.location.replace(this.root + this.location.search + '#' + this.fragment);
     1432          this.location.replace(this.root + '#' + this.fragment);
    14081433          // Return immediately as browser will do redirect to new url
    14091434          return true;
    14101435
    14111436        // Or if we've started out with a hash-based route, but we're currently
    14121437        // in a browser where it could be `pushState`-based instead...
    1413         } else if (this._hasPushState && atRoot && loc.hash) {
     1438        } else if (this._hasPushState && this.atRoot() && loc.hash) {
    14141439          this.fragment = this.getHash().replace(routeStripper, '');
    1415           this.history.replaceState({}, document.title, this.root + this.fragment + loc.search);
     1440          this.history.replaceState({}, document.title, this.root + this.fragment);
    14161441        }
    14171442
    14181443      }
     
    14241449    // but possibly useful for unit testing Routers.
    14251450    stop: function() {
    14261451      Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl);
    1427       clearInterval(this._checkUrlInterval);
     1452      if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
    14281453      History.started = false;
    14291454    },
    14301455
     
    14721497
    14731498      var url = this.root + (fragment = this.getFragment(fragment || ''));
    14741499
    1475       // Strip the fragment of the query and hash for matching.
     1500      // Strip the hash for matching.
    14761501      fragment = fragment.replace(pathStripper, '');
    14771502
    14781503      if (this.fragment === fragment) return;
     
    15781603    };
    15791604  };
    15801605
    1581 }).call(this);
     1606  return Backbone;
     1607
     1608}));
  • deleted file src/wp-includes/js/backbone.min.js

    diff --git src/wp-includes/js/backbone.min.js src/wp-includes/js/backbone.min.js
    deleted file mode 100644
    index c1ceabc..0000000
    + -  
    1 (function(){var t=this;var e=t.Backbone;var i=[];var r=i.push;var s=i.slice;var n=i.splice;var a;if(typeof exports!=="undefined"){a=exports}else{a=t.Backbone={}}a.VERSION="1.1.0";var h=t._;if(!h&&typeof require!=="undefined")h=require("underscore");a.$=t.jQuery||t.Zepto||t.ender||t.$;a.noConflict=function(){t.Backbone=e;return this};a.emulateHTTP=false;a.emulateJSON=false;var o=a.Events={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this;var s=h.once(function(){r.off(t,s);e.apply(this,arguments)});s._callback=e;return this.on(t,s,i)},off:function(t,e,i){var r,s,n,a,o,u,c,f;if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i){this._events={};return this}a=t?[t]:h.keys(this._events);for(o=0,u=a.length;o<u;o++){t=a[o];if(n=this._events[t]){this._events[t]=r=[];if(e||i){for(c=0,f=n.length;c<f;c++){s=n[c];if(e&&e!==s.callback&&e!==s.callback._callback||i&&i!==s.context){r.push(s)}}}if(!r.length)delete this._events[t]}}return this},trigger:function(t){if(!this._events)return this;var e=s.call(arguments,1);if(!l(this,"trigger",t,e))return this;var i=this._events[t];var r=this._events.all;if(i)c(i,e);if(r)c(r,arguments);return this},stopListening:function(t,e,i){var r=this._listeningTo;if(!r)return this;var s=!e&&!i;if(!i&&typeof e==="object")i=this;if(t)(r={})[t._listenId]=t;for(var n in r){t=r[n];t.off(e,i,this);if(s||h.isEmpty(t._events))delete this._listeningTo[n]}return this}};var u=/\s+/;var l=function(t,e,i,r){if(!i)return true;if(typeof i==="object"){for(var s in i){t[e].apply(t,[s,i[s]].concat(r))}return false}if(u.test(i)){var n=i.split(u);for(var a=0,h=n.length;a<h;a++){t[e].apply(t,[n[a]].concat(r))}return false}return true};var c=function(t,e){var i,r=-1,s=t.length,n=e[0],a=e[1],h=e[2];switch(e.length){case 0:while(++r<s)(i=t[r]).callback.call(i.ctx);return;case 1:while(++r<s)(i=t[r]).callback.call(i.ctx,n);return;case 2:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a);return;case 3:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a,h);return;default:while(++r<s)(i=t[r]).callback.apply(i.ctx,e)}};var f={listenTo:"on",listenToOnce:"once"};h.each(f,function(t,e){o[e]=function(e,i,r){var s=this._listeningTo||(this._listeningTo={});var n=e._listenId||(e._listenId=h.uniqueId("l"));s[n]=e;if(!r&&typeof i==="object")r=this;e[t](i,r,this);return this}});o.bind=o.on;o.unbind=o.off;h.extend(a,o);var d=a.Model=function(t,e){var i=t||{};e||(e={});this.cid=h.uniqueId("c");this.attributes={};if(e.collection)this.collection=e.collection;if(e.parse)i=this.parse(i,e)||{};i=h.defaults({},i,h.result(this,"defaults"));this.set(i,e);this.changed={};this.initialize.apply(this,arguments)};h.extend(d.prototype,o,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(t){return h.clone(this.attributes)},sync:function(){return a.sync.apply(this,arguments)},get:function(t){return this.attributes[t]},escape:function(t){return h.escape(this.get(t))},has:function(t){return this.get(t)!=null},set:function(t,e,i){var r,s,n,a,o,u,l,c;if(t==null)return this;if(typeof t==="object"){s=t;i=e}else{(s={})[t]=e}i||(i={});if(!this._validate(s,i))return false;n=i.unset;o=i.silent;a=[];u=this._changing;this._changing=true;if(!u){this._previousAttributes=h.clone(this.attributes);this.changed={}}c=this.attributes,l=this._previousAttributes;if(this.idAttribute in s)this.id=s[this.idAttribute];for(r in s){e=s[r];if(!h.isEqual(c[r],e))a.push(r);if(!h.isEqual(l[r],e)){this.changed[r]=e}else{delete this.changed[r]}n?delete c[r]:c[r]=e}if(!o){if(a.length)this._pending=true;for(var f=0,d=a.length;f<d;f++){this.trigger("change:"+a[f],this,c[a[f]],i)}}if(u)return this;if(!o){while(this._pending){this._pending=false;this.trigger("change",this,i)}}this._pending=false;this._changing=false;return this},unset:function(t,e){return this.set(t,void 0,h.extend({},e,{unset:true}))},clear:function(t){var e={};for(var i in this.attributes)e[i]=void 0;return this.set(e,h.extend({},t,{unset:true}))},hasChanged:function(t){if(t==null)return!h.isEmpty(this.changed);return h.has(this.changed,t)},changedAttributes:function(t){if(!t)return this.hasChanged()?h.clone(this.changed):false;var e,i=false;var r=this._changing?this._previousAttributes:this.attributes;for(var s in t){if(h.isEqual(r[s],e=t[s]))continue;(i||(i={}))[s]=e}return i},previous:function(t){if(t==null||!this._previousAttributes)return null;return this._previousAttributes[t]},previousAttributes:function(){return h.clone(this._previousAttributes)},fetch:function(t){t=t?h.clone(t):{};if(t.parse===void 0)t.parse=true;var e=this;var i=t.success;t.success=function(r){if(!e.set(e.parse(r,t),t))return false;if(i)i(e,r,t);e.trigger("sync",e,r,t)};M(this,t);return this.sync("read",this,t)},save:function(t,e,i){var r,s,n,a=this.attributes;if(t==null||typeof t==="object"){r=t;i=e}else{(r={})[t]=e}i=h.extend({validate:true},i);if(r&&!i.wait){if(!this.set(r,i))return false}else{if(!this._validate(r,i))return false}if(r&&i.wait){this.attributes=h.extend({},a,r)}if(i.parse===void 0)i.parse=true;var o=this;var u=i.success;i.success=function(t){o.attributes=a;var e=o.parse(t,i);if(i.wait)e=h.extend(r||{},e);if(h.isObject(e)&&!o.set(e,i)){return false}if(u)u(o,t,i);o.trigger("sync",o,t,i)};M(this,i);s=this.isNew()?"create":i.patch?"patch":"update";if(s==="patch")i.attrs=r;n=this.sync(s,this,i);if(r&&i.wait)this.attributes=a;return n},destroy:function(t){t=t?h.clone(t):{};var e=this;var i=t.success;var r=function(){e.trigger("destroy",e,e.collection,t)};t.success=function(s){if(t.wait||e.isNew())r();if(i)i(e,s,t);if(!e.isNew())e.trigger("sync",e,s,t)};if(this.isNew()){t.success();return false}M(this,t);var s=this.sync("delete",this,t);if(!t.wait)r();return s},url:function(){var t=h.result(this,"urlRoot")||h.result(this.collection,"url")||U();if(this.isNew())return t;return t+(t.charAt(t.length-1)==="/"?"":"/")+encodeURIComponent(this.id)},parse:function(t,e){return t},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return this.id==null},isValid:function(t){return this._validate({},h.extend(t||{},{validate:true}))},_validate:function(t,e){if(!e.validate||!this.validate)return true;t=h.extend({},this.attributes,t);var i=this.validationError=this.validate(t,e)||null;if(!i)return true;this.trigger("invalid",this,i,h.extend(e,{validationError:i}));return false}});var p=["keys","values","pairs","invert","pick","omit"];h.each(p,function(t){d.prototype[t]=function(){var e=s.call(arguments);e.unshift(this.attributes);return h[t].apply(h,e)}});var v=a.Collection=function(t,e){e||(e={});if(e.model)this.model=e.model;if(e.comparator!==void 0)this.comparator=e.comparator;this._reset();this.initialize.apply(this,arguments);if(t)this.reset(t,h.extend({silent:true},e))};var g={add:true,remove:true,merge:true};var m={add:true,remove:false};h.extend(v.prototype,o,{model:d,initialize:function(){},toJSON:function(t){return this.map(function(e){return e.toJSON(t)})},sync:function(){return a.sync.apply(this,arguments)},add:function(t,e){return this.set(t,h.extend({merge:false},e,m))},remove:function(t,e){var i=!h.isArray(t);t=i?[t]:h.clone(t);e||(e={});var r,s,n,a;for(r=0,s=t.length;r<s;r++){a=t[r]=this.get(t[r]);if(!a)continue;delete this._byId[a.id];delete this._byId[a.cid];n=this.indexOf(a);this.models.splice(n,1);this.length--;if(!e.silent){e.index=n;a.trigger("remove",a,this,e)}this._removeReference(a)}return i?t[0]:t},set:function(t,e){e=h.defaults({},e,g);if(e.parse)t=this.parse(t,e);var i=!h.isArray(t);t=i?t?[t]:[]:h.clone(t);var r,s,n,a,o,u,l;var c=e.at;var f=this.model;var p=this.comparator&&c==null&&e.sort!==false;var v=h.isString(this.comparator)?this.comparator:null;var m=[],y=[],_={};var w=e.add,b=e.merge,x=e.remove;var E=!p&&w&&x?[]:false;for(r=0,s=t.length;r<s;r++){o=t[r];if(o instanceof d){n=a=o}else{n=o[f.prototype.idAttribute]}if(u=this.get(n)){if(x)_[u.cid]=true;if(b){o=o===a?a.attributes:o;if(e.parse)o=u.parse(o,e);u.set(o,e);if(p&&!l&&u.hasChanged(v))l=true}t[r]=u}else if(w){a=t[r]=this._prepareModel(o,e);if(!a)continue;m.push(a);a.on("all",this._onModelEvent,this);this._byId[a.cid]=a;if(a.id!=null)this._byId[a.id]=a}if(E)E.push(u||a)}if(x){for(r=0,s=this.length;r<s;++r){if(!_[(a=this.models[r]).cid])y.push(a)}if(y.length)this.remove(y,e)}if(m.length||E&&E.length){if(p)l=true;this.length+=m.length;if(c!=null){for(r=0,s=m.length;r<s;r++){this.models.splice(c+r,0,m[r])}}else{if(E)this.models.length=0;var T=E||m;for(r=0,s=T.length;r<s;r++){this.models.push(T[r])}}}if(l)this.sort({silent:true});if(!e.silent){for(r=0,s=m.length;r<s;r++){(a=m[r]).trigger("add",a,this,e)}if(l||E&&E.length)this.trigger("sort",this,e)}return i?t[0]:t},reset:function(t,e){e||(e={});for(var i=0,r=this.models.length;i<r;i++){this._removeReference(this.models[i])}e.previousModels=this.models;this._reset();t=this.add(t,h.extend({silent:true},e));if(!e.silent)this.trigger("reset",this,e);return t},push:function(t,e){return this.add(t,h.extend({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);this.remove(e,t);return e},unshift:function(t,e){return this.add(t,h.extend({at:0},e))},shift:function(t){var e=this.at(0);this.remove(e,t);return e},slice:function(){return s.apply(this.models,arguments)},get:function(t){if(t==null)return void 0;return this._byId[t.id]||this._byId[t.cid]||this._byId[t]},at:function(t){return this.models[t]},where:function(t,e){if(h.isEmpty(t))return e?void 0:[];return this[e?"find":"filter"](function(e){for(var i in t){if(t[i]!==e.get(i))return false}return true})},findWhere:function(t){return this.where(t,true)},sort:function(t){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");t||(t={});if(h.isString(this.comparator)||this.comparator.length===1){this.models=this.sortBy(this.comparator,this)}else{this.models.sort(h.bind(this.comparator,this))}if(!t.silent)this.trigger("sort",this,t);return this},pluck:function(t){return h.invoke(this.models,"get",t)},fetch:function(t){t=t?h.clone(t):{};if(t.parse===void 0)t.parse=true;var e=t.success;var i=this;t.success=function(r){var s=t.reset?"reset":"set";i[s](r,t);if(e)e(i,r,t);i.trigger("sync",i,r,t)};M(this,t);return this.sync("read",this,t)},create:function(t,e){e=e?h.clone(e):{};if(!(t=this._prepareModel(t,e)))return false;if(!e.wait)this.add(t,e);var i=this;var r=e.success;e.success=function(t,e,s){if(s.wait)i.add(t,s);if(r)r(t,e,s)};t.save(null,e);return t},parse:function(t,e){return t},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0;this.models=[];this._byId={}},_prepareModel:function(t,e){if(t instanceof d){if(!t.collection)t.collection=this;return t}e=e?h.clone(e):{};e.collection=this;var i=new this.model(t,e);if(!i.validationError)return i;this.trigger("invalid",this,i.validationError,e);return false},_removeReference:function(t){if(this===t.collection)delete t.collection;t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,i,r){if((t==="add"||t==="remove")&&i!==this)return;if(t==="destroy")this.remove(e,r);if(e&&t==="change:"+e.idAttribute){delete this._byId[e.previous(e.idAttribute)];if(e.id!=null)this._byId[e.id]=e}this.trigger.apply(this,arguments)}});var y=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain"];h.each(y,function(t){v.prototype[t]=function(){var e=s.call(arguments);e.unshift(this.models);return h[t].apply(h,e)}});var _=["groupBy","countBy","sortBy"];h.each(_,function(t){v.prototype[t]=function(e,i){var r=h.isFunction(e)?e:function(t){return t.get(e)};return h[t](this.models,r,i)}});var w=a.View=function(t){this.cid=h.uniqueId("view");t||(t={});h.extend(this,h.pick(t,x));this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()};var b=/^(\S+)\s*(.*)$/;var x=["model","collection","el","id","attributes","className","tagName","events"];h.extend(w.prototype,o,{tagName:"div",$:function(t){return this.$el.find(t)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();this.stopListening();return this},setElement:function(t,e){if(this.$el)this.undelegateEvents();this.$el=t instanceof a.$?t:a.$(t);this.el=this.$el[0];if(e!==false)this.delegateEvents();return this},delegateEvents:function(t){if(!(t||(t=h.result(this,"events"))))return this;this.undelegateEvents();for(var e in t){var i=t[e];if(!h.isFunction(i))i=this[t[e]];if(!i)continue;var r=e.match(b);var s=r[1],n=r[2];i=h.bind(i,this);s+=".delegateEvents"+this.cid;if(n===""){this.$el.on(s,i)}else{this.$el.on(s,n,i)}}return this},undelegateEvents:function(){this.$el.off(".delegateEvents"+this.cid);return this},_ensureElement:function(){if(!this.el){var t=h.extend({},h.result(this,"attributes"));if(this.id)t.id=h.result(this,"id");if(this.className)t["class"]=h.result(this,"className");var e=a.$("<"+h.result(this,"tagName")+">").attr(t);this.setElement(e,false)}else{this.setElement(h.result(this,"el"),false)}}});a.sync=function(t,e,i){var r=T[t];h.defaults(i||(i={}),{emulateHTTP:a.emulateHTTP,emulateJSON:a.emulateJSON});var s={type:r,dataType:"json"};if(!i.url){s.url=h.result(e,"url")||U()}if(i.data==null&&e&&(t==="create"||t==="update"||t==="patch")){s.contentType="application/json";s.data=JSON.stringify(i.attrs||e.toJSON(i))}if(i.emulateJSON){s.contentType="application/x-www-form-urlencoded";s.data=s.data?{model:s.data}:{}}if(i.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){s.type="POST";if(i.emulateJSON)s.data._method=r;var n=i.beforeSend;i.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",r);if(n)return n.apply(this,arguments)}}if(s.type!=="GET"&&!i.emulateJSON){s.processData=false}if(s.type==="PATCH"&&E){s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var o=i.xhr=a.ajax(h.extend(s,i));e.trigger("request",e,o,i);return o};var E=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};a.ajax=function(){return a.$.ajax.apply(a.$,arguments)};var k=a.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var S=/\((.*?)\)/g;var $=/(\(\?)?:\w+/g;var H=/\*\w+/g;var A=/[\-{}\[\]+?.,\\\^$|#\s]/g;h.extend(k.prototype,o,{initialize:function(){},route:function(t,e,i){if(!h.isRegExp(t))t=this._routeToRegExp(t);if(h.isFunction(e)){i=e;e=""}if(!i)i=this[e];var r=this;a.history.route(t,function(s){var n=r._extractParameters(t,s);i&&i.apply(r,n);r.trigger.apply(r,["route:"+e].concat(n));r.trigger("route",e,n);a.history.trigger("route",r,e,n)});return this},navigate:function(t,e){a.history.navigate(t,e);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=h.result(this,"routes");var t,e=h.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(A,"\\$&").replace(S,"(?:$1)?").replace($,function(t,e){return e?t:"([^/]+)"}).replace(H,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return h.map(i,function(t){return t?decodeURIComponent(t):null})}});var I=a.History=function(){this.handlers=[];h.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var N=/^[#\/]|\s+$/g;var O=/^\/+|\/+$/g;var P=/msie [\w.]+/;var C=/\/$/;var j=/[?#].*$/;I.started=false;h.extend(I.prototype,o,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(N,"")},start:function(t){if(I.started)throw new Error("Backbone.history has already been started");I.started=true;this.options=h.extend({root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment();var i=document.documentMode;var r=P.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(O,"/");if(r&&this._wantsHashChange){this.iframe=a.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow;this.navigate(e)}if(this._hasPushState){a.$(window).on("popstate",this.checkUrl)}else if(this._wantsHashChange&&"onhashchange"in window&&!r){a.$(window).on("hashchange",this.checkUrl)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}this.fragment=e;var s=this.location;var n=s.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!n){this.fragment=this.getFragment(null,true);this.location.replace(this.root+this.location.search+"#"+this.fragment);return true}else if(this._hasPushState&&n&&s.hash){this.fragment=this.getHash().replace(N,"");this.history.replaceState({},document.title,this.root+this.fragment+s.search)}}if(!this.options.silent)return this.loadUrl()},stop:function(){a.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);I.started=false},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe){e=this.getFragment(this.getHash(this.iframe))}if(e===this.fragment)return false;if(this.iframe)this.navigate(e);this.loadUrl()},loadUrl:function(t){t=this.fragment=this.getFragment(t);return h.any(this.handlers,function(e){if(e.route.test(t)){e.callback(t);return true}})},navigate:function(t,e){if(!I.started)return false;if(!e||e===true)e={trigger:!!e};var i=this.root+(t=this.getFragment(t||""));t=t.replace(j,"");if(this.fragment===t)return;this.fragment=t;if(t===""&&i!=="/")i=i.slice(0,-1);if(this._hasPushState){this.history[e.replace?"replaceState":"pushState"]({},document.title,i)}else if(this._wantsHashChange){this._updateHash(this.location,t,e.replace);if(this.iframe&&t!==this.getFragment(this.getHash(this.iframe))){if(!e.replace)this.iframe.document.open().close();this._updateHash(this.iframe.location,t,e.replace)}}else{return this.location.assign(i)}if(e.trigger)return this.loadUrl(t)},_updateHash:function(t,e,i){if(i){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else{t.hash="#"+e}}});a.history=new I;var R=function(t,e){var i=this;var r;if(t&&h.has(t,"constructor")){r=t.constructor}else{r=function(){return i.apply(this,arguments)}}h.extend(r,i,e);var s=function(){this.constructor=r};s.prototype=i.prototype;r.prototype=new s;if(t)h.extend(r.prototype,t);r.__super__=i.prototype;return r};d.extend=v.extend=k.extend=w.extend=I.extend=R;var U=function(){throw new Error('A "url" property or function must be specified')};var M=function(t,e){var i=e.error;e.error=function(r){if(i)i(t,r,e);t.trigger("error",t,r,e)}}}).call(this);
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index 98e4a87..caeb56b 100644
    function wp_default_scripts( &$scripts ) { 
    275275        $scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2011-02-23');
    276276
    277277        $scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.6.0', 1 );
    278         $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore','jquery' ), '1.1.0', 1 );
     278        $scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore','jquery' ), '1.1.2', 1 );
    279279
    280280        $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 );
    281281        did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array(