mix-rails 0.12.1 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/MIX_RAILS_VERSION +1 -1
  2. data/admix/app/assets/javascripts/admix/application.js.coffee +17 -13
  3. data/admix/app/assets/stylesheets/admix/application.css +7 -1
  4. data/admix/app/controllers/admix/inherited_controller.rb +1 -1
  5. data/admix/lib/admix/version.rb +1 -1
  6. data/mix-rails-albums/app/assets/javascripts/admix/photos.js.erb +4 -17
  7. data/mix-rails-albums/app/assets/javascripts/{albums.js → application.js} +0 -0
  8. data/mix-rails-albums/app/assets/javascripts/backbone/application.js.coffee +12 -0
  9. data/mix-rails-albums/app/assets/javascripts/backbone/models/.gitkeep +0 -0
  10. data/mix-rails-albums/app/assets/javascripts/backbone/models/photo.js.coffee +39 -0
  11. data/mix-rails-albums/app/assets/javascripts/backbone/routers/.gitkeep +0 -0
  12. data/mix-rails-albums/app/assets/javascripts/backbone/routers/photos_router.js.coffee +36 -0
  13. data/mix-rails-albums/app/assets/javascripts/backbone/templates/.gitkeep +0 -0
  14. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/edit.jst.ejs +20 -0
  15. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/index.jst.ejs +15 -0
  16. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/modal.hamlc.erb +14 -0
  17. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/new.jst.ejs +20 -0
  18. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/photo.jst.ejs +6 -0
  19. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/show.jst.ejs +12 -0
  20. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/thumbnail.hamlc.erb +16 -0
  21. data/mix-rails-albums/app/assets/javascripts/backbone/templates/photos/upload_index.hamlc.erb +1 -0
  22. data/mix-rails-albums/app/assets/javascripts/backbone/views/.gitkeep +0 -0
  23. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/edit_view.js.coffee +24 -0
  24. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/index_view.js.coffee +20 -0
  25. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/new_view.js.coffee +37 -0
  26. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/photo_view.js.coffee +19 -0
  27. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/show_view.js.coffee +8 -0
  28. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/thumbnail_view.js.coffee +30 -0
  29. data/mix-rails-albums/app/assets/javascripts/backbone/views/photos/upload_index_view.js.coffee +22 -0
  30. data/mix-rails-albums/app/assets/javascripts/collections/filelist.js +1 -0
  31. data/mix-rails-albums/app/assets/javascripts/models/fileitem.js +3 -0
  32. data/mix-rails-albums/app/assets/javascripts/photos/upload.js.coffee.erb +9 -0
  33. data/mix-rails-albums/app/assets/javascripts/routers/photo_router.js.coffee.erb +7 -0
  34. data/mix-rails-albums/app/assets/javascripts/templates/photo_modal_edit.hamlc.erb +14 -0
  35. data/mix-rails-albums/app/assets/javascripts/templates/photo_view.hamlc.erb +1 -1
  36. data/mix-rails-albums/app/assets/javascripts/views/filelistview.js +2 -0
  37. data/mix-rails-albums/app/assets/javascripts/views/fileview.js +6 -1
  38. data/mix-rails-albums/app/assets/javascripts/views/photo_modal_view.js.coffee +25 -0
  39. data/mix-rails-albums/app/models/photo.rb +2 -2
  40. data/mix-rails-albums/app/views/admix/photos/_upload.html.haml +2 -2
  41. data/mix-rails-albums/config/routes.rb +5 -1
  42. data/mix-rails-albums/lib/mix-rails-albums.rb +1 -1
  43. data/mix-rails-albums/lib/mix-rails-albums/version.rb +1 -1
  44. data/mix-rails-albums/script/rails +1 -1
  45. data/mix-rails-auth/app/models/ability.rb +1 -1
  46. data/mix-rails-auth/lib/mix-rails-auth/version.rb +1 -1
  47. data/mix-rails-core/Gemfile +2 -0
  48. data/mix-rails-core/config/initializers/mongoid.rb +3 -0
  49. data/mix-rails-core/lib/mix-rails-core.rb +4 -2
  50. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/concerns/engine.rb +0 -0
  51. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/engine.rb +0 -0
  52. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/railtie.rb +0 -0
  53. data/mix-rails-core/lib/{mix-rails-core → mix-rails}/version.rb +1 -1
  54. data/mix-rails-core/mix-rails-core.gemspec +1 -0
  55. data/mix-rails-message-board/lib/mix-rails-message-board/version.rb +1 -1
  56. data/mix-rails-settings/lib/mix-rails-settings/version.rb +1 -1
  57. data/mix-rails-songs/lib/mix-rails-songs/version.rb +1 -1
  58. data/mix-rails-videos/lib/mix-rails-videos/version.rb +1 -1
  59. data/mix-rails-vouchers/lib/mix-rails-vouchers/version.rb +1 -1
  60. data/mix-rails-writer/lib/mix-rails-writer/version.rb +1 -1
  61. data/version.rb +1 -1
  62. metadata +56 -34
  63. data/admix/app/assets/javascripts/admix/backbone-min.js +0 -42
  64. data/admix/app/assets/javascripts/admix/underscore-min.js +0 -1
  65. data/mix-rails-albums/app/assets/javascripts/colorbox/jquery.colorbox-min.js +0 -4
  66. data/mix-rails-albums/app/assets/javascripts/photo_uploader.coffee +0 -2
  67. data/mix-rails-core/app/assets/javascripts/underscore.js +0 -1221
@@ -1,42 +0,0 @@
1
- // Backbone.js 0.9.9
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
- (function(){var k=this,y=k.Backbone,h=[],z=h.push,r=h.slice,A=h.splice,g;g="undefined"!==typeof exports?exports:k.Backbone={};g.VERSION="0.9.9";var e=k._;!e&&"undefined"!==typeof require&&(e=require("underscore"));g.$=k.jQuery||k.Zepto||k.ender;g.noConflict=function(){k.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var s=/\s+/,n=function(a,b,c,d){if(!c)return!0;if("object"===typeof c)for(var f in c)a[b].apply(a,[f,c[f]].concat(d));else if(s.test(c)){c=c.split(s);f=0;for(var e=c.length;f<
8
- e;f++)a[b].apply(a,[c[f]].concat(d))}else return!0},t=function(a,b,c){var d,a=-1,f=b.length;switch(c.length){case 0:for(;++a<f;)(d=b[a]).callback.call(d.ctx);break;case 1:for(;++a<f;)(d=b[a]).callback.call(d.ctx,c[0]);break;case 2:for(;++a<f;)(d=b[a]).callback.call(d.ctx,c[0],c[1]);break;case 3:for(;++a<f;)(d=b[a]).callback.call(d.ctx,c[0],c[1],c[2]);break;default:for(;++a<f;)(d=b[a]).callback.apply(d.ctx,c)}},h=g.Events={on:function(a,b,c){if(!n(this,"on",a,[b,c])||!b)return this;this._events||(this._events=
9
- {});(this._events[a]||(this._events[a]=[])).push({callback:b,context:c,ctx:c||this});return this},once:function(a,b,c){if(!n(this,"once",a,[b,c])||!b)return this;var d=this,f=e.once(function(){d.off(a,f);b.apply(this,arguments)});f._callback=b;this.on(a,f,c);return this},off:function(a,b,c){var d,f,l,g,i,m,h,j;if(!this._events||!n(this,"off",a,[b,c]))return this;if(!a&&!b&&!c)return this._events={},this;g=a?[a]:e.keys(this._events);i=0;for(m=g.length;i<m;i++)if(a=g[i],d=this._events[a]){l=[];if(b||
10
- c){h=0;for(j=d.length;h<j;h++)f=d[h],(b&&b!==(f.callback._callback||f.callback)||c&&c!==f.context)&&l.push(f)}this._events[a]=l}return this},trigger:function(a){if(!this._events)return this;var b=r.call(arguments,1);if(!n(this,"trigger",a,b))return this;var c=this._events[a],d=this._events.all;c&&t(this,c,b);d&&t(this,d,arguments);return this},listenTo:function(a,b,c){var d=this._listeners||(this._listeners={}),f=a._listenerId||(a._listenerId=e.uniqueId("l"));d[f]=a;a.on(b,c||this,this);return this},
11
- stopListening:function(a,b,c){var d=this._listeners;if(d){if(a)a.off(b,c,this),!b&&!c&&delete d[a._listenerId];else{for(var f in d)d[f].off(null,null,this);this._listeners={}}return this}}};h.bind=h.on;h.unbind=h.off;e.extend(g,h);var o=g.Model=function(a,b){var c,d=a||{};this.cid=e.uniqueId("c");this.changed={};this.attributes={};this._changes=[];b&&b.collection&&(this.collection=b.collection);b&&b.parse&&(d=this.parse(d));(c=e.result(this,"defaults"))&&e.defaults(d,c);this.set(d,{silent:!0});this._currentAttributes=
12
- e.clone(this.attributes);this._previousAttributes=e.clone(this.attributes);this.initialize.apply(this,arguments)};e.extend(o.prototype,h,{changed:null,idAttribute:"id",initialize:function(){},toJSON:function(){return e.clone(this.attributes)},sync:function(){return g.sync.apply(this,arguments)},get:function(a){return this.attributes[a]},escape:function(a){return e.escape(this.get(a))},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,f;if(null==a)return this;e.isObject(a)?(f=a,c=
13
- b):(f={})[a]=b;var a=c&&c.silent,l=c&&c.unset;if(!this._validate(f,c))return!1;this.idAttribute in f&&(this.id=f[this.idAttribute]);var g=this.attributes;for(d in f)b=f[d],l?delete g[d]:g[d]=b,this._changes.push(d,b);this._hasComputed=!1;a||this.change(c);return this},unset:function(a,b){return this.set(a,void 0,e.extend({},b,{unset:!0}))},clear:function(a){var b={},c;for(c in this.attributes)b[c]=void 0;return this.set(b,e.extend({},a,{unset:!0}))},fetch:function(a){a=a?e.clone(a):{};void 0===a.parse&&
14
- (a.parse=!0);var b=this,c=a.success;a.success=function(d){if(!b.set(b.parse(d),a))return false;c&&c(b,d,a)};return this.sync("read",this,a)},save:function(a,b,c){var d,f,g;null==a||e.isObject(a)?(d=a,c=b):null!=a&&((d={})[a]=b);c=c?e.clone(c):{};if(c.wait){if(d&&!this._validate(d,c))return!1;f=e.clone(this.attributes)}a=e.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c)||!d&&!this._validate(null,c))return!1;var q=this,i=c.success;c.success=function(a){g=true;var b=q.parse(a);c.wait&&(b=e.extend(d||
15
- {},b));if(!q.set(b,c))return false;i&&i(q,a,c)};b=this.isNew()?"create":c.patch?"patch":"update";"patch"==b&&(c.attrs=d);b=this.sync(b,this,c);!g&&c.wait&&(this.clear(a),this.set(f,a));return b},destroy:function(a){var a=a?e.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};a.success=function(f){(a.wait||b.isNew())&&d();c&&c(b,f,a)};if(this.isNew())return a.success(),!1;var f=this.sync("delete",this,a);a.wait||d();return f},url:function(){var a=e.result(this,"urlRoot")||
16
- e.result(this.collection,"url")||u();return this.isNew()?a:a+("/"===a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){var b=this._changing;this._changing=!0;var c=this._computeChanges(!0);this._pending=!!c.length;for(var d=c.length-2;0<=d;d-=2)this.trigger("change:"+c[d],this,c[d+1],a);if(b)return this;for(;this._pending;)this._pending=!1,this.trigger("change",
17
- this,a),this._previousAttributes=e.clone(this.attributes);this._changing=!1;return this},hasChanged:function(a){this._hasComputed||this._computeChanges();return null==a?!e.isEmpty(this.changed):e.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?e.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,f;for(f in a)if(!e.isEqual(d[f],b=a[f]))(c||(c={}))[f]=b;return c},_computeChanges:function(a){this.changed={};for(var b={},c=[],d=this._currentAttributes,f=this._changes,
18
- e=f.length-2;0<=e;e-=2){var g=f[e],i=f[e+1];b[g]||(b[g]=!0,d[g]!==i&&(this.changed[g]=i,a&&(c.push(g,i),d[g]=i)))}a&&(this._changes=[]);this._hasComputed=!0;return c},previous:function(a){return null==a||!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return e.clone(this._previousAttributes)},_validate:function(a,b){if(!this.validate)return!0;var a=e.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error&&b.error(this,c,b);this.trigger("error",
19
- this,c,b);return!1}});var p=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);void 0!==b.comparator&&(this.comparator=b.comparator);this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,e.extend({silent:!0},b))};e.extend(p.prototype,h,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},sync:function(){return g.sync.apply(this,arguments)},add:function(a,b){var c,d,f,g,h=b&&b.at,i=null==(b&&b.sort)?!0:b.sort,a=e.isArray(a)?
20
- a.slice():[a];for(c=a.length-1;0<=c;c--)(d=this._prepareModel(a[c],b))?(a[c]=d,(f=null!=d.id&&this._byId[d.id])||this._byCid[d.cid]?(b&&(b.merge&&f)&&(f.set(d.attributes,b),g=i),a.splice(c,1)):(d.on("all",this._onModelEvent,this),this._byCid[d.cid]=d,null!=d.id&&(this._byId[d.id]=d))):(this.trigger("error",this,a[c],b),a.splice(c,1));a.length&&(g=i);this.length+=a.length;c=[null!=h?h:this.models.length,0];z.apply(c,a);A.apply(this.models,c);g&&(this.comparator&&null==h)&&this.sort({silent:!0});if(b&&
21
- b.silent)return this;for(;d=a.shift();)d.trigger("add",d,this,b);return this},remove:function(a,b){var c,d,f,g;b||(b={});a=e.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],f=this.indexOf(g),this.models.splice(f,1),this.length--,b.silent||(b.index=f,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,e.extend({at:this.length},b));return a},pop:function(a){var b=
22
- this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,e.extend({at:0},b));return a},shift:function(a){var b=this.at(0);this.remove(b,a);return b},slice:function(a,b){return this.models.slice(a,b)},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]||this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return e.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},
23
- sort:function(a){if(!this.comparator)throw Error("Cannot sort a set without a comparator");e.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(e.bind(this.comparator,this));(!a||!a.silent)&&this.trigger("sort",this,a);return this},pluck:function(a){return e.invoke(this.models,"get",a)},update:function(a,b){var c,d,f,g,h=[],i=[],m={},j=this.model.prototype.idAttribute,b=e.extend({add:!0,merge:!0,remove:!0},b);b.parse&&(a=this.parse(a));
24
- e.isArray(a)||(a=a?[a]:[]);if(b.add&&!b.remove)return this.add(a,b);d=0;for(f=a.length;d<f;d++)c=a[d],g=this.get(c.id||c.cid||c[j]),b.remove&&g&&(m[g.cid]=!0),(b.add&&!g||b.merge&&g)&&h.push(c);if(b.remove){d=0;for(f=this.models.length;d<f;d++)c=this.models[d],m[c.cid]||i.push(c)}i.length&&this.remove(i,b);h.length&&this.add(h,b);return this},reset:function(a,b){b||(b={});b.parse&&(a=this.parse(a));for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);b.previousModels=this.models;
25
- this._reset();a&&this.add(a,e.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?e.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d){b[a.update?"update":"reset"](d,a);c&&c(b,d,a)};return this.sync("read",this,a)},create:function(a,b){var c=this,b=b?e.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(a,b,e){e.wait&&c.add(a,e);d&&d(a,b,e)};a.save(null,b);return a},
26
- parse:function(a){return a},clone:function(){return new this.constructor(this.models)},chain:function(){return e(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId={};this._byCid={}},_prepareModel:function(a,b){if(a instanceof o)return a.collection||(a.collection=this),a;b||(b={});b.collection=this;var c=new this.model(a,b);return!c._validate(a,b)?!1:c},_removeReference:function(a){this===a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,
27
- b,c,d){("add"===a||"remove"===a)&&c!==this||("destroy"===a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],null!=b.id&&(this._byId[b.id]=b)),this.trigger.apply(this,arguments))}});e.each("forEach each map collect reduce foldl inject reduceRight foldr find detect filter select reject every all some any include contains invoke max min sortedIndex toArray size first head take initial rest tail last without indexOf shuffle lastIndexOf isEmpty".split(" "),
28
- function(a){p.prototype[a]=function(){var b=r.call(arguments);b.unshift(this.models);return e[a].apply(e,b)}});e.each(["groupBy","countBy","sortBy"],function(a){p.prototype[a]=function(b,c){var d=e.isFunction(b)?b:function(a){return a.get(b)};return e[a](this.models,d,c)}});var v=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/\((.*?)\)/g,C=/:\w+/g,D=/\*\w+/g,E=/[\-{}\[\]+?.,\\\^$|#\s]/g;e.extend(v.prototype,h,{initialize:function(){},
29
- route:function(a,b,c){e.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,e.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b);return this},_bindRoutes:function(){if(this.routes)for(var a,b=e.keys(this.routes);null!=(a=b.pop());)this.route(a,this.routes[a])},_routeToRegExp:function(a){a=a.replace(E,"\\$&").replace(B,
30
- "(?:$1)?").replace(C,"([^/]+)").replace(D,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var j=g.History=function(){this.handlers=[];e.bindAll(this,"checkUrl");"undefined"!==typeof window&&(this.location=window.location,this.history=window.history)},w=/^[#\/]|\s+$/g,F=/^\/+|\/+$/g,G=/msie [\w.]+/,H=/\/$/;j.started=!1;e.extend(j.prototype,h,{interval:50,getHash:function(a){return(a=(a||this).location.href.match(/#(.*)$/))?a[1]:""},getFragment:function(a,
31
- b){if(null==a)if(this._hasPushState||!this._wantsHashChange||b){var a=this.location.pathname,c=this.root.replace(H,"");a.indexOf(c)||(a=a.substr(c.length))}else a=this.getHash();return a.replace(w,"")},start:function(a){if(j.started)throw Error("Backbone.history has already been started");j.started=!0;this.options=e.extend({},{root:"/"},this.options,a);this.root=this.options.root;this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=!(!this.options.pushState||
32
- !this.history||!this.history.pushState);var a=this.getFragment(),b=document.documentMode,b=G.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b);this.root=("/"+this.root+"/").replace(F,"/");b&&this._wantsHashChange&&(this.iframe=g.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a));this._hasPushState?g.$(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?g.$(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&
33
- (this._checkUrlInterval=setInterval(this.checkUrl,this.interval));this.fragment=a;a=this.location;b=a.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),this.location.replace(this.root+this.location.search+"#"+this.fragment),!0;this._wantsPushState&&(this._hasPushState&&b&&a.hash)&&(this.fragment=this.getHash().replace(w,""),this.history.replaceState({},document.title,this.root+this.fragment+
34
- a.search));if(!this.options.silent)return this.loadUrl()},stop:function(){g.$(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);j.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a===this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a===this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},
35
- loadUrl:function(a){var b=this.fragment=this.getFragment(a);return e.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!j.started)return!1;if(!b||!0===b)b={trigger:b};a=this.getFragment(a||"");if(this.fragment!==a){this.fragment=a;var c=this.root+a;if(this._hasPushState)this.history[b.replace?"replaceState":"pushState"]({},document.title,c);else if(this._wantsHashChange)this._updateHash(this.location,a,b.replace),this.iframe&&a!==this.getFragment(this.getHash(this.iframe))&&
36
- (b.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,a,b.replace));else return this.location.assign(c);b.trigger&&this.loadUrl(a)}},_updateHash:function(a,b,c){c?(c=a.href.replace(/(javascript:|#).*$/,""),a.replace(c+"#"+b)):a.hash="#"+b}});g.history=new j;var x=g.View=function(a){this.cid=e.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},I=/^(\S+)\s*(.*)$/,J="model collection el id attributes className tagName events".split(" ");
37
- e.extend(x.prototype,h,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();this.stopListening();return this},make:function(a,b,c){a=document.createElement(a);b&&g.$(a).attr(b);null!=c&&g.$(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof g.$?a:g.$(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=e.result(this,
38
- "events"))){this.undelegateEvents();for(var b in a){var c=a[b];e.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(I),f=d[1],d=d[2],c=e.bind(c,this),f=f+(".delegateEvents"+this.cid);""===d?this.$el.bind(f,c):this.$el.delegate(d,f,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=e.extend({},e.result(this,"options"),a));e.extend(this,e.pick(a,J));this.options=a},_ensureElement:function(){if(this.el)this.setElement(e.result(this,
39
- "el"),!1);else{var a=e.extend({},e.result(this,"attributes"));this.id&&(a.id=e.result(this,"id"));this.className&&(a["class"]=e.result(this,"className"));this.setElement(this.make(e.result(this,"tagName"),a),!1)}}});var K={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=K[a];e.defaults(c||(c={}),{emulateHTTP:g.emulateHTTP,emulateJSON:g.emulateJSON});var f={type:d,dataType:"json"};c.url||(f.url=e.result(b,"url")||u());if(null==c.data&&b&&("create"===
40
- a||"update"===a||"patch"===a))f.contentType="application/json",f.data=JSON.stringify(c.attrs||b.toJSON(c));c.emulateJSON&&(f.contentType="application/x-www-form-urlencoded",f.data=f.data?{model:f.data}:{});if(c.emulateHTTP&&("PUT"===d||"DELETE"===d||"PATCH"===d)){f.type="POST";c.emulateJSON&&(f.data._method=d);var h=c.beforeSend;c.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d);if(h)return h.apply(this,arguments)}}"GET"!==f.type&&!c.emulateJSON&&(f.processData=!1);var j=c.success;
41
- c.success=function(a,d,e){j&&j(a,d,e);b.trigger("sync",b,a,c)};var i=c.error;c.error=function(a){i&&i(b,a,c);b.trigger("error",b,a,c)};a=g.ajax(e.extend(f,c));b.trigger("request",b,a,c);return a};g.ajax=function(){return g.$.ajax.apply(g.$,arguments)};o.extend=p.extend=v.extend=x.extend=j.extend=function(a,b){var c=this,d;d=a&&e.has(a,"constructor")?a.constructor:function(){c.apply(this,arguments)};e.extend(d,c,b);var f=function(){this.constructor=d};f.prototype=c.prototype;d.prototype=new f;a&&e.extend(d.prototype,
42
- a);d.__super__=c.prototype;return d};var u=function(){throw Error('A "url" property or function must be specified');}}).call(this);
@@ -1 +0,0 @@
1
- (function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.index<t.index?-1:1}),"value")};var k=function(n,t,r,e){var u={},i=F(t||w.identity);return A(n,function(t,a){var o=i.call(r,t,a,n);e(u,o,t)}),u};w.groupBy=function(n,t,r){return k(n,t,r,function(n,t,r){(w.has(n,t)?n[t]:n[t]=[]).push(r)})},w.countBy=function(n,t,r){return k(n,t,r,function(n,t){w.has(n,t)||(n[t]=0),n[t]++})},w.sortedIndex=function(n,t,r,e){r=null==r?w.identity:F(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0==t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){r=w.defaults({},r,w.templateSettings);var e=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(D,function(n){return"\\"+B[n]}),r&&(i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(i+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),a&&(i+="';\n"+a+"\n__p+='"),u=o+t.length,t}),i+="';\n",r.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=Function(r.variable||"obj","_",i)}catch(o){throw o.source=i,o}if(t)return a(t,w);var c=function(n){return a.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+i+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);
@@ -1,4 +0,0 @@
1
- // ColorBox v1.3.20.2 - jQuery lightbox plugin
2
- // (c) 2012 Jack Moore - jacklmoore.com
3
- // License: http://www.opensource.org/licenses/mit-license.php
4
- (function(a,b,c){function Z(c,d,e){var g=b.createElement(c);return d&&(g.id=f+d),e&&(g.style.cssText=e),a(g)}function $(a){var b=y.length,c=(Q+a)%b;return 0>c?b+c:c}function _(a,b){return Math.round((/%/.test(a)?("x"===b?z.width():z.height())/100:1)*parseInt(a,10))}function ab(a){return K.photo||/\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i.test(a)}function bb(){var b,c=a.data(P,e);null==c?(K=a.extend({},d),console&&console.log&&console.log("Error: cboxElement missing settings object")):K=a.extend({},c);for(b in K)a.isFunction(K[b])&&"on"!==b.slice(0,2)&&(K[b]=K[b].call(P));K.rel=K.rel||P.rel||a(P).data("rel")||"nofollow",K.href=K.href||a(P).attr("href"),K.title=K.title||P.title,"string"==typeof K.href&&(K.href=a.trim(K.href))}function cb(b,c){a.event.trigger(b),c&&c.call(P)}function db(){var a,d,e,b=f+"Slideshow_",c="click."+f;K.slideshow&&y[1]?(d=function(){F.html(K.slideshowStop).unbind(c).bind(j,function(){(K.loop||y[Q+1])&&(a=setTimeout(W.next,K.slideshowSpeed))}).bind(i,function(){clearTimeout(a)}).one(c+" "+k,e),r.removeClass(b+"off").addClass(b+"on"),a=setTimeout(W.next,K.slideshowSpeed)},e=function(){clearTimeout(a),F.html(K.slideshowStart).unbind([j,i,k,c].join(" ")).one(c,function(){W.next(),d()}),r.removeClass(b+"on").addClass(b+"off")},K.slideshowAuto?d():e()):r.removeClass(b+"off "+b+"on")}function eb(b){U||(P=b,bb(),y=a(P),Q=0,"nofollow"!==K.rel&&(y=a("."+g).filter(function(){var c,b=a.data(this,e);return b&&(c=a(this).data("rel")||b.rel||this.rel),c===K.rel}),Q=y.index(P),-1===Q&&(y=y.add(P),Q=y.length-1)),S||(S=T=!0,r.show(),K.returnFocus&&a(P).blur().one(l,function(){a(this).focus()}),q.css({opacity:+K.opacity,cursor:K.overlayClose?"pointer":"auto"}).show(),K.w=_(K.initialWidth,"x"),K.h=_(K.initialHeight,"y"),W.position(),o&&z.bind("resize."+p+" scroll."+p,function(){q.css({width:z.width(),height:z.height(),top:z.scrollTop(),left:z.scrollLeft()})}).trigger("resize."+p),cb(h,K.onOpen),J.add(D).hide(),I.html(K.close).show()),W.load(!0))}function fb(){!r&&b.body&&(Y=!1,z=a(c),r=Z(X).attr({id:e,"class":n?f+(o?"IE6":"IE"):""}).hide(),q=Z(X,"Overlay",o?"position:absolute":"").hide(),C=Z(X,"LoadingOverlay").add(Z(X,"LoadingGraphic")),s=Z(X,"Wrapper"),t=Z(X,"Content").append(A=Z(X,"LoadedContent","width:0; height:0; overflow:hidden"),D=Z(X,"Title"),E=Z(X,"Current"),G=Z(X,"Next"),H=Z(X,"Previous"),F=Z(X,"Slideshow").bind(h,db),I=Z(X,"Close")),s.append(Z(X).append(Z(X,"TopLeft"),u=Z(X,"TopCenter"),Z(X,"TopRight")),Z(X,!1,"clear:left").append(v=Z(X,"MiddleLeft"),t,w=Z(X,"MiddleRight")),Z(X,!1,"clear:left").append(Z(X,"BottomLeft"),x=Z(X,"BottomCenter"),Z(X,"BottomRight"))).find("div div").css({"float":"left"}),B=Z(X,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),J=G.add(H).add(E).add(F),a(b.body).append(q,r.append(s,B)))}function gb(){return r?(Y||(Y=!0,L=u.height()+x.height()+t.outerHeight(!0)-t.height(),M=v.width()+w.width()+t.outerWidth(!0)-t.width(),N=A.outerHeight(!0),O=A.outerWidth(!0),r.css({"padding-bottom":L,"padding-right":M}),G.click(function(){W.next()}),H.click(function(){W.prev()}),I.click(function(){W.close()}),q.click(function(){K.overlayClose&&W.close()}),a(b).bind("keydown."+f,function(a){var b=a.keyCode;S&&K.escKey&&27===b&&(a.preventDefault(),W.close()),S&&K.arrowKey&&y[1]&&(37===b?(a.preventDefault(),H.click()):39===b&&(a.preventDefault(),G.click()))}),a(b).delegate("."+g,"click",function(a){a.which>1||a.shiftKey||a.altKey||a.metaKey||(a.preventDefault(),eb(this))})),!0):!1}var q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,Y,d={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",open:!1,returnFocus:!0,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0},e="colorbox",f="cbox",g=f+"Element",h=f+"_open",i=f+"_load",j=f+"_complete",k=f+"_cleanup",l=f+"_closed",m=f+"_purge",n=!a.support.opacity&&!a.support.style,o=n&&!c.XMLHttpRequest,p=f+"_IE6",X="div";a.colorbox||(a(fb),W=a.fn[e]=a[e]=function(b,c){var f=this;if(b=b||{},fb(),gb()){if(!f[0]){if(f.selector)return f;f=a("<a/>"),b.open=!0}c&&(b.onComplete=c),f.each(function(){a.data(this,e,a.extend({},a.data(this,e)||d,b))}).addClass(g),(a.isFunction(b.open)&&b.open.call(f)||b.open)&&eb(f[0])}return f},W.position=function(a,b){function j(a){u[0].style.width=x[0].style.width=t[0].style.width=a.style.width,t[0].style.height=v[0].style.height=w[0].style.height=a.style.height}var c,h,i,d=0,e=0,g=r.offset();z.unbind("resize."+f),r.css({top:-9e4,left:-9e4}),h=z.scrollTop(),i=z.scrollLeft(),K.fixed&&!o?(g.top-=h,g.left-=i,r.css({position:"fixed"})):(d=h,e=i,r.css({position:"absolute"})),e+=K.right!==!1?Math.max(z.width()-K.w-O-M-_(K.right,"x"),0):K.left!==!1?_(K.left,"x"):Math.round(Math.max(z.width()-K.w-O-M,0)/2),d+=K.bottom!==!1?Math.max(z.height()-K.h-N-L-_(K.bottom,"y"),0):K.top!==!1?_(K.top,"y"):Math.round(Math.max(z.height()-K.h-N-L,0)/2),r.css({top:g.top,left:g.left}),a=r.width()===K.w+O&&r.height()===K.h+N?0:a||0,s[0].style.width=s[0].style.height="9999px",c={width:K.w+O,height:K.h+N,top:d,left:e},0===a&&r.css(c),r.dequeue().animate(c,{duration:a,complete:function(){j(this),T=!1,s[0].style.width=K.w+O+M+"px",s[0].style.height=K.h+N+L+"px",K.reposition&&setTimeout(function(){z.bind("resize."+f,W.position)},1),b&&b()},step:function(){j(this)}})},W.resize=function(a){S&&(a=a||{},a.width&&(K.w=_(a.width,"x")-O-M),a.innerWidth&&(K.w=_(a.innerWidth,"x")),A.css({width:K.w}),a.height&&(K.h=_(a.height,"y")-N-L),a.innerHeight&&(K.h=_(a.innerHeight,"y")),a.innerHeight||a.height||(A.css({height:"auto"}),K.h=A.height()),A.css({height:K.h}),W.position("none"===K.transition?0:K.speed))},W.prep=function(b){function g(){return K.w=K.w||A.width(),K.w=K.mw&&K.mw<K.w?K.mw:K.w,K.w}function h(){return K.h=K.h||A.height(),K.h=K.mh&&K.mh<K.h?K.mh:K.h,K.h}if(S){var c,d="none"===K.transition?0:K.speed;A.remove(),A=Z(X,"LoadedContent").append(b),A.hide().appendTo(B.show()).css({width:g(),overflow:K.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(t),B.hide(),a(R).css({"float":"none"}),o&&a("select").not(r.find("select")).filter(function(){return"hidden"!==this.style.visibility}).css({visibility:"hidden"}).one(k,function(){this.style.visibility="inherit"}),c=function(){function s(){n&&r[0].style.removeAttribute("filter")}var b,c,h,l,o,p,q,g=y.length,i="frameBorder",k="allowTransparency";if(S){if(l=function(){clearTimeout(V),C.detach().hide(),cb(j,K.onComplete)},n&&R&&A.fadeIn(100),D.html(K.title).add(A).show(),g>1){if("string"==typeof K.current&&E.html(K.current.replace("{current}",Q+1).replace("{total}",g)).show(),G[K.loop||g-1>Q?"show":"hide"]().html(K.next),H[K.loop||Q?"show":"hide"]().html(K.previous),K.slideshow&&F.show(),K.preloading)for(b=[$(-1),$(1)];c=y[b.pop()];)q=a.data(c,e),q&&q.href?(o=q.href,a.isFunction(o)&&(o=o.call(c))):o=c.href,ab(o)&&(p=new Image,p.src=o)}else J.hide();K.iframe?(h=Z("iframe")[0],i in h&&(h[i]=0),k in h&&(h[k]="true"),K.scrolling||(h.scrolling="no"),a(h).attr({src:K.href,name:(new Date).getTime(),"class":f+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",l).one(m,function(){h.src="//about:blank"}).appendTo(A),K.fastIframe&&a(h).trigger("load")):l(),"fade"===K.transition?r.fadeTo(d,1,s):s()}},"fade"===K.transition?r.fadeTo(d,0,function(){W.position(0,c)}):W.position(d,c)}},W.load=function(b){var c,d,e=W.prep;T=!0,R=!1,P=y[Q],b||bb(),cb(m),cb(i,K.onLoad),K.h=K.height?_(K.height,"y")-N-L:K.innerHeight&&_(K.innerHeight,"y"),K.w=K.width?_(K.width,"x")-O-M:K.innerWidth&&_(K.innerWidth,"x"),K.mw=K.w,K.mh=K.h,K.maxWidth&&(K.mw=_(K.maxWidth,"x")-O-M,K.mw=K.w&&K.w<K.mw?K.w:K.mw),K.maxHeight&&(K.mh=_(K.maxHeight,"y")-N-L,K.mh=K.h&&K.h<K.mh?K.h:K.mh),c=K.href,V=setTimeout(function(){C.show().appendTo(t)},100),K.inline?(Z(X).hide().insertBefore(a(c)[0]).one(m,function(){a(this).replaceWith(A.children())}),e(a(c))):K.iframe?e(" "):K.html?e(K.html):ab(c)?(a(R=new Image).addClass(f+"Photo").error(function(){K.title=!1,e(Z(X,"Error").html(K.imgError))}).load(function(){var a;R.onload=null,K.scalePhotos&&(d=function(){R.height-=R.height*a,R.width-=R.width*a},K.mw&&R.width>K.mw&&(a=(R.width-K.mw)/R.width,d()),K.mh&&R.height>K.mh&&(a=(R.height-K.mh)/R.height,d())),K.h&&(R.style.marginTop=Math.max(K.h-R.height,0)/2+"px"),y[1]&&(K.loop||y[Q+1])&&(R.style.cursor="pointer",R.onclick=function(){W.next()}),n&&(R.style.msInterpolationMode="bicubic"),setTimeout(function(){e(R)},1)}),setTimeout(function(){R.src=c},1)):c&&B.load(c,K.data,function(b,c){e("error"===c?Z(X,"Error").html(K.xhrError):a(this).contents())})},W.next=function(){!T&&y[1]&&(K.loop||y[Q+1])&&(Q=$(1),W.load())},W.prev=function(){!T&&y[1]&&(K.loop||Q)&&(Q=$(-1),W.load())},W.close=function(){S&&!U&&(U=!0,S=!1,cb(k,K.onCleanup),z.unbind("."+f+" ."+p),q.fadeTo(200,0),r.stop().fadeTo(300,0,function(){r.add(q).css({opacity:1,cursor:"auto"}).hide(),cb(m),A.remove(),setTimeout(function(){U=!1,cb(l,K.onClosed)},1)}))},W.remove=function(){a([]).add(r).add(q).remove(),r=null,a("."+g).removeData(e).removeClass(g),a(b).undelegate("."+g)},W.element=function(){return a(P)},W.settings=d)})(jQuery,document,window);
@@ -1,2 +0,0 @@
1
- class window.PhotoUploader
2
- sanity: -> true
@@ -1,1221 +0,0 @@
1
- // Underscore.js 1.4.3
2
- // http://underscorejs.org
3
- // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
4
- // Underscore may be freely distributed under the MIT license.
5
-
6
- (function() {
7
-
8
- // Baseline setup
9
- // --------------
10
-
11
- // Establish the root object, `window` in the browser, or `global` on the server.
12
- var root = this;
13
-
14
- // Save the previous value of the `_` variable.
15
- var previousUnderscore = root._;
16
-
17
- // Establish the object that gets returned to break out of a loop iteration.
18
- var breaker = {};
19
-
20
- // Save bytes in the minified (but not gzipped) version:
21
- var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
22
-
23
- // Create quick reference variables for speed access to core prototypes.
24
- var push = ArrayProto.push,
25
- slice = ArrayProto.slice,
26
- concat = ArrayProto.concat,
27
- toString = ObjProto.toString,
28
- hasOwnProperty = ObjProto.hasOwnProperty;
29
-
30
- // All **ECMAScript 5** native function implementations that we hope to use
31
- // are declared here.
32
- var
33
- nativeForEach = ArrayProto.forEach,
34
- nativeMap = ArrayProto.map,
35
- nativeReduce = ArrayProto.reduce,
36
- nativeReduceRight = ArrayProto.reduceRight,
37
- nativeFilter = ArrayProto.filter,
38
- nativeEvery = ArrayProto.every,
39
- nativeSome = ArrayProto.some,
40
- nativeIndexOf = ArrayProto.indexOf,
41
- nativeLastIndexOf = ArrayProto.lastIndexOf,
42
- nativeIsArray = Array.isArray,
43
- nativeKeys = Object.keys,
44
- nativeBind = FuncProto.bind;
45
-
46
- // Create a safe reference to the Underscore object for use below.
47
- var _ = function(obj) {
48
- if (obj instanceof _) return obj;
49
- if (!(this instanceof _)) return new _(obj);
50
- this._wrapped = obj;
51
- };
52
-
53
- // Export the Underscore object for **Node.js**, with
54
- // backwards-compatibility for the old `require()` API. If we're in
55
- // the browser, add `_` as a global object via a string identifier,
56
- // for Closure Compiler "advanced" mode.
57
- if (typeof exports !== 'undefined') {
58
- if (typeof module !== 'undefined' && module.exports) {
59
- exports = module.exports = _;
60
- }
61
- exports._ = _;
62
- } else {
63
- root._ = _;
64
- }
65
-
66
- // Current version.
67
- _.VERSION = '1.4.3';
68
-
69
- // Collection Functions
70
- // --------------------
71
-
72
- // The cornerstone, an `each` implementation, aka `forEach`.
73
- // Handles objects with the built-in `forEach`, arrays, and raw objects.
74
- // Delegates to **ECMAScript 5**'s native `forEach` if available.
75
- var each = _.each = _.forEach = function(obj, iterator, context) {
76
- if (obj == null) return;
77
- if (nativeForEach && obj.forEach === nativeForEach) {
78
- obj.forEach(iterator, context);
79
- } else if (obj.length === +obj.length) {
80
- for (var i = 0, l = obj.length; i < l; i++) {
81
- if (iterator.call(context, obj[i], i, obj) === breaker) return;
82
- }
83
- } else {
84
- for (var key in obj) {
85
- if (_.has(obj, key)) {
86
- if (iterator.call(context, obj[key], key, obj) === breaker) return;
87
- }
88
- }
89
- }
90
- };
91
-
92
- // Return the results of applying the iterator to each element.
93
- // Delegates to **ECMAScript 5**'s native `map` if available.
94
- _.map = _.collect = function(obj, iterator, context) {
95
- var results = [];
96
- if (obj == null) return results;
97
- if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
98
- each(obj, function(value, index, list) {
99
- results[results.length] = iterator.call(context, value, index, list);
100
- });
101
- return results;
102
- };
103
-
104
- var reduceError = 'Reduce of empty array with no initial value';
105
-
106
- // **Reduce** builds up a single result from a list of values, aka `inject`,
107
- // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
108
- _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
109
- var initial = arguments.length > 2;
110
- if (obj == null) obj = [];
111
- if (nativeReduce && obj.reduce === nativeReduce) {
112
- if (context) iterator = _.bind(iterator, context);
113
- return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
114
- }
115
- each(obj, function(value, index, list) {
116
- if (!initial) {
117
- memo = value;
118
- initial = true;
119
- } else {
120
- memo = iterator.call(context, memo, value, index, list);
121
- }
122
- });
123
- if (!initial) throw new TypeError(reduceError);
124
- return memo;
125
- };
126
-
127
- // The right-associative version of reduce, also known as `foldr`.
128
- // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
129
- _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
130
- var initial = arguments.length > 2;
131
- if (obj == null) obj = [];
132
- if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
133
- if (context) iterator = _.bind(iterator, context);
134
- return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
135
- }
136
- var length = obj.length;
137
- if (length !== +length) {
138
- var keys = _.keys(obj);
139
- length = keys.length;
140
- }
141
- each(obj, function(value, index, list) {
142
- index = keys ? keys[--length] : --length;
143
- if (!initial) {
144
- memo = obj[index];
145
- initial = true;
146
- } else {
147
- memo = iterator.call(context, memo, obj[index], index, list);
148
- }
149
- });
150
- if (!initial) throw new TypeError(reduceError);
151
- return memo;
152
- };
153
-
154
- // Return the first value which passes a truth test. Aliased as `detect`.
155
- _.find = _.detect = function(obj, iterator, context) {
156
- var result;
157
- any(obj, function(value, index, list) {
158
- if (iterator.call(context, value, index, list)) {
159
- result = value;
160
- return true;
161
- }
162
- });
163
- return result;
164
- };
165
-
166
- // Return all the elements that pass a truth test.
167
- // Delegates to **ECMAScript 5**'s native `filter` if available.
168
- // Aliased as `select`.
169
- _.filter = _.select = function(obj, iterator, context) {
170
- var results = [];
171
- if (obj == null) return results;
172
- if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
173
- each(obj, function(value, index, list) {
174
- if (iterator.call(context, value, index, list)) results[results.length] = value;
175
- });
176
- return results;
177
- };
178
-
179
- // Return all the elements for which a truth test fails.
180
- _.reject = function(obj, iterator, context) {
181
- return _.filter(obj, function(value, index, list) {
182
- return !iterator.call(context, value, index, list);
183
- }, context);
184
- };
185
-
186
- // Determine whether all of the elements match a truth test.
187
- // Delegates to **ECMAScript 5**'s native `every` if available.
188
- // Aliased as `all`.
189
- _.every = _.all = function(obj, iterator, context) {
190
- iterator || (iterator = _.identity);
191
- var result = true;
192
- if (obj == null) return result;
193
- if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
194
- each(obj, function(value, index, list) {
195
- if (!(result = result && iterator.call(context, value, index, list))) return breaker;
196
- });
197
- return !!result;
198
- };
199
-
200
- // Determine if at least one element in the object matches a truth test.
201
- // Delegates to **ECMAScript 5**'s native `some` if available.
202
- // Aliased as `any`.
203
- var any = _.some = _.any = function(obj, iterator, context) {
204
- iterator || (iterator = _.identity);
205
- var result = false;
206
- if (obj == null) return result;
207
- if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
208
- each(obj, function(value, index, list) {
209
- if (result || (result = iterator.call(context, value, index, list))) return breaker;
210
- });
211
- return !!result;
212
- };
213
-
214
- // Determine if the array or object contains a given value (using `===`).
215
- // Aliased as `include`.
216
- _.contains = _.include = function(obj, target) {
217
- if (obj == null) return false;
218
- if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
219
- return any(obj, function(value) {
220
- return value === target;
221
- });
222
- };
223
-
224
- // Invoke a method (with arguments) on every item in a collection.
225
- _.invoke = function(obj, method) {
226
- var args = slice.call(arguments, 2);
227
- return _.map(obj, function(value) {
228
- return (_.isFunction(method) ? method : value[method]).apply(value, args);
229
- });
230
- };
231
-
232
- // Convenience version of a common use case of `map`: fetching a property.
233
- _.pluck = function(obj, key) {
234
- return _.map(obj, function(value){ return value[key]; });
235
- };
236
-
237
- // Convenience version of a common use case of `filter`: selecting only objects
238
- // with specific `key:value` pairs.
239
- _.where = function(obj, attrs) {
240
- if (_.isEmpty(attrs)) return [];
241
- return _.filter(obj, function(value) {
242
- for (var key in attrs) {
243
- if (attrs[key] !== value[key]) return false;
244
- }
245
- return true;
246
- });
247
- };
248
-
249
- // Return the maximum element or (element-based computation).
250
- // Can't optimize arrays of integers longer than 65,535 elements.
251
- // See: https://bugs.webkit.org/show_bug.cgi?id=80797
252
- _.max = function(obj, iterator, context) {
253
- if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
254
- return Math.max.apply(Math, obj);
255
- }
256
- if (!iterator && _.isEmpty(obj)) return -Infinity;
257
- var result = {computed : -Infinity, value: -Infinity};
258
- each(obj, function(value, index, list) {
259
- var computed = iterator ? iterator.call(context, value, index, list) : value;
260
- computed >= result.computed && (result = {value : value, computed : computed});
261
- });
262
- return result.value;
263
- };
264
-
265
- // Return the minimum element (or element-based computation).
266
- _.min = function(obj, iterator, context) {
267
- if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) {
268
- return Math.min.apply(Math, obj);
269
- }
270
- if (!iterator && _.isEmpty(obj)) return Infinity;
271
- var result = {computed : Infinity, value: Infinity};
272
- each(obj, function(value, index, list) {
273
- var computed = iterator ? iterator.call(context, value, index, list) : value;
274
- computed < result.computed && (result = {value : value, computed : computed});
275
- });
276
- return result.value;
277
- };
278
-
279
- // Shuffle an array.
280
- _.shuffle = function(obj) {
281
- var rand;
282
- var index = 0;
283
- var shuffled = [];
284
- each(obj, function(value) {
285
- rand = _.random(index++);
286
- shuffled[index - 1] = shuffled[rand];
287
- shuffled[rand] = value;
288
- });
289
- return shuffled;
290
- };
291
-
292
- // An internal function to generate lookup iterators.
293
- var lookupIterator = function(value) {
294
- return _.isFunction(value) ? value : function(obj){ return obj[value]; };
295
- };
296
-
297
- // Sort the object's values by a criterion produced by an iterator.
298
- _.sortBy = function(obj, value, context) {
299
- var iterator = lookupIterator(value);
300
- return _.pluck(_.map(obj, function(value, index, list) {
301
- return {
302
- value : value,
303
- index : index,
304
- criteria : iterator.call(context, value, index, list)
305
- };
306
- }).sort(function(left, right) {
307
- var a = left.criteria;
308
- var b = right.criteria;
309
- if (a !== b) {
310
- if (a > b || a === void 0) return 1;
311
- if (a < b || b === void 0) return -1;
312
- }
313
- return left.index < right.index ? -1 : 1;
314
- }), 'value');
315
- };
316
-
317
- // An internal function used for aggregate "group by" operations.
318
- var group = function(obj, value, context, behavior) {
319
- var result = {};
320
- var iterator = lookupIterator(value || _.identity);
321
- each(obj, function(value, index) {
322
- var key = iterator.call(context, value, index, obj);
323
- behavior(result, key, value);
324
- });
325
- return result;
326
- };
327
-
328
- // Groups the object's values by a criterion. Pass either a string attribute
329
- // to group by, or a function that returns the criterion.
330
- _.groupBy = function(obj, value, context) {
331
- return group(obj, value, context, function(result, key, value) {
332
- (_.has(result, key) ? result[key] : (result[key] = [])).push(value);
333
- });
334
- };
335
-
336
- // Counts instances of an object that group by a certain criterion. Pass
337
- // either a string attribute to count by, or a function that returns the
338
- // criterion.
339
- _.countBy = function(obj, value, context) {
340
- return group(obj, value, context, function(result, key) {
341
- if (!_.has(result, key)) result[key] = 0;
342
- result[key]++;
343
- });
344
- };
345
-
346
- // Use a comparator function to figure out the smallest index at which
347
- // an object should be inserted so as to maintain order. Uses binary search.
348
- _.sortedIndex = function(array, obj, iterator, context) {
349
- iterator = iterator == null ? _.identity : lookupIterator(iterator);
350
- var value = iterator.call(context, obj);
351
- var low = 0, high = array.length;
352
- while (low < high) {
353
- var mid = (low + high) >>> 1;
354
- iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid;
355
- }
356
- return low;
357
- };
358
-
359
- // Safely convert anything iterable into a real, live array.
360
- _.toArray = function(obj) {
361
- if (!obj) return [];
362
- if (_.isArray(obj)) return slice.call(obj);
363
- if (obj.length === +obj.length) return _.map(obj, _.identity);
364
- return _.values(obj);
365
- };
366
-
367
- // Return the number of elements in an object.
368
- _.size = function(obj) {
369
- if (obj == null) return 0;
370
- return (obj.length === +obj.length) ? obj.length : _.keys(obj).length;
371
- };
372
-
373
- // Array Functions
374
- // ---------------
375
-
376
- // Get the first element of an array. Passing **n** will return the first N
377
- // values in the array. Aliased as `head` and `take`. The **guard** check
378
- // allows it to work with `_.map`.
379
- _.first = _.head = _.take = function(array, n, guard) {
380
- if (array == null) return void 0;
381
- return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
382
- };
383
-
384
- // Returns everything but the last entry of the array. Especially useful on
385
- // the arguments object. Passing **n** will return all the values in
386
- // the array, excluding the last N. The **guard** check allows it to work with
387
- // `_.map`.
388
- _.initial = function(array, n, guard) {
389
- return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
390
- };
391
-
392
- // Get the last element of an array. Passing **n** will return the last N
393
- // values in the array. The **guard** check allows it to work with `_.map`.
394
- _.last = function(array, n, guard) {
395
- if (array == null) return void 0;
396
- if ((n != null) && !guard) {
397
- return slice.call(array, Math.max(array.length - n, 0));
398
- } else {
399
- return array[array.length - 1];
400
- }
401
- };
402
-
403
- // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
404
- // Especially useful on the arguments object. Passing an **n** will return
405
- // the rest N values in the array. The **guard**
406
- // check allows it to work with `_.map`.
407
- _.rest = _.tail = _.drop = function(array, n, guard) {
408
- return slice.call(array, (n == null) || guard ? 1 : n);
409
- };
410
-
411
- // Trim out all falsy values from an array.
412
- _.compact = function(array) {
413
- return _.filter(array, _.identity);
414
- };
415
-
416
- // Internal implementation of a recursive `flatten` function.
417
- var flatten = function(input, shallow, output) {
418
- each(input, function(value) {
419
- if (_.isArray(value)) {
420
- shallow ? push.apply(output, value) : flatten(value, shallow, output);
421
- } else {
422
- output.push(value);
423
- }
424
- });
425
- return output;
426
- };
427
-
428
- // Return a completely flattened version of an array.
429
- _.flatten = function(array, shallow) {
430
- return flatten(array, shallow, []);
431
- };
432
-
433
- // Return a version of the array that does not contain the specified value(s).
434
- _.without = function(array) {
435
- return _.difference(array, slice.call(arguments, 1));
436
- };
437
-
438
- // Produce a duplicate-free version of the array. If the array has already
439
- // been sorted, you have the option of using a faster algorithm.
440
- // Aliased as `unique`.
441
- _.uniq = _.unique = function(array, isSorted, iterator, context) {
442
- if (_.isFunction(isSorted)) {
443
- context = iterator;
444
- iterator = isSorted;
445
- isSorted = false;
446
- }
447
- var initial = iterator ? _.map(array, iterator, context) : array;
448
- var results = [];
449
- var seen = [];
450
- each(initial, function(value, index) {
451
- if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
452
- seen.push(value);
453
- results.push(array[index]);
454
- }
455
- });
456
- return results;
457
- };
458
-
459
- // Produce an array that contains the union: each distinct element from all of
460
- // the passed-in arrays.
461
- _.union = function() {
462
- return _.uniq(concat.apply(ArrayProto, arguments));
463
- };
464
-
465
- // Produce an array that contains every item shared between all the
466
- // passed-in arrays.
467
- _.intersection = function(array) {
468
- var rest = slice.call(arguments, 1);
469
- return _.filter(_.uniq(array), function(item) {
470
- return _.every(rest, function(other) {
471
- return _.indexOf(other, item) >= 0;
472
- });
473
- });
474
- };
475
-
476
- // Take the difference between one array and a number of other arrays.
477
- // Only the elements present in just the first array will remain.
478
- _.difference = function(array) {
479
- var rest = concat.apply(ArrayProto, slice.call(arguments, 1));
480
- return _.filter(array, function(value){ return !_.contains(rest, value); });
481
- };
482
-
483
- // Zip together multiple lists into a single array -- elements that share
484
- // an index go together.
485
- _.zip = function() {
486
- var args = slice.call(arguments);
487
- var length = _.max(_.pluck(args, 'length'));
488
- var results = new Array(length);
489
- for (var i = 0; i < length; i++) {
490
- results[i] = _.pluck(args, "" + i);
491
- }
492
- return results;
493
- };
494
-
495
- // Converts lists into objects. Pass either a single array of `[key, value]`
496
- // pairs, or two parallel arrays of the same length -- one of keys, and one of
497
- // the corresponding values.
498
- _.object = function(list, values) {
499
- if (list == null) return {};
500
- var result = {};
501
- for (var i = 0, l = list.length; i < l; i++) {
502
- if (values) {
503
- result[list[i]] = values[i];
504
- } else {
505
- result[list[i][0]] = list[i][1];
506
- }
507
- }
508
- return result;
509
- };
510
-
511
- // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
512
- // we need this function. Return the position of the first occurrence of an
513
- // item in an array, or -1 if the item is not included in the array.
514
- // Delegates to **ECMAScript 5**'s native `indexOf` if available.
515
- // If the array is large and already in sort order, pass `true`
516
- // for **isSorted** to use binary search.
517
- _.indexOf = function(array, item, isSorted) {
518
- if (array == null) return -1;
519
- var i = 0, l = array.length;
520
- if (isSorted) {
521
- if (typeof isSorted == 'number') {
522
- i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted);
523
- } else {
524
- i = _.sortedIndex(array, item);
525
- return array[i] === item ? i : -1;
526
- }
527
- }
528
- if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted);
529
- for (; i < l; i++) if (array[i] === item) return i;
530
- return -1;
531
- };
532
-
533
- // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
534
- _.lastIndexOf = function(array, item, from) {
535
- if (array == null) return -1;
536
- var hasIndex = from != null;
537
- if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) {
538
- return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item);
539
- }
540
- var i = (hasIndex ? from : array.length);
541
- while (i--) if (array[i] === item) return i;
542
- return -1;
543
- };
544
-
545
- // Generate an integer Array containing an arithmetic progression. A port of
546
- // the native Python `range()` function. See
547
- // [the Python documentation](http://docs.python.org/library/functions.html#range).
548
- _.range = function(start, stop, step) {
549
- if (arguments.length <= 1) {
550
- stop = start || 0;
551
- start = 0;
552
- }
553
- step = arguments[2] || 1;
554
-
555
- var len = Math.max(Math.ceil((stop - start) / step), 0);
556
- var idx = 0;
557
- var range = new Array(len);
558
-
559
- while(idx < len) {
560
- range[idx++] = start;
561
- start += step;
562
- }
563
-
564
- return range;
565
- };
566
-
567
- // Function (ahem) Functions
568
- // ------------------
569
-
570
- // Reusable constructor function for prototype setting.
571
- var ctor = function(){};
572
-
573
- // Create a function bound to a given object (assigning `this`, and arguments,
574
- // optionally). Binding with arguments is also known as `curry`.
575
- // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
576
- // We check for `func.bind` first, to fail fast when `func` is undefined.
577
- _.bind = function(func, context) {
578
- var args, bound;
579
- if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
580
- if (!_.isFunction(func)) throw new TypeError;
581
- args = slice.call(arguments, 2);
582
- return bound = function() {
583
- if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
584
- ctor.prototype = func.prototype;
585
- var self = new ctor;
586
- ctor.prototype = null;
587
- var result = func.apply(self, args.concat(slice.call(arguments)));
588
- if (Object(result) === result) return result;
589
- return self;
590
- };
591
- };
592
-
593
- // Bind all of an object's methods to that object. Useful for ensuring that
594
- // all callbacks defined on an object belong to it.
595
- _.bindAll = function(obj) {
596
- var funcs = slice.call(arguments, 1);
597
- if (funcs.length == 0) funcs = _.functions(obj);
598
- each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
599
- return obj;
600
- };
601
-
602
- // Memoize an expensive function by storing its results.
603
- _.memoize = function(func, hasher) {
604
- var memo = {};
605
- hasher || (hasher = _.identity);
606
- return function() {
607
- var key = hasher.apply(this, arguments);
608
- return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
609
- };
610
- };
611
-
612
- // Delays a function for the given number of milliseconds, and then calls
613
- // it with the arguments supplied.
614
- _.delay = function(func, wait) {
615
- var args = slice.call(arguments, 2);
616
- return setTimeout(function(){ return func.apply(null, args); }, wait);
617
- };
618
-
619
- // Defers a function, scheduling it to run after the current call stack has
620
- // cleared.
621
- _.defer = function(func) {
622
- return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
623
- };
624
-
625
- // Returns a function, that, when invoked, will only be triggered at most once
626
- // during a given window of time.
627
- _.throttle = function(func, wait) {
628
- var context, args, timeout, result;
629
- var previous = 0;
630
- var later = function() {
631
- previous = new Date;
632
- timeout = null;
633
- result = func.apply(context, args);
634
- };
635
- return function() {
636
- var now = new Date;
637
- var remaining = wait - (now - previous);
638
- context = this;
639
- args = arguments;
640
- if (remaining <= 0) {
641
- clearTimeout(timeout);
642
- timeout = null;
643
- previous = now;
644
- result = func.apply(context, args);
645
- } else if (!timeout) {
646
- timeout = setTimeout(later, remaining);
647
- }
648
- return result;
649
- };
650
- };
651
-
652
- // Returns a function, that, as long as it continues to be invoked, will not
653
- // be triggered. The function will be called after it stops being called for
654
- // N milliseconds. If `immediate` is passed, trigger the function on the
655
- // leading edge, instead of the trailing.
656
- _.debounce = function(func, wait, immediate) {
657
- var timeout, result;
658
- return function() {
659
- var context = this, args = arguments;
660
- var later = function() {
661
- timeout = null;
662
- if (!immediate) result = func.apply(context, args);
663
- };
664
- var callNow = immediate && !timeout;
665
- clearTimeout(timeout);
666
- timeout = setTimeout(later, wait);
667
- if (callNow) result = func.apply(context, args);
668
- return result;
669
- };
670
- };
671
-
672
- // Returns a function that will be executed at most one time, no matter how
673
- // often you call it. Useful for lazy initialization.
674
- _.once = function(func) {
675
- var ran = false, memo;
676
- return function() {
677
- if (ran) return memo;
678
- ran = true;
679
- memo = func.apply(this, arguments);
680
- func = null;
681
- return memo;
682
- };
683
- };
684
-
685
- // Returns the first function passed as an argument to the second,
686
- // allowing you to adjust arguments, run code before and after, and
687
- // conditionally execute the original function.
688
- _.wrap = function(func, wrapper) {
689
- return function() {
690
- var args = [func];
691
- push.apply(args, arguments);
692
- return wrapper.apply(this, args);
693
- };
694
- };
695
-
696
- // Returns a function that is the composition of a list of functions, each
697
- // consuming the return value of the function that follows.
698
- _.compose = function() {
699
- var funcs = arguments;
700
- return function() {
701
- var args = arguments;
702
- for (var i = funcs.length - 1; i >= 0; i--) {
703
- args = [funcs[i].apply(this, args)];
704
- }
705
- return args[0];
706
- };
707
- };
708
-
709
- // Returns a function that will only be executed after being called N times.
710
- _.after = function(times, func) {
711
- if (times <= 0) return func();
712
- return function() {
713
- if (--times < 1) {
714
- return func.apply(this, arguments);
715
- }
716
- };
717
- };
718
-
719
- // Object Functions
720
- // ----------------
721
-
722
- // Retrieve the names of an object's properties.
723
- // Delegates to **ECMAScript 5**'s native `Object.keys`
724
- _.keys = nativeKeys || function(obj) {
725
- if (obj !== Object(obj)) throw new TypeError('Invalid object');
726
- var keys = [];
727
- for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
728
- return keys;
729
- };
730
-
731
- // Retrieve the values of an object's properties.
732
- _.values = function(obj) {
733
- var values = [];
734
- for (var key in obj) if (_.has(obj, key)) values.push(obj[key]);
735
- return values;
736
- };
737
-
738
- // Convert an object into a list of `[key, value]` pairs.
739
- _.pairs = function(obj) {
740
- var pairs = [];
741
- for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]);
742
- return pairs;
743
- };
744
-
745
- // Invert the keys and values of an object. The values must be serializable.
746
- _.invert = function(obj) {
747
- var result = {};
748
- for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key;
749
- return result;
750
- };
751
-
752
- // Return a sorted list of the function names available on the object.
753
- // Aliased as `methods`
754
- _.functions = _.methods = function(obj) {
755
- var names = [];
756
- for (var key in obj) {
757
- if (_.isFunction(obj[key])) names.push(key);
758
- }
759
- return names.sort();
760
- };
761
-
762
- // Extend a given object with all the properties in passed-in object(s).
763
- _.extend = function(obj) {
764
- each(slice.call(arguments, 1), function(source) {
765
- if (source) {
766
- for (var prop in source) {
767
- obj[prop] = source[prop];
768
- }
769
- }
770
- });
771
- return obj;
772
- };
773
-
774
- // Return a copy of the object only containing the whitelisted properties.
775
- _.pick = function(obj) {
776
- var copy = {};
777
- var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
778
- each(keys, function(key) {
779
- if (key in obj) copy[key] = obj[key];
780
- });
781
- return copy;
782
- };
783
-
784
- // Return a copy of the object without the blacklisted properties.
785
- _.omit = function(obj) {
786
- var copy = {};
787
- var keys = concat.apply(ArrayProto, slice.call(arguments, 1));
788
- for (var key in obj) {
789
- if (!_.contains(keys, key)) copy[key] = obj[key];
790
- }
791
- return copy;
792
- };
793
-
794
- // Fill in a given object with default properties.
795
- _.defaults = function(obj) {
796
- each(slice.call(arguments, 1), function(source) {
797
- if (source) {
798
- for (var prop in source) {
799
- if (obj[prop] == null) obj[prop] = source[prop];
800
- }
801
- }
802
- });
803
- return obj;
804
- };
805
-
806
- // Create a (shallow-cloned) duplicate of an object.
807
- _.clone = function(obj) {
808
- if (!_.isObject(obj)) return obj;
809
- return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
810
- };
811
-
812
- // Invokes interceptor with the obj, and then returns obj.
813
- // The primary purpose of this method is to "tap into" a method chain, in
814
- // order to perform operations on intermediate results within the chain.
815
- _.tap = function(obj, interceptor) {
816
- interceptor(obj);
817
- return obj;
818
- };
819
-
820
- // Internal recursive comparison function for `isEqual`.
821
- var eq = function(a, b, aStack, bStack) {
822
- // Identical objects are equal. `0 === -0`, but they aren't identical.
823
- // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
824
- if (a === b) return a !== 0 || 1 / a == 1 / b;
825
- // A strict comparison is necessary because `null == undefined`.
826
- if (a == null || b == null) return a === b;
827
- // Unwrap any wrapped objects.
828
- if (a instanceof _) a = a._wrapped;
829
- if (b instanceof _) b = b._wrapped;
830
- // Compare `[[Class]]` names.
831
- var className = toString.call(a);
832
- if (className != toString.call(b)) return false;
833
- switch (className) {
834
- // Strings, numbers, dates, and booleans are compared by value.
835
- case '[object String]':
836
- // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
837
- // equivalent to `new String("5")`.
838
- return a == String(b);
839
- case '[object Number]':
840
- // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
841
- // other numeric values.
842
- return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
843
- case '[object Date]':
844
- case '[object Boolean]':
845
- // Coerce dates and booleans to numeric primitive values. Dates are compared by their
846
- // millisecond representations. Note that invalid dates with millisecond representations
847
- // of `NaN` are not equivalent.
848
- return +a == +b;
849
- // RegExps are compared by their source patterns and flags.
850
- case '[object RegExp]':
851
- return a.source == b.source &&
852
- a.global == b.global &&
853
- a.multiline == b.multiline &&
854
- a.ignoreCase == b.ignoreCase;
855
- }
856
- if (typeof a != 'object' || typeof b != 'object') return false;
857
- // Assume equality for cyclic structures. The algorithm for detecting cyclic
858
- // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
859
- var length = aStack.length;
860
- while (length--) {
861
- // Linear search. Performance is inversely proportional to the number of
862
- // unique nested structures.
863
- if (aStack[length] == a) return bStack[length] == b;
864
- }
865
- // Add the first object to the stack of traversed objects.
866
- aStack.push(a);
867
- bStack.push(b);
868
- var size = 0, result = true;
869
- // Recursively compare objects and arrays.
870
- if (className == '[object Array]') {
871
- // Compare array lengths to determine if a deep comparison is necessary.
872
- size = a.length;
873
- result = size == b.length;
874
- if (result) {
875
- // Deep compare the contents, ignoring non-numeric properties.
876
- while (size--) {
877
- if (!(result = eq(a[size], b[size], aStack, bStack))) break;
878
- }
879
- }
880
- } else {
881
- // Objects with different constructors are not equivalent, but `Object`s
882
- // from different frames are.
883
- var aCtor = a.constructor, bCtor = b.constructor;
884
- if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) &&
885
- _.isFunction(bCtor) && (bCtor instanceof bCtor))) {
886
- return false;
887
- }
888
- // Deep compare objects.
889
- for (var key in a) {
890
- if (_.has(a, key)) {
891
- // Count the expected number of properties.
892
- size++;
893
- // Deep compare each member.
894
- if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break;
895
- }
896
- }
897
- // Ensure that both objects contain the same number of properties.
898
- if (result) {
899
- for (key in b) {
900
- if (_.has(b, key) && !(size--)) break;
901
- }
902
- result = !size;
903
- }
904
- }
905
- // Remove the first object from the stack of traversed objects.
906
- aStack.pop();
907
- bStack.pop();
908
- return result;
909
- };
910
-
911
- // Perform a deep comparison to check if two objects are equal.
912
- _.isEqual = function(a, b) {
913
- return eq(a, b, [], []);
914
- };
915
-
916
- // Is a given array, string, or object empty?
917
- // An "empty" object has no enumerable own-properties.
918
- _.isEmpty = function(obj) {
919
- if (obj == null) return true;
920
- if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
921
- for (var key in obj) if (_.has(obj, key)) return false;
922
- return true;
923
- };
924
-
925
- // Is a given value a DOM element?
926
- _.isElement = function(obj) {
927
- return !!(obj && obj.nodeType === 1);
928
- };
929
-
930
- // Is a given value an array?
931
- // Delegates to ECMA5's native Array.isArray
932
- _.isArray = nativeIsArray || function(obj) {
933
- return toString.call(obj) == '[object Array]';
934
- };
935
-
936
- // Is a given variable an object?
937
- _.isObject = function(obj) {
938
- return obj === Object(obj);
939
- };
940
-
941
- // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
942
- each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
943
- _['is' + name] = function(obj) {
944
- return toString.call(obj) == '[object ' + name + ']';
945
- };
946
- });
947
-
948
- // Define a fallback version of the method in browsers (ahem, IE), where
949
- // there isn't any inspectable "Arguments" type.
950
- if (!_.isArguments(arguments)) {
951
- _.isArguments = function(obj) {
952
- return !!(obj && _.has(obj, 'callee'));
953
- };
954
- }
955
-
956
- // Optimize `isFunction` if appropriate.
957
- if (typeof (/./) !== 'function') {
958
- _.isFunction = function(obj) {
959
- return typeof obj === 'function';
960
- };
961
- }
962
-
963
- // Is a given object a finite number?
964
- _.isFinite = function(obj) {
965
- return isFinite(obj) && !isNaN(parseFloat(obj));
966
- };
967
-
968
- // Is the given value `NaN`? (NaN is the only number which does not equal itself).
969
- _.isNaN = function(obj) {
970
- return _.isNumber(obj) && obj != +obj;
971
- };
972
-
973
- // Is a given value a boolean?
974
- _.isBoolean = function(obj) {
975
- return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
976
- };
977
-
978
- // Is a given value equal to null?
979
- _.isNull = function(obj) {
980
- return obj === null;
981
- };
982
-
983
- // Is a given variable undefined?
984
- _.isUndefined = function(obj) {
985
- return obj === void 0;
986
- };
987
-
988
- // Shortcut function for checking if an object has a given property directly
989
- // on itself (in other words, not on a prototype).
990
- _.has = function(obj, key) {
991
- return hasOwnProperty.call(obj, key);
992
- };
993
-
994
- // Utility Functions
995
- // -----------------
996
-
997
- // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
998
- // previous owner. Returns a reference to the Underscore object.
999
- _.noConflict = function() {
1000
- root._ = previousUnderscore;
1001
- return this;
1002
- };
1003
-
1004
- // Keep the identity function around for default iterators.
1005
- _.identity = function(value) {
1006
- return value;
1007
- };
1008
-
1009
- // Run a function **n** times.
1010
- _.times = function(n, iterator, context) {
1011
- var accum = Array(n);
1012
- for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i);
1013
- return accum;
1014
- };
1015
-
1016
- // Return a random integer between min and max (inclusive).
1017
- _.random = function(min, max) {
1018
- if (max == null) {
1019
- max = min;
1020
- min = 0;
1021
- }
1022
- return min + (0 | Math.random() * (max - min + 1));
1023
- };
1024
-
1025
- // List of HTML entities for escaping.
1026
- var entityMap = {
1027
- escape: {
1028
- '&': '&amp;',
1029
- '<': '&lt;',
1030
- '>': '&gt;',
1031
- '"': '&quot;',
1032
- "'": '&#x27;',
1033
- '/': '&#x2F;'
1034
- }
1035
- };
1036
- entityMap.unescape = _.invert(entityMap.escape);
1037
-
1038
- // Regexes containing the keys and values listed immediately above.
1039
- var entityRegexes = {
1040
- escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'),
1041
- unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g')
1042
- };
1043
-
1044
- // Functions for escaping and unescaping strings to/from HTML interpolation.
1045
- _.each(['escape', 'unescape'], function(method) {
1046
- _[method] = function(string) {
1047
- if (string == null) return '';
1048
- return ('' + string).replace(entityRegexes[method], function(match) {
1049
- return entityMap[method][match];
1050
- });
1051
- };
1052
- });
1053
-
1054
- // If the value of the named property is a function then invoke it;
1055
- // otherwise, return it.
1056
- _.result = function(object, property) {
1057
- if (object == null) return null;
1058
- var value = object[property];
1059
- return _.isFunction(value) ? value.call(object) : value;
1060
- };
1061
-
1062
- // Add your own custom functions to the Underscore object.
1063
- _.mixin = function(obj) {
1064
- each(_.functions(obj), function(name){
1065
- var func = _[name] = obj[name];
1066
- _.prototype[name] = function() {
1067
- var args = [this._wrapped];
1068
- push.apply(args, arguments);
1069
- return result.call(this, func.apply(_, args));
1070
- };
1071
- });
1072
- };
1073
-
1074
- // Generate a unique integer id (unique within the entire client session).
1075
- // Useful for temporary DOM ids.
1076
- var idCounter = 0;
1077
- _.uniqueId = function(prefix) {
1078
- var id = '' + ++idCounter;
1079
- return prefix ? prefix + id : id;
1080
- };
1081
-
1082
- // By default, Underscore uses ERB-style template delimiters, change the
1083
- // following template settings to use alternative delimiters.
1084
- _.templateSettings = {
1085
- evaluate : /<%([\s\S]+?)%>/g,
1086
- interpolate : /<%=([\s\S]+?)%>/g,
1087
- escape : /<%-([\s\S]+?)%>/g
1088
- };
1089
-
1090
- // When customizing `templateSettings`, if you don't want to define an
1091
- // interpolation, evaluation or escaping regex, we need one that is
1092
- // guaranteed not to match.
1093
- var noMatch = /(.)^/;
1094
-
1095
- // Certain characters need to be escaped so that they can be put into a
1096
- // string literal.
1097
- var escapes = {
1098
- "'": "'",
1099
- '\\': '\\',
1100
- '\r': 'r',
1101
- '\n': 'n',
1102
- '\t': 't',
1103
- '\u2028': 'u2028',
1104
- '\u2029': 'u2029'
1105
- };
1106
-
1107
- var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
1108
-
1109
- // JavaScript micro-templating, similar to John Resig's implementation.
1110
- // Underscore templating handles arbitrary delimiters, preserves whitespace,
1111
- // and correctly escapes quotes within interpolated code.
1112
- _.template = function(text, data, settings) {
1113
- settings = _.defaults({}, settings, _.templateSettings);
1114
-
1115
- // Combine delimiters into one regular expression via alternation.
1116
- var matcher = new RegExp([
1117
- (settings.escape || noMatch).source,
1118
- (settings.interpolate || noMatch).source,
1119
- (settings.evaluate || noMatch).source
1120
- ].join('|') + '|$', 'g');
1121
-
1122
- // Compile the template source, escaping string literals appropriately.
1123
- var index = 0;
1124
- var source = "__p+='";
1125
- text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
1126
- source += text.slice(index, offset)
1127
- .replace(escaper, function(match) { return '\\' + escapes[match]; });
1128
-
1129
- if (escape) {
1130
- source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
1131
- }
1132
- if (interpolate) {
1133
- source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
1134
- }
1135
- if (evaluate) {
1136
- source += "';\n" + evaluate + "\n__p+='";
1137
- }
1138
- index = offset + match.length;
1139
- return match;
1140
- });
1141
- source += "';\n";
1142
-
1143
- // If a variable is not specified, place data values in local scope.
1144
- if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
1145
-
1146
- source = "var __t,__p='',__j=Array.prototype.join," +
1147
- "print=function(){__p+=__j.call(arguments,'');};\n" +
1148
- source + "return __p;\n";
1149
-
1150
- try {
1151
- var render = new Function(settings.variable || 'obj', '_', source);
1152
- } catch (e) {
1153
- e.source = source;
1154
- throw e;
1155
- }
1156
-
1157
- if (data) return render(data, _);
1158
- var template = function(data) {
1159
- return render.call(this, data, _);
1160
- };
1161
-
1162
- // Provide the compiled function source as a convenience for precompilation.
1163
- template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}';
1164
-
1165
- return template;
1166
- };
1167
-
1168
- // Add a "chain" function, which will delegate to the wrapper.
1169
- _.chain = function(obj) {
1170
- return _(obj).chain();
1171
- };
1172
-
1173
- // OOP
1174
- // ---------------
1175
- // If Underscore is called as a function, it returns a wrapped object that
1176
- // can be used OO-style. This wrapper holds altered versions of all the
1177
- // underscore functions. Wrapped objects may be chained.
1178
-
1179
- // Helper function to continue chaining intermediate results.
1180
- var result = function(obj) {
1181
- return this._chain ? _(obj).chain() : obj;
1182
- };
1183
-
1184
- // Add all of the Underscore functions to the wrapper object.
1185
- _.mixin(_);
1186
-
1187
- // Add all mutator Array functions to the wrapper.
1188
- each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
1189
- var method = ArrayProto[name];
1190
- _.prototype[name] = function() {
1191
- var obj = this._wrapped;
1192
- method.apply(obj, arguments);
1193
- if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0];
1194
- return result.call(this, obj);
1195
- };
1196
- });
1197
-
1198
- // Add all accessor Array functions to the wrapper.
1199
- each(['concat', 'join', 'slice'], function(name) {
1200
- var method = ArrayProto[name];
1201
- _.prototype[name] = function() {
1202
- return result.call(this, method.apply(this._wrapped, arguments));
1203
- };
1204
- });
1205
-
1206
- _.extend(_.prototype, {
1207
-
1208
- // Start chaining a wrapped Underscore object.
1209
- chain: function() {
1210
- this._chain = true;
1211
- return this;
1212
- },
1213
-
1214
- // Extracts the result from a wrapped and chained object.
1215
- value: function() {
1216
- return this._wrapped;
1217
- }
1218
-
1219
- });
1220
-
1221
- }).call(this);