diff --git a/backbone/LICENSE b/backbone/LICENSE deleted file mode 100644 index d8cef48..0000000 --- a/backbone/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2010 Jeremy Ashkenas, DocumentCloud - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/backbone/README b/backbone/README deleted file mode 100644 index 0723e1a..0000000 --- a/backbone/README +++ /dev/null @@ -1,25 +0,0 @@ - ____ _ _ _ - | _ \ | | | | (_) - | |_) | __ _ ___| | __| |__ ___ _ __ ___ _ ___ - | _ < / _` |/ __| |/ /| '_ \ / _ \| '_ \ / _ \ | / __| - | |_) | (_| | (__| < | |_) | (_) | | | | __/_| \__ \ - |____/ \__,_|\___|_|\_\|_.__/ \___/|_| |_|\___(_) |___/ - _/ | - |__/ -(_'___________________________________________________'_) -(_.———————————————————————————————————————————————————._) - - -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. - -For Docs, License, Tests, and pre-packed downloads, see: -http://documentcloud.github.com/backbone/ - -To suggest a feature, report a bug, or general discussion: -http://github.com/documentcloud/backbone/issues/ - -All contributors are listed here: -http://github.com/documentcloud/backbone/contributors - -Special thanks to Robert Kieffer for the original philosophy behind Backbone. -http://github.com/broofa diff --git a/backbone/Rakefile b/backbone/Rakefile deleted file mode 100644 index f0b0cf6..0000000 --- a/backbone/Rakefile +++ /dev/null @@ -1,42 +0,0 @@ -require 'rubygems' - -HEADER = /((^\s*\/\/.*\n)+)/ - -desc "rebuild the backbone-min.js files for distribution" -task :build do - begin - require 'closure-compiler' - rescue LoadError - puts "closure-compiler not found.\nInstall it by running 'gem install closure-compiler" - exit - end - source = File.read 'backbone.js' - header = source.match(HEADER) - File.open('backbone-min.js', 'w+') do |file| - file.write header[1].squeeze(' ') + Closure::Compiler.new.compress(source) - end -end - -desc "build the docco documentation" -task :doc do - check 'docco', 'docco', 'https://github.com/jashkenas/docco' - system 'docco backbone.js && docco examples/todos/todos.js examples/backbone-localstorage.js' -end - -desc "run JavaScriptLint on the source" -task :lint do - system "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js" -end - -desc "test the CoffeeScript integration" -task :test do - check 'coffee', 'CoffeeScript', 'https://github.com/jashkenas/coffee-script.git' - system "coffee test/*.coffee" -end - -# Check for the existence of an executable. -def check(exec, name, url) - return unless `which #{exec}`.empty? - puts "#{name} not found.\nInstall it from #{url}" - exit -end diff --git a/backbone/examples/backbone-localstorage.js b/backbone/examples/backbone-localstorage.js deleted file mode 100644 index 091d7f3..0000000 --- a/backbone/examples/backbone-localstorage.js +++ /dev/null @@ -1,84 +0,0 @@ -// A simple module to replace `Backbone.sync` with *localStorage*-based -// persistence. Models are given GUIDS, and saved into a JSON object. Simple -// as that. - -// Generate four random hex digits. -function S4() { - return (((1+Math.random())*0x10000)|0).toString(16).substring(1); -}; - -// Generate a pseudo-GUID by concatenating random hexadecimal. -function guid() { - return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); -}; - -// Our Store is represented by a single JS object in *localStorage*. Create it -// with a meaningful name, like the name you'd give a table. -var Store = function(name) { - this.name = name; - var store = localStorage.getItem(this.name); - this.data = (store && JSON.parse(store)) || {}; -}; - -_.extend(Store.prototype, { - - // Save the current state of the **Store** to *localStorage*. - save: function() { - localStorage.setItem(this.name, JSON.stringify(this.data)); - }, - - // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already - // have an id of it's own. - create: function(model) { - if (!model.id) model.id = model.attributes.id = guid(); - this.data[model.id] = model; - this.save(); - return model; - }, - - // Update a model by replacing its copy in `this.data`. - update: function(model) { - this.data[model.id] = model; - this.save(); - return model; - }, - - // Retrieve a model from `this.data` by id. - find: function(model) { - return this.data[model.id]; - }, - - // Return the array of all models currently in storage. - findAll: function() { - return _.values(this.data); - }, - - // Delete a model from `this.data`, returning it. - destroy: function(model) { - delete this.data[model.id]; - this.save(); - return model; - } - -}); - -// Override `Backbone.sync` to use delegate to the model or collection's -// *localStorage* property, which should be an instance of `Store`. -Backbone.sync = function(method, model, options) { - - var resp; - var store = model.localStorage || model.collection.localStorage; - - switch (method) { - case "read": resp = model.id ? store.find(model) : store.findAll(); break; - case "create": resp = store.create(model); break; - case "update": resp = store.update(model); break; - case "delete": resp = store.destroy(model); break; - } - - if (resp) { - options.success(resp); - } else { - options.error("Record not found"); - } -}; \ No newline at end of file diff --git a/backbone/examples/todos/destroy.png b/backbone/examples/todos/destroy.png deleted file mode 100644 index 56d7637..0000000 Binary files a/backbone/examples/todos/destroy.png and /dev/null differ diff --git a/backbone/examples/todos/index.html b/backbone/examples/todos/index.html deleted file mode 100644 index 7f1c20f..0000000 --- a/backbone/examples/todos/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - Backbone Demo: Todos - - - - - - - - - - - - - -
- -
-

Todos

-
- -
- -
- - -
- -
-
    -
    - -
    - -
    - -
    - - - -
    - Created by -
    - Jérôme Gravel-Niquet -
    - - - - - - - - - - diff --git a/backbone/examples/todos/todos.css b/backbone/examples/todos/todos.css deleted file mode 100644 index 8fdd0c8..0000000 --- a/backbone/examples/todos/todos.css +++ /dev/null @@ -1,311 +0,0 @@ -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, font, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td { - margin: 0; - padding: 0; - border: 0; - outline: 0; - font-weight: inherit; - font-style: inherit; - font-size: 100%; - font-family: inherit; - vertical-align: baseline; -} -body { - line-height: 1; - color: black; - background: white; -} -ol, ul { - list-style: none; -} -a img { - border: none; -} - -html { - background: #eeeeee; -} - body { - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 1.4em; - background: #eeeeee; - color: #333333; - } - -#todoapp { - width: 480px; - margin: 0 auto 40px; - background: white; - padding: 20px; - -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0; - -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0; - -o-box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0; - box-shadow: rgba(0, 0, 0, 0.2) 0 5px 6px 0; -} - #todoapp h1 { - font-size: 36px; - font-weight: bold; - text-align: center; - padding: 20px 0 30px 0; - line-height: 1; - } - -#create-todo { - position: relative; -} - #create-todo input { - width: 466px; - font-size: 24px; - font-family: inherit; - line-height: 1.4em; - border: 0; - outline: none; - padding: 6px; - border: 1px solid #999999; - -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - } - #create-todo input::-webkit-input-placeholder { - font-style: italic; - } - #create-todo span { - position: absolute; - z-index: 999; - width: 170px; - left: 50%; - margin-left: -85px; - } - -#todo-list { - margin-top: 10px; -} - #todo-list li { - padding: 12px 20px 11px 0; - position: relative; - font-size: 24px; - line-height: 1.1em; - border-bottom: 1px solid #cccccc; - } - #todo-list li:after { - content: "\0020"; - display: block; - height: 0; - clear: both; - overflow: hidden; - visibility: hidden; - } - #todo-list li.editing { - padding: 0; - border-bottom: 0; - } - #todo-list .editing .display, - #todo-list .edit { - display: none; - } - #todo-list .editing .edit { - display: block; - } - #todo-list .editing input { - width: 444px; - font-size: 24px; - font-family: inherit; - margin: 0; - line-height: 1.6em; - border: 0; - outline: none; - padding: 10px 7px 0px 27px; - border: 1px solid #999999; - -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - -o-box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - box-shadow: rgba(0, 0, 0, 0.2) 0 1px 2px 0 inset; - } - #todo-list .check { - position: relative; - top: 9px; - margin: 0 10px 0 7px; - float: left; - } - #todo-list .done .todo-content { - text-decoration: line-through; - color: #777777; - } - #todo-list .todo-destroy { - position: absolute; - right: 5px; - top: 14px; - display: none; - cursor: pointer; - width: 20px; - height: 20px; - background: url(destroy.png) no-repeat 0 0; - } - #todo-list li:hover .todo-destroy { - display: block; - } - #todo-list .todo-destroy:hover { - background-position: 0 -20px; - } - -#todo-stats { - *zoom: 1; - margin-top: 10px; - color: #777777; -} - #todo-stats:after { - content: "\0020"; - display: block; - height: 0; - clear: both; - overflow: hidden; - visibility: hidden; - } - #todo-stats .todo-count { - float: left; - } - #todo-stats .todo-count .number { - font-weight: bold; - color: #333333; - } - #todo-stats .todo-clear { - float: right; - } - #todo-stats .todo-clear a { - color: #777777; - font-size: 12px; - } - #todo-stats .todo-clear a:visited { - color: #777777; - } - #todo-stats .todo-clear a:hover { - color: #336699; - } - -#instructions { - width: 520px; - margin: 10px auto; - color: #777777; - text-shadow: rgba(255, 255, 255, 0.8) 0 1px 0; - text-align: center; -} - #instructions a { - color: #336699; - } - -#credits { - width: 520px; - margin: 30px auto; - color: #999; - text-shadow: rgba(255, 255, 255, 0.8) 0 1px 0; - text-align: center; -} - #credits a { - color: #888; - } - - -/* - * François 'cahnory' Germain - */ -.ui-tooltip, .ui-tooltip-top, .ui-tooltip-right, .ui-tooltip-bottom, .ui-tooltip-left { - color:#ffffff; - cursor:normal; - display:-moz-inline-stack; - display:inline-block; - font-size:12px; - font-family:arial; - padding:.5em 1em; - position:relative; - text-align:center; - text-shadow:0 -1px 1px #111111; - -webkit-border-top-left-radius:4px ; - -webkit-border-top-right-radius:4px ; - -webkit-border-bottom-right-radius:4px ; - -webkit-border-bottom-left-radius:4px ; - -khtml-border-top-left-radius:4px ; - -khtml-border-top-right-radius:4px ; - -khtml-border-bottom-right-radius:4px ; - -khtml-border-bottom-left-radius:4px ; - -moz-border-radius-topleft:4px ; - -moz-border-radius-topright:4px ; - -moz-border-radius-bottomright:4px ; - -moz-border-radius-bottomleft:4px ; - border-top-left-radius:4px ; - border-top-right-radius:4px ; - border-bottom-right-radius:4px ; - border-bottom-left-radius:4px ; - -o-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444; - -moz-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444; - -khtml-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444; - -webkit-box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444; - box-shadow:0 1px 2px #000000, inset 0 0 0 1px #222222, inset 0 2px #666666, inset 0 -2px 2px #444444; - background-color:#3b3b3b; - background-image:-moz-linear-gradient(top,#555555,#222222); - background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#555555),color-stop(1,#222222)); - filter:progid:DXImageTransform.Microsoft.gradient(startColorStr=#555555,EndColorStr=#222222); - -ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorStr=#555555,EndColorStr=#222222); -} -.ui-tooltip:after, .ui-tooltip-top:after, .ui-tooltip-right:after, .ui-tooltip-bottom:after, .ui-tooltip-left:after { - content:"\25B8"; - display:block; - font-size:2em; - height:0; - line-height:0; - position:absolute; -} -.ui-tooltip:after, .ui-tooltip-bottom:after { - color:#2a2a2a; - bottom:0; - left:1px; - text-align:center; - text-shadow:1px 0 2px #000000; - -o-transform:rotate(90deg); - -moz-transform:rotate(90deg); - -khtml-transform:rotate(90deg); - -webkit-transform:rotate(90deg); - width:100%; -} -.ui-tooltip-top:after { - bottom:auto; - color:#4f4f4f; - left:-2px; - top:0; - text-align:center; - text-shadow:none; - -o-transform:rotate(-90deg); - -moz-transform:rotate(-90deg); - -khtml-transform:rotate(-90deg); - -webkit-transform:rotate(-90deg); - width:100%; -} -.ui-tooltip-right:after { - color:#222222; - right:-0.375em; - top:50%; - margin-top:-.05em; - text-shadow:0 1px 2px #000000; - -o-transform:rotate(0); - -moz-transform:rotate(0); - -khtml-transform:rotate(0); - -webkit-transform:rotate(0); -} -.ui-tooltip-left:after { - color:#222222; - left:-0.375em; - top:50%; - margin-top:.1em; - text-shadow:0 -1px 2px #000000; - -o-transform:rotate(180deg); - -moz-transform:rotate(180deg); - -khtml-transform:rotate(180deg); - -webkit-transform:rotate(180deg); -} diff --git a/backbone/examples/todos/todos.js b/backbone/examples/todos/todos.js deleted file mode 100644 index 47c7e37..0000000 --- a/backbone/examples/todos/todos.js +++ /dev/null @@ -1,258 +0,0 @@ -// An example Backbone application contributed by -// [Jérôme Gravel-Niquet](http://jgn.me/). This demo uses a simple -// [LocalStorage adapter](backbone-localstorage.html) -// to persist Backbone models within your browser. - -// Load the application once the DOM is ready, using `jQuery.ready`: -$(function(){ - - // Todo Model - // ---------- - - // Our basic **Todo** model has `content`, `order`, and `done` attributes. - window.Todo = Backbone.Model.extend({ - - // Default attributes for the todo. - defaults: { - content: "empty todo...", - done: false - }, - - // Ensure that each todo created has `content`. - initialize: function() { - if (!this.get("content")) { - this.set({"content": this.defaults.content}); - } - }, - - // Toggle the `done` state of this todo item. - toggle: function() { - this.save({done: !this.get("done")}); - }, - - // Remove this Todo from *localStorage* and delete its view. - clear: function() { - this.destroy(); - this.view.remove(); - } - - }); - - // Todo Collection - // --------------- - - // The collection of todos is backed by *localStorage* instead of a remote - // server. - window.TodoList = Backbone.Collection.extend({ - - // Reference to this collection's model. - model: Todo, - - // Save all of the todo items under the `"todos"` namespace. - localStorage: new Store("todos"), - - // Filter down the list of all todo items that are finished. - done: function() { - return this.filter(function(todo){ return todo.get('done'); }); - }, - - // Filter down the list to only todo items that are still not finished. - remaining: function() { - return this.without.apply(this, this.done()); - }, - - // We keep the Todos in sequential order, despite being saved by unordered - // GUID in the database. This generates the next order number for new items. - nextOrder: function() { - if (!this.length) return 1; - return this.last().get('order') + 1; - }, - - // Todos are sorted by their original insertion order. - comparator: function(todo) { - return todo.get('order'); - } - - }); - - // Create our global collection of **Todos**. - window.Todos = new TodoList; - - // Todo Item View - // -------------- - - // The DOM element for a todo item... - window.TodoView = Backbone.View.extend({ - - //... is a list tag. - tagName: "li", - - // Cache the template function for a single item. - template: _.template($('#item-template').html()), - - // The DOM events specific to an item. - events: { - "click .check" : "toggleDone", - "dblclick div.todo-content" : "edit", - "click span.todo-destroy" : "clear", - "keypress .todo-input" : "updateOnEnter" - }, - - // The TodoView listens for changes to its model, re-rendering. Since there's - // a one-to-one correspondence between a **Todo** and a **TodoView** in this - // app, we set a direct reference on the model for convenience. - initialize: function() { - _.bindAll(this, 'render', 'close'); - this.model.bind('change', this.render); - this.model.view = this; - }, - - // Re-render the contents of the todo item. - render: function() { - $(this.el).html(this.template(this.model.toJSON())); - this.setContent(); - return this; - }, - - // To avoid XSS (not that it would be harmful in this particular app), - // we use `jQuery.text` to set the contents of the todo item. - setContent: function() { - var content = this.model.get('content'); - this.$('.todo-content').text(content); - this.input = this.$('.todo-input'); - this.input.bind('blur', this.close); - this.input.val(content); - }, - - // Toggle the `"done"` state of the model. - toggleDone: function() { - this.model.toggle(); - }, - - // Switch this view into `"editing"` mode, displaying the input field. - edit: function() { - $(this.el).addClass("editing"); - this.input.focus(); - }, - - // Close the `"editing"` mode, saving changes to the todo. - close: function() { - this.model.save({content: this.input.val()}); - $(this.el).removeClass("editing"); - }, - - // If you hit `enter`, we're through editing the item. - updateOnEnter: function(e) { - if (e.keyCode == 13) this.close(); - }, - - // Remove this view from the DOM. - remove: function() { - $(this.el).remove(); - }, - - // Remove the item, destroy the model. - clear: function() { - this.model.clear(); - } - - }); - - // The Application - // --------------- - - // Our overall **AppView** is the top-level piece of UI. - window.AppView = Backbone.View.extend({ - - // Instead of generating a new element, bind to the existing skeleton of - // the App already present in the HTML. - el: $("#todoapp"), - - // Our template for the line of statistics at the bottom of the app. - statsTemplate: _.template($('#stats-template').html()), - - // Delegated events for creating new items, and clearing completed ones. - events: { - "keypress #new-todo": "createOnEnter", - "keyup #new-todo": "showTooltip", - "click .todo-clear a": "clearCompleted" - }, - - // At initialization we bind to the relevant events on the `Todos` - // collection, when items are added or changed. Kick things off by - // loading any preexisting todos that might be saved in *localStorage*. - initialize: function() { - _.bindAll(this, 'addOne', 'addAll', 'render'); - - this.input = this.$("#new-todo"); - - Todos.bind('add', this.addOne); - Todos.bind('reset', this.addAll); - Todos.bind('all', this.render); - - Todos.fetch(); - }, - - // Re-rendering the App just means refreshing the statistics -- the rest - // of the app doesn't change. - render: function() { - this.$('#todo-stats').html(this.statsTemplate({ - total: Todos.length, - done: Todos.done().length, - remaining: Todos.remaining().length - })); - }, - - // Add a single todo item to the list by creating a view for it, and - // appending its element to the `