├── .gitignore ├── .npmignore ├── .travis.yml ├── CNAME ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── backbone-min.js ├── backbone-min.map ├── backbone.js ├── docs ├── backbone-localstorage.html ├── backbone.html ├── backbone.localstorage.html ├── docco.css ├── images │ ├── airbnb.png │ ├── arrows.png │ ├── artsy.png │ ├── backbone-mobile.png │ ├── backbone.png │ ├── background.png │ ├── baroque.jpg │ ├── basecamp-calendar.jpg │ ├── bitbucket.png │ ├── blossom.png │ ├── cloudapp.png │ ├── code-school.png │ ├── dc-workspace.png │ ├── diaspora.png │ ├── disqus.png │ ├── do.png │ ├── easel.png │ ├── favicon.ico │ ├── flow.png │ ├── foursquare.png │ ├── gawker.png │ ├── gilt.jpg │ ├── groupon.png │ ├── hulu.png │ ├── inkling.png │ ├── irccloud.png │ ├── jolicloud.jpg │ ├── khan-academy.png │ ├── lens.png │ ├── menagerievet.png │ ├── newsblur.jpg │ ├── pandora.png │ ├── pitchfork.png │ ├── quartz.jpg │ ├── rdio.png │ ├── salon.png │ ├── seatgeek.png │ ├── slavery-footprint.png │ ├── soundcloud.png │ ├── spin.png │ ├── stripe.png │ ├── syllabus.jpg │ ├── tilemill.png │ ├── todos.png │ ├── trello.png │ ├── tzigla.png │ ├── usa-today.png │ ├── walmart-mobile.png │ ├── wpcom-notifications.png │ └── zocdoc.jpg ├── js │ └── jquery.lazyload.js ├── jsl.conf ├── public │ ├── fonts │ │ ├── aller-bold.eot │ │ ├── aller-bold.ttf │ │ ├── aller-bold.woff │ │ ├── aller-light.eot │ │ ├── aller-light.ttf │ │ ├── aller-light.woff │ │ ├── fleurons.eot │ │ ├── fleurons.ttf │ │ ├── fleurons.woff │ │ ├── novecento-bold.eot │ │ ├── novecento-bold.ttf │ │ └── novecento-bold.woff │ ├── images │ │ └── grey_@2X.png │ └── stylesheets │ │ └── normalize.css └── todos.html ├── examples ├── backbone.localStorage.js └── todos │ ├── destroy.png │ ├── index.html │ ├── todos.css │ └── todos.js ├── index.html ├── index.js ├── package.json └── test ├── collection.js ├── environment.js ├── events.js ├── index.html ├── model.coffee ├── model.js ├── noconflict.js ├── router.js ├── sync.js ├── vendor ├── jquery.js ├── json2.js ├── qunit.css ├── qunit.js ├── runner.js └── underscore.js └── view.js /.gitignore: -------------------------------------------------------------------------------- 1 | raw 2 | *.sw? 3 | .DS_Store 4 | node_modules 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test/ 2 | Rakefile 3 | docs/ 4 | raw/ 5 | examples/ 6 | index.html 7 | .jshintrc 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.8 4 | notifications: 5 | email: false 6 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | backbonejs.org 2 | 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to Open a Backbone.js Ticket 2 | 3 | * Do not use tickets to ask for help with (debugging) your application. Ask on 4 | the [mailing list](https://groups.google.com/forum/#!forum/backbonejs), 5 | in the IRC channel (`#documentcloud` on Freenode), or if you understand your 6 | specific problem, on [StackOverflow](http://stackoverflow.com/questions/tagged/backbone.js). 7 | 8 | * Before you open a ticket or send a pull request, 9 | [search](https://github.com/jashkenas/backbone/issues) for previous 10 | discussions about the same feature or issue. Add to the earlier ticket if you 11 | find one. 12 | 13 | * Before sending a pull request for a feature or bug fix, be sure to have 14 | [tests](http://backbonejs.org/test/). 15 | 16 | * Use the same coding style as the rest of the 17 | [codebase](https://github.com/jashkenas/backbone/blob/master/backbone.js). 18 | 19 | * In your pull request, do not add documentation or rebuild the minified 20 | `backbone-min.js` file. We'll do that before cutting a new release. 21 | 22 | * All pull requests should be made to the `master` branch. 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2013 Jeremy Ashkenas, DocumentCloud 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ____ __ __ 2 | /\ _`\ /\ \ /\ \ __ 3 | \ \ \ \ \ __ ___\ \ \/'\\ \ \____ ___ ___ __ /\_\ ____ 4 | \ \ _ <' /'__`\ /'___\ \ , < \ \ '__`\ / __`\ /' _ `\ /'__`\ \/\ \ /',__\ 5 | \ \ \ \ \/\ \ \.\_/\ \__/\ \ \\`\\ \ \ \ \/\ \ \ \/\ \/\ \/\ __/ __ \ \ \/\__, `\ 6 | \ \____/\ \__/.\_\ \____\\ \_\ \_\ \_,__/\ \____/\ \_\ \_\ \____\/\_\_\ \ \/\____/ 7 | \/___/ \/__/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/_/\/_/\/____/\/_/\ \_\ \/___/ 8 | \ \____/ 9 | \/___/ 10 | (_'_______________________________________________________________________________'_) 11 | (_.———————————————————————————————————————————————————————————————————————————————._) 12 | 13 | 14 | Backbone supplies structure to JavaScript-heavy applications by providing models key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface. 15 | 16 | For Docs, License, Tests, pre-packed downloads, and everything else, really, see: 17 | http://backbonejs.org 18 | 19 | To suggest a feature, report a bug, or general discussion: 20 | http://github.com/jashkenas/backbone/issues 21 | 22 | Backbone is an open-sourced component of DocumentCloud: 23 | https://github.com/documentcloud 24 | 25 | Many thanks to our contributors: 26 | http://github.com/jashkenas/backbone/contributors 27 | 28 | Special thanks to Robert Kieffer for the original philosophy behind Backbone. 29 | http://github.com/broofa 30 | -------------------------------------------------------------------------------- /backbone-min.js: -------------------------------------------------------------------------------- 1 | (function(t,e){if(typeof exports!=="undefined"){e(t,exports,require("underscore"))}else if(typeof define==="function"&&define.amd){define(["underscore","jquery","exports"],function(i,r,s){t.Backbone=e(t,s,i,r)})}else{t.Backbone=e(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)}})(this,function(t,e,i,r){var s=t.Backbone;var n=[];var a=n.push;var o=n.slice;var h=n.splice;e.VERSION="1.1.0";e.$=r;e.noConflict=function(){t.Backbone=s;return this};e.emulateHTTP=false;e.emulateJSON=false;var u=e.Events={on:function(t,e,i){if(!c(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,r){if(!c(this,"once",t,[e,r])||!e)return this;var s=this;var n=i.once(function(){s.off(t,n);e.apply(this,arguments)});n._callback=e;return this.on(t,n,r)},off:function(t,e,r){var s,n,a,o,h,u,l,f;if(!this._events||!c(this,"off",t,[e,r]))return this;if(!t&&!e&&!r){this._events={};return this}o=t?[t]:i.keys(this._events);for(h=0,u=o.length;h").attr(t);this.setElement(r,false)}else{this.setElement(i.result(this,"el"),false)}}});e.sync=function(t,r,s){var n=T[t];i.defaults(s||(s={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var a={type:n,dataType:"json"};if(!s.url){a.url=i.result(r,"url")||M()}if(s.data==null&&r&&(t==="create"||t==="update"||t==="patch")){a.contentType="application/json";a.data=JSON.stringify(s.attrs||r.toJSON(s))}if(s.emulateJSON){a.contentType="application/x-www-form-urlencoded";a.data=a.data?{model:a.data}:{}}if(s.emulateHTTP&&(n==="PUT"||n==="DELETE"||n==="PATCH")){a.type="POST";if(s.emulateJSON)a.data._method=n;var o=s.beforeSend;s.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",n);if(o)return o.apply(this,arguments)}}if(a.type!=="GET"&&!s.emulateJSON){a.processData=false}if(a.type==="PATCH"&&k){a.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var h=s.xhr=e.ajax(i.extend(a,s));r.trigger("request",r,h,s);return h};var k=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var S=e.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var $=/\((.*?)\)/g;var H=/(\(\?)?:\w+/g;var A=/\*\w+/g;var I=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend(S.prototype,u,{initialize:function(){},route:function(t,r,s){if(!i.isRegExp(t))t=this._routeToRegExp(t);if(i.isFunction(r)){s=r;r=""}if(!s)s=this[r];var n=this;e.history.route(t,function(i){var a=n._extractParameters(t,i);s&&s.apply(n,a);n.trigger.apply(n,["route:"+r].concat(a));n.trigger("route",r,a);e.history.trigger("route",n,r,a)});return this},navigate:function(t,i){e.history.navigate(t,i);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=i.result(this,"routes");var t,e=i.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(I,"\\$&").replace($,"(?:$1)?").replace(H,function(t,e){return e?t:"([^/]+)"}).replace(A,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var r=t.exec(e).slice(1);return i.map(r,function(t){return t?decodeURIComponent(t):null})}});var N=e.History=function(){this.handlers=[];i.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var O=/^[#\/]|\s+$/g;var P=/^\/+|\/+$/g;var C=/msie [\w.]+/;var j=/\/$/;var R=/[?#].*$/;N.started=false;i.extend(N.prototype,u,{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(j,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(O,"")},start:function(t){if(N.started)throw new Error("Backbone.history has already been started");N.started=true;this.options=i.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 r=this.getFragment();var s=document.documentMode;var n=C.exec(navigator.userAgent.toLowerCase())&&(!s||s<=7);this.root=("/"+this.root+"/").replace(P,"/");if(n&&this._wantsHashChange){this.iframe=e.$('