Permalink
Browse files

New version from my DevoxxFR 2013 live-coding session

  • Loading branch information...
1 parent 0c7a4c7 commit e222362229ba1102cddf3bbdec3b6f73043cd741 @sylvinus committed Mar 27, 2013
Showing with 53,126 additions and 17 deletions.
  1. BIN .DS_Store
  2. +3 −0 .bowerrc
  3. +21 −0 .editorconfig
  4. +1 −0 .gitattributes
  5. +1 −2 .gitignore
  6. +27 −0 .jshintrc
  7. +5 −0 .tmp/scripts/hello.js
  8. +6,800 −0 .tmp/styles/main.css
  9. +297 −0 Gruntfile.js
  10. +268 −0 README
  11. +0 −15 README.md
  12. +543 −0 app/.htaccess
  13. +157 −0 app/404.html
  14. +4 −0 app/components/backbone/.gitignore
  15. +7 −0 app/components/backbone/.npmignore
  16. +5 −0 app/components/backbone/.travis.yml
  17. +2 −0 app/components/backbone/CNAME
  18. +17 −0 app/components/backbone/CONTRIBUTING.md
  19. +22 −0 app/components/backbone/LICENSE
  20. +26 −0 app/components/backbone/README.md
  21. +24 −0 app/components/backbone/Rakefile
  22. +4 −0 app/components/backbone/backbone-min.js
  23. +1 −0 app/components/backbone/backbone-min.map
  24. +1,571 −0 app/components/backbone/backbone.js
  25. +8 −0 app/components/backbone/component.json
  26. +284 −0 app/components/backbone/docs/backbone-localstorage.html
  27. +4,152 −0 app/components/backbone/docs/backbone.html
  28. +458 −0 app/components/backbone/docs/backbone.localstorage.html
  29. +508 −0 app/components/backbone/docs/docco.css
  30. BIN app/components/backbone/docs/images/airbnb.png
  31. BIN app/components/backbone/docs/images/arrows.png
  32. BIN app/components/backbone/docs/images/artsy.png
  33. BIN app/components/backbone/docs/images/backbone-mobile.png
  34. BIN app/components/backbone/docs/images/backbone.png
  35. BIN app/components/backbone/docs/images/background.png
  36. BIN app/components/backbone/docs/images/baroque.jpg
  37. BIN app/components/backbone/docs/images/basecamp-calendar.jpg
  38. BIN app/components/backbone/docs/images/battlefield.png
  39. BIN app/components/backbone/docs/images/bitbucket.png
  40. BIN app/components/backbone/docs/images/blossom.png
  41. BIN app/components/backbone/docs/images/cloudapp.png
  42. BIN app/components/backbone/docs/images/code-school.png
  43. BIN app/components/backbone/docs/images/dc-workspace.png
  44. BIN app/components/backbone/docs/images/diaspora.png
  45. BIN app/components/backbone/docs/images/disqus.png
  46. BIN app/components/backbone/docs/images/do.png
  47. BIN app/components/backbone/docs/images/easel.png
  48. BIN app/components/backbone/docs/images/favicon.ico
  49. BIN app/components/backbone/docs/images/flow.png
  50. BIN app/components/backbone/docs/images/foursquare.png
  51. BIN app/components/backbone/docs/images/gilt.jpg
  52. BIN app/components/backbone/docs/images/groupon.png
  53. BIN app/components/backbone/docs/images/hulu.png
  54. BIN app/components/backbone/docs/images/inkling.png
  55. BIN app/components/backbone/docs/images/irccloud.png
  56. BIN app/components/backbone/docs/images/jolicloud.jpg
  57. BIN app/components/backbone/docs/images/khan-academy.png
  58. BIN app/components/backbone/docs/images/linkedin-mobile.png
  59. BIN app/components/backbone/docs/images/menagerievet.png
  60. BIN app/components/backbone/docs/images/newsblur.jpg
  61. BIN app/components/backbone/docs/images/pandora.png
  62. BIN app/components/backbone/docs/images/pitchfork.png
  63. BIN app/components/backbone/docs/images/prose.png
  64. BIN app/components/backbone/docs/images/quartz.jpg
  65. BIN app/components/backbone/docs/images/rdio.png
  66. BIN app/components/backbone/docs/images/salon.png
  67. BIN app/components/backbone/docs/images/seatgeek.png
  68. BIN app/components/backbone/docs/images/slavery-footprint.png
  69. BIN app/components/backbone/docs/images/soundcloud.png
  70. BIN app/components/backbone/docs/images/spin.png
  71. BIN app/components/backbone/docs/images/stripe.png
  72. BIN app/components/backbone/docs/images/syllabus.jpg
  73. BIN app/components/backbone/docs/images/tilemill.png
  74. BIN app/components/backbone/docs/images/todos.png
  75. BIN app/components/backbone/docs/images/trello.png
  76. BIN app/components/backbone/docs/images/tzigla.png
  77. BIN app/components/backbone/docs/images/usa-today.png
  78. BIN app/components/backbone/docs/images/walmart-mobile.png
  79. BIN app/components/backbone/docs/images/wpcom-notifications.png
  80. +210 −0 app/components/backbone/docs/js/jquery.lazyload.js
  81. +44 −0 app/components/backbone/docs/jsl.conf
  82. BIN app/components/backbone/docs/public/fonts/aller-bold.eot
  83. BIN app/components/backbone/docs/public/fonts/aller-bold.ttf
  84. BIN app/components/backbone/docs/public/fonts/aller-bold.woff
  85. BIN app/components/backbone/docs/public/fonts/aller-light.eot
  86. BIN app/components/backbone/docs/public/fonts/aller-light.ttf
  87. BIN app/components/backbone/docs/public/fonts/aller-light.woff
  88. BIN app/components/backbone/docs/public/fonts/fleurons.eot
  89. BIN app/components/backbone/docs/public/fonts/fleurons.ttf
  90. BIN app/components/backbone/docs/public/fonts/fleurons.woff
  91. BIN app/components/backbone/docs/public/fonts/novecento-bold.eot
  92. BIN app/components/backbone/docs/public/fonts/novecento-bold.ttf
  93. BIN app/components/backbone/docs/public/fonts/novecento-bold.woff
  94. BIN app/components/backbone/docs/public/images/grey_@2X.png
  95. +375 −0 app/components/backbone/docs/public/stylesheets/normalize.css
  96. +765 −0 app/components/backbone/docs/todos.html
  97. +184 −0 app/components/backbone/examples/backbone.localStorage.js
  98. BIN app/components/backbone/examples/todos/destroy.png
  99. +69 −0 app/components/backbone/examples/todos/index.html
  100. +211 −0 app/components/backbone/examples/todos/todos.css
  101. +234 −0 app/components/backbone/examples/todos/todos.js
  102. +4,438 −0 app/components/backbone/index.html
  103. +1 −0 app/components/backbone/index.js
  104. +20 −0 app/components/backbone/package.json
  105. +1,100 −0 app/components/backbone/test/collection.js
  106. +45 −0 app/components/backbone/test/environment.js
  107. +452 −0 app/components/backbone/test/events.js
  108. +29 −0 app/components/backbone/test/index.html
  109. +43 −0 app/components/backbone/test/model.coffee
  110. +1,102 −0 app/components/backbone/test/model.js
  111. +12 −0 app/components/backbone/test/noconflict.js
  112. +612 −0 app/components/backbone/test/router.js
  113. +212 −0 app/components/backbone/test/sync.js
  114. +9,472 −0 app/components/backbone/test/vendor/jquery.js
  115. +481 −0 app/components/backbone/test/vendor/json2.js
  116. +244 −0 app/components/backbone/test/vendor/qunit.css
  117. +2,152 −0 app/components/backbone/test/vendor/qunit.js
  118. +127 −0 app/components/backbone/test/vendor/runner.js
  119. +1,222 −0 app/components/backbone/test/vendor/underscore.js
  120. +357 −0 app/components/backbone/test/view.js
  121. +14 −0 app/components/jquery/component.json
  122. +26 −0 app/components/jquery/composer.json
  123. +496 −0 app/components/jquery/jquery-migrate.js
  124. +3 −0 app/components/jquery/jquery-migrate.min.js
  125. +9,597 −0 app/components/jquery/jquery.js
  126. +5 −0 app/components/jquery/jquery.min.js
  127. +10 −0 app/components/modernizr/.editorconfig
  128. +2 −0 app/components/modernizr/.gitignore
  129. +6 −0 app/components/modernizr/.travis.yml
  130. +8 −0 app/components/modernizr/component.json
  131. +8 −0 app/components/modernizr/feature-detects/a-download.js
  132. +4 −0 app/components/modernizr/feature-detects/audio-audiodata-api.js
  133. +4 −0 app/components/modernizr/feature-detects/audio-webaudio-api.js
  134. +8 −0 app/components/modernizr/feature-detects/battery-api.js
  135. +11 −0 app/components/modernizr/feature-detects/battery-level.js
  136. +10 −0 app/components/modernizr/feature-detects/blob-constructor.js
  137. +28 −0 app/components/modernizr/feature-detects/canvas-todataurl-type.js
  138. +9 −0 app/components/modernizr/feature-detects/contenteditable.js
  139. +10 −0 app/components/modernizr/feature-detects/contentsecuritypolicy.js
  140. +11 −0 app/components/modernizr/feature-detects/contextmenu.js
  141. +15 −0 app/components/modernizr/feature-detects/cookies.js
  142. +3 −0 app/components/modernizr/feature-detects/cors.js
  143. +19 −0 app/components/modernizr/feature-detects/css-backgroundposition-shorthand.js
  144. +15 −0 app/components/modernizr/feature-detects/css-backgroundposition-xy.js
  145. +31 −0 app/components/modernizr/feature-detects/css-backgroundrepeat.js
  146. +10 −0 app/components/modernizr/feature-detects/css-backgroundsizecover.js
  147. +9 −0 app/components/modernizr/feature-detects/css-boxsizing.js
  148. +12 −0 app/components/modernizr/feature-detects/css-calc.js
  149. +8 −0 app/components/modernizr/feature-detects/css-cubicbezierrange.js
  150. +18 −0 app/components/modernizr/feature-detects/css-displayrunin.js
  151. +27 −0 app/components/modernizr/feature-detects/css-displaytable.js
  152. +7 −0 app/components/modernizr/feature-detects/css-filters.js
  153. +205 −0 app/components/modernizr/feature-detects/css-hyphens.js
  154. +11 −0 app/components/modernizr/feature-detects/css-lastchild.js
  155. +13 −0 app/components/modernizr/feature-detects/css-mask.js
  156. +3 −0 app/components/modernizr/feature-detects/css-mediaqueries.js
  157. +6 −0 app/components/modernizr/feature-detects/css-objectfit.js
  158. +9 −0 app/components/modernizr/feature-detects/css-overflow-scrolling.js
  159. +25 −0 app/components/modernizr/feature-detects/css-pointerevents.js
  160. +13 −0 app/components/modernizr/feature-detects/css-positionsticky.js
  161. +55 −0 app/components/modernizr/feature-detects/css-regions.js
  162. +19 −0 app/components/modernizr/feature-detects/css-remunit.js
  163. +8 −0 app/components/modernizr/feature-detects/css-resize.js
  164. +19 −0 app/components/modernizr/feature-detects/css-scrollbars.js
  165. +23 −0 app/components/modernizr/feature-detects/css-subpixelfont.js
  166. +6 −0 app/components/modernizr/feature-detects/css-supports.js
  167. +10 −0 app/components/modernizr/feature-detects/css-userselect.js
  168. +14 −0 app/components/modernizr/feature-detects/css-vhunit.js
  169. +14 −0 app/components/modernizr/feature-detects/css-vmaxunit.js
  170. +14 −0 app/components/modernizr/feature-detects/css-vminunit.js
  171. +14 −0 app/components/modernizr/feature-detects/css-vwunit.js
  172. +10 −0 app/components/modernizr/feature-detects/custom-protocol-handler.js
  173. +6 −0 app/components/modernizr/feature-detects/dart.js
  174. +4 −0 app/components/modernizr/feature-detects/dataview-api.js
  175. +4 −0 app/components/modernizr/feature-detects/dom-classlist.js
  176. +11 −0 app/components/modernizr/feature-detects/dom-createElement-attrs.js
  177. +9 −0 app/components/modernizr/feature-detects/dom-dataset.js
  178. +4 −0 app/components/modernizr/feature-detects/dom-microdata.js
  179. +12 −0 app/components/modernizr/feature-detects/elem-datalist.js
  180. +25 −0 app/components/modernizr/feature-detects/elem-details.js
  181. +4 −0 app/components/modernizr/feature-detects/elem-output.js
  182. +11 −0 app/components/modernizr/feature-detects/elem-progress-meter.js
  183. +53 −0 app/components/modernizr/feature-detects/elem-ruby.js
  184. +4 −0 app/components/modernizr/feature-detects/elem-time.js
  185. +11 −0 app/components/modernizr/feature-detects/elem-track.js
  186. +11 −0 app/components/modernizr/feature-detects/emoji.js
  187. +7 −0 app/components/modernizr/feature-detects/es5-strictmode.js
  188. +11 −0 app/components/modernizr/feature-detects/event-deviceorientation-motion.js
  189. +32 −0 app/components/modernizr/feature-detects/exif-orientation.js
  190. +12 −0 app/components/modernizr/feature-detects/file-api.js
  191. +9 −0 app/components/modernizr/feature-detects/file-filesystem.js
  192. +13 −0 app/components/modernizr/feature-detects/forms-fileinput.js
  193. +29 −0 app/components/modernizr/feature-detects/forms-formattribute.js
  194. +32 −0 app/components/modernizr/feature-detects/forms-inputnumber-l10n.js
  195. +10 −0 app/components/modernizr/feature-detects/forms-placeholder.js
  196. +19 −0 app/components/modernizr/feature-detects/forms-speechinput.js
  197. +83 −0 app/components/modernizr/feature-detects/forms-validation.js
  198. +10 −0 app/components/modernizr/feature-detects/fullscreen-api.js
  199. +12 −0 app/components/modernizr/feature-detects/gamepad.js
  200. +5 −0 app/components/modernizr/feature-detects/getusermedia.js
  201. +12 −0 app/components/modernizr/feature-detects/ie8compat.js
  202. +5 −0 app/components/modernizr/feature-detects/iframe-sandbox.js
  203. +5 −0 app/components/modernizr/feature-detects/iframe-seamless.js
  204. +5 −0 app/components/modernizr/feature-detects/iframe-srcdoc.js
  205. +26 −0 app/components/modernizr/feature-detects/img-apng.js
  206. +20 −0 app/components/modernizr/feature-detects/img-webp.js
  207. +7 −0 app/components/modernizr/feature-detects/json.js
  208. +6 −0 app/components/modernizr/feature-detects/lists-reversed.js
  209. +23 −0 app/components/modernizr/feature-detects/mathml.js
  210. +22 −0 app/components/modernizr/feature-detects/network-connection.js
  211. +5 −0 app/components/modernizr/feature-detects/network-eventsource.js
  212. +13 −0 app/components/modernizr/feature-detects/network-xhr2.js
  213. +10 −0 app/components/modernizr/feature-detects/notification.js
  214. +5 −0 app/components/modernizr/feature-detects/performance.js
  215. +4 −0 app/components/modernizr/feature-detects/pointerlock-api.js
  216. +11 −0 app/components/modernizr/feature-detects/quota-management-api.js
  217. +7 −0 app/components/modernizr/feature-detects/requestanimationframe.js
  218. +3 −0 app/components/modernizr/feature-detects/script-async.js
  219. +3 −0 app/components/modernizr/feature-detects/script-defer.js
  220. +6 −0 app/components/modernizr/feature-detects/style-scoped.js
  221. +13 −0 app/components/modernizr/feature-detects/svg-filters.js
  222. +32 −0 app/components/modernizr/feature-detects/unicode.js
  223. +26 −0 app/components/modernizr/feature-detects/url-data-uri.js
  224. +7 −0 app/components/modernizr/feature-detects/userdata.js
  225. +4 −0 app/components/modernizr/feature-detects/vibration.js
  226. +6 −0 app/components/modernizr/feature-detects/web-intents.js
  227. +42 −0 app/components/modernizr/feature-detects/webgl-extensions.js
  228. +7 −0 app/components/modernizr/feature-detects/websockets-binary.js
  229. +8 −0 app/components/modernizr/feature-detects/window-framed.js
  230. +48 −0 app/components/modernizr/feature-detects/workers-blobworkers.js
  231. +34 −0 app/components/modernizr/feature-detects/workers-dataworkers.js
  232. +3 −0 app/components/modernizr/feature-detects/workers-sharedworkers.js
  233. +69 −0 app/components/modernizr/grunt.js
  234. +291 −0 app/components/modernizr/media/Modernizr 2 Logo.ai
  235. BIN app/components/modernizr/media/Modernizr 2 Logo.eps
  236. BIN app/components/modernizr/media/Modernizr 2 Logo.pdf
  237. BIN app/components/modernizr/media/Modernizr 2 Logo.png
  238. +35 −0 app/components/modernizr/media/Modernizr 2 Logo.svg
  239. +1,393 −0 app/components/modernizr/modernizr.js
  240. +28 −0 app/components/modernizr/readme.md
  241. +65 −0 app/components/modernizr/test/basic.html
Sorry, we could not display the entire diff because too many files (12,949) changed.
View
BIN .DS_Store
Binary file not shown.
View
3 .bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory": "app/components"
+}
View
21 .editorconfig
@@ -0,0 +1,21 @@
+# EditorConfig helps developers define and maintain consistent
+# coding styles between different editors and IDEs
+# editorconfig.org
+
+root = true
+
+
+[*]
+
+# Change these settings to your own preference
+indent_style = space
+indent_size = 4
+
+# We recommend you to keep these unchanged
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
View
1 .gitattributes
@@ -0,0 +1 @@
+* text=auto
View
3 .gitignore
@@ -11,5 +11,4 @@ pids
logs
results
-node_modules
-npm-debug.log
+npm-debug.log
View
27 .jshintrc
@@ -0,0 +1,27 @@
+{
+ "node": true,
+ "browser": true,
+ "bitwise": true,
+ "forin": true,
+
+ "globalstrict": false,
+ "immed": true,
+
+ "strict": false,
+
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "nonew": true,
+ "sub": true,
+ "undef": true,
+ "boss": true,
+ "eqnull": true,
+ "browser": true,
+ "devel":true,
+ "globals": {
+ "window": true,
+ "define": true,
+ "require": true
+ }
+}
View
5 .tmp/scripts/hello.js
@@ -0,0 +1,5 @@
+(function() {
+
+ console.log("'Allo from CoffeeScript!");
+
+}).call(this);
View
6,800 .tmp/styles/main.css
6,800 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
297 Gruntfile.js
@@ -0,0 +1,297 @@
+// Generated on 2013-03-26 using generator-webapp 0.1.5
+
+var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
+var mountFolder = function (connect, dir) {
+ return connect["static"](require('path').resolve(dir));
+};
+
+// # Globbing
+// for performance reasons we're only matching one level down:
+// 'test/spec/{,*/}*.js'
+// use this if you want to match all subfolders:
+// 'test/spec/**/*.js'
+
+module.exports = function (grunt) {
+ // load all grunt tasks
+ require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
+
+ // configurable paths
+ var yeomanConfig = {
+ app: 'app',
+ dist: 'dist'
+ };
+
+ grunt.initConfig({
+ yeoman: yeomanConfig,
+ watch: {
+ coffee: {
+ files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
+ tasks: ['coffee:dist']
+ },
+ coffeeTest: {
+ files: ['test/spec/{,*/}*.coffee'],
+ tasks: ['coffee:test']
+ },
+ compass: {
+ files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
+ tasks: ['compass']
+ },
+ livereload: {
+ files: [
+ '<%= yeoman.app %>/*.html',
+ '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
+ '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
+ '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,webp}'
+ ],
+ tasks: ['livereload']
+ }
+ },
+ connect: {
+ options: {
+ port: 9000,
+ // change this to '0.0.0.0' to access the server from outside
+ hostname: 'localhost'
+ },
+ livereload: {
+ options: {
+ middleware: function (connect) {
+ return [
+ lrSnippet,
+ mountFolder(connect, '.tmp'),
+ mountFolder(connect, 'app')
+ ];
+ }
+ }
+ },
+ test: {
+ options: {
+ middleware: function (connect) {
+ return [
+ mountFolder(connect, '.tmp'),
+ mountFolder(connect, 'test')
+ ];
+ }
+ }
+ },
+ dist: {
+ options: {
+ middleware: function (connect) {
+ return [
+ mountFolder(connect, 'dist')
+ ];
+ }
+ }
+ }
+ },
+ open: {
+ server: {
+ path: 'http://localhost:<%= connect.options.port %>'
+ }
+ },
+ clean: {
+ dist: ['.tmp', '<%= yeoman.dist %>/*'],
+ server: '.tmp'
+ },
+ jshint: {
+ options: {
+ jshintrc: '.jshintrc'
+ },
+ all: [
+ 'Gruntfile.js',
+ '<%= yeoman.app %>/scripts/{,*/}*.js',
+ '!<%= yeoman.app %>/scripts/vendor/*',
+ 'test/spec/{,*/}*.js'
+ ]
+ },
+ mocha: {
+ all: {
+ options: {
+ run: true,
+ urls: ['http://localhost:<%= connect.options.port %>/index.html']
+ }
+ }
+ },
+ coffee: {
+ dist: {
+ files: [{
+ // rather than compiling multiple files here you should
+ // require them into your main .coffee file
+ expand: true,
+ cwd: '<%= yeoman.app %>/scripts',
+ src: '*.coffee',
+ dest: '.tmp/scripts',
+ ext: '.js'
+ }]
+ },
+ test: {
+ files: [{
+ expand: true,
+ cwd: '.tmp/spec',
+ src: '*.coffee',
+ dest: 'test/spec'
+ }]
+ }
+ },
+ compass: {
+ options: {
+ sassDir: '<%= yeoman.app %>/styles',
+ cssDir: '.tmp/styles',
+ imagesDir: '<%= yeoman.app %>/images',
+ javascriptsDir: '<%= yeoman.app %>/scripts',
+ fontsDir: '<%= yeoman.app %>/styles/fonts',
+ importPath: 'app/components',
+ relativeAssets: true
+ },
+ dist: {},
+ server: {
+ options: {
+ debugInfo: true
+ }
+ }
+ },
+ // not used since Uglify task does concat,
+ // but still available if needed
+ /*concat: {
+ dist: {}
+ },*/
+ requirejs: {
+ dist: {
+ // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
+ options: {
+ // `name` and `out` is set by grunt-usemin
+ baseUrl: 'app/scripts',
+ optimize: 'none',
+ // TODO: Figure out how to make sourcemaps work with grunt-usemin
+ // https://github.com/yeoman/grunt-usemin/issues/30
+ //generateSourceMaps: true,
+ // required to support SourceMaps
+ // http://requirejs.org/docs/errors.html#sourcemapcomments
+ preserveLicenseComments: false,
+ useStrict: true,
+ wrap: true
+ //uglify2: {} // https://github.com/mishoo/UglifyJS2
+ }
+ }
+ },
+ useminPrepare: {
+ html: '<%= yeoman.app %>/index.html',
+ options: {
+ dest: '<%= yeoman.dist %>'
+ }
+ },
+ usemin: {
+ html: ['<%= yeoman.dist %>/{,*/}*.html'],
+ css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
+ options: {
+ dirs: ['<%= yeoman.dist %>']
+ }
+ },
+ imagemin: {
+ dist: {
+ files: [{
+ expand: true,
+ cwd: '<%= yeoman.app %>/images',
+ src: '{,*/}*.{png,jpg,jpeg}',
+ dest: '<%= yeoman.dist %>/images'
+ }]
+ }
+ },
+ cssmin: {
+ dist: {
+ files: {
+ '<%= yeoman.dist %>/styles/main.css': [
+ '.tmp/styles/{,*/}*.css',
+ '<%= yeoman.app %>/styles/{,*/}*.css'
+ ]
+ }
+ }
+ },
+ htmlmin: {
+ dist: {
+ options: {
+ /*removeCommentsFromCDATA: true,
+ // https://github.com/yeoman/grunt-usemin/issues/44
+ //collapseWhitespace: true,
+ collapseBooleanAttributes: true,
+ removeAttributeQuotes: true,
+ removeRedundantAttributes: true,
+ useShortDoctype: true,
+ removeEmptyAttributes: true,
+ removeOptionalTags: true*/
+ },
+ files: [{
+ expand: true,
+ cwd: '<%= yeoman.app %>',
+ src: '*.html',
+ dest: '<%= yeoman.dist %>'
+ }]
+ }
+ },
+ copy: {
+ dist: {
+ files: [{
+ expand: true,
+ dot: true,
+ cwd: '<%= yeoman.app %>',
+ dest: '<%= yeoman.dist %>',
+ src: [
+ '*.{ico,txt}',
+ '.htaccess'
+ ]
+ }]
+ }
+ },
+ bower: {
+ all: {
+ rjsConfig: '<%= yeoman.app %>/scripts/main.js'
+ }
+ }
+ });
+
+ grunt.renameTask('regarde', 'watch');
+
+ grunt.registerTask('server', function (target) {
+ if (target === 'dist') {
+ return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
+ }
+
+ grunt.task.run([
+ 'clean:server',
+ 'coffee:dist',
+ 'compass:server',
+ 'livereload-start',
+ 'connect:livereload',
+ 'open',
+ 'watch'
+ ]);
+ });
+
+ grunt.registerTask('test', [
+ 'clean:server',
+ 'coffee',
+ 'compass',
+ 'connect:test',
+ 'mocha'
+ ]);
+
+ grunt.registerTask('build', [
+ 'clean:dist',
+ 'coffee',
+ 'compass:dist',
+ 'useminPrepare',
+ 'requirejs',
+ 'imagemin',
+ 'htmlmin',
+ 'concat',
+ 'cssmin',
+ 'uglify',
+ 'copy',
+ 'usemin'
+ ]);
+
+ grunt.registerTask('default', [
+ 'jshint',
+ 'test',
+ 'build'
+ ]);
+};
View
268 README
@@ -0,0 +1,268 @@
+backbone-simpleapp-kitlers
+==========================
+
+A very simple Backbone.js demo app I first live-coded in 10 minutes at ParisJS #18. Features face detection of Kitlers!
+
+For more on Kitlers:
+http://www.catsthatlooklikehitler.com/
+
+The code was updated for a new livecoding session at DevoxxFR 2013 where I started over with yeoman & requireJS.
+
+
+How to run
+==========
+
+$ npm install -g yo grunt-cli bower
+$ grunt server
+
+You can then use the global variable R from the console like I did on stage to test some calls on the main KitlerDB View.
+
+Sample call:
+
+R.klv.col.at(2).set("name", "Jean-Emarre");
+
+
+
+How to reproduce for livecoding
+===============================
+
+Explain yeoman and scaffolding
+
+$ yo webapp
+
+Explain bower & dependencies
+
+$ npm install && bower install
+
+$ Copy static files in app/ (images & kitlers.json)
+
+WTF
+
+$ ln -s Gruntfile.js grunt.js
+
+Showcase grunt jshint, grunt test
+
+$ grunt server
+
+demo livereload
+
+
+paste html:
+
+
+
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="brand" href="#">Backbone Live Code</a>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li><a href="#">Home</a></li>
+ <li><a href="#kitlers">KitlerDB</a></li>
+ <li><a href="https://github.com/sylvinus/backbone-simpleapp-kitlers">GitHub</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="container" style="padding-top: 60px;">
+
+ <div class="page" id="page_home">
+ Welcome!
+ </div>
+
+ <ul class="page" id="page_list">
+
+ </ul>
+
+ </div>
+
+ <script type="text/template" id="kitemplate">
+ <li class='thumbnail span3'>
+ <img src='<%= m.get("url") %>'/>
+ <div class='caption'><%= m.get("name") %></div>
+ <button class="btn detect">Detect</button>
+ </li>
+ </script>
+
+
+
+
+explain requirejs
+
+
+paste main.js
+
+
+
+require.config({
+ paths: {
+ jquery: '../components/jquery/jquery',
+ backbone: '../components/backbone/backbone',
+ underscore: '../components/underscore/underscore',
+ bootstrap: 'vendor/bootstrap'
+ },
+ shim: {
+ bootstrap: {
+ deps: ['jquery'],
+ exports: 'jquery'
+ },
+ backbone: {
+ deps: ['underscore'],
+ exports: 'Backbone'
+ },
+ underscore: {
+ deps: [''],
+ exports: '_'
+ }
+ }
+});
+
+
+then
+
+
+ $(function() {
+ window.R = new Router();
+ window.R.start();
+ });
+
+
+paster router :
+
+
+define(["backbone", "jquery", "views/kitlers"], function (Backbone, $, KitlersView) {
+
+ return Backbone.Router.extend({
+
+ routes: {
+ "":"home",
+ "kitlers":"list"
+ },
+
+ changePage:function(id) {
+ $(".page").hide();
+ $("#page_"+id).show();
+ },
+
+ home:function() {
+ this.changePage("home");
+ },
+
+ list:function() {
+ this.changePage("list");
+ this.klv = new KitlersView();
+ },
+
+ start:function() {
+ Backbone.history.start();
+ }
+
+ });
+});
+
+
+
+
+
+paste base view:
+
+
+
+
+define(["backbone", "jquery", "underscore", "collections/kitlers"], function (Backbone, $, _, KitlersCol) {
+
+ return Backbone.View.extend({
+ el:"#page_list",
+
+ _itemTpl:_.template($("#kitemplate").html()),
+
+ events:{
+ },
+
+ initialize:function() {
+
+ this.col = new KitlersCol();
+
+ this.col.on("all",this.render,this);
+
+ this.col.fetch();
+
+ },
+
+ render:function() {
+ this.$el.html(
+ this.col.map(function(k) {
+ return this._itemTpl({"m":k});
+ },this).join("")
+ );
+ }
+ });
+});
+
+
+
+
+paste base collection:
+
+
+define(["backbone", "models/kitler"], function (Backbone, KitlerModel) {
+
+ return Backbone.Collection.extend({
+ model:KitlerModel,
+ url:"/kitlers.json"
+ });
+});
+
+
+
+
+paste base model:
+
+
+define(["backbone"], function (Backbone) {
+
+ return Backbone.Model.extend({
+ shout:function() {
+ alert(this.get("name"));
+ }
+ });
+});
+
+
+then play with the app via chrome console
+
+collection.pop()
+model.get, set, save, shout
+
+
+
+BONUS: Kitler face detection!
+
+
+face.js in app/scripts/vendor + requirejs conf + require()
+
+Add this to the model and then play with the buttons:
+
+ detect:function(evt) {
+ var img = $("img",$(evt.target).parent());
+ var coordinates = img.faceDetection();
+
+ if(coordinates.length) {
+ coordinates.forEach(function(coord) {
+
+ $("<div>", {
+ css: {
+ position: "absolute",
+ left: coord.positionX - 5 + parseInt(img.css("margin-left"),10) + "px",
+ top: coord.positionY - 5 + "px",
+ width: coord.width + "px",
+ height: coord.height + "px",
+ border: "3px solid red"
+ }
+ }).appendTo(img.parent());
+ });
+ }
+ }
+
View
15 README.md
@@ -1,15 +0,0 @@
-backbone-simpleapp-kitlers
-==========================
-
-A very simple Backbone.js demo app I live-coded in 10 minutes at ParisJS #18. Features face detection of Kitlers!
-
-How to run:
-
-$ npm install express request
-(yes I didn't bother to do a package.json)
-
-$ node backend/app.js
-
-Then browse to http://localhost:3000 and enjoy some kitlers
-
-You can then use the global variable KLV from the console like I did on stage to test some calls on the main KitlerDB View.
View
543 app/.htaccess
@@ -0,0 +1,543 @@
+# Apache configuration file
+# httpd.apache.org/docs/2.2/mod/quickreference.html
+
+# Note .htaccess files are an overhead, this logic should be in your Apache
+# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
+
+# Techniques in here adapted from all over, including:
+# Kroc Camen: camendesign.com/.htaccess
+# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
+# Sample .htaccess file of CMS MODx: modxcms.com
+
+
+# ----------------------------------------------------------------------
+# Better website experience for IE users
+# ----------------------------------------------------------------------
+
+# Force the latest IE version, in various cases when it may fall back to IE7 mode
+# github.com/rails/rails/commit/123eb25#commitcomment-118920
+# Use ChromeFrame if it's installed for a better experience for the poor IE folk
+
+<IfModule mod_headers.c>
+ Header set X-UA-Compatible "IE=Edge,chrome=1"
+ # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
+ <FilesMatch "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
+ Header unset X-UA-Compatible
+ </FilesMatch>
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Cross-domain AJAX requests
+# ----------------------------------------------------------------------
+
+# Serve cross-domain Ajax requests, disabled by default.
+# enable-cors.org
+# code.google.com/p/html5security/wiki/CrossOriginRequestSecurity
+
+# <IfModule mod_headers.c>
+# Header set Access-Control-Allow-Origin "*"
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# CORS-enabled images (@crossorigin)
+# ----------------------------------------------------------------------
+
+# Send CORS headers if browsers request them; enabled by default for images.
+# developer.mozilla.org/en/CORS_Enabled_Image
+# blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
+# hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
+# wiki.mozilla.org/Security/Reviews/crossoriginAttribute
+
+<IfModule mod_setenvif.c>
+ <IfModule mod_headers.c>
+ # mod_headers, y u no match by Content-Type?!
+ <FilesMatch "\.(gif|ico|jpe?g|png|svg|svgz|webp)$">
+ SetEnvIf Origin ":" IS_CORS
+ Header set Access-Control-Allow-Origin "*" env=IS_CORS
+ </FilesMatch>
+ </IfModule>
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Webfont access
+# ----------------------------------------------------------------------
+
+# Allow access from all domains for webfonts.
+# Alternatively you could only whitelist your
+# subdomains like "subdomain.example.com".
+
+<IfModule mod_headers.c>
+ <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
+ Header set Access-Control-Allow-Origin "*"
+ </FilesMatch>
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Proper MIME type for all files
+# ----------------------------------------------------------------------
+
+# JavaScript
+# Normalize to standard type (it's sniffed in IE anyways)
+# tools.ietf.org/html/rfc4329#section-7.2
+AddType application/javascript js jsonp
+AddType application/json json
+
+# Audio
+AddType audio/mp4 m4a f4a f4b
+AddType audio/ogg oga ogg
+
+# Video
+AddType video/mp4 mp4 m4v f4v f4p
+AddType video/ogg ogv
+AddType video/webm webm
+AddType video/x-flv flv
+
+# SVG
+# Required for svg webfonts on iPad
+# twitter.com/FontSquirrel/status/14855840545
+AddType image/svg+xml svg svgz
+AddEncoding gzip svgz
+
+# Webfonts
+AddType application/vnd.ms-fontobject eot
+AddType application/x-font-ttf ttf ttc
+AddType application/x-font-woff woff
+AddType font/opentype otf
+
+# Assorted types
+AddType application/octet-stream safariextz
+AddType application/x-chrome-extension crx
+AddType application/x-opera-extension oex
+AddType application/x-shockwave-flash swf
+AddType application/x-web-app-manifest+json webapp
+AddType application/x-xpinstall xpi
+AddType application/xml rss atom xml rdf
+AddType image/webp webp
+AddType image/x-icon ico
+AddType text/cache-manifest appcache manifest
+AddType text/vtt vtt
+AddType text/x-component htc
+AddType text/x-vcard vcf
+
+
+# ----------------------------------------------------------------------
+# Allow concatenation from within specific js and css files
+# ----------------------------------------------------------------------
+
+# e.g. Inside of script.combined.js you could have
+# <!--#include file="libs/jquery-1.5.0.min.js" -->
+# <!--#include file="plugins/jquery.idletimer.js" -->
+# and they would be included into this single file.
+
+# This is not in use in the boilerplate as it stands. You may
+# choose to use this technique if you do not have a build process.
+
+#<FilesMatch "\.combined\.js$">
+# Options +Includes
+# AddOutputFilterByType INCLUDES application/javascript application/json
+# SetOutputFilter INCLUDES
+#</FilesMatch>
+
+#<FilesMatch "\.combined\.css$">
+# Options +Includes
+# AddOutputFilterByType INCLUDES text/css
+# SetOutputFilter INCLUDES
+#</FilesMatch>
+
+
+# ----------------------------------------------------------------------
+# Gzip compression
+# ----------------------------------------------------------------------
+
+<IfModule mod_deflate.c>
+
+ # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
+ <IfModule mod_setenvif.c>
+ <IfModule mod_headers.c>
+ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
+ RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
+ </IfModule>
+ </IfModule>
+
+ # Compress all output labeled with one of the following MIME-types
+ # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
+ # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines as
+ # `AddOutputFilterByType` is still in the core directives)
+ <IfModule mod_filter.c>
+ AddOutputFilterByType DEFLATE application/atom+xml \
+ application/javascript \
+ application/json \
+ application/rss+xml \
+ application/vnd.ms-fontobject \
+ application/x-font-ttf \
+ application/xhtml+xml \
+ application/xml \
+ font/opentype \
+ image/svg+xml \
+ image/x-icon \
+ text/css \
+ text/html \
+ text/plain \
+ text/x-component \
+ text/xml
+ </IfModule>
+
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Expires headers (for better cache control)
+# ----------------------------------------------------------------------
+
+# These are pretty far-future expires headers.
+# They assume you control versioning with filename-based cache busting
+# Additionally, consider that outdated proxies may miscache
+# www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
+
+# If you don't use filenames to version, lower the CSS and JS to something like
+# "access plus 1 week".
+
+<IfModule mod_expires.c>
+ ExpiresActive on
+
+# Perhaps better to whitelist expires rules? Perhaps.
+ ExpiresDefault "access plus 1 month"
+
+# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
+ ExpiresByType text/cache-manifest "access plus 0 seconds"
+
+# Your document html
+ ExpiresByType text/html "access plus 0 seconds"
+
+# Data
+ ExpiresByType application/json "access plus 0 seconds"
+ ExpiresByType application/xml "access plus 0 seconds"
+ ExpiresByType text/xml "access plus 0 seconds"
+
+# Feed
+ ExpiresByType application/atom+xml "access plus 1 hour"
+ ExpiresByType application/rss+xml "access plus 1 hour"
+
+# Favicon (cannot be renamed)
+ ExpiresByType image/x-icon "access plus 1 week"
+
+# Media: images, video, audio
+ ExpiresByType audio/ogg "access plus 1 month"
+ ExpiresByType image/gif "access plus 1 month"
+ ExpiresByType image/jpeg "access plus 1 month"
+ ExpiresByType image/png "access plus 1 month"
+ ExpiresByType video/mp4 "access plus 1 month"
+ ExpiresByType video/ogg "access plus 1 month"
+ ExpiresByType video/webm "access plus 1 month"
+
+# HTC files (css3pie)
+ ExpiresByType text/x-component "access plus 1 month"
+
+# Webfonts
+ ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
+ ExpiresByType application/x-font-ttf "access plus 1 month"
+ ExpiresByType application/x-font-woff "access plus 1 month"
+ ExpiresByType font/opentype "access plus 1 month"
+ ExpiresByType image/svg+xml "access plus 1 month"
+
+# CSS and JavaScript
+ ExpiresByType application/javascript "access plus 1 year"
+ ExpiresByType text/css "access plus 1 year"
+
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Prevent mobile network providers from modifying your site
+# ----------------------------------------------------------------------
+
+# The following header prevents modification of your code over 3G on some
+# European providers.
+# This is the official 'bypass' suggested by O2 in the UK.
+
+# <IfModule mod_headers.c>
+# Header set Cache-Control "no-transform"
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# ETag removal
+# ----------------------------------------------------------------------
+
+# FileETag None is not enough for every server.
+<IfModule mod_headers.c>
+ Header unset ETag
+</IfModule>
+
+# Since we're sending far-future expires, we don't need ETags for
+# static content.
+# developer.yahoo.com/performance/rules.html#etags
+FileETag None
+
+
+# ----------------------------------------------------------------------
+# Stop screen flicker in IE on CSS rollovers
+# ----------------------------------------------------------------------
+
+# The following directives stop screen flicker in IE on CSS rollovers - in
+# combination with the "ExpiresByType" rules for images (see above).
+
+# BrowserMatch "MSIE" brokenvary=1
+# BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
+# BrowserMatch "Opera" !brokenvary
+# SetEnvIf brokenvary 1 force-no-vary
+
+
+# ----------------------------------------------------------------------
+# Set Keep-Alive Header
+# ----------------------------------------------------------------------
+
+# Keep-Alive allows the server to send multiple requests through one
+# TCP-connection. Be aware of possible disadvantages of this setting. Turn on
+# if you serve a lot of static content.
+
+# <IfModule mod_headers.c>
+# Header set Connection Keep-Alive
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Cookie setting from iframes
+# ----------------------------------------------------------------------
+
+# Allow cookies to be set from iframes (for IE only)
+# If needed, specify a path or regex in the Location directive.
+
+# <IfModule mod_headers.c>
+# Header set P3P "policyref=\"/w3c/p3p.xml\", CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\""
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Start rewrite engine
+# ----------------------------------------------------------------------
+
+# Turning on the rewrite engine is necessary for the following rules and
+# features. FollowSymLinks must be enabled for this to work.
+
+# Some cloud hosting services require RewriteBase to be set: goo.gl/HOcPN
+# If using the h5bp in a subdirectory, use `RewriteBase /foo` instead where
+# 'foo' is your directory.
+
+# If your web host doesn't allow the FollowSymlinks option, you may need to
+# comment it out and use `Options +SymLinksIfOwnerMatch`, but be aware of the
+# performance impact: http://goo.gl/Mluzd
+
+<IfModule mod_rewrite.c>
+ Options +FollowSymlinks
+# Options +SymLinksIfOwnerMatch
+ RewriteEngine On
+# RewriteBase /
+</IfModule>
+
+
+# ----------------------------------------------------------------------
+# Suppress or force the "www." at the beginning of URLs
+# ----------------------------------------------------------------------
+
+# The same content should never be available under two different URLs -
+# especially not with and without "www." at the beginning, since this can cause
+# SEO problems (duplicate content). That's why you should choose one of the
+# alternatives and redirect the other one.
+
+# By default option 1 (no "www.") is activated.
+# no-www.org/faq.php?q=class_b
+
+# If you'd prefer to use option 2, just comment out all option 1 lines
+# and uncomment option 2.
+
+# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
+
+# ----------------------------------------------------------------------
+
+# Option 1:
+# Rewrite "www.example.com -> example.com".
+
+<IfModule mod_rewrite.c>
+ RewriteCond %{HTTPS} !=on
+ RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
+ RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
+</IfModule>
+
+# ----------------------------------------------------------------------
+
+# Option 2:
+# Rewrite "example.com -> www.example.com".
+# Be aware that the following rule might not be a good idea if you use "real"
+# subdomains for certain parts of your website.
+
+# <IfModule mod_rewrite.c>
+# RewriteCond %{HTTPS} !=on
+# RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
+# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Built-in filename-based cache busting
+# ----------------------------------------------------------------------
+
+# If you're not using the build script to manage your filename version revving,
+# you might want to consider enabling this, which will route requests for
+# `/css/style.20110203.css` to `/css/style.css`.
+
+# To understand why this is important and a better idea than all.css?v1231,
+# please refer to the bundled documentation about `.htaccess`.
+
+# <IfModule mod_rewrite.c>
+# RewriteCond %{REQUEST_FILENAME} !-f
+# RewriteCond %{REQUEST_FILENAME} !-d
+# RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Prevent SSL cert warnings
+# ----------------------------------------------------------------------
+
+# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
+# https://www.example.com when your cert only allows https://secure.example.com
+
+# <IfModule mod_rewrite.c>
+# RewriteCond %{SERVER_PORT} !^443
+# RewriteRule ^ https://example-domain-please-change-me.com%{REQUEST_URI} [R=301,L]
+# </IfModule>
+
+
+# ----------------------------------------------------------------------
+# Prevent 404 errors for non-existing redirected folders
+# ----------------------------------------------------------------------
+
+# without -MultiViews, Apache will give a 404 for a rewrite if a folder of the
+# same name does not exist.
+# webmasterworld.com/apache/3808792.htm
+
+Options -MultiViews
+
+
+# ----------------------------------------------------------------------
+# Custom 404 page
+# ----------------------------------------------------------------------
+
+# You can add custom pages to handle 500 or 403 pretty easily, if you like.
+# If you are hosting your site in subdirectory, adjust this accordingly
+# e.g. ErrorDocument 404 /subdir/404.html
+ErrorDocument 404 /404.html
+
+
+# ----------------------------------------------------------------------
+# UTF-8 encoding
+# ----------------------------------------------------------------------
+
+# Use UTF-8 encoding for anything served text/plain or text/html
+AddDefaultCharset utf-8
+
+# Force UTF-8 for a number of file formats
+AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
+
+
+# ----------------------------------------------------------------------
+# A little more security
+# ----------------------------------------------------------------------
+
+# To avoid displaying the exact version number of Apache being used, add the
+# following to httpd.conf (it will not work in .htaccess):
+# ServerTokens Prod
+
+# "-Indexes" will have Apache block users from browsing folders without a
+# default document Usually you should leave this activated, because you
+# shouldn't allow everybody to surf through every folder on your server (which
+# includes rather private places like CMS system folders).
+<IfModule mod_autoindex.c>
+ Options -Indexes
+</IfModule>
+
+# Block access to "hidden" directories or files whose names begin with a
+# period. This includes directories used by version control systems such as
+# Subversion or Git.
+<IfModule mod_rewrite.c>
+ RewriteCond %{SCRIPT_FILENAME} -d [OR]
+ RewriteCond %{SCRIPT_FILENAME} -f
+ RewriteRule "(^|/)\." - [F]
+</IfModule>
+
+# Block access to backup and source files. These files may be left by some
+# text/html editors and pose a great security danger, when anyone can access
+# them.
+<FilesMatch "(\.(bak|config|dist|fla|inc|ini|log|psd|sh|sql|swp)|~)$">
+ Order allow,deny
+ Deny from all
+ Satisfy All
+</FilesMatch>
+
+# If your server is not already configured as such, the following directive
+# should be uncommented in order to set PHP's register_globals option to OFF.
+# This closes a major security hole that is abused by most XSS (cross-site
+# scripting) attacks. For more information: http://php.net/register_globals
+#
+# IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS:
+#
+# Your server does not allow PHP directives to be set via .htaccess. In that
+# case you must make this change in your php.ini file instead. If you are
+# using a commercial web host, contact the administrators for assistance in
+# doing this. Not all servers allow local php.ini files, and they should
+# include all PHP configurations (not just this one), or you will effectively
+# reset everything to PHP defaults. Consult www.php.net for more detailed
+# information about setting PHP directives.
+
+# php_flag register_globals Off
+
+# Rename session cookie to something else, than PHPSESSID
+# php_value session.name sid
+
+# Disable magic quotes (This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.)
+# php_flag magic_quotes_gpc Off
+
+# Do not show you are using PHP
+# Note: Move this line to php.ini since it won't work in .htaccess
+# php_flag expose_php Off
+
+# Level of log detail - log all errors
+# php_value error_reporting -1
+
+# Write errors to log file
+# php_flag log_errors On
+
+# Do not display errors in browser (production - Off, development - On)
+# php_flag display_errors Off
+
+# Do not display startup errors (production - Off, development - On)
+# php_flag display_startup_errors Off
+
+# Format errors in plain text
+# Note: Leave this setting 'On' for xdebug's var_dump() output
+# php_flag html_errors Off
+
+# Show multiple occurrence of error
+# php_flag ignore_repeated_errors Off
+
+# Show same errors from different sources
+# php_flag ignore_repeated_source Off
+
+# Size limit for error messages
+# php_value log_errors_max_len 1024
+
+# Don't precede error with string (doesn't accept empty string, use whitespace if you need)
+# php_value error_prepend_string " "
+
+# Don't prepend to error (doesn't accept empty string, use whitespace if you need)
+# php_value error_append_string " "
+
+# Increase cookie security
+<IfModule mod_php5.c>
+ php_value session.cookie_httponly true
+</IfModule>
View
157 app/404.html
@@ -0,0 +1,157 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Page Not Found :(</title>
+ <style>
+ ::-moz-selection {
+ background: #b3d4fc;
+ text-shadow: none;
+ }
+
+ ::selection {
+ background: #b3d4fc;
+ text-shadow: none;
+ }
+
+ html {
+ padding: 30px 10px;
+ font-size: 20px;
+ line-height: 1.4;
+ color: #737373;
+ background: #f0f0f0;
+ -webkit-text-size-adjust: 100%;
+ -ms-text-size-adjust: 100%;
+ }
+
+ html,
+ input {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ }
+
+ body {
+ max-width: 500px;
+ _width: 500px;
+ padding: 30px 20px 50px;
+ border: 1px solid #b3b3b3;
+ border-radius: 4px;
+ margin: 0 auto;
+ box-shadow: 0 1px 10px #a7a7a7, inset 0 1px 0 #fff;
+ background: #fcfcfc;
+ }
+
+ h1 {
+ margin: 0 10px;
+ font-size: 50px;
+ text-align: center;
+ }
+
+ h1 span {
+ color: #bbb;
+ }
+
+ h3 {
+ margin: 1.5em 0 0.5em;
+ }
+
+ p {
+ margin: 1em 0;
+ }
+
+ ul {
+ padding: 0 0 0 40px;
+ margin: 1em 0;
+ }
+
+ .container {
+ max-width: 380px;
+ _width: 380px;
+ margin: 0 auto;
+ }
+
+ /* google search */
+
+ #goog-fixurl ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ }
+
+ #goog-fixurl form {
+ margin: 0;
+ }
+
+ #goog-wm-qt,
+ #goog-wm-sb {
+ border: 1px solid #bbb;
+ font-size: 16px;
+ line-height: normal;
+ vertical-align: top;
+ color: #444;
+ border-radius: 2px;
+ }
+
+ #goog-wm-qt {
+ width: 220px;
+ height: 20px;
+ padding: 5px;
+ margin: 5px 10px 0 0;
+ box-shadow: inset 0 1px 1px #ccc;
+ }
+
+ #goog-wm-sb {
+ display: inline-block;
+ height: 32px;
+ padding: 0 10px;
+ margin: 5px 0 0;
+ white-space: nowrap;
+ cursor: pointer;
+ background-color: #f5f5f5;
+ background-image: -webkit-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -moz-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -ms-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -o-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ *overflow: visible;
+ *display: inline;
+ *zoom: 1;
+ }
+
+ #goog-wm-sb:hover,
+ #goog-wm-sb:focus {
+ border-color: #aaa;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
+ background-color: #f8f8f8;
+ }
+
+ #goog-wm-qt:hover,
+ #goog-wm-qt:focus {
+ border-color: #105cb6;
+ outline: 0;
+ color: #222;
+ }
+
+ input::-moz-focus-inner {
+ padding: 0;
+ border: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="container">
+ <h1>Not found <span>:(</span></h1>
+ <p>Sorry, but the page you were trying to view does not exist.</p>
+ <p>It looks like this was the result of either:</p>
+ <ul>
+ <li>a mistyped address</li>
+ <li>an out-of-date link</li>
+ </ul>
+ <script>
+ var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),GOOG_FIXURL_SITE = location.host;
+ </script>
+ <script src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
+ </div>
+ </body>
+</html>
View
4 app/components/backbone/.gitignore
@@ -0,0 +1,4 @@
+raw
+*.sw?
+.DS_Store
+node_modules
View
7 app/components/backbone/.npmignore
@@ -0,0 +1,7 @@
+test/
+Rakefile
+docs/
+raw/
+examples/
+index.html
+.jshintrc
View
5 app/components/backbone/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - 0.8
+notifications:
+ email: false
View
2 app/components/backbone/CNAME
@@ -0,0 +1,2 @@
+backbonejs.org
+
View
17 app/components/backbone/CONTRIBUTING.md
@@ -0,0 +1,17 @@
+## How to contribute to Backbone.js
+
+* Before you open a ticket or send a pull request,
+[search](https://github.com/documentcloud/backbone/issues) for previous
+discussions about the same feature or issue. Add to the earlier ticket if you
+find one.
+
+* Before sending a pull request for a feature or bug fix, be sure to have
+[tests](http://backbonejs.org/test/test.html).
+
+* Use the same coding style as the rest of the
+[codebase](https://github.com/documentcloud/backbone/blob/master/backbone.js).
+
+* In your pull request, do not add documentation or rebuild the minified
+`backbone-min.js` file. We'll do that before cutting a new release.
+
+* All pull requests should be made to the `master` branch.
View
22 app/components/backbone/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2010-2013 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.
View
26 app/components/backbone/README.md
@@ -0,0 +1,26 @@
+ ____ __ __
+ /\ _`\ /\ \ /\ \ __
+ \ \ \ \ \ __ ___\ \ \/'\\ \ \____ ___ ___ __ /\_\ ____
+ \ \ _ <' /'__`\ /'___\ \ , < \ \ '__`\ / __`\ /' _ `\ /'__`\ \/\ \ /',__\
+ \ \ \ \ \/\ \ \.\_/\ \__/\ \ \\`\\ \ \ \ \/\ \ \ \/\ \/\ \/\ __/ __ \ \ \/\__, `\
+ \ \____/\ \__/.\_\ \____\\ \_\ \_\ \_,__/\ \____/\ \_\ \_\ \____\/\_\_\ \ \/\____/
+ \/___/ \/__/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/_/\/_/\/____/\/_/\ \_\ \/___/
+ \ \____/
+ \/___/
+ (_'_______________________________________________________________________________'_)
+ (_.———————————————————————————————————————————————————————————————————————————————._)
+
+
+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, pre-packed downloads, and everything else, really, see:
+http://backbonejs.org
+
+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
View
24 app/components/backbone/Rakefile
@@ -0,0 +1,24 @@
+desc "rebuild the backbone-min.js files for distribution"
+task :build do
+ check 'uglifyjs', 'UglifyJS', 'https://github.com/mishoo/UglifyJS2'
+ system 'uglifyjs backbone.js --source-map backbone-min.map -o backbone-min.js'
+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
+ check 'jsl', 'JavaScript Lint', 'http://www.javascriptlint.com/'
+ system "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
+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
View
4 app/components/backbone/backbone-min.js
@@ -0,0 +1,4 @@
+(function(){var root=this;var previousBackbone=root.Backbone;var array=[];var push=array.push;var slice=array.slice;var splice=array.splice;var Backbone;if(typeof exports!=="undefined"){Backbone=exports}else{Backbone=root.Backbone={}}Backbone.VERSION="1.0.0";var _=root._;if(!_&&typeof require!=="undefined")_=require("underscore");Backbone.$=root.jQuery||root.Zepto||root.ender||root.$;Backbone.noConflict=function(){root.Backbone=previousBackbone;return this};Backbone.emulateHTTP=false;Backbone.emulateJSON=false;var Events=Backbone.Events={on:function(name,callback,context){if(!eventsApi(this,"on",name,[callback,context])||!callback)return this;this._events||(this._events={});var events=this._events[name]||(this._events[name]=[]);events.push({callback:callback,context:context,ctx:context||this});return this},once:function(name,callback,context){if(!eventsApi(this,"once",name,[callback,context])||!callback)return this;var self=this;var once=_.once(function(){self.off(name,once);callback.apply(this,arguments)});once._callback=callback;return this.on(name,once,context)},off:function(name,callback,context){var retain,ev,events,names,i,l,j,k;if(!this._events||!eventsApi(this,"off",name,[callback,context]))return this;if(!name&&!callback&&!context){this._events={};return this}names=name?[name]:_.keys(this._events);for(i=0,l=names.length;i<l;i++){name=names[i];if(events=this._events[name]){this._events[name]=retain=[];if(callback||context){for(j=0,k=events.length;j<k;j++){ev=events[j];if(callback&&callback!==ev.callback&&callback!==ev.callback._callback||context&&context!==ev.context){retain.push(ev)}}}if(!retain.length)delete this._events[name]}}return this},trigger:function(name){if(!this._events)return this;var args=slice.call(arguments,1);if(!eventsApi(this,"trigger",name,args))return this;var events=this._events[name];var allEvents=this._events.all;if(events)triggerEvents(events,args);if(allEvents)triggerEvents(allEvents,arguments);return this},stopListening:function(obj,name,callback){var listeners=this._listeners;if(!listeners)return this;var deleteListener=!name&&!callback;if(typeof name==="object")callback=this;if(obj)(listeners={})[obj._listenerId]=obj;for(var id in listeners){listeners[id].off(name,callback,this);if(deleteListener)delete this._listeners[id]}return this}};var eventSplitter=/\s+/;var eventsApi=function(obj,action,name,rest){if(!name)return true;if(typeof name==="object"){for(var key in name){obj[action].apply(obj,[key,name[key]].concat(rest))}return false}if(eventSplitter.test(name)){var names=name.split(eventSplitter);for(var i=0,l=names.length;i<l;i++){obj[action].apply(obj,[names[i]].concat(rest))}return false}return true};var triggerEvents=function(events,args){var ev,i=-1,l=events.length,a1=args[0],a2=args[1],a3=args[2];switch(args.length){case 0:while(++i<l)(ev=events[i]).callback.call(ev.ctx);return;case 1:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1);return;case 2:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2);return;case 3:while(++i<l)(ev=events[i]).callback.call(ev.ctx,a1,a2,a3);return;default:while(++i<l)(ev=events[i]).callback.apply(ev.ctx,args)}};var listenMethods={listenTo:"on",listenToOnce:"once"};_.each(listenMethods,function(implementation,method){Events[method]=function(obj,name,callback){var listeners=this._listeners||(this._listeners={});var id=obj._listenerId||(obj._listenerId=_.uniqueId("l"));listeners[id]=obj;if(typeof name==="object")callback=this;obj[implementation](name,callback,this);return this}});Events.bind=Events.on;Events.unbind=Events.off;_.extend(Backbone,Events);var Model=Backbone.Model=function(attributes,options){var defaults;var attrs=attributes||{};options||(options={});this.cid=_.uniqueId("c");this.attributes={};_.extend(this,_.pick(options,modelOptions));if(options.parse)attrs=this.parse(attrs,options)||{};if(defaults=_.result(this,"defaults")){attrs=_.defaults({},attrs,defaults)}this.set(attrs,options);this.changed={};this.initialize.apply(this,arguments)};var modelOptions=["url","urlRoot","collection"];_.extend(Model.prototype,Events,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(options){return _.clone(this.attributes)},sync:function(){return Backbone.sync.apply(this,arguments)},get:function(attr){return this.attributes[attr]},escape:function(attr){return _.escape(this.get(attr))},has:function(attr){return this.get(attr)!=null},set:function(key,val,options){var attr,attrs,unset,changes,silent,changing,prev,current;if(key==null)return this;if(typeof key==="object"){attrs=key;options=val}else{(attrs={})[key]=val}options||(options={});if(!this._validate(attrs,options))return false;unset=options.unset;silent=options.silent;changes=[];changing=this._changing;this._changing=true;if(!changing){this._previousAttributes=_.clone(this.attributes);this.changed={}}current=this.attributes,prev=this._previousAttributes;if(this.idAttribute in attrs)this.id=attrs[this.idAttribute];for(attr in attrs){val=attrs[attr];if(!_.isEqual(current[attr],val))changes.push(attr);if(!_.isEqual(prev[attr],val)){this.changed[attr]=val}else{delete this.changed[attr]}unset?delete current[attr]:current[attr]=val}if(!silent){if(changes.length)this._pending=true;for(var i=0,l=changes.length;i<l;i++){this.trigger("change:"+changes[i],this,current[changes[i]],options)}}if(changing)return this;if(!silent){while(this._pending){this._pending=false;this.trigger("change",this,options)}}this._pending=false;this._changing=false;return this},unset:function(attr,options){return this.set(attr,void 0,_.extend({},options,{unset:true}))},clear:function(options){var attrs={};for(var key in this.attributes)attrs[key]=void 0;return this.set(attrs,_.extend({},options,{unset:true}))},hasChanged:function(attr){if(attr==null)return!_.isEmpty(this.changed);return _.has(this.changed,attr)},changedAttributes:function(diff){if(!diff)return this.hasChanged()?_.clone(this.changed):false;var val,changed=false;var old=this._changing?this._previousAttributes:this.attributes;for(var attr in diff){if(_.isEqual(old[attr],val=diff[attr]))continue;(changed||(changed={}))[attr]=val}return changed},previous:function(attr){if(attr==null||!this._previousAttributes)return null;return this._previousAttributes[attr]},previousAttributes:function(){return _.clone(this._previousAttributes)},fetch:function(options){options=options?_.clone(options):{};if(options.parse===void 0)options.parse=true;var model=this;var success=options.success;options.success=function(resp){if(!model.set(model.parse(resp,options),options))return false;if(success)success(model,resp,options);model.trigger("sync",model,resp,options)};wrapError(this,options);return this.sync("read",this,options)},save:function(key,val,options){var attrs,method,xhr,attributes=this.attributes;if(key==null||typeof key==="object"){attrs=key;options=val}else{(attrs={})[key]=val}if(attrs&&(!options||!options.wait)&&!this.set(attrs,options))return false;options=_.extend({validate:true},options);if(!this._validate(attrs,options))return false;if(attrs&&options.wait){this.attributes=_.extend({},attributes,attrs)}if(options.parse===void 0)options.parse=true;var model=this;var success=options.success;options.success=function(resp){model.attributes=attributes;var serverAttrs=model.parse(resp,options);if(options.wait)serverAttrs=_.extend(attrs||{},serverAttrs);if(_.isObject(serverAttrs)&&!model.set(serverAttrs,options)){return false}if(success)success(model,resp,options);model.trigger("sync",model,resp,options)};wrapError(this,options);method=this.isNew()?"create":options.patch?"patch":"update";if(method==="patch")options.attrs=attrs;xhr=this.sync(method,this,options);if(attrs&&options.wait)this.attributes=attributes;return xhr},destroy:function(options){options=options?_.clone(options):{};var model=this;var success=options.success;var destroy=function(){model.trigger("destroy",model,model.collection,options)};options.success=function(resp){if(options.wait||model.isNew())destroy();if(success)success(model,resp,options);if(!model.isNew())model.trigger("sync",model,resp,options)};if(this.isNew()){options.success();return false}wrapError(this,options);var xhr=this.sync("delete",this,options);if(!options.wait)destroy();return xhr},url:function(){var base=_.result(this,"urlRoot")||_.result(this.collection,"url")||urlError();if(this.isNew())return base;return base+(base.charAt(base.length-1)==="/"?"":"/")+encodeURIComponent(this.id)},parse:function(resp,options){return resp},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return this.id==null},isValid:function(options){return this._validate({},_.extend(options||{},{validate:true}))},_validate:function(attrs,options){if(!options.validate||!this.validate)return true;attrs=_.extend({},this.attributes,attrs);var error=this.validationError=this.validate(attrs,options)||null;if(!error)return true;this.trigger("invalid",this,error,_.extend(options||{},{validationError:error}));return false}});var modelMethods=["keys","values","pairs","invert","pick","omit"];_.each(modelMethods,function(method){Model.prototype[method]=function(){var args=slice.call(arguments);args.unshift(this.attributes);return _[method].apply(_,args)}});var Collection=Backbone.Collection=function(models,options){options||(options={});if(options.url)this.url=options.url;if(options.model)this.model=options.model;if(options.comparator!==void 0)this.comparator=options.comparator;this._reset();this.initialize.apply(this,arguments);if(models)this.reset(models,_.extend({silent:true},options))};var setOptions={add:true,remove:true,merge:true};var addOptions={add:true,merge:false,remove:false};_.extend(Collection.prototype,Events,{model:Model,initialize:function(){},toJSON:function(options){return this.map(function(model){return model.toJSON(options)})},sync:function(){return Backbone.sync.apply(this,arguments)},add:function(models,options){return this.set(models,_.defaults(options||{},addOptions))},remove:function(models,options){models=_.isArray(models)?models.slice():[models];options||(options={});var i,l,index,model;for(i=0,l=models.length;i<l;i++){model=this.get(models[i]);if(!model)continue;delete this._byId[model.id];delete this._byId[model.cid];index=this.indexOf(model);this.models.splice(index,1);this.length--;if(!options.silent){options.index=index;model.trigger("remove",model,this,options)}this._removeReference(model)}return this},set:function(models,options){options=_.defaults(options||{},setOptions);if(options.parse)models=this.parse(models,options);if(!_.isArray(models))models=models?[models]:[];var i,l,model,attrs,existing,sort;var at=options.at;var sortable=this.comparator&&at==null&&options.sort!==false;var sortAttr=_.isString(this.comparator)?this.comparator:null;var toAdd=[],toRemove=[],modelMap={};for(i=0,l=models.length;i<l;i++){if(!(model=this._prepareModel(models[i],options)))continue;if(existing=this.get(model)){if(options.remove)modelMap[existing.cid]=true;if(options.merge){existing.set(model.attributes,options);if(sortable&&!sort&&existing.hasChanged(sortAttr))sort=true}}else if(options.add){toAdd.push(model);model.on("all",this._onModelEvent,this);this._byId[model.cid]=model;if(model.id!=null)this._byId[model.id]=model}}if(options.remove){for(i=0,l=this.length;i<l;++i){if(!modelMap[(model=this.models[i]).cid])toRemove.push(model)}if(toRemove.length)this.remove(toRemove,options)}if(toAdd.length){if(sortable)sort=true;this.length+=toAdd.length;if(at!=null){splice.apply(this.models,[at,0].concat(toAdd))}else{push.apply(this.models,toAdd)}}if(sort)this.sort({silent:true});if(options.silent)return this;for(i=0,l=toAdd.length;i<l;i++){(model=toAdd[i]).trigger("add",model,this,options)}if(sort)this.trigger("sort",this,options);return this},reset:function(models,options){options||(options={});for(var i=0,l=this.models.length;i<l;i++){this._removeReference(this.models[i])}options.previousModels=this.models;this._reset();this.add(models,_.extend({silent:true},options));if(!options.silent)this.trigger("reset",this,options);return this},push:function(model,options){model=this._prepareModel(model,options);this.add(model,_.extend({at:this.length},options));return model},pop:function(options){var model=this.at(this.length-1);this.remove(model,options);return model},unshift:function(model,options){model=this._prepareModel(model,options);this.add(model,_.extend({at:0},options));return model},shift:function(options){var model=this.at(0);this.remove(model,options);return model},slice:function(begin,end){return this.models.slice(begin,end)},get:function(obj){if(obj==null)return void 0;return this._byId[obj.id!=null?obj.id:obj.cid||obj]},at:function(index){return this.models[index]},where:function(attrs,first){if(_.isEmpty(attrs))return first?void 0:[];return this[first?"find":"filter"](function(model){for(var key in attrs){if(attrs[key]!==model.get(key))return false}return true})},findWhere:function(attrs){return this.where(attrs,true)},sort:function(options){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");options||(options={});if(_.isString(this.comparator)||this.comparator.length===1){this.models=this.sortBy(this.comparator,this)}else{this.models.sort(_.bind(this.comparator,this))}if(!options.silent)this.trigger("sort",this,options);return this},sortedIndex:function(model,value,context){value||(value=this.comparator);var iterator=_.isFunction(value)?value:function(model){return model.get(value)};return _.sortedIndex(this.models,model,iterator,context)},pluck:function(attr){return _.invoke(this.models,"get",attr)},fetch:function(options){options=options?_.clone(options):{};if(options.parse===void 0)options.parse=true;var success=options.success;var collection=this;options.success=function(resp){var method=options.reset?"reset":"set";collection[method](resp,options);if(success)success(collection,resp,options);collection.trigger("sync",collection,resp,options)};wrapError(this,options);return this.sync("read",this,options)},create:function(model,options){options=options?_.clone(options):{};if(!(model=this._prepareModel(model,options)))return false;if(!options.wait)this.add(model,options);var collection=this;var success=options.success;options.success=function(resp){if(options.wait)collection.add(model,options);if(success)success(model,resp,options)};model.save(null,options);return model},parse:function(resp,options){return resp},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0;this.models=[];this._byId={}},_prepareModel:function(attrs,options){if(attrs instanceof Model){if(!attrs.collection)attrs.collection=this;return attrs}options||(options={});options.collection=this;var model=new this.model(attrs,options);if(!model._validate(attrs,options)){this.trigger("invalid",this,attrs,options);return false}return model},_removeReference:function(model){if(this===model.collection)delete model.collection;model.off("all",this._onModelEvent,this)},_onModelEvent:function(event,model,collection,options){if((event==="add"||event==="remove")&&collection!==this)return;if(event==="destroy")this.remove(model,options);if(model&&event==="change:"+model.idAttribute){delete this._byId[model.previous(model.idAttribute)];if(model.id!=null)this._byId[model.id]=model}this.trigger.apply(this,arguments)}});var methods=["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","indexOf","shuffle","lastIndexOf","isEmpty","chain"];_.each(methods,function(method){Collection.prototype[method]=function(){var args=slice.call(arguments);args.unshift(this.models);return _[method].apply(_,args)}});var attributeMethods=["groupBy","countBy","sortBy"];_.each(attributeMethods,function(method){Collection.prototype[method]=function(value,context){var iterator=_.isFunction(value)?value:function(model){return model.get(value)};return _[method](this.models,iterator,context)}});var View=Backbone.View=function(options){this.cid=_.uniqueId("view");this._configure(options||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()};var delegateEventSplitter=/^(\S+)\s*(.*)$/;var viewOptions=["model","collection","el","id","attributes","className","tagName","events"];_.extend(View.prototype,Events,{tagName:"div",$:function(selector){return this.$el.find(selector)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();this.stopListening();return this},setElement:function(element,delegate){if(this.$el)this.undelegateEvents();this.$el=element instanceof Backbone.$?element:Backbone.$(element);this.el=this.$el[0];if(delegate!==false)this.delegateEvents();return this},delegateEvents:function(events){if(!(events||(events=_.result(this,"events"))))return this;this.undelegateEvents();for(var key in events){var method=events[key];if(!_.isFunction(method))method=this[events[key]];if(!method)continue;var match=key.match(delegateEventSplitter);var eventName=match[1],selector=match[2];method=_.bind(method,this);eventName+=".delegateEvents"+this.cid;if(selector===""){this.$el.on(eventName,method)}else{this.$el.on(eventName,selector,method)}}return this},undelegateEvents:function(){this.$el.off(".delegateEvents"+this.cid);return this},_configure:function(options){if(this.options)options=_.extend({},_.result(this,"options"),options);_.extend(this,_.pick(options,viewOptions));this.options=options},_ensureElement:function(){if(!this.el){var attrs=_.extend({},_.result(this,"attributes"));if(this.id)attrs.id=_.result(this,"id");if(this.className)attrs["class"]=_.result(this,"className");var $el=Backbone.$("<"+_.result(this,"tagName")+">").attr(attrs);this.setElement($el,false)}else{this.setElement(_.result(this,"el"),false)}}});Backbone.sync=function(method,model,options){var type=methodMap[method];_.defaults(options||(options={}),{emulateHTTP:Backbone.emulateHTTP,emulateJSON:Backbone.emulateJSON});var params={type:type,dataType:"json"};if(!options.url){params.url=_.result(model,"url")||urlError()}if(options.data==null&&model&&(method==="create"||method==="update"||method==="patch")){params.contentType="application/json";params.data=JSON.stringify(options.attrs||model.toJSON(options))}if(options.emulateJSON){params.contentType="application/x-www-form-urlencoded";params.data=params.data?{model:params.data}:{}}if(options.emulateHTTP&&(type==="PUT"||type==="DELETE"||type==="PATCH")){params.type="POST";if(options.emulateJSON)params.data._method=type;var beforeSend=options.beforeSend;options.beforeSend=function(xhr){xhr.setRequestHeader("X-HTTP-Method-Override",type);if(beforeSend)return beforeSend.apply(this,arguments)}}if(params.type!=="GET"&&!options.emulateJSON){params.processData=false}if(params.type==="PATCH"&&window.ActiveXObject&&!(window.external&&window.external.msActiveXFilteringEnabled)){params.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var xhr=options.xhr=Backbone.ajax(_.extend(params,options));model.trigger("request",model,xhr,options);return xhr};var methodMap={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};Backbone.ajax=function(){return Backbone.$.ajax.apply(Backbone.$,arguments)};var Router=Backbone.Router=function(options){options||(options={});if(options.routes)this.routes=options.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var optionalParam=/\((.*?)\)/g;var namedParam=/(\(\?)?:\w+/g;var splatParam=/\*\w+/g;var escapeRegExp=/[\-{}\[\]+?.,\\\^$|#\s]/g;_.extend(Router.prototype,Events,{initialize:function(){},route:function(route,name,callback){if(!_.isRegExp(route))route=this._routeToRegExp(route);if(_.isFunction(name)){callback=name;name=""}if(!callback)callback=this[name];var router=this;Backbone.history.route(route,function(fragment){var args=router._extractParameters(route,fragment);callback&&callback.apply(router,args);router.trigger.apply(router,["route:"+name].concat(args));router.trigger("route",name,args);Backbone.history.trigger("route",router,name,args)});return this},navigate:function(fragment,options){Backbone.history.navigate(fragment,options);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=_.result(this,"routes");var route,routes=_.keys(this.routes);while((route=routes.pop())!=null){this.route(route,this.routes[route])}},_routeToRegExp:function(route){route=route.replace(escapeRegExp,"\\$&").replace(optionalParam,"(?:$1)?").replace(namedParam,function(match,optional){return optional?match:"([^/]+)"}).replace(splatParam,"(.*?)");return new RegExp("^"+route+"$")},_extractParameters:function(route,fragment){var params=route.exec(fragment).slice(1);return _.map(params,function(param){return param?decodeURIComponent(param):null})}});var History=Backbone.History=function(){this.handlers=[];_.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var routeStripper=/^[#\/]|\s+$/g;var rootStripper=/^\/+|\/+$/g;var isExplorer=/msie [\w.]+/;var trailingSlash=/\/$/;History.started=false;_.extend(History.prototype,Events,{interval:50,getHash:function(window){var match=(window||this).location.href.match(/#(.*)$/);return match?match[1]:""},getFragment:function(fragment,forcePushState){if(fragment==null){if(this._hasPushState||!this._wantsHashChange||forcePushState){fragment=this.location.pathname;var root=this.root.replace(trailingSlash,"");if(!fragment.indexOf(root))fragment=fragment.substr(root.length)}else{fragment=this.getHash()}}return fragment.replace(routeStripper,"")},start:function(options){if(History.started)throw new Error("Backbone.history has already been started");History.started=true;this.options=_.extend({},{root:"/"},this.options,options);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 fragment=this.getFragment();var docMode=document.documentMode;var oldIE=isExplorer.exec(navigator.userAgent.toLowerCase())&&(!docMode||docMode<=7);this.root=("/"+this.root+"/").replace(rootStripper,"/");if(oldIE&&this._wantsHashChange){this.iframe=Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow;this.navigate(fragment)}if(this._hasPushState){Backbone.$(window).on("popstate",this.checkUrl)}else if(this._wantsHashChange&&"onhashchange"in window&&!oldIE){Backbone.$(window).on("hashchange",this.checkUrl)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}this.fragment=fragment;var loc=this.location;var atRoot=loc.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!atRoot){this.fragment=this.getFragment(null,true);this.location.replace(this.root+this.location.search+"#"+this.fragment);return true}else if(this._wantsPushState&&this._hasPushState&&atRoot&&loc.hash){this.fragment=this.getHash().replace(routeStripper,"");this.history.replaceState({},document.title,this.root+this.fragment+loc.search)}if(!this.options.silent)return this.loadUrl()},stop:function(){Backbone.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);History.started=false},route:function(route,callback){this.handlers.unshift({route:route,callback:callback})},checkUrl:function(e){var current=this.getFragment();if(current===this.fragment&&this.iframe){current=this.getFragment(this.getHash(this.iframe))}if(current===this.fragment)return false;if(this.iframe)this.navigate(current);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(fragmentOverride){var fragment=this.fragment=this.getFragment(fragmentOverride);var matched=_.any(this.handlers,function(handler){if(handler.route.test(fragment)){handler.callback(fragment);return true}});return matched},navigate:function(fragment,options){if(!History.started)return false;if(!options||options===true)options={trigger:options};fragment=this.getFragment(fragment||"");if(this.fragment===fragment)return;this.fragment=fragment;var url=this.root+fragment;if(this._hasPushState){this.history[options.replace?"replaceState":"pushState"]({},document.title,url)}else if(this._wantsHashChange){this._updateHash(this.location,fragment,options.replace);if(this.iframe&&fragment!==this.getFragment(this.getHash(this.iframe))){if(!options.replace)this.iframe.document.open().close();this._updateHash(this.iframe.location,fragment,options.replace)}}else{return this.location.assign(url)}if(options.trigger)this.loadUrl(fragment)},_updateHash:function(location,fragment,replace){if(replace){var href=location.href.replace(/(javascript:|#).*$/,"");location.replace(href+"#"+fragment)}else{location.hash="#"+fragment}}});Backbone.history=new History;var extend=function(protoProps,staticProps){var parent=this;var child;if(protoProps&&_.has(protoProps,"constructor")){child=protoProps.constructor}else{child=function(){return parent.apply(this,arguments)}}_.extend(child,parent,staticProps);var Surrogate=function(){this.constructor=child};Surrogate.prototype=parent.prototype;child.prototype=new Surrogate;if(protoProps)_.extend(child.prototype,protoProps);child.__super__=parent.prototype;return child};Model.extend=Collection.extend=Router.extend=View.extend=History.extend=extend;var urlError=function(){throw new Error('A "url" property or function must be specified')};var wrapError=function(model,options){var error=options.error;options.error=function(resp){if(error)error(model,resp,options);model.trigger("error",model,resp,options)}}}).call(this);
+/*
+//@ sourceMappingURL=backbone-min.map
+*/
View
1 app/components/backbone/backbone-min.map
@@ -0,0 +1 @@
+{"version":3,"file":"backbone-min.js","sources":["backbone.js"],"names":["root","this","previousBackbone","Backbone","array","push","slice","splice","exports","VERSION","_","require","$","jQuery","Zepto","ender","noConflict","emulateHTTP","emulateJSON","Events","on","name","callback","context","eventsApi","_events","events","ctx","once","self","off","apply","arguments","_callback","retain","ev","names","i","l","j","k","keys","length","trigger","args","call","allEvents","all","triggerEvents","stopListening","obj","listeners","_listeners","deleteListener","_listenerId","id","eventSplitter","action","rest","key","concat","test","split","a1","a2","a3","listenMethods","listenTo","listenToOnce","each","implementation","method","uniqueId","bind","unbind","extend","Model","attributes","options","defaults","attrs","cid","pick","modelOptions","parse","result","set","changed","initialize","prototype","validationError","idAttribute","toJSON","clone","sync","get","attr","escape","has","val","unset","changes","silent","changing","prev","current","_validate","_changing","_previousAttributes","isEqual","_pending","clear","hasChanged","isEmpty","changedAttributes","diff","old","previous","previousAttributes","fetch","model","success","resp","wrapError","save","xhr","wait","validate","serverAttrs","isObject","isNew","patch","destroy","collection","url","base","urlError","charAt","encodeURIComponent","constructor","isValid","error","modelMethods","unshift","Collection","models","comparator","_reset","reset","setOptions","add","remove","merge","addOptions","map","isArray","index","_byId","indexOf","_removeReference","existing","sort","at","sortable","sortAttr","isString","toAdd","toRemove","modelMap","_prepareModel","_onModelEvent","previousModels","pop","shift","begin","end","where","first","findWhere","Error","sortBy","sortedIndex","value","iterator","isFunction","pluck","invoke","create","event","methods","attributeMethods","View","_configure","_ensureElement","delegateEvents","delegateEventSplitter","viewOptions","tagName","selector","$el","find","render","setElement","element","delegate","undelegateEvents","el","match","eventName","className","type","methodMap","params","dataType","data","contentType","JSON","stringify","_method","beforeSend","setRequestHeader","processData","window","ActiveXObject","external","msActiveXFilteringEnabled","ajax","update","delete","read","Router","routes","_bindRoutes","optionalParam","namedParam","splatParam","escapeRegExp","route","isRegExp","_routeToRegExp","router","history","fragment","_extractParameters","navigate","replace","optional","RegExp","exec","param","decodeURIComponent","History","handlers","bindAll","location","routeStripper","rootStripper","isExplorer","trailingSlash","started","interval","getHash","href","getFragment","forcePushState","_hasPushState","_wantsHashChange","pathname","substr","start","hashChange","_wantsPushState","pushState","docMode","document","documentMode","oldIE","navigator","userAgent","toLowerCase","iframe","hide","appendTo","contentWindow","checkUrl","_checkUrlInterval","setInterval","loc","atRoot","search","hash","replaceState","title","loadUrl","stop","clearInterval","e","fragmentOverride","matched","any","handler","_updateHash","open","close","assign","protoProps","staticProps","parent","child","Surrogate","__super__"],"mappings":"CAOA,WAOE,GAAIA,MAAOC,IAIX,IAAIC,kBAAmBF,KAAKG,QAG5B,IAAIC,SACJ,IAAIC,MAAOD,MAAMC,IACjB,IAAIC,OAAQF,MAAME,KAClB,IAAIC,QAASH,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ashkenas, DocumentCloud Inc.
+// Backbone may be freely distributed under the MIT license.
+// For all details and documentation:
+// http://backbonejs.org
+
+(function(){
+
+ // Initial Setup
+ // -------------
+
+ // Save a reference to the global object (`window` in the browser, `exports`
+ // on the server).
+ var root = this;
+
+ // Save the previous value of the `Backbone` variable, so that it can be
+ // restored later on, if `noConflict` is used.
+ var previousBackbone = root.Backbone;
+
+ // Create local references to array methods we'll want to use later.
+ var array = [];
+ var push = array.push;
+ var slice = array.slice;
+ var splice = array.splice;
+
+ // The top-level namespace. All public Backbone classes and modules will
+ // be attached to this. Exported for both the browser and the server.
+ var Backbone;
+ if (typeof exports !== 'undefined') {
+ Backbone = exports;
+ } else {
+ Backbone = root.Backbone = {};
+ }
+
+ // Current version of the library. Keep in sync with `package.json`.
+ Backbone.VERSION = '1.0.0';
+
+ // Require Underscore, if we're on the server, and it's not already present.
+ var _ = root._;
+ if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
+
+ // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
+ // the `$` variable.
+ Backbone.$ = root.jQuery || root.Zepto || root.ender || root.$;
+
+ // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
+ // to its previous owner. Returns a reference to this Backbone object.
+ Backbone.noConflict = function() {
+ root.Backbone = previousBackbone;
+ return this;
+ };
+
+ // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
+ // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and
+ // set a `X-Http-Method-Override` header.
+ Backbone.emulateHTTP = false;
+
+ // Turn on `emulateJSON` to support legacy servers that can't deal with direct
+ // `application/json` requests ... will encode the body as
+ // `application/x-www-form-urlencoded` instead and will send the model in a
+ // form param named `model`.
+ Backbone.emulateJSON = false;
+
+ // Backbone.Events
+ // ---------------
+
+ // A module that can be mixed in to *any object* in order to provide it with
+ // custom events. You may bind with `on` or remove with `off` callback
+ // functions to an event; `trigger`-ing an event fires all callbacks in
+ // succession.
+ //
+ // var object = {};
+ // _.extend(object, Backbone.Events);
+ // object.on('expand', function(){ alert('expanded'); });
+ // object.trigger('expand');
+ //
+ var Events = Backbone.Events = {
+
+ // Bind an event to a `callback` function. Passing `"all"` will bind
+ // the callback to all events fired.
+ on: function(name, callback, context) {
+ if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this;
+ this._events || (this._events = {});
+ var events = this._events[name] || (this._events[name] = []);
+ events.push({callback: callback, context: context, ctx: context || this});
+ return this;
+ },
+
+ // Bind an event to only be triggered a single time. After the first time
+ // the callback is invoked, it will be removed.
+ once: function(name, callback, context) {
+ if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this;
+ var self = this;
+ var once = _.once(function() {
+ self.off(name, once);
+ callback.apply(this, arguments);
+ });
+ once._callback = callback;
+ return this.on(name, once, context);
+ },
+
+ // Remove one or many callbacks. If `context` is null, removes all
+ // callbacks with that function. If `callback` is null, removes all
+ // callbacks for the event. If `name` is null, removes all bound
+ // callbacks for all events.
+ off: function(name, callback, context) {
+ var retain, ev, events, names, i, l, j, k;
+ if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this;
+ if (!name && !callback && !context) {
+ this._events = {};
+ return this;
+ }
+
+ names = name ? [name] : _.keys(this._events);
+ for (i = 0, l = names.length; i < l; i++) {
+ name = names[i];
+ if (events = this._events[name]) {
+ this._events[name] = retain = [];
+ if (callback || context) {
+ for (j = 0, k = events.length; j < k; j++) {
+ ev = events[j];
+ if ((callback && callback !== ev.callback && callback !== ev.callback._callback) ||
+ (context && context !== ev.context)) {
+ retain.push(ev);
+ }
+ }
+ }
+ if (!retain.length) delete this._events[name];
+ }
+ }
+
+ return this;
+ },
+
+ // Trigger one or many events, firing all bound callbacks. Callbacks are
+ // passed the same arguments as `trigger` is, apart from the event name
+ // (unless you're listening on `"all"`, which will cause your callback to
+ // receive the true name of the event as the first argument).
+ trigger: function(name) {
+ if (!this._events) return this;
+ var args = slice.call(arguments, 1);
+ if (!eventsApi(this, 'trigger', name, args)) return this;
+ var events = this._events[name];
+ var allEvents = this._events.all;
+ if (events) triggerEvents(events, args);
+ if (allEvents) triggerEvents(allEvents, arguments);
+ return this;
+ },
+
+ // Tell this object to stop listening to either specific events ... or
+ // to every object it's currently listening to.
+ stopListening: function(obj, name, callback) {
+ var listeners = this._listeners;
+ if (!listeners) return this;
+ var deleteListener = !name && !callback;
+ if (typeof name === 'object') callback = this;
+ if (obj) (listeners = {})[obj._listenerId] = obj;
+ for (var id in listeners) {
+ listeners[id].off(name, callback, this);
+ if (deleteListener) delete this._listeners[id];
+ }
+ return this;
+ }
+
+ };
+
+ // Regular expression used to split event strings.
+ var eventSplitter = /\s+/;
+
+ // Implement fancy features of the Events API such as multiple event
+ // names `"change blur"` and jQuery-style event maps `{change: action}`
+ // in terms of the existing API.
+ var eventsApi = function(obj, action, name, rest) {
+ if (!name) return true;
+
+ // Handle event maps.
+ if (typeof name === 'object') {
+ for (var key in name) {
+ obj[action].apply(obj, [key, name[key]].concat(rest));
+ }
+ return false;
+ }
+
+ // Handle space separated event names.
+ if (eventSplitter.test(name)) {
+ var names = name.split(eventSplitter);
+ for (var i = 0, l = names.length; i < l; i++) {
+ obj[action].apply(obj, [names[i]].concat(rest));
+ }
+ return false;
+ }
+
+ return true;
+ };
+
+ // A difficult-to-believe, but optimized internal dispatch function for
+ // triggering events. Tries to keep the usual cases speedy (most internal
+ // Backbone events have 3 arguments).
+ var triggerEvents = function(events, args) {
+ var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];
+ switch (args.length) {
+ case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;
+ case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;
+ case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;
+ case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;
+ default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args);
+ }
+ };
+
+ var listenMethods = {listenTo: 'on', listenToOnce: 'once'};
+
+ // Inversion-of-control versions of `on` and `once`. Tell *this* object to
+ // listen to an event in another object ... keeping track of what it's
+ // listening to.
+ _.each(listenMethods, function(implementation, method) {
+ Events[method] = function(obj, name, callback) {
+ var listeners = this._listeners || (this._listeners = {});
+ var id = obj._listenerId || (obj._listenerId = _.uniqueId('l'));
+ listeners[id] = obj;
+ if (typeof name === 'object') callback = this;
+ obj[implementation](name, callback, this);
+ return this;
+ };
+ });
+
+ // Aliases for backwards compatibility.
+ Events.bind = Events.on;
+ Events.unbind = Events.off;
+
+ // Allow the `Backbone` object to serve as a global event bus, for folks who
+ // want global "pubsub" in a convenient place.
+ _.extend(Backbone, Events);
+
+ // Backbone.Model
+ // --------------
+
+ // Backbone **Models** are the basic data object in the framework --
+ // frequently representing a row in a table in a database on your server.
+ // A discrete chunk of data and a bunch of useful, related methods for
+ // performing computations and transformations on that data.
+
+ // Create a new model with the specified attributes. A client id (`cid`)
+ // is automatically generated and assigned for you.
+ var Model = Backbone.Model = function(attributes, options) {
+ var defaults;
+ var attrs = attributes || {};
+ options || (options = {});
+ this.cid = _.uniqueId('c');
+ this.attributes = {};
+ _.extend(this, _.pick(options, modelOptions));
+ if (options.parse) attrs = this.parse(attrs, options) || {};
+ if (defaults = _.result(this, 'defaults')) {
+ attrs = _.defaults({}, attrs, defaults);
+ }
+ this.set(attrs, options);
+ this.changed = {};
+ this.initialize.apply(this, arguments);
+ };
+
+ // A list of options to be attached directly to the model, if provided.
+ var modelOptions = ['url', 'urlRoot', 'collection'];
+
+ // Attach all inheritable methods to the Model prototype.
+ _.extend(Model.prototype, Events, {
+
+ // A hash of attributes whose current and previous value differ.
+ changed: null,
+
+ // The value returned during the last failed validation.
+ validationError: null,
+
+ // The default name for the JSON `id` attribute is `"id"`. MongoDB and
+ // CouchDB users may want to set this to `"_id"`.
+ idAttribute: 'id',
+
+ // Initialize is an empty function by default. Override it with your own
+ // initialization logic.