Change name to setDomLibrary

This commit is contained in:
James Sanders
2012-01-31 17:25:41 -07:00
parent 9bd086e64b
commit e97c58f547
4 changed files with 12 additions and 12 deletions

4
backbone-min.js vendored
View File

@@ -3,8 +3,8 @@
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
(function(){var i=this,r=i.Backbone,s=Array.prototype.slice,t=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:i.Backbone={};g.VERSION="0.9.0";var f=i._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var h=i.jQuery||i.Zepto||i.ender;g.setjQuery=function(a){h=a};g.noConflict=function(){i.Backbone=r;return this};g.emulateHTTP=!1;g.emulateJSON=!1;g.Events={on:function(a,b,c){for(var d,a=a.split(/\s+/),e=this._callbacks||(this._callbacks={});d=a.shift();){d=e[d]||(e[d]={});
var f=d.tail||(d.tail=d.next={});f.callback=b;f.context=c;d.tail=f.next={}}return this},off:function(a,b,c){var d,e,f;if(a){if(e=this._callbacks)for(a=a.split(/\s+/);d=a.shift();)if(f=e[d],delete e[d],b&&f)for(;(f=f.next)&&f.next;)if(!(f.callback===b&&(!c||f.context===c)))this.on(d,f.callback,f.context)}else delete this._callbacks;return this},trigger:function(a){var b,c,d,e;if(!(d=this._callbacks))return this;e=d.all;for((a=a.split(/\s+/)).push(null);b=a.shift();)e&&a.push({next:e.next,tail:e.tail,
(function(){var i=this,r=i.Backbone,s=Array.prototype.slice,t=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:i.Backbone={};g.VERSION="0.9.0";var f=i._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var h=i.jQuery||i.Zepto||i.ender;g.setDomLibrary=function(a){h=a};g.noConflict=function(){i.Backbone=r;return this};g.emulateHTTP=!1;g.emulateJSON=!1;g.Events={on:function(a,b,c){for(var d,a=a.split(/\s+/),e=this._callbacks||(this._callbacks={});d=a.shift();){d=e[d]||(e[d]=
{});var f=d.tail||(d.tail=d.next={});f.callback=b;f.context=c;d.tail=f.next={}}return this},off:function(a,b,c){var d,e,f;if(a){if(e=this._callbacks)for(a=a.split(/\s+/);d=a.shift();)if(f=e[d],delete e[d],b&&f)for(;(f=f.next)&&f.next;)if(!(f.callback===b&&(!c||f.context===c)))this.on(d,f.callback,f.context)}else delete this._callbacks;return this},trigger:function(a){var b,c,d,e;if(!(d=this._callbacks))return this;e=d.all;for((a=a.split(/\s+/)).push(null);b=a.shift();)e&&a.push({next:e.next,tail:e.tail,
event:b}),(c=d[b])&&a.push({next:c.next,tail:c.tail});for(e=s.call(arguments,1);c=a.pop();){b=c.tail;for(d=c.event?[c.event].concat(e):e;(c=c.next)!==b;)c.callback.apply(c.context||this,d)}return this}};g.Events.bind=g.Events.on;g.Events.unbind=g.Events.off;g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=j(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this._changed=
{};if(!this.set(a,{silent:!0}))throw Error("Can't create an invalid model");this._changed={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(g.Model.prototype,g.Events,{idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.attributes[a];return this._escapedAttributes[a]=f.escape(null==b?"":""+b)},
has:function(a){return null!=this.attributes[a]},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof g.Model&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=this.attributes,k=this._escapedAttributes,n=this._previousAttributes||{},u=this._changing;this._changing=!0;for(e in d)if(a=d[e],f.isEqual(b[e],a)||delete k[e],c.unset?delete b[e]:b[e]=

View File

@@ -44,7 +44,7 @@
// Set the javascript library that will be used for the selector work
// (a.k.a. the `$` variable).
//
// By default Backbone will use: jQuery, Zepto, or Ender; but the `setjQuery()`
// By default Backbone will use: jQuery, Zepto, or Ender; but the `setDomLibrary()`
// method let's you inject an alternate javascript library (or a mock
// library for testing your views outside of a browser). This is also useful
// if you are using a packaging library -- to add support for `require()`
@@ -52,9 +52,9 @@
// support `require()`, prevents Backbone from automatically loading the
// default javascript library.
//
// Backbone.setjQuery(jQuery)
// Backbone.setDomLibrary(jQuery)
//
Backbone.setjQuery = function(lib) {
Backbone.setDomLibrary = function(lib) {
$ = lib;
};

View File

@@ -9,22 +9,22 @@ $(document).ready(function() {
};
};
var viewAttrs = { id: 'test-setjquery', className: 'test-setjquery' }
var viewAttrs = { id: 'test-setdomlibrary', className: 'test-setdomlibrary' }
module("Backbone.setjQuery");
module("Backbone.setDomLibrary");
test('Changing jQuery library to custom library', function() {
Backbone.setjQuery(myLib);
Backbone.setDomLibrary(myLib);
var view = new Backbone.View(viewAttrs);
ok(view.$el.hasClass('test-setjquery') === 'spam');
ok(view.$el.hasClass('test-setdomlibrary') === 'spam');
});
test('Changing jQuery library back to global jQuery', function() {
Backbone.setjQuery(jQuery);
Backbone.setDomLibrary(jQuery);
var view = new Backbone.View(viewAttrs);
ok(view.$el.hasClass('test-setjquery'));
ok(view.$el.hasClass('test-setdomlibrary'));
});
});

View File

@@ -21,7 +21,7 @@
<script type="text/javascript" src="view.js"></script>
<script type="text/javascript" src="sync.js"></script>
<script type="text/javascript" src="speed.js"></script>
<script type="text/javascript" src="setjquery.js"></script>
<script type="text/javascript" src="setdomlibrary.js"></script>
</head>
<body>
<h1 id="qunit-header">Backbone Test Suite</h1>