iugu-ux 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/Rakefile +14 -0
  2. data/lib/iugu-ux.rb +41 -0
  3. data/lib/iugu-ux/railtie.rb +13 -0
  4. data/lib/iugu-ux/version.rb +3 -0
  5. data/sandbox/Rakefile +7 -0
  6. data/sandbox/app/assets/images/assets-hd-s827ab39c93.png +0 -0
  7. data/sandbox/app/assets/images/assets-sf5326dcc8f.png +0 -0
  8. data/sandbox/app/assets/images/iux-default-hd-sc9d2356e0b.png +0 -0
  9. data/sandbox/app/assets/images/iux-default-s80f46e65ce.png +0 -0
  10. data/sandbox/app/assets/images/rails.png +0 -0
  11. data/sandbox/app/assets/javascripts/application.js +0 -0
  12. data/sandbox/app/assets/javascripts/web-app/config.js.erb +9 -0
  13. data/sandbox/app/assets/javascripts/web-app/i18n-languages.js.erb +12 -0
  14. data/sandbox/app/assets/javascripts/web-app/locale/en.json +11 -0
  15. data/sandbox/app/assets/javascripts/web-app/locale/pt-BR.json +11 -0
  16. data/sandbox/app/assets/javascripts/web-app/models.js +1 -0
  17. data/sandbox/app/assets/javascripts/web-app/presenters.js +1 -0
  18. data/sandbox/app/assets/javascripts/web-app/presenters/main-view.jst.eco +50 -0
  19. data/sandbox/app/assets/javascripts/web-app/usecode.js +1 -0
  20. data/sandbox/app/assets/javascripts/web-app/usecode/root-view.coffee +13 -0
  21. data/sandbox/app/assets/javascripts/web-app/usecode/router.coffee +19 -0
  22. data/sandbox/app/assets/sprites/a/assets-hd/arrow-down.png +0 -0
  23. data/sandbox/app/assets/sprites/a/assets-hd/arrow-up.png +0 -0
  24. data/sandbox/app/assets/sprites/a/assets-hd/btn-dashboard.png +0 -0
  25. data/sandbox/app/assets/sprites/a/assets-hd/btn-yell.png +0 -0
  26. data/sandbox/app/assets/sprites/a/assets-hd/clock.png +0 -0
  27. data/sandbox/app/assets/sprites/a/assets-hd/dashboard-places.png +0 -0
  28. data/sandbox/app/assets/sprites/a/assets-hd/dashboard-products.png +0 -0
  29. data/sandbox/app/assets/sprites/a/assets-hd/dashboard-spaces.png +0 -0
  30. data/sandbox/app/assets/sprites/a/assets-hd/dashboard-user.png +0 -0
  31. data/sandbox/app/assets/sprites/a/assets-hd/header-letsyell-logo.png +0 -0
  32. data/sandbox/app/assets/sprites/a/assets-hd/icon-facebook.png +0 -0
  33. data/sandbox/app/assets/sprites/a/assets-hd/icon-google.png +0 -0
  34. data/sandbox/app/assets/sprites/a/assets-hd/icon-linkedin.png +0 -0
  35. data/sandbox/app/assets/sprites/a/assets-hd/icon-twitter.png +0 -0
  36. data/sandbox/app/assets/sprites/a/assets-hd/icon-windows.png +0 -0
  37. data/sandbox/app/assets/sprites/a/assets-hd/icon-yahoo.png +0 -0
  38. data/sandbox/app/assets/sprites/a/assets-hd/place-coffee.png +0 -0
  39. data/sandbox/app/assets/sprites/a/assets-hd/right-arrow.png +0 -0
  40. data/sandbox/app/assets/sprites/a/assets-hd/stars-five.png +0 -0
  41. data/sandbox/app/assets/sprites/a/assets-hd/stars-four-half.png +0 -0
  42. data/sandbox/app/assets/sprites/a/assets-hd/stars-four.png +0 -0
  43. data/sandbox/app/assets/sprites/a/assets-hd/stars-half.png +0 -0
  44. data/sandbox/app/assets/sprites/a/assets-hd/stars-one-half.png +0 -0
  45. data/sandbox/app/assets/sprites/a/assets-hd/stars-one.png +0 -0
  46. data/sandbox/app/assets/sprites/a/assets-hd/stars-three-half.png +0 -0
  47. data/sandbox/app/assets/sprites/a/assets-hd/stars-three.png +0 -0
  48. data/sandbox/app/assets/sprites/a/assets-hd/stars-two-half.png +0 -0
  49. data/sandbox/app/assets/sprites/a/assets-hd/stars-two.png +0 -0
  50. data/sandbox/app/assets/sprites/a/assets-hd/stars-zero.png +0 -0
  51. data/sandbox/app/assets/sprites/a/assets/arrow-down.png +0 -0
  52. data/sandbox/app/assets/sprites/a/assets/arrow-up.png +0 -0
  53. data/sandbox/app/assets/sprites/a/assets/btn-dashboard.png +0 -0
  54. data/sandbox/app/assets/sprites/a/assets/btn-yell.png +0 -0
  55. data/sandbox/app/assets/sprites/a/assets/clock.png +0 -0
  56. data/sandbox/app/assets/sprites/a/assets/dashboard-places.png +0 -0
  57. data/sandbox/app/assets/sprites/a/assets/dashboard-products.png +0 -0
  58. data/sandbox/app/assets/sprites/a/assets/dashboard-spaces.png +0 -0
  59. data/sandbox/app/assets/sprites/a/assets/dashboard-user.png +0 -0
  60. data/sandbox/app/assets/sprites/a/assets/header-letsyell-logo.png +0 -0
  61. data/sandbox/app/assets/sprites/a/assets/icon-facebook.png +0 -0
  62. data/sandbox/app/assets/sprites/a/assets/icon-google.png +0 -0
  63. data/sandbox/app/assets/sprites/a/assets/icon-linkedin.png +0 -0
  64. data/sandbox/app/assets/sprites/a/assets/icon-twitter.png +0 -0
  65. data/sandbox/app/assets/sprites/a/assets/icon-windows.png +0 -0
  66. data/sandbox/app/assets/sprites/a/assets/icon-yahoo.png +0 -0
  67. data/sandbox/app/assets/sprites/a/assets/place-coffee.png +0 -0
  68. data/sandbox/app/assets/sprites/a/assets/right-arrow.png +0 -0
  69. data/sandbox/app/assets/sprites/a/assets/stars-five.png +0 -0
  70. data/sandbox/app/assets/sprites/a/assets/stars-four-half.png +0 -0
  71. data/sandbox/app/assets/sprites/a/assets/stars-four.png +0 -0
  72. data/sandbox/app/assets/sprites/a/assets/stars-half.png +0 -0
  73. data/sandbox/app/assets/sprites/a/assets/stars-one-half.png +0 -0
  74. data/sandbox/app/assets/sprites/a/assets/stars-one.png +0 -0
  75. data/sandbox/app/assets/sprites/a/assets/stars-three-half.png +0 -0
  76. data/sandbox/app/assets/sprites/a/assets/stars-three.png +0 -0
  77. data/sandbox/app/assets/sprites/a/assets/stars-two-half.png +0 -0
  78. data/sandbox/app/assets/sprites/a/assets/stars-two.png +0 -0
  79. data/sandbox/app/assets/sprites/a/assets/stars-zero.png +0 -0
  80. data/sandbox/app/assets/sprites/assets-hd/arrow-down.png +0 -0
  81. data/sandbox/app/assets/sprites/assets-hd/arrow-up.png +0 -0
  82. data/sandbox/app/assets/sprites/assets/arrow-down.png +0 -0
  83. data/sandbox/app/assets/sprites/assets/arrow-up.png +0 -0
  84. data/sandbox/app/assets/stylesheets/application.css +3 -0
  85. data/sandbox/app/assets/stylesheets/default-sprites.sass +8 -0
  86. data/sandbox/app/assets/stylesheets/experiment.sass +178 -0
  87. data/sandbox/app/assets/stylesheets/sandbox-sprites.css +6 -0
  88. data/sandbox/app/controllers/application_controller.rb +3 -0
  89. data/sandbox/app/controllers/ui_library_controller.rb +15 -0
  90. data/sandbox/app/views/layouts/ui.html.haml +18 -0
  91. data/sandbox/app/views/ui_library/boiler.html.haml +32 -0
  92. data/sandbox/app/views/ui_library/components.html.haml +189 -0
  93. data/sandbox/app/views/ui_library/index.html.haml +300 -0
  94. data/sandbox/config.ru +4 -0
  95. data/sandbox/config/application.rb +55 -0
  96. data/sandbox/config/boot.rb +10 -0
  97. data/sandbox/config/environment.rb +5 -0
  98. data/sandbox/config/environments/development.rb +35 -0
  99. data/sandbox/config/environments/production.rb +67 -0
  100. data/sandbox/config/environments/test.rb +39 -0
  101. data/sandbox/config/initializers/backtrace_silencers.rb +7 -0
  102. data/sandbox/config/initializers/inflections.rb +10 -0
  103. data/sandbox/config/initializers/mime_types.rb +5 -0
  104. data/sandbox/config/initializers/secret_token.rb +7 -0
  105. data/sandbox/config/initializers/session_store.rb +8 -0
  106. data/sandbox/config/initializers/wrap_parameters.rb +10 -0
  107. data/sandbox/config/locales/en.yml +5 -0
  108. data/sandbox/config/routes.rb +5 -0
  109. data/sandbox/doc/README_FOR_APP +2 -0
  110. data/sandbox/lib/sass/sprite_relative.rb +7 -0
  111. data/sandbox/public/404.html +26 -0
  112. data/sandbox/public/422.html +26 -0
  113. data/sandbox/public/500.html +26 -0
  114. data/sandbox/public/favicon.ico +0 -0
  115. data/sandbox/public/robots.txt +5 -0
  116. data/sandbox/script/rails +6 -0
  117. data/vendor/assets/javascripts/iugu-ux.js +7 -0
  118. data/vendor/assets/javascripts/iugu-ux/capabilities.js +209 -0
  119. data/vendor/assets/javascripts/iugu-ux/enable-prettify.js +3 -0
  120. data/vendor/assets/javascripts/iugu-ux/google-code-prettify/prettify.js +28 -0
  121. data/vendor/assets/javascripts/iugu-ux/iugu-ux.js +11 -0
  122. data/vendor/assets/javascripts/iugu-ux/twitter-bootstrap/bootstrap.js +7 -0
  123. data/vendor/assets/javascripts/iugu-ux/twitter-bootstrap/notice.js +90 -0
  124. data/vendor/assets/javascripts/iugu-ux/web-app.js +24 -0
  125. data/vendor/assets/javascripts/vendor.js +15 -0
  126. data/vendor/assets/javascripts/vendor/backbone.js +1479 -0
  127. data/vendor/assets/javascripts/vendor/gmaps.js +1058 -0
  128. data/vendor/assets/javascripts/vendor/iscroll.js +1080 -0
  129. data/vendor/assets/javascripts/vendor/jquery.base64.js +190 -0
  130. data/vendor/assets/javascripts/vendor/jquery.checkboxes.js +284 -0
  131. data/vendor/assets/javascripts/vendor/jquery.cookie.js +47 -0
  132. data/vendor/assets/javascripts/vendor/jquery.js +9267 -0
  133. data/vendor/assets/javascripts/vendor/jquery.ui.js +11363 -0
  134. data/vendor/assets/javascripts/vendor/jquery.ui.touch-punch.js +160 -0
  135. data/vendor/assets/javascripts/vendor/jquery.web-storage.js +489 -0
  136. data/vendor/assets/javascripts/vendor/underscore.js +1204 -0
  137. data/vendor/assets/javascripts/web-app/comm.coffee +1 -0
  138. data/vendor/assets/javascripts/web-app/config.js.erb +3 -0
  139. data/vendor/assets/javascripts/web-app/controllers.js +0 -0
  140. data/vendor/assets/javascripts/web-app/environment.js.coffee +8 -0
  141. data/vendor/assets/javascripts/web-app/helpers.coffee +86 -0
  142. data/vendor/assets/javascripts/web-app/i18n-languages.js +0 -0
  143. data/vendor/assets/javascripts/web-app/i18n.coffee +37 -0
  144. data/vendor/assets/javascripts/web-app/models.js +0 -0
  145. data/vendor/assets/javascripts/web-app/sound.coffee +67 -0
  146. data/vendor/assets/javascripts/web-app/views.js +0 -0
  147. data/vendor/assets/sprites/iux-default-hd/menu-icon.png +0 -0
  148. data/vendor/assets/sprites/iux-default/menu-icon.png +0 -0
  149. data/vendor/assets/stylesheets/iugu-ux.css +8 -0
  150. data/vendor/assets/stylesheets/iugu-ux/adaptative-mixins.sass +50 -0
  151. data/vendor/assets/stylesheets/iugu-ux/components.sass +185 -0
  152. data/vendor/assets/stylesheets/iugu-ux/core.sass +10 -0
  153. data/vendor/assets/stylesheets/iugu-ux/google-code-prettify/prettify.css +48 -0
  154. data/vendor/assets/stylesheets/iugu-ux/iugu-ux.sass +16 -0
  155. data/vendor/assets/stylesheets/iugu-ux/iux-sprites.sass +8 -0
  156. data/vendor/assets/stylesheets/iugu-ux/mixins.sass +32 -0
  157. data/vendor/assets/stylesheets/iugu-ux/no-js.sass +15 -0
  158. data/vendor/assets/stylesheets/iugu-ux/reset.sass +229 -0
  159. data/vendor/assets/stylesheets/iugu-ux/sprite-mixins.sass +49 -0
  160. data/vendor/assets/stylesheets/iugu-ux/typography.sass +268 -0
  161. data/vendor/assets/stylesheets/iugu-ux/utilities.sass +51 -0
  162. data/vendor/assets/stylesheets/iugu-ux/variables.sass +46 -0
  163. metadata +485 -0
@@ -0,0 +1,3 @@
1
+ $( function() {
2
+ prettyPrint()
3
+ });
@@ -0,0 +1,28 @@
1
+ var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
2
+ (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
3
+ [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
4
+ f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
5
+ (j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
6
+ {b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
7
+ t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
8
+ "string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
9
+ l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10
+ q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
11
+ q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
12
+ "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
13
+ a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
14
+ for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
15
+ m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
16
+ a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
17
+ j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18
+ "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
19
+ H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20
+ J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
21
+ I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
22
+ ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
23
+ /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
24
+ ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
25
+ hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
26
+ !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
27
+ 250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
28
+ PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
@@ -0,0 +1,11 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require_tree ./google-code-prettify
8
+ //= require ./twitter-bootstrap/bootstrap.js
9
+ //= require ./capabilities
10
+ //= require ./enable-prettify
11
+ //= require ./web-app
@@ -0,0 +1,7 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require ./notice
@@ -0,0 +1,90 @@
1
+ /* ==========================================================
2
+ * bootstrap-notice.js v2.0.4
3
+ * http://twitter.github.com/bootstrap/javascript.html#notices
4
+ * ==========================================================
5
+ * Copyright 2012 Twitter, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ * ========================================================== */
19
+
20
+
21
+ !function ($) {
22
+
23
+ "use strict"; // jshint ;_;
24
+
25
+
26
+ /* notice CLASS DEFINITION
27
+ * ====================== */
28
+
29
+ var dismiss = '[data-dismiss="notice"]'
30
+ , Notice = function (el) {
31
+ $(el).on('click', dismiss, this.close)
32
+ }
33
+
34
+ Notice.prototype.close = function (e) {
35
+ var $this = $(this)
36
+ , selector = $this.attr('data-target')
37
+ , $parent
38
+
39
+ if (!selector) {
40
+ selector = $this.attr('href')
41
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
42
+ }
43
+
44
+ $parent = $(selector)
45
+
46
+ e && e.preventDefault()
47
+
48
+ $parent.length || ($parent = $this.hasClass('notice') ? $this : $this.parent())
49
+
50
+ $parent.trigger(e = $.Event('close'))
51
+
52
+ if (e.isDefaultPrevented()) return
53
+
54
+ $parent.removeClass('in')
55
+
56
+ function removeElement() {
57
+ $parent
58
+ .trigger('closed')
59
+ .remove()
60
+ }
61
+
62
+ $.support.transition && $parent.hasClass('fade') ?
63
+ $parent.on($.support.transition.end, removeElement) :
64
+ removeElement()
65
+ }
66
+
67
+
68
+ /* notice PLUGIN DEFINITION
69
+ * ======================= */
70
+
71
+ $.fn.notice = function (option) {
72
+ return this.each(function () {
73
+ var $this = $(this)
74
+ , data = $this.data('notice')
75
+ if (!data) $this.data('notice', (data = new Notice(this)))
76
+ if (typeof option == 'string') data[option].call($this)
77
+ })
78
+ }
79
+
80
+ $.fn.notice.Constructor = Notice
81
+
82
+
83
+ /* notice DATA-API
84
+ * ============== */
85
+
86
+ $(function () {
87
+ $('body').on('click.notice.data-api', dismiss, Notice.prototype.close)
88
+ })
89
+
90
+ }(window.jQuery);
@@ -0,0 +1,24 @@
1
+ // Encoding: UTF-8
2
+ // Adding a UTF-8 Character to Fix áé
3
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
4
+ // listed below.
5
+ //
6
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
7
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
8
+ //
9
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
10
+ // the compiled file.
11
+ //
12
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
13
+ // GO AFTER THE REQUIRES BELOW.
14
+ //
15
+ //= require web-app/environment
16
+ //= require web-app/config
17
+ //= require web-app/comm
18
+ //= require web-app/presenters
19
+ //= require web-app/i18n-languages
20
+ //= require web-app/i18n
21
+ //= require web-app/sound
22
+ //= require web-app/helpers
23
+ //= require web-app/models
24
+ //= require web-app/usecode
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require ./vendor/jquery
8
+ //= require ./vendor/jquery.web-storage
9
+ //= require ./vendor/jquery.cookie
10
+ //= require ./vendor/jquery.checkboxes
11
+ //= require ./vendor/jquery.ui
12
+ //= require ./vendor/jquery.ui.touch-punch
13
+ //= require ./vendor/jquery.base64
14
+ //= require ./vendor/underscore
15
+ //= require ./vendor/backbone
@@ -0,0 +1,1479 @@
1
+ // Backbone.js 0.9.2
2
+
3
+ // (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
4
+ // Backbone may be freely distributed under the MIT license.
5
+ // For all details and documentation:
6
+ // http://backbonejs.org
7
+
8
+ (function(){
9
+
10
+ // Initial Setup
11
+ // -------------
12
+
13
+ // Save a reference to the global object (`window` in the browser, `global`
14
+ // on the server).
15
+ var root = this;
16
+
17
+ // Save the previous value of the `Backbone` variable, so that it can be
18
+ // restored later on, if `noConflict` is used.
19
+ var previousBackbone = root.Backbone;
20
+
21
+ // Create a local reference to array methods.
22
+ var ArrayProto = Array.prototype;
23
+ var push = ArrayProto.push;
24
+ var slice = ArrayProto.slice;
25
+ var splice = ArrayProto.splice;
26
+
27
+ // The top-level namespace. All public Backbone classes and modules will
28
+ // be attached to this. Exported for both CommonJS and the browser.
29
+ var Backbone;
30
+ if (typeof exports !== 'undefined') {
31
+ Backbone = exports;
32
+ } else {
33
+ Backbone = root.Backbone = {};
34
+ }
35
+
36
+ // Current version of the library. Keep in sync with `package.json`.
37
+ Backbone.VERSION = '0.9.2';
38
+
39
+ // Require Underscore, if we're on the server, and it's not already present.
40
+ var _ = root._;
41
+ if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
42
+
43
+ // For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable.
44
+ Backbone.$ = root.jQuery || root.Zepto || root.ender;
45
+
46
+ // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
47
+ // to its previous owner. Returns a reference to this Backbone object.
48
+ Backbone.noConflict = function() {
49
+ root.Backbone = previousBackbone;
50
+ return this;
51
+ };
52
+
53
+ // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
54
+ // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and
55
+ // set a `X-Http-Method-Override` header.
56
+ Backbone.emulateHTTP = false;
57
+
58
+ // Turn on `emulateJSON` to support legacy servers that can't deal with direct
59
+ // `application/json` requests ... will encode the body as
60
+ // `application/x-www-form-urlencoded` instead and will send the model in a
61
+ // form param named `model`.
62
+ Backbone.emulateJSON = false;
63
+
64
+ // Backbone.Events
65
+ // -----------------
66
+
67
+ // Regular expression used to split event strings
68
+ var eventSplitter = /\s+/;
69
+
70
+ // A module that can be mixed in to *any object* in order to provide it with
71
+ // custom events. You may bind with `on` or remove with `off` callback functions
72
+ // to an event; `trigger`-ing an event fires all callbacks in succession.
73
+ //
74
+ // var object = {};
75
+ // _.extend(object, Backbone.Events);
76
+ // object.on('expand', function(){ alert('expanded'); });
77
+ // object.trigger('expand');
78
+ //
79
+ var Events = Backbone.Events = {
80
+
81
+ // Bind one or more space separated events, `events`, to a `callback`
82
+ // function. Passing `"all"` will bind the callback to all events fired.
83
+ on: function(events, callback, context) {
84
+ var calls, event, list;
85
+ if (!callback) return this;
86
+
87
+ events = events.split(eventSplitter);
88
+ calls = this._callbacks || (this._callbacks = {});
89
+
90
+ while (event = events.shift()) {
91
+ list = calls[event] || (calls[event] = []);
92
+ list.push(callback, context);
93
+ }
94
+
95
+ return this;
96
+ },
97
+
98
+ // Remove one or many callbacks. If `context` is null, removes all callbacks
99
+ // with that function. If `callback` is null, removes all callbacks for the
100
+ // event. If `events` is null, removes all bound callbacks for all events.
101
+ off: function(events, callback, context) {
102
+ var event, calls, list, i;
103
+
104
+ // No events, or removing *all* events.
105
+ if (!(calls = this._callbacks)) return this;
106
+ if (!(events || callback || context)) {
107
+ delete this._callbacks;
108
+ return this;
109
+ }
110
+
111
+ events = events ? events.split(eventSplitter) : _.keys(calls);
112
+
113
+ // Loop through the callback list, splicing where appropriate.
114
+ while (event = events.shift()) {
115
+ if (!(list = calls[event]) || !(callback || context)) {
116
+ delete calls[event];
117
+ continue;
118
+ }
119
+
120
+ for (i = list.length - 2; i >= 0; i -= 2) {
121
+ if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) {
122
+ list.splice(i, 2);
123
+ }
124
+ }
125
+ }
126
+
127
+ return this;
128
+ },
129
+
130
+ // Trigger one or many events, firing all bound callbacks. Callbacks are
131
+ // passed the same arguments as `trigger` is, apart from the event name
132
+ // (unless you're listening on `"all"`, which will cause your callback to
133
+ // receive the true name of the event as the first argument).
134
+ trigger: function(events) {
135
+ var event, calls, list, i, length, args, all, rest;
136
+ if (!(calls = this._callbacks)) return this;
137
+
138
+ rest = [];
139
+ events = events.split(eventSplitter);
140
+
141
+ // Fill up `rest` with the callback arguments. Since we're only copying
142
+ // the tail of `arguments`, a loop is much faster than Array#slice.
143
+ for (i = 1, length = arguments.length; i < length; i++) {
144
+ rest[i - 1] = arguments[i];
145
+ }
146
+
147
+ // For each event, walk through the list of callbacks twice, first to
148
+ // trigger the event, then to trigger any `"all"` callbacks.
149
+ while (event = events.shift()) {
150
+ // Copy callback lists to prevent modification.
151
+ if (all = calls.all) all = all.slice();
152
+ if (list = calls[event]) list = list.slice();
153
+
154
+ // Execute event callbacks.
155
+ if (list) {
156
+ for (i = 0, length = list.length; i < length; i += 2) {
157
+ list[i].apply(list[i + 1] || this, rest);
158
+ }
159
+ }
160
+
161
+ // Execute "all" callbacks.
162
+ if (all) {
163
+ args = [event].concat(rest);
164
+ for (i = 0, length = all.length; i < length; i += 2) {
165
+ all[i].apply(all[i + 1] || this, args);
166
+ }
167
+ }
168
+ }
169
+
170
+ return this;
171
+ }
172
+
173
+ };
174
+
175
+ // Aliases for backwards compatibility.
176
+ Events.bind = Events.on;
177
+ Events.unbind = Events.off;
178
+
179
+ // Backbone.Model
180
+ // --------------
181
+
182
+ // Create a new model, with defined attributes. A client id (`cid`)
183
+ // is automatically generated and assigned for you.
184
+ var Model = Backbone.Model = function(attributes, options) {
185
+ var defaults;
186
+ var attrs = attributes || {};
187
+ if (options && options.collection) this.collection = options.collection;
188
+ if (options && options.parse) attributes = this.parse(attributes);
189
+ if (defaults = _.result(this, 'defaults')) {
190
+ attrs = _.extend({}, defaults, attrs);
191
+ }
192
+ this.attributes = {};
193
+ this._escapedAttributes = {};
194
+ this.cid = _.uniqueId('c');
195
+ this.changed = {};
196
+ this._changes = {};
197
+ this._pending = {};
198
+ this.set(attrs, {silent: true});
199
+ // Reset change tracking.
200
+ this.changed = {};
201
+ this._changes = {};
202
+ this._pending = {};
203
+ this._previousAttributes = _.clone(this.attributes);
204
+ this.initialize.apply(this, arguments);
205
+ };
206
+
207
+ // Attach all inheritable methods to the Model prototype.
208
+ _.extend(Model.prototype, Events, {
209
+
210
+ // A hash of attributes whose current and previous value differ.
211
+ changed: null,
212
+
213
+ // A hash of attributes that have changed since the last time `change`
214
+ // was called.
215
+ _changes: null,
216
+
217
+ // A hash of attributes that have changed since the last `change` event
218
+ // began.
219
+ _pending: null,
220
+
221
+ // A hash of attributes with the current model state to determine if
222
+ // a `change` should be recorded within a nested `change` block.
223
+ _changing : null,
224
+
225
+ // The default name for the JSON `id` attribute is `"id"`. MongoDB and
226
+ // CouchDB users may want to set this to `"_id"`.
227
+ idAttribute: 'id',
228
+
229
+ // Initialize is an empty function by default. Override it with your own
230
+ // initialization logic.
231
+ initialize: function(){},
232
+
233
+ // Return a copy of the model's `attributes` object.
234
+ toJSON: function(options) {
235
+ return _.clone(this.attributes);
236
+ },
237
+
238
+ // Proxy `Backbone.sync` by default.
239
+ sync: function() {
240
+ return Backbone.sync.apply(this, arguments);
241
+ },
242
+
243
+ // Get the value of an attribute.
244
+ get: function(attr) {
245
+ return this.attributes[attr];
246
+ },
247
+
248
+ // Get the HTML-escaped value of an attribute.
249
+ escape: function(attr) {
250
+ var html;
251
+ if (html = this._escapedAttributes[attr]) return html;
252
+ var val = this.get(attr);
253
+ return this._escapedAttributes[attr] = _.escape(val == null ? '' : '' + val);
254
+ },
255
+
256
+ // Returns `true` if the attribute contains a value that is not null
257
+ // or undefined.
258
+ has: function(attr) {
259
+ return this.get(attr) != null;
260
+ },
261
+
262
+ // Set a hash of model attributes on the object, firing `"change"` unless
263
+ // you choose to silence it.
264
+ set: function(attrs, options) {
265
+ var attr, key, val;
266
+ if (attrs == null) return this;
267
+
268
+ // Handle both `"key", value` and `{key: value}` -style arguments.
269
+ if (!_.isObject(attrs)) {
270
+ key = attrs;
271
+ (attrs = {})[key] = options;
272
+ options = arguments[2];
273
+ }
274
+
275
+ // Extract attributes and options.
276
+ var silent = options && options.silent;
277
+ var unset = options && options.unset;
278
+ if (attrs instanceof Model) attrs = attrs.attributes;
279
+ if (unset) for (attr in attrs) attrs[attr] = void 0;
280
+
281
+ // Run validation.
282
+ if (!this._validate(attrs, options)) return false;
283
+
284
+ // Check for changes of `id`.
285
+ if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
286
+
287
+ var changing = this._changing;
288
+ var now = this.attributes;
289
+ var escaped = this._escapedAttributes;
290
+ var prev = this._previousAttributes || {};
291
+
292
+ // For each `set` attribute...
293
+ for (attr in attrs) {
294
+ val = attrs[attr];
295
+
296
+ // If the new and current value differ, record the change.
297
+ if (!_.isEqual(now[attr], val) || (unset && _.has(now, attr))) {
298
+ delete escaped[attr];
299
+ this._changes[attr] = true;
300
+ }
301
+
302
+ // Update or delete the current value.
303
+ unset ? delete now[attr] : now[attr] = val;
304
+
305
+ // If the new and previous value differ, record the change. If not,
306
+ // then remove changes for this attribute.
307
+ if (!_.isEqual(prev[attr], val) || (_.has(now, attr) !== _.has(prev, attr))) {
308
+ this.changed[attr] = val;
309
+ if (!silent) this._pending[attr] = true;
310
+ } else {
311
+ delete this.changed[attr];
312
+ delete this._pending[attr];
313
+ if (!changing) delete this._changes[attr];
314
+ }
315
+
316
+ if (changing && _.isEqual(now[attr], changing[attr])) delete this._changes[attr];
317
+ }
318
+
319
+ // Fire the `"change"` events.
320
+ if (!silent) this.change(options);
321
+ return this;
322
+ },
323
+
324
+ // Remove an attribute from the model, firing `"change"` unless you choose
325
+ // to silence it. `unset` is a noop if the attribute doesn't exist.
326
+ unset: function(attr, options) {
327
+ options = _.extend({}, options, {unset: true});
328
+ return this.set(attr, null, options);
329
+ },
330
+
331
+ // Clear all attributes on the model, firing `"change"` unless you choose
332
+ // to silence it.
333
+ clear: function(options) {
334
+ options = _.extend({}, options, {unset: true});
335
+ return this.set(_.clone(this.attributes), options);
336
+ },
337
+
338
+ // Fetch the model from the server. If the server's representation of the
339
+ // model differs from its current attributes, they will be overriden,
340
+ // triggering a `"change"` event.
341
+ fetch: function(options) {
342
+ options = options ? _.clone(options) : {};
343
+ var model = this;
344
+ var success = options.success;
345
+ options.success = function(resp, status, xhr) {
346
+ if (!model.set(model.parse(resp, xhr), options)) return false;
347
+ if (success) success(model, resp, options);
348
+ };
349
+ return this.sync('read', this, options);
350
+ },
351
+
352
+ // Set a hash of model attributes, and sync the model to the server.
353
+ // If the server returns an attributes hash that differs, the model's
354
+ // state will be `set` again.
355
+ save: function(attrs, options) {
356
+ var key, current, done;
357
+
358
+ // Handle both `"key", value` and `{key: value}` -style arguments.
359
+ if (attrs != null && !_.isObject(attrs)) {
360
+ key = attrs;
361
+ (attrs = {})[key] = options;
362
+ options = arguments[2];
363
+ }
364
+ options = options ? _.clone(options) : {};
365
+
366
+ // If we're "wait"-ing to set changed attributes, validate early.
367
+ if (options.wait) {
368
+ if (!this._validate(attrs, options)) return false;
369
+ current = _.clone(this.attributes);
370
+ }
371
+
372
+ // Regular saves `set` attributes before persisting to the server.
373
+ var silentOptions = _.extend({}, options, {silent: true});
374
+ if (attrs && !this.set(attrs, options.wait ? silentOptions : options)) {
375
+ return false;
376
+ }
377
+
378
+ // Do not persist invalid models.
379
+ if (!attrs && !this._validate(null, options)) return false;
380
+
381
+ // After a successful server-side save, the client is (optionally)
382
+ // updated with the server-side state.
383
+ var model = this;
384
+ var success = options.success;
385
+ options.success = function(resp, status, xhr) {
386
+ done = true;
387
+ var serverAttrs = model.parse(resp, xhr);
388
+ if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
389
+ if (!model.set(serverAttrs, options)) return false;
390
+ if (success) success(model, resp, options);
391
+ };
392
+
393
+ // Finish configuring and sending the Ajax request.
394
+ var xhr = this.sync(this.isNew() ? 'create' : 'update', this, options);
395
+
396
+ // When using `wait`, reset attributes to original values unless
397
+ // `success` has been called already.
398
+ if (!done && options.wait) {
399
+ this.clear(silentOptions);
400
+ this.set(current, silentOptions);
401
+ }
402
+
403
+ return xhr;
404
+ },
405
+
406
+ // Destroy this model on the server if it was already persisted.
407
+ // Optimistically removes the model from its collection, if it has one.
408
+ // If `wait: true` is passed, waits for the server to respond before removal.
409
+ destroy: function(options) {
410
+ options = options ? _.clone(options) : {};
411
+ var model = this;
412
+ var success = options.success;
413
+
414
+ var destroy = function() {
415
+ model.trigger('destroy', model, model.collection, options);
416
+ };
417
+
418
+ options.success = function(resp) {
419
+ if (options.wait || model.isNew()) destroy();
420
+ if (success) success(model, resp, options);
421
+ };
422
+
423
+ if (this.isNew()) {
424
+ options.success();
425
+ return false;
426
+ }
427
+
428
+ var xhr = this.sync('delete', this, options);
429
+ if (!options.wait) destroy();
430
+ return xhr;
431
+ },
432
+
433
+ // Default URL for the model's representation on the server -- if you're
434
+ // using Backbone's restful methods, override this to change the endpoint
435
+ // that will be called.
436
+ url: function() {
437
+ var base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError();
438
+ if (this.isNew()) return base;
439
+ return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
440
+ },
441
+
442
+ // **parse** converts a response into the hash of attributes to be `set` on
443
+ // the model. The default implementation is just to pass the response along.
444
+ parse: function(resp, xhr) {
445
+ return resp;
446
+ },
447
+
448
+ // Create a new model with identical attributes to this one.
449
+ clone: function() {
450
+ return new this.constructor(this.attributes);
451
+ },
452
+
453
+ // A model is new if it has never been saved to the server, and lacks an id.
454
+ isNew: function() {
455
+ return this.id == null;
456
+ },
457
+
458
+ // Call this method to manually fire a `"change"` event for this model and
459
+ // a `"change:attribute"` event for each changed attribute.
460
+ // Calling this will cause all objects observing the model to update.
461
+ change: function(options) {
462
+ var changing = this._changing;
463
+ var current = this._changing = {};
464
+
465
+ // Silent changes become pending changes.
466
+ for (var attr in this._changes) this._pending[attr] = true;
467
+
468
+ // Trigger 'change:attr' for any new or silent changes.
469
+ var changes = this._changes;
470
+ this._changes = {};
471
+
472
+ // Set the correct state for this._changing values
473
+ var triggers = [];
474
+ for (var attr in changes) {
475
+ current[attr] = this.get(attr);
476
+ triggers.push(attr);
477
+ }
478
+
479
+ for (var i=0, l=triggers.length; i < l; i++) {
480
+ this.trigger('change:' + triggers[i], this, current[triggers[i]], options);
481
+ }
482
+ if (changing) return this;
483
+
484
+ // Continue firing `"change"` events while there are pending changes.
485
+ while (!_.isEmpty(this._pending)) {
486
+ this._pending = {};
487
+ this.trigger('change', this, options);
488
+ // Pending and silent changes still remain.
489
+ for (var attr in this.changed) {
490
+ if (this._pending[attr] || this._changes[attr]) continue;
491
+ delete this.changed[attr];
492
+ }
493
+ this._previousAttributes = _.clone(this.attributes);
494
+ }
495
+
496
+ this._changing = null;
497
+ return this;
498
+ },
499
+
500
+ // Determine if the model has changed since the last `"change"` event.
501
+ // If you specify an attribute name, determine if that attribute has changed.
502
+ hasChanged: function(attr) {
503
+ if (attr == null) return !_.isEmpty(this.changed);
504
+ return _.has(this.changed, attr);
505
+ },
506
+
507
+ // Return an object containing all the attributes that have changed, or
508
+ // false if there are no changed attributes. Useful for determining what
509
+ // parts of a view need to be updated and/or what attributes need to be
510
+ // persisted to the server. Unset attributes will be set to undefined.
511
+ // You can also pass an attributes object to diff against the model,
512
+ // determining if there *would be* a change.
513
+ changedAttributes: function(diff) {
514
+ if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
515
+ var val, changed = false, old = this._previousAttributes;
516
+ for (var attr in diff) {
517
+ if (_.isEqual(old[attr], (val = diff[attr]))) continue;
518
+ (changed || (changed = {}))[attr] = val;
519
+ }
520
+ return changed;
521
+ },
522
+
523
+ // Get the previous value of an attribute, recorded at the time the last
524
+ // `"change"` event was fired.
525
+ previous: function(attr) {
526
+ if (attr == null || !this._previousAttributes) return null;
527
+ return this._previousAttributes[attr];
528
+ },
529
+
530
+ // Get all of the attributes of the model at the time of the previous
531
+ // `"change"` event.
532
+ previousAttributes: function() {
533
+ return _.clone(this._previousAttributes);
534
+ },
535
+
536
+ // Check if the model is currently in a valid state. It's only possible to
537
+ // get into an *invalid* state if you're using silent changes.
538
+ isValid: function(options) {
539
+ return !this.validate || !this.validate(this.attributes, options);
540
+ },
541
+
542
+ // Run validation against the next complete set of model attributes,
543
+ // returning `true` if all is well. If a specific `error` callback has
544
+ // been passed, call that instead of firing the general `"error"` event.
545
+ _validate: function(attrs, options) {
546
+ if (options && options.silent || !this.validate) return true;
547
+ attrs = _.extend({}, this.attributes, attrs);
548
+ var error = this.validate(attrs, options);
549
+ if (!error) return true;
550
+ if (options && options.error) options.error(this, error, options);
551
+ this.trigger('error', this, error, options);
552
+ return false;
553
+ }
554
+
555
+ });
556
+
557
+ // Backbone.Collection
558
+ // -------------------
559
+
560
+ // Provides a standard collection class for our sets of models, ordered
561
+ // or unordered. If a `comparator` is specified, the Collection will maintain
562
+ // its models in sort order, as they're added and removed.
563
+ var Collection = Backbone.Collection = function(models, options) {
564
+ options || (options = {});
565
+ if (options.model) this.model = options.model;
566
+ if (options.comparator !== void 0) this.comparator = options.comparator;
567
+ this._reset();
568
+ this.initialize.apply(this, arguments);
569
+ if (models) {
570
+ if (options.parse) models = this.parse(models);
571
+ this.reset(models, {silent: true, parse: options.parse});
572
+ }
573
+ };
574
+
575
+ // Define the Collection's inheritable methods.
576
+ _.extend(Collection.prototype, Events, {
577
+
578
+ // The default model for a collection is just a **Backbone.Model**.
579
+ // This should be overridden in most cases.
580
+ model: Model,
581
+
582
+ // Initialize is an empty function by default. Override it with your own
583
+ // initialization logic.
584
+ initialize: function(){},
585
+
586
+ // The JSON representation of a Collection is an array of the
587
+ // models' attributes.
588
+ toJSON: function(options) {
589
+ return this.map(function(model){ return model.toJSON(options); });
590
+ },
591
+
592
+ // Proxy `Backbone.sync` by default.
593
+ sync: function() {
594
+ return Backbone.sync.apply(this, arguments);
595
+ },
596
+
597
+ // Add a model, or list of models to the set. Pass **silent** to avoid
598
+ // firing the `add` event for every new model.
599
+ add: function(models, options) {
600
+ var i, args, length, model, existing;
601
+ var at = options && options.at;
602
+ models = _.isArray(models) ? models.slice() : [models];
603
+
604
+ // Begin by turning bare objects into model references, and preventing
605
+ // invalid models from being added.
606
+ for (i = 0, length = models.length; i < length; i++) {
607
+ if (models[i] = this._prepareModel(models[i], options)) continue;
608
+ throw new Error("Can't add an invalid model to a collection");
609
+ }
610
+
611
+ for (i = models.length - 1; i >= 0; i--) {
612
+ model = models[i];
613
+ existing = model.id != null && this._byId[model.id];
614
+
615
+ // If a duplicate is found, splice it out and optionally merge it into
616
+ // the existing model.
617
+ if (existing || this._byCid[model.cid]) {
618
+ if (options && options.merge && existing) {
619
+ existing.set(model, options);
620
+ }
621
+ models.splice(i, 1);
622
+ continue;
623
+ }
624
+
625
+ // Listen to added models' events, and index models for lookup by
626
+ // `id` and by `cid`.
627
+ model.on('all', this._onModelEvent, this);
628
+ this._byCid[model.cid] = model;
629
+ if (model.id != null) this._byId[model.id] = model;
630
+ }
631
+
632
+ // Update `length` and splice in new models.
633
+ this.length += models.length;
634
+ args = [at != null ? at : this.models.length, 0];
635
+ push.apply(args, models);
636
+ splice.apply(this.models, args);
637
+
638
+ // Sort the collection if appropriate.
639
+ if (this.comparator && at == null) this.sort({silent: true});
640
+
641
+ if (options && options.silent) return this;
642
+
643
+ // Trigger `add` events.
644
+ while (model = models.shift()) {
645
+ model.trigger('add', model, this, options);
646
+ }
647
+
648
+ return this;
649
+ },
650
+
651
+ // Remove a model, or a list of models from the set. Pass silent to avoid
652
+ // firing the `remove` event for every model removed.
653
+ remove: function(models, options) {
654
+ var i, l, index, model;
655
+ options || (options = {});
656
+ models = _.isArray(models) ? models.slice() : [models];
657
+ for (i = 0, l = models.length; i < l; i++) {
658
+ model = this.getByCid(models[i]) || this.get(models[i]);
659
+ if (!model) continue;
660
+ delete this._byId[model.id];
661
+ delete this._byCid[model.cid];
662
+ index = this.indexOf(model);
663
+ this.models.splice(index, 1);
664
+ this.length--;
665
+ if (!options.silent) {
666
+ options.index = index;
667
+ model.trigger('remove', model, this, options);
668
+ }
669
+ this._removeReference(model);
670
+ }
671
+ return this;
672
+ },
673
+
674
+ // Add a model to the end of the collection.
675
+ push: function(model, options) {
676
+ model = this._prepareModel(model, options);
677
+ this.add(model, options);
678
+ return model;
679
+ },
680
+
681
+ // Remove a model from the end of the collection.
682
+ pop: function(options) {
683
+ var model = this.at(this.length - 1);
684
+ this.remove(model, options);
685
+ return model;
686
+ },
687
+
688
+ // Add a model to the beginning of the collection.
689
+ unshift: function(model, options) {
690
+ model = this._prepareModel(model, options);
691
+ this.add(model, _.extend({at: 0}, options));
692
+ return model;
693
+ },
694
+
695
+ // Remove a model from the beginning of the collection.
696
+ shift: function(options) {
697
+ var model = this.at(0);
698
+ this.remove(model, options);
699
+ return model;
700
+ },
701
+
702
+ // Slice out a sub-array of models from the collection.
703
+ slice: function(begin, end) {
704
+ return this.models.slice(begin, end);
705
+ },
706
+
707
+ // Get a model from the set by id.
708
+ get: function(id) {
709
+ if (id == null) return void 0;
710
+ return this._byId[id.id != null ? id.id : id];
711
+ },
712
+
713
+ // Get a model from the set by client id.
714
+ getByCid: function(cid) {
715
+ return cid && this._byCid[cid.cid || cid];
716
+ },
717
+
718
+ // Get the model at the given index.
719
+ at: function(index) {
720
+ return this.models[index];
721
+ },
722
+
723
+ // Return models with matching attributes. Useful for simple cases of `filter`.
724
+ where: function(attrs) {
725
+ if (_.isEmpty(attrs)) return [];
726
+ return this.filter(function(model) {
727
+ for (var key in attrs) {
728
+ if (attrs[key] !== model.get(key)) return false;
729
+ }
730
+ return true;
731
+ });
732
+ },
733
+
734
+ // Force the collection to re-sort itself. You don't need to call this under
735
+ // normal circumstances, as the set will maintain sort order as each item
736
+ // is added.
737
+ sort: function(options) {
738
+ if (!this.comparator) {
739
+ throw new Error('Cannot sort a set without a comparator');
740
+ }
741
+
742
+ if (_.isString(this.comparator) || this.comparator.length === 1) {
743
+ this.models = this.sortBy(this.comparator, this);
744
+ } else {
745
+ this.models.sort(_.bind(this.comparator, this));
746
+ }
747
+
748
+ if (!options || !options.silent) this.trigger('reset', this, options);
749
+ return this;
750
+ },
751
+
752
+ // Pluck an attribute from each model in the collection.
753
+ pluck: function(attr) {
754
+ return _.invoke(this.models, 'get', attr);
755
+ },
756
+
757
+ // When you have more items than you want to add or remove individually,
758
+ // you can reset the entire set with a new list of models, without firing
759
+ // any `add` or `remove` events. Fires `reset` when finished.
760
+ reset: function(models, options) {
761
+ for (var i = 0, l = this.models.length; i < l; i++) {
762
+ this._removeReference(this.models[i]);
763
+ }
764
+ this._reset();
765
+ if (models) this.add(models, _.extend({silent: true}, options));
766
+ if (!options || !options.silent) this.trigger('reset', this, options);
767
+ return this;
768
+ },
769
+
770
+ // Fetch the default set of models for this collection, resetting the
771
+ // collection when they arrive. If `add: true` is passed, appends the
772
+ // models to the collection instead of resetting.
773
+ fetch: function(options) {
774
+ options = options ? _.clone(options) : {};
775
+ if (options.parse === void 0) options.parse = true;
776
+ var collection = this;
777
+ var success = options.success;
778
+ options.success = function(resp, status, xhr) {
779
+ collection[options.add ? 'add' : 'reset'](collection.parse(resp, xhr), options);
780
+ if (success) success(collection, resp, options);
781
+ };
782
+ return this.sync('read', this, options);
783
+ },
784
+
785
+ // Create a new instance of a model in this collection. Add the model to the
786
+ // collection immediately, unless `wait: true` is passed, in which case we
787
+ // wait for the server to agree.
788
+ create: function(model, options) {
789
+ var collection = this;
790
+ options = options ? _.clone(options) : {};
791
+ model = this._prepareModel(model, options);
792
+ if (!model) return false;
793
+ if (!options.wait) collection.add(model, options);
794
+ var success = options.success;
795
+ options.success = function(model, resp, options) {
796
+ if (options.wait) collection.add(model, options);
797
+ if (success) success(model, resp, options);
798
+ };
799
+ model.save(null, options);
800
+ return model;
801
+ },
802
+
803
+ // **parse** converts a response into a list of models to be added to the
804
+ // collection. The default implementation is just to pass it through.
805
+ parse: function(resp, xhr) {
806
+ return resp;
807
+ },
808
+
809
+ // Create a new collection with an identical list of models as this one.
810
+ clone: function() {
811
+ return new this.constructor(this.models);
812
+ },
813
+
814
+ // Proxy to _'s chain. Can't be proxied the same way the rest of the
815
+ // underscore methods are proxied because it relies on the underscore
816
+ // constructor.
817
+ chain: function() {
818
+ return _(this.models).chain();
819
+ },
820
+
821
+ // Reset all internal state. Called when the collection is reset.
822
+ _reset: function(options) {
823
+ this.length = 0;
824
+ this.models = [];
825
+ this._byId = {};
826
+ this._byCid = {};
827
+ },
828
+
829
+ // Prepare a model or hash of attributes to be added to this collection.
830
+ _prepareModel: function(attrs, options) {
831
+ if (attrs instanceof Model) {
832
+ if (!attrs.collection) attrs.collection = this;
833
+ return attrs;
834
+ }
835
+ options || (options = {});
836
+ options.collection = this;
837
+ var model = new this.model(attrs, options);
838
+ if (!model._validate(model.attributes, options)) return false;
839
+ return model;
840
+ },
841
+
842
+ // Internal method to remove a model's ties to a collection.
843
+ _removeReference: function(model) {
844
+ if (this === model.collection) delete model.collection;
845
+ model.off('all', this._onModelEvent, this);
846
+ },
847
+
848
+ // Internal method called every time a model in the set fires an event.
849
+ // Sets need to update their indexes when models change ids. All other
850
+ // events simply proxy through. "add" and "remove" events that originate
851
+ // in other collections are ignored.
852
+ _onModelEvent: function(event, model, collection, options) {
853
+ if ((event === 'add' || event === 'remove') && collection !== this) return;
854
+ if (event === 'destroy') this.remove(model, options);
855
+ if (model && event === 'change:' + model.idAttribute) {
856
+ delete this._byId[model.previous(model.idAttribute)];
857
+ if (model.id != null) this._byId[model.id] = model;
858
+ }
859
+ this.trigger.apply(this, arguments);
860
+ }
861
+
862
+ });
863
+
864
+ // Underscore methods that we want to implement on the Collection.
865
+ var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl',
866
+ 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select',
867
+ 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke',
868
+ 'max', 'min', 'sortedIndex', 'toArray', 'size', 'first', 'head', 'take',
869
+ 'initial', 'rest', 'tail', 'last', 'without', 'indexOf', 'shuffle',
870
+ 'lastIndexOf', 'isEmpty'];
871
+
872
+ // Mix in each Underscore method as a proxy to `Collection#models`.
873
+ _.each(methods, function(method) {
874
+ Collection.prototype[method] = function() {
875
+ var args = slice.call(arguments);
876
+ args.unshift(this.models);
877
+ return _[method].apply(_, args);
878
+ };
879
+ });
880
+
881
+ // Underscore methods that take a property name as an argument.
882
+ var attributeMethods = ['groupBy', 'countBy', 'sortBy'];
883
+
884
+ // Use attributes instead of properties.
885
+ _.each(attributeMethods, function(method) {
886
+ Collection.prototype[method] = function(value, context) {
887
+ var iterator = _.isFunction(value) ? value : function(model) {
888
+ return model.get(value);
889
+ };
890
+ return _[method](this.models, iterator, context);
891
+ };
892
+ });
893
+
894
+ // Backbone.Router
895
+ // -------------------
896
+
897
+ // Routers map faux-URLs to actions, and fire events when routes are
898
+ // matched. Creating a new one sets its `routes` hash, if not set statically.
899
+ var Router = Backbone.Router = function(options) {
900
+ options || (options = {});
901
+ if (options.routes) this.routes = options.routes;
902
+ this._bindRoutes();
903
+ this.initialize.apply(this, arguments);
904
+ };
905
+
906
+ // Cached regular expressions for matching named param parts and splatted
907
+ // parts of route strings.
908
+ var optionalParam = /\((.*?)\)/g;
909
+ var namedParam = /:\w+/g;
910
+ var splatParam = /\*\w+/g;
911
+ var escapeRegExp = /[-{}[\]+?.,\\^$|#\s]/g;
912
+
913
+ // Set up all inheritable **Backbone.Router** properties and methods.
914
+ _.extend(Router.prototype, Events, {
915
+
916
+ // Initialize is an empty function by default. Override it with your own
917
+ // initialization logic.
918
+ initialize: function(){},
919
+
920
+ // Manually bind a single named route to a callback. For example:
921
+ //
922
+ // this.route('search/:query/p:num', 'search', function(query, num) {
923
+ // ...
924
+ // });
925
+ //
926
+ route: function(route, name, callback) {
927
+ if (!_.isRegExp(route)) route = this._routeToRegExp(route);
928
+ if (!callback) callback = this[name];
929
+ Backbone.history.route(route, _.bind(function(fragment) {
930
+ var args = this._extractParameters(route, fragment);
931
+ callback && callback.apply(this, args);
932
+ this.trigger.apply(this, ['route:' + name].concat(args));
933
+ Backbone.history.trigger('route', this, name, args);
934
+ }, this));
935
+ return this;
936
+ },
937
+
938
+ // Simple proxy to `Backbone.history` to save a fragment into the history.
939
+ navigate: function(fragment, options) {
940
+ Backbone.history.navigate(fragment, options);
941
+ return this;
942
+ },
943
+
944
+ // Bind all defined routes to `Backbone.history`. We have to reverse the
945
+ // order of the routes here to support behavior where the most general
946
+ // routes can be defined at the bottom of the route map.
947
+ _bindRoutes: function() {
948
+ if (!this.routes) return;
949
+ var routes = [];
950
+ for (var route in this.routes) {
951
+ routes.unshift([route, this.routes[route]]);
952
+ }
953
+ for (var i = 0, l = routes.length; i < l; i++) {
954
+ this.route(routes[i][0], routes[i][1], this[routes[i][1]]);
955
+ }
956
+ },
957
+
958
+ // Convert a route string into a regular expression, suitable for matching
959
+ // against the current location hash.
960
+ _routeToRegExp: function(route) {
961
+ route = route.replace(escapeRegExp, '\\$&')
962
+ .replace(optionalParam, '(?:$1)?')
963
+ .replace(namedParam, '([^\/]+)')
964
+ .replace(splatParam, '(.*?)');
965
+ return new RegExp('^' + route + '$');
966
+ },
967
+
968
+ // Given a route, and a URL fragment that it matches, return the array of
969
+ // extracted parameters.
970
+ _extractParameters: function(route, fragment) {
971
+ return route.exec(fragment).slice(1);
972
+ }
973
+
974
+ });
975
+
976
+ // Backbone.History
977
+ // ----------------
978
+
979
+ // Handles cross-browser history management, based on URL fragments. If the
980
+ // browser does not support `onhashchange`, falls back to polling.
981
+ var History = Backbone.History = function() {
982
+ this.handlers = [];
983
+ _.bindAll(this, 'checkUrl');
984
+
985
+ // #1653 - Ensure that `History` can be used outside of the browser.
986
+ if (typeof window !== 'undefined') {
987
+ this.location = window.location;
988
+ this.history = window.history;
989
+ }
990
+ };
991
+
992
+ // Cached regex for cleaning leading hashes and slashes.
993
+ var routeStripper = /^[#\/]/;
994
+
995
+ // Cached regex for stripping leading and trailing slashes.
996
+ var rootStripper = /^\/+|\/+$/g;
997
+
998
+ // Cached regex for detecting MSIE.
999
+ var isExplorer = /msie [\w.]+/;
1000
+
1001
+ // Cached regex for removing a trailing slash.
1002
+ var trailingSlash = /\/$/;
1003
+
1004
+ // Has the history handling already been started?
1005
+ History.started = false;
1006
+
1007
+ // Set up all inheritable **Backbone.History** properties and methods.
1008
+ _.extend(History.prototype, Events, {
1009
+
1010
+ // The default interval to poll for hash changes, if necessary, is
1011
+ // twenty times a second.
1012
+ interval: 50,
1013
+
1014
+ // Gets the true hash value. Cannot use location.hash directly due to bug
1015
+ // in Firefox where location.hash will always be decoded.
1016
+ getHash: function(window) {
1017
+ var match = (window || this).location.href.match(/#(.*)$/);
1018
+ return match ? match[1] : '';
1019
+ },
1020
+
1021
+ // Get the cross-browser normalized URL fragment, either from the URL,
1022
+ // the hash, or the override.
1023
+ getFragment: function(fragment, forcePushState) {
1024
+ if (fragment == null) {
1025
+ if (this._hasPushState || !this._wantsHashChange || forcePushState) {
1026
+ fragment = this.location.pathname;
1027
+ var root = this.root.replace(trailingSlash, '');
1028
+ if (!fragment.indexOf(root)) fragment = fragment.substr(root.length);
1029
+ } else {
1030
+ fragment = this.getHash();
1031
+ }
1032
+ }
1033
+ return decodeURIComponent(fragment.replace(routeStripper, ''));
1034
+ },
1035
+
1036
+ // Start the hash change handling, returning `true` if the current URL matches
1037
+ // an existing route, and `false` otherwise.
1038
+ start: function(options) {
1039
+ if (History.started) throw new Error("Backbone.history has already been started");
1040
+ History.started = true;
1041
+
1042
+ // Figure out the initial configuration. Do we need an iframe?
1043
+ // Is pushState desired ... is it available?
1044
+ this.options = _.extend({}, {root: '/'}, this.options, options);
1045
+ this.root = this.options.root;
1046
+ this._wantsHashChange = this.options.hashChange !== false;
1047
+ this._wantsPushState = !!this.options.pushState;
1048
+ this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
1049
+ var fragment = this.getFragment();
1050
+ var docMode = document.documentMode;
1051
+ var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
1052
+
1053
+ // Normalize root to always include a leading and trailing slash.
1054
+ this.root = ('/' + this.root + '/').replace(rootStripper, '/');
1055
+
1056
+ if (oldIE && this._wantsHashChange) {
1057
+ this.iframe = Backbone.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
1058
+ this.navigate(fragment);
1059
+ }
1060
+
1061
+ // Depending on whether we're using pushState or hashes, and whether
1062
+ // 'onhashchange' is supported, determine how we check the URL state.
1063
+ if (this._hasPushState) {
1064
+ Backbone.$(window).bind('popstate', this.checkUrl);
1065
+ } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) {
1066
+ Backbone.$(window).bind('hashchange', this.checkUrl);
1067
+ } else if (this._wantsHashChange) {
1068
+ this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
1069
+ }
1070
+
1071
+ // Determine if we need to change the base url, for a pushState link
1072
+ // opened by a non-pushState browser.
1073
+ this.fragment = fragment;
1074
+ var loc = this.location;
1075
+ var atRoot = loc.pathname.replace(/[^\/]$/, '$&/') === this.root;
1076
+
1077
+ // If we've started off with a route from a `pushState`-enabled browser,
1078
+ // but we're currently in a browser that doesn't support it...
1079
+ if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !atRoot) {
1080
+ this.fragment = this.getFragment(null, true);
1081
+ this.location.replace(this.root + this.location.search + '#' + this.fragment);
1082
+ // Return immediately as browser will do redirect to new url
1083
+ return true;
1084
+
1085
+ // Or if we've started out with a hash-based route, but we're currently
1086
+ // in a browser where it could be `pushState`-based instead...
1087
+ } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) {
1088
+ this.fragment = this.getHash().replace(routeStripper, '');
1089
+ this.history.replaceState({}, document.title, this.root + this.fragment + loc.search);
1090
+ }
1091
+
1092
+ if (!this.options.silent) return this.loadUrl();
1093
+ },
1094
+
1095
+ // Disable Backbone.history, perhaps temporarily. Not useful in a real app,
1096
+ // but possibly useful for unit testing Routers.
1097
+ stop: function() {
1098
+ Backbone.$(window).unbind('popstate', this.checkUrl).unbind('hashchange', this.checkUrl);
1099
+ clearInterval(this._checkUrlInterval);
1100
+ History.started = false;
1101
+ },
1102
+
1103
+ // Add a route to be tested when the fragment changes. Routes added later
1104
+ // may override previous routes.
1105
+ route: function(route, callback) {
1106
+ this.handlers.unshift({route: route, callback: callback});
1107
+ },
1108
+
1109
+ // Checks the current URL to see if it has changed, and if it has,
1110
+ // calls `loadUrl`, normalizing across the hidden iframe.
1111
+ checkUrl: function(e) {
1112
+ var current = this.getFragment();
1113
+ if (current === this.fragment && this.iframe) {
1114
+ current = this.getFragment(this.getHash(this.iframe));
1115
+ }
1116
+ if (current === this.fragment) return false;
1117
+ if (this.iframe) this.navigate(current);
1118
+ this.loadUrl() || this.loadUrl(this.getHash());
1119
+ },
1120
+
1121
+ // Attempt to load the current URL fragment. If a route succeeds with a
1122
+ // match, returns `true`. If no defined routes matches the fragment,
1123
+ // returns `false`.
1124
+ loadUrl: function(fragmentOverride) {
1125
+ var fragment = this.fragment = this.getFragment(fragmentOverride);
1126
+ var matched = _.any(this.handlers, function(handler) {
1127
+ if (handler.route.test(fragment)) {
1128
+ handler.callback(fragment);
1129
+ return true;
1130
+ }
1131
+ });
1132
+ return matched;
1133
+ },
1134
+
1135
+ // Save a fragment into the hash history, or replace the URL state if the
1136
+ // 'replace' option is passed. You are responsible for properly URL-encoding
1137
+ // the fragment in advance.
1138
+ //
1139
+ // The options object can contain `trigger: true` if you wish to have the
1140
+ // route callback be fired (not usually desirable), or `replace: true`, if
1141
+ // you wish to modify the current URL without adding an entry to the history.
1142
+ navigate: function(fragment, options) {
1143
+ if (!History.started) return false;
1144
+ if (!options || options === true) options = {trigger: options};
1145
+ fragment = this.getFragment(fragment || '');
1146
+ if (this.fragment === fragment) return;
1147
+ this.fragment = fragment;
1148
+ var url = this.root + fragment;
1149
+
1150
+ // If pushState is available, we use it to set the fragment as a real URL.
1151
+ if (this._hasPushState) {
1152
+ this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
1153
+
1154
+ // If hash changes haven't been explicitly disabled, update the hash
1155
+ // fragment to store history.
1156
+ } else if (this._wantsHashChange) {
1157
+ this._updateHash(this.location, fragment, options.replace);
1158
+ if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) {
1159
+ // Opening and closing the iframe tricks IE7 and earlier to push a
1160
+ // history entry on hash-tag change. When replace is true, we don't
1161
+ // want this.
1162
+ if(!options.replace) this.iframe.document.open().close();
1163
+ this._updateHash(this.iframe.location, fragment, options.replace);
1164
+ }
1165
+
1166
+ // If you've told us that you explicitly don't want fallback hashchange-
1167
+ // based history, then `navigate` becomes a page refresh.
1168
+ } else {
1169
+ return this.location.assign(url);
1170
+ }
1171
+ if (options.trigger) this.loadUrl(fragment);
1172
+ },
1173
+
1174
+ // Update the hash location, either replacing the current entry, or adding
1175
+ // a new one to the browser history.
1176
+ _updateHash: function(location, fragment, replace) {
1177
+ if (replace) {
1178
+ var href = location.href.replace(/(javascript:|#).*$/, '');
1179
+ location.replace(href + '#' + fragment);
1180
+ } else {
1181
+ // #1649 - Some browsers require that `hash` contains a leading #.
1182
+ location.hash = '#' + fragment;
1183
+ }
1184
+ }
1185
+
1186
+ });
1187
+
1188
+ // Create the default Backbone.history.
1189
+ Backbone.history = new History;
1190
+
1191
+ // Backbone.View
1192
+ // -------------
1193
+
1194
+ // Creating a Backbone.View creates its initial element outside of the DOM,
1195
+ // if an existing element is not provided...
1196
+ var View = Backbone.View = function(options) {
1197
+ this.cid = _.uniqueId('view');
1198
+ this._configure(options || {});
1199
+ this._ensureElement();
1200
+ this.initialize.apply(this, arguments);
1201
+ this.delegateEvents();
1202
+ };
1203
+
1204
+ // Cached regex to split keys for `delegate`.
1205
+ var delegateEventSplitter = /^(\S+)\s*(.*)$/;
1206
+
1207
+ // List of view options to be merged as properties.
1208
+ var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName'];
1209
+
1210
+ // Set up all inheritable **Backbone.View** properties and methods.
1211
+ _.extend(View.prototype, Events, {
1212
+
1213
+ // The default `tagName` of a View's element is `"div"`.
1214
+ tagName: 'div',
1215
+
1216
+ // jQuery delegate for element lookup, scoped to DOM elements within the
1217
+ // current view. This should be prefered to global lookups where possible.
1218
+ $: function(selector) {
1219
+ return this.$el.find(selector);
1220
+ },
1221
+
1222
+ // Initialize is an empty function by default. Override it with your own
1223
+ // initialization logic.
1224
+ initialize: function(){},
1225
+
1226
+ // **render** is the core function that your view should override, in order
1227
+ // to populate its element (`this.el`), with the appropriate HTML. The
1228
+ // convention is for **render** to always return `this`.
1229
+ render: function() {
1230
+ return this;
1231
+ },
1232
+
1233
+ // Clean up references to this view in order to prevent latent effects and
1234
+ // memory leaks.
1235
+ dispose: function() {
1236
+ this.undelegateEvents();
1237
+ if (this.model && this.model.off) this.model.off(null, null, this);
1238
+ if (this.collection && this.collection.off) this.collection.off(null, null, this);
1239
+ return this;
1240
+ },
1241
+
1242
+ // Remove this view from the DOM. Note that the view isn't present in the
1243
+ // DOM by default, so calling this method may be a no-op.
1244
+ remove: function() {
1245
+ this.dispose();
1246
+ this.$el.remove();
1247
+ return this;
1248
+ },
1249
+
1250
+ // For small amounts of DOM Elements, where a full-blown template isn't
1251
+ // needed, use **make** to manufacture elements, one at a time.
1252
+ //
1253
+ // var el = this.make('li', {'class': 'row'}, this.model.escape('title'));
1254
+ //
1255
+ make: function(tagName, attributes, content) {
1256
+ var el = document.createElement(tagName);
1257
+ if (attributes) Backbone.$(el).attr(attributes);
1258
+ if (content != null) Backbone.$(el).html(content);
1259
+ return el;
1260
+ },
1261
+
1262
+ // Change the view's element (`this.el` property), including event
1263
+ // re-delegation.
1264
+ setElement: function(element, delegate) {
1265
+ if (this.$el) this.undelegateEvents();
1266
+ this.$el = element instanceof Backbone.$ ? element : Backbone.$(element);
1267
+ this.el = this.$el[0];
1268
+ if (delegate !== false) this.delegateEvents();
1269
+ return this;
1270
+ },
1271
+
1272
+ // Set callbacks, where `this.events` is a hash of
1273
+ //
1274
+ // *{"event selector": "callback"}*
1275
+ //
1276
+ // {
1277
+ // 'mousedown .title': 'edit',
1278
+ // 'click .button': 'save'
1279
+ // 'click .open': function(e) { ... }
1280
+ // }
1281
+ //
1282
+ // pairs. Callbacks will be bound to the view, with `this` set properly.
1283
+ // Uses event delegation for efficiency.
1284
+ // Omitting the selector binds the event to `this.el`.
1285
+ // This only works for delegate-able events: not `focus`, `blur`, and
1286
+ // not `change`, `submit`, and `reset` in Internet Explorer.
1287
+ delegateEvents: function(events) {
1288
+ if (!(events || (events = _.result(this, 'events')))) return;
1289
+ this.undelegateEvents();
1290
+ for (var key in events) {
1291
+ var method = events[key];
1292
+ if (!_.isFunction(method)) method = this[events[key]];
1293
+ if (!method) throw new Error('Method "' + events[key] + '" does not exist');
1294
+ var match = key.match(delegateEventSplitter);
1295
+ var eventName = match[1], selector = match[2];
1296
+ method = _.bind(method, this);
1297
+ eventName += '.delegateEvents' + this.cid;
1298
+ if (selector === '') {
1299
+ this.$el.bind(eventName, method);
1300
+ } else {
1301
+ this.$el.delegate(selector, eventName, method);
1302
+ }
1303
+ }
1304
+ },
1305
+
1306
+ // Clears all callbacks previously bound to the view with `delegateEvents`.
1307
+ // You usually don't need to use this, but may wish to if you have multiple
1308
+ // Backbone views attached to the same DOM element.
1309
+ undelegateEvents: function() {
1310
+ this.$el.unbind('.delegateEvents' + this.cid);
1311
+ },
1312
+
1313
+ // Performs the initial configuration of a View with a set of options.
1314
+ // Keys with special meaning *(model, collection, id, className)*, are
1315
+ // attached directly to the view.
1316
+ _configure: function(options) {
1317
+ if (this.options) options = _.extend({}, this.options, options);
1318
+ for (var i = 0, l = viewOptions.length; i < l; i++) {
1319
+ var attr = viewOptions[i];
1320
+ if (options[attr]) this[attr] = options[attr];
1321
+ }
1322
+ this.options = options;
1323
+ },
1324
+
1325
+ // Ensure that the View has a DOM element to render into.
1326
+ // If `this.el` is a string, pass it through `$()`, take the first
1327
+ // matching element, and re-assign it to `el`. Otherwise, create
1328
+ // an element from the `id`, `className` and `tagName` properties.
1329
+ _ensureElement: function() {
1330
+ if (!this.el) {
1331
+ var attrs = _.extend({}, _.result(this, 'attributes'));
1332
+ if (this.id) attrs.id = _.result(this, 'id');
1333
+ if (this.className) attrs['class'] = _.result(this, 'className');
1334
+ this.setElement(this.make(_.result(this, 'tagName'), attrs), false);
1335
+ } else {
1336
+ this.setElement(_.result(this, 'el'), false);
1337
+ }
1338
+ }
1339
+
1340
+ });
1341
+
1342
+ // Backbone.sync
1343
+ // -------------
1344
+
1345
+ // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
1346
+ var methodMap = {
1347
+ 'create': 'POST',
1348
+ 'update': 'PUT',
1349
+ 'delete': 'DELETE',
1350
+ 'read': 'GET'
1351
+ };
1352
+
1353
+ // Override this function to change the manner in which Backbone persists
1354
+ // models to the server. You will be passed the type of request, and the
1355
+ // model in question. By default, makes a RESTful Ajax request
1356
+ // to the model's `url()`. Some possible customizations could be:
1357
+ //
1358
+ // * Use `setTimeout` to batch rapid-fire updates into a single request.
1359
+ // * Send up the models as XML instead of JSON.
1360
+ // * Persist models via WebSockets instead of Ajax.
1361
+ //
1362
+ // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests
1363
+ // as `POST`, with a `_method` parameter containing the true HTTP method,
1364
+ // as well as all requests with the body as `application/x-www-form-urlencoded`
1365
+ // instead of `application/json` with the model in a param named `model`.
1366
+ // Useful when interfacing with server-side languages like **PHP** that make
1367
+ // it difficult to read the body of `PUT` requests.
1368
+ Backbone.sync = function(method, model, options) {
1369
+ var type = methodMap[method];
1370
+
1371
+ // Default options, unless specified.
1372
+ options || (options = {});
1373
+
1374
+ // Default JSON-request options.
1375
+ var params = {type: type, dataType: 'json'};
1376
+
1377
+ // Ensure that we have a URL.
1378
+ if (!options.url) {
1379
+ params.url = _.result(model, 'url') || urlError();
1380
+ }
1381
+
1382
+ // Ensure that we have the appropriate request data.
1383
+ if (!options.data && model && (method === 'create' || method === 'update')) {
1384
+ params.contentType = 'application/json';
1385
+ params.data = JSON.stringify(model);
1386
+ }
1387
+
1388
+ // For older servers, emulate JSON by encoding the request into an HTML-form.
1389
+ if (Backbone.emulateJSON) {
1390
+ params.contentType = 'application/x-www-form-urlencoded';
1391
+ params.data = params.data ? {model: params.data} : {};
1392
+ }
1393
+
1394
+ // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
1395
+ // And an `X-HTTP-Method-Override` header.
1396
+ if (Backbone.emulateHTTP) {
1397
+ if (type === 'PUT' || type === 'DELETE') {
1398
+ if (Backbone.emulateJSON) params.data._method = type;
1399
+ params.type = 'POST';
1400
+ params.beforeSend = function(xhr) {
1401
+ xhr.setRequestHeader('X-HTTP-Method-Override', type);
1402
+ };
1403
+ }
1404
+ }
1405
+
1406
+ // Don't process data on a non-GET request.
1407
+ if (params.type !== 'GET' && !Backbone.emulateJSON) {
1408
+ params.processData = false;
1409
+ }
1410
+
1411
+ var success = options.success;
1412
+ options.success = function(resp, status, xhr) {
1413
+ if (success) success(resp, status, xhr);
1414
+ model.trigger('sync', model, resp, options);
1415
+ };
1416
+
1417
+ var error = options.error;
1418
+ options.error = function(xhr, status, thrown) {
1419
+ if (error) error(model, xhr, options);
1420
+ model.trigger('error', model, xhr, options);
1421
+ };
1422
+
1423
+ // Make the request, allowing the user to override any Ajax options.
1424
+ return Backbone.ajax(_.extend(params, options));
1425
+ };
1426
+
1427
+ // Set the default implementation of `Backbone.ajax` to proxy through to `$`.
1428
+ Backbone.ajax = function() {
1429
+ return Backbone.$.ajax.apply(Backbone.$, arguments);
1430
+ };
1431
+
1432
+ // Helpers
1433
+ // -------
1434
+
1435
+ // Helper function to correctly set up the prototype chain, for subclasses.
1436
+ // Similar to `goog.inherits`, but uses a hash of prototype properties and
1437
+ // class properties to be extended.
1438
+ var extend = function(protoProps, staticProps) {
1439
+ var parent = this;
1440
+ var child;
1441
+
1442
+ // The constructor function for the new subclass is either defined by you
1443
+ // (the "constructor" property in your `extend` definition), or defaulted
1444
+ // by us to simply call the parent's constructor.
1445
+ if (protoProps && _.has(protoProps, 'constructor')) {
1446
+ child = protoProps.constructor;
1447
+ } else {
1448
+ child = function(){ parent.apply(this, arguments); };
1449
+ }
1450
+
1451
+ // Add static properties to the constructor function, if supplied.
1452
+ _.extend(child, parent, staticProps);
1453
+
1454
+ // Set the prototype chain to inherit from `parent`, without calling
1455
+ // `parent`'s constructor function.
1456
+ var Surrogate = function(){ this.constructor = child; };
1457
+ Surrogate.prototype = parent.prototype;
1458
+ child.prototype = new Surrogate;
1459
+
1460
+ // Add prototype properties (instance properties) to the subclass,
1461
+ // if supplied.
1462
+ if (protoProps) _.extend(child.prototype, protoProps);
1463
+
1464
+ // Set a convenience property in case the parent's prototype is needed
1465
+ // later.
1466
+ child.__super__ = parent.prototype;
1467
+
1468
+ return child;
1469
+ };
1470
+
1471
+ // Set up inheritance for the model, collection, router, and view.
1472
+ Model.extend = Collection.extend = Router.extend = View.extend = extend;
1473
+
1474
+ // Throw an error when a URL is needed, and none is supplied.
1475
+ var urlError = function() {
1476
+ throw new Error('A "url" property or function must be specified');
1477
+ };
1478
+
1479
+ }).call(this);