├── LICENSE-MIT
├── README.md
├── app
├── .DS_Store
├── app.js
├── collections
│ └── company.js
├── dummy_data_generator.js
├── models
│ └── company.js
├── vendor
│ ├── Faker.js
│ ├── backbone-localstorage.js
│ ├── backbone.js
│ ├── jquery-1.7.1.js
│ └── underscore.js
└── views
│ ├── company_list_item_view.js
│ ├── company_list_view.js
│ └── company_marker_view.js
├── css
├── bootstrap.spacelab.min.css
└── style.css
├── img
├── buildings_32x32.png
├── buildings_32x32_selected.png
├── glyphicons-halflings-white.png
└── glyphicons-halflings.png
├── index.html
└── screenshots
└── backbonejs_google_maps01.png
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 Iván Loire
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Backbone.js with Google Maps demo
2 |
3 | 
4 |
5 | Don't expect anything fancy. Just a simple demo of how to use Backbone.js with Google Maps and some interaction with markers and views..
6 |
7 | ## Getting Started
8 |
9 | Open index.html.
10 |
11 | ## Online demo in GitHub (gh-pages)
12 |
13 | http://iloire.github.com/backbonejs-googlemaps-demo/
14 |
15 | ## Release History
16 | ### 0.1.0 Initial release
17 |
18 | ## License
19 | Copyright (c) 2012 Iván Loire
20 | Licensed under the MIT license.
21 |
--------------------------------------------------------------------------------
/app/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iloire/backbonejs-googlemaps-demo/6da7143b2fdbcabcf71b67d460d35381e03e60a6/app/.DS_Store
--------------------------------------------------------------------------------
/app/app.js:
--------------------------------------------------------------------------------
1 |
2 | // global for the sake of this example
3 | var Companies = new CompanyList();
4 | var App = null;
5 |
6 | /**
7 | * The App
8 | * Our overall **AppView** is the top-level piece of UI.
9 | */
10 | var AppView = Backbone.View.extend({
11 |
12 | el: $("#hub"),
13 |
14 | //--------------------------------------
15 | // Event wiring (events and event handlers)
16 |
17 | events: {
18 | 'click #btn_content' : 'show_content',
19 | 'click #btn_map' : 'show_map'
20 | },
21 |
22 | show_content: function() { //triggers "content" mode
23 | var self = this;
24 | var top = 200;
25 | var speed = 600;
26 |
27 | // set content position and fade in
28 | self.main.animate({top: (top) + 'px'}, speed, function() {
29 | self.main.fadeIn();
30 | });
31 |
32 | self.companies_holder.fadeOut();
33 |
34 | // controls to switch back to map
35 | self.controls.hide().css({top: (top - 100) + 'px'});
36 | setTimeout(function() {
37 | self.content_controls.fadeIn();
38 | }, 2 * speed);
39 |
40 | // resize map canvas
41 | self.map_canvas.animate({height: (top) + 'px'}, speed);
42 | },
43 |
44 | show_map: function() { // triggers "map" mode
45 | var self = this;
46 | var speed = 800;
47 |
48 | // hide content
49 | self.main.fadeOut();
50 |
51 | // hide controls
52 | self.controls.hide();
53 |
54 | self.companies_holder.fadeIn();
55 |
56 | // resize map canvas. make map 100%
57 | self.map_canvas.animate({height: '100%'}, speed);
58 |
59 | setTimeout(function() {
60 | // show map controls
61 | self.map_controls.css({top: '80%'});
62 | self.map_controls.fadeIn();
63 | }, speed);
64 | },
65 |
66 | // END Events and event handlers
67 | //----------------------------------
68 |
69 |
70 | //--------------------------------------
71 | // Initialise map
72 | //--------------------------------------
73 | _initialize_map : function() {
74 | var center = new google.maps.LatLng(41.63, -1);
75 | var styles = [
76 | {
77 | elementType: "geometry",
78 | stylers: [
79 | { lightness: 33 },
80 | { saturation: -90 }
81 | ]
82 | }
83 | ];
84 |
85 | var mapOptions = {
86 | zoom: 9,
87 | mapTypeId: google.maps.MapTypeId.ROADMAP,
88 | center: center,
89 | styles: styles
90 | };
91 | this.map = new google.maps.Map(document.getElementById('map_canvas'),
92 | mapOptions);
93 | },
94 |
95 |
96 | //--------------------------------------
97 | // Initialise app
98 | //--------------------------------------
99 |
100 | initialize: function() {
101 | var self = this;
102 |
103 | // cache DOM elements for faster access
104 | self.main = $('#main');
105 | self.controls = $('.nav_controls');
106 | self.content_controls = $('#content_controls');
107 | self.map_controls = $('#map_controls');
108 | self.map_canvas = $('#map_canvas');
109 | self.header = $('header');
110 | self.companies_holder = $('#companies_holder');
111 |
112 | // initialize map
113 | self._initialize_map();
114 |
115 | // Initial control positions
116 | // Move header up (out of window)
117 | self.header.css({top:'-1000px'});
118 | self.header.animate({top: '0px'}, 1500);
119 |
120 | // hide all controls
121 | self.controls.hide();
122 | self.controls.css({top: '80%'});
123 |
124 | // self.map_controls.fadeIn();
125 | setTimeout(function() {
126 | self.map_controls.fadeIn();
127 | }, 1000);
128 |
129 | setTimeout(function() { // fetch data with some delay
130 | Companies.fetch();
131 | // create views
132 | var list_view = new CompanyListView({model: Companies, map: self.map});
133 | }, 2000);
134 | }
135 | });
136 |
137 | // Load the application once the DOM is ready, using `jQuery.ready`:
138 | $(function() {
139 | App = new AppView();
140 | });
141 |
--------------------------------------------------------------------------------
/app/collections/company.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Company Collection
4 | * The collection of companies is backed by *localStorage* instead of a remote
5 | * server.
6 | */
7 |
8 | var CompanyList = Backbone.Collection.extend({
9 |
10 | // reference to this collection's model.
11 | model: Company,
12 |
13 | localStorage: new Store("company-cachirulo"),
14 |
15 | add_new: function(company) {
16 | this.create(company);
17 | },
18 |
19 | // companies are sorted by their name
20 | comparator: function(company) {
21 | return company.get('name');
22 | },
23 |
24 | remove_all: function() {
25 | var model;
26 | while (model = this.pop()) {
27 | model.destroy();
28 | }
29 | }
30 | });
--------------------------------------------------------------------------------
/app/dummy_data_generator.js:
--------------------------------------------------------------------------------
1 |
2 | var dummy_data_generator = {
3 |
4 | 'reset' : function() {
5 | Companies.remove_all();
6 | },
7 |
8 | 'get_dummy_company': function() {
9 | var rnd_id = (new Date).getTime();
10 | var company = {
11 | company_id : rnd_id,
12 | name : Faker.Company.companyName(),
13 | address: Faker.Address.streetAddress(),
14 | pos: {lat: 41 + Math.random(), lon: -1.3 + Math.random()}
15 | };
16 |
17 | company.descr = '
'+
18 | '
'+
19 | '
'+
20 | '
' + company.name + ' ' + company.address + '
'+
21 | '
'+
22 | '

' +
23 | '
' + Faker.Lorem.paragraph() + '
' +
24 | '
' + Faker.Lorem.paragraph() + '
' +
25 | '
' + Faker.Lorem.paragraph() + '
' +
26 | '
'+
27 | '
';
28 |
29 | return company;
30 | },
31 |
32 | 'repopulate' : function() {
33 | Companies.remove_all();
34 | for (var i = 0, l = 10; i < l ; i++) {
35 | Companies.add_new(this.get_dummy_company());
36 | }
37 | }
38 | };
39 |
40 | dummy_data_generator.repopulate();
41 |
--------------------------------------------------------------------------------
/app/models/company.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Company Model
4 | */
5 |
6 | var Company = Backbone.Model.extend({
7 |
8 | initialize: function() {},
9 |
10 | localStorage: new Store("company-cachirulo"),
11 |
12 | clear: function() {
13 | this.destroy();
14 | }
15 |
16 | });
--------------------------------------------------------------------------------
/app/vendor/Faker.js:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2010 Matthew Bergman & Marak Squires http://github.com/marak/Faker.js/
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 | The above copyright notice and this permission notice shall be
11 | included in all copies or substantial portions of the Software.
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 | */
20 | /*************** AUTOGENERATED @ 1280636665409 ***************
21 | WARNING: THIS FILE WAS AUTOGENERATED BY THE FAKER BUILD SCRIPT
22 | MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING
23 | THE LIBRARY DIRECTLY AND REGENERATING THIS FILE USING BUILD.js!!!!
24 | Faker.js - Written by Matthew Bergman and Marak Squires
25 |
26 | ## USAGE
27 |
28 | ### browser -
29 |
30 |
35 | ### node.js -
36 | var Faker = require('./Faker');
37 | var randomName = Faker.Name.findName(); // Rowan Nikolaus
38 | var randomEmail = Faker.Internet.email(); // Kassandra.Haley@erich.biz
39 | var randomCard = Faker.Helpers.createCard(); // random contact card containing many properties
40 | */
41 | var Faker = {};
42 | Faker.version = "0.2.0";
43 | Faker.Name = {};
44 | Faker.Name.findName = function () {
45 | var r = Helpers.randomNumber(8);
46 | switch(r)
47 | {
48 | case 0:
49 | return Helpers.randomize(definitions.name_prefix()) + " " + Helpers.randomize(definitions.first_name()) + " " + Helpers.randomize(definitions.last_name());
50 | break;
51 | case 1:
52 | return Helpers.randomize(definitions.first_name()) + " " + Helpers.randomize(definitions.last_name()); + " " + Helpers.randomize(definitions.name_suffix);
53 | break;
54 | }
55 |
56 | return Helpers.randomize(definitions.first_name()) + " " + Helpers.randomize(definitions.last_name());
57 |
58 | };
59 |
60 | Faker.Name.firstName = function () {
61 | return Helpers.randomize(definitions.first_name());
62 | };
63 |
64 | Faker.Name.lastName = function () {
65 | return Helpers.randomize(definitions.last_name());
66 | };
67 |
68 | Faker.Address = {};
69 | Faker.Address.zipCode = function () {
70 | return Helpers.replaceSymbolWithNumber(Helpers.randomize(["#####", '#####-####']));
71 | };
72 |
73 | Faker.Address.zipCodeFormat = function ( format ) {
74 | return Helpers.replaceSymbolWithNumber( ["#####", '#####-####'][format] );
75 | };
76 |
77 | Faker.Address.city = function () {
78 | switch(Helpers.randomNumber(3))
79 | {
80 | case 0:
81 | return Helpers.randomize(definitions.city_prefix()) + " " + Helpers.randomize(definitions.first_name()) + Helpers.randomize(definitions.city_suffix());
82 | break;
83 | case 1:
84 | return Helpers.randomize(definitions.city_prefix()) + " " + Helpers.randomize(definitions.first_name());
85 | break;
86 | case 2:
87 | return Helpers.randomize(definitions.first_name()) + Helpers.randomize(definitions.city_suffix());
88 | break;
89 | case 3:
90 | return Helpers.randomize(definitions.last_name()) + Helpers.randomize(definitions.city_suffix());
91 | break;
92 | }
93 | };
94 |
95 | Faker.Address.streetName = function () {
96 | switch(Helpers.randomNumber(1))
97 | {
98 | case 0:
99 | return Helpers.randomize(definitions.last_name()) + " " + Helpers.randomize(definitions.street_suffix());
100 | break;
101 | case 1:
102 | return Helpers.randomize(definitions.first_name()) + " " + Helpers.randomize(definitions.street_suffix());
103 | break;
104 | }
105 | };
106 |
107 | Faker.Address.streetAddress = function (i) {
108 | if( typeof i == 'undefined'){ var i = false;}
109 | var address = "";
110 | switch(Helpers.randomNumber(2))
111 | {
112 | case 0:
113 | address = Helpers.replaceSymbolWithNumber("#####") + " " + this.streetName();
114 | break;
115 | case 1:
116 | address = Helpers.replaceSymbolWithNumber("####") + " " + this.streetName();
117 | break;
118 | case 2:
119 | address = Helpers.replaceSymbolWithNumber("###") + " " + this.streetName();
120 | break;
121 | }
122 | var full_address = i ? address + " " + this.secondaryAddress() : address;
123 | return full_address;
124 | };
125 |
126 | Faker.Address.secondaryAddress = function () {
127 | return Helpers.replaceSymbolWithNumber(Helpers.randomize(
128 | [
129 | 'Apt. ###',
130 | 'Suite ###'
131 | ]
132 | )
133 | );
134 | };
135 |
136 | Faker.Address.ukCounty = function (){
137 | return Helpers.randomize(definitions.uk_county());
138 | };
139 |
140 | Faker.Address.ukCountry = function (){
141 | return Helpers.randomize(definitions.uk_country());
142 | };
143 |
144 | Faker.Address.usState = function ( abbr ) {
145 | return Helpers.randomize( definitions[ abbr ? 'us_state_abbr' : 'us_state']() );
146 | };
147 |
148 | Faker.PhoneNumber = {};
149 | Faker.PhoneNumber.phoneNumber = function (){
150 |
151 | return Helpers.replaceSymbolWithNumber(Helpers.randomize(definitions.phone_formats()));
152 |
153 | };
154 |
155 | Faker.PhoneNumber.phoneNumberFormat = function ( format ){
156 | return Helpers.replaceSymbolWithNumber(definitions.phone_formats()[format]);
157 | };
158 |
159 | Faker.Internet = {};
160 | Faker.Internet.email = function () {
161 | return this.userName() + "@" + this.domainName();
162 | };
163 |
164 | Faker.Internet.userName = function () {
165 | switch(Helpers.randomNumber(2))
166 | {
167 | case 0:
168 | return Helpers.randomize(definitions.first_name());
169 | break;
170 | case 1:
171 | return Helpers.randomize(definitions.first_name()) + Helpers.randomize([".", "_"]) + Helpers.randomize(definitions.last_name()) ;
172 | break;
173 | }
174 | };
175 |
176 | Faker.Internet.domainName = function () {
177 | return this.domainWord() + "." + Helpers.randomize(definitions.domain_suffix());
178 | };
179 |
180 | Faker.Internet.domainWord = function () {
181 | return Helpers.randomize(definitions.first_name()).toLowerCase();
182 | };
183 |
184 | Faker.Company = {};
185 | Faker.Company.companyName = function ( format ) {
186 | switch( ( format ? format : Helpers.randomNumber(3) ) )
187 | {
188 | case 0:
189 | return Helpers.randomize(definitions.last_name()) + " " + this.companySuffix();
190 | break;
191 | case 1:
192 | return Helpers.randomize(definitions.last_name()) + "-" + Helpers.randomize(definitions.last_name()) ;
193 | break;
194 | case 2:
195 | return Helpers.randomize(definitions.last_name()) + "," + Helpers.randomize(definitions.last_name()) + " and " + Helpers.randomize(definitions.last_name());
196 | break;
197 | }
198 | };
199 |
200 | Faker.Company.companySuffix = function () {
201 | return Helpers.randomize(["Inc", "and\ Sons", "LLC", "Group", "and\ Daughters"]);
202 | };
203 |
204 | Faker.Company.catchPhrase = function () {
205 | return Helpers.randomize(definitions.catch_phrase_adjective()) + " " + Helpers.randomize(definitions.catch_phrase_descriptor()) + " "+ Helpers.randomize(definitions.catch_phrase_noun());
206 | };
207 |
208 | Faker.Company.bs = function () {
209 | return Helpers.randomize(definitions.bs_adjective()) + " " + Helpers.randomize(definitions.bs_buzz()) + " "+ Helpers.randomize(definitions.bs_noun());
210 | };
211 |
212 | Faker.Lorem = {};
213 | Faker.Lorem.words = function (num){
214 | if( typeof num == 'undefined'){ var num = 3;}
215 | return Helpers.shuffle(definitions.lorem()).slice(0, num);
216 | //Words.shuffle[0, num]
217 | };
218 |
219 | Faker.Lorem.sentence = function (wordCount){
220 | if( typeof wordCount == 'undefined'){ var wordCount = 3;}
221 |
222 | // strange issue with the node_min_test failing for captialize, please fix and add this back
223 | //return this.words(wordCount + Helpers.randomNumber(7)).join(' ').capitalize();
224 |
225 | return this.words(wordCount + Helpers.randomNumber(7)).join(' ');
226 | };
227 |
228 | Faker.Lorem.sentences = function (sentenceCount){
229 | if( typeof sentenceCount == 'undefined'){ var sentenceCount = 3;}
230 | var sentences = [];
231 | for(sentenceCount; sentenceCount >= 0; sentenceCount--){
232 | sentences.push(this.sentence());
233 | }
234 | return sentences.join("\n");
235 | };
236 |
237 | Faker.Lorem.paragraph = function (sentenceCount){
238 | if( typeof sentenceCount == 'undefined'){ var sentenceCount = 3;}
239 | return this.sentences(sentenceCount + Helpers.randomNumber(3));
240 | };
241 |
242 | Faker.Lorem.paragraphs = function (paragraphCount){
243 | if( typeof paragraphCount == 'undefined'){ var paragraphCount = 3;}
244 | var paragraphs = [];
245 | for(paragraphCount; paragraphCount >= 0; paragraphCount--){
246 | paragraphs.push(this.paragraph());
247 | }
248 | return paragraphs.join("\n \r\t");
249 | };
250 |
251 | Faker.Helpers = {};
252 | Faker.Helpers.randomNumber = function (range) {
253 | r = Math.floor(Math.random()*range);
254 | return r;
255 | };
256 |
257 | Faker.Helpers.randomize = function (array) {
258 | r = Math.floor(Math.random()*array.length);
259 | return array[r];
260 | };
261 |
262 | Faker.Helpers.replaceSymbolWithNumber = function (string, symbol){
263 |
264 | // default symbol is '#'
265 | if(typeof symbol == 'undefined'){
266 | var symbol = '#';
267 | }
268 |
269 | var str = '';
270 | for(var i = 0; i < string.length; i++){
271 | if(string[i] == symbol){
272 | str += Math.floor(Math.random()*10);
273 | }
274 | else{
275 | str += string[i];
276 | }
277 | }
278 | return str;
279 | };
280 |
281 | Faker.Helpers.shuffle = function (o){
282 | for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
283 | return o;
284 | };
285 |
286 | Faker.Helpers.generateDataSet = function (size){
287 |
288 | };
289 |
290 | Faker.Helpers.createCard = function (){
291 |
292 | return {
293 | "name":Faker.Name.findName(),
294 | "username":Faker.Internet.userName(),
295 | "email":Faker.Internet.email(),
296 | "address":{
297 | "streetA":Faker.Address.streetName(),
298 | "streetB":Faker.Address.streetAddress(),
299 | "streetC":Faker.Address.streetAddress(true),
300 | "streetD":Faker.Address.secondaryAddress(),
301 | "city":Faker.Address.city(),
302 | "ukCounty":Faker.Address.ukCounty(),
303 | "ukCountry":Faker.Address.ukCountry(),
304 | "zipcode":Faker.Address.zipCode()
305 | },
306 | "phone":Faker.PhoneNumber.phoneNumber(),
307 | "website":Faker.Internet.domainName(),
308 | "company":{
309 | "name":Faker.Company.companyName(),
310 | "catchPhrase":Faker.Company.catchPhrase(),
311 | "bs":Faker.Company.bs(),
312 | },
313 | "posts":[
314 | {
315 | "words":Faker.Lorem.words(),
316 | "sentence":Faker.Lorem.sentence(),
317 | "sentences":Faker.Lorem.sentences(),
318 | "paragraph":Faker.Lorem.paragraph()
319 | },
320 | {
321 | "words":Faker.Lorem.words(),
322 | "sentence":Faker.Lorem.sentence(),
323 | "sentences":Faker.Lorem.sentences(),
324 | "paragraph":Faker.Lorem.paragraph()
325 | },
326 | {
327 | "words":Faker.Lorem.words(),
328 | "sentence":Faker.Lorem.sentence(),
329 | "sentences":Faker.Lorem.sentences(),
330 | "paragraph":Faker.Lorem.paragraph()
331 | }
332 | ]
333 | };
334 | };
335 |
336 | Faker.Helpers.userCard = function (){
337 |
338 | return {
339 | "name":Faker.Name.findName(),
340 | "username":Faker.Internet.userName(),
341 | "email":Faker.Internet.email(),
342 | "address":{
343 | "street":Faker.Address.streetName(true),
344 | "suite":Faker.Address.secondaryAddress(),
345 | "city":Faker.Address.city(),
346 | "zipcode":Faker.Address.zipCode()
347 | },
348 | "phone":Faker.PhoneNumber.phoneNumber(),
349 | "website":Faker.Internet.domainName(),
350 | "company":{
351 | "name":Faker.Company.companyName(),
352 | "catchPhrase":Faker.Company.catchPhrase(),
353 | "bs":Faker.Company.bs(),
354 | },
355 | };
356 | };
357 |
358 | Faker.definitions = {};
359 | Faker.definitions.first_name = function (){return ["Aaliyah","Aaron","Abagail","Abbey","Abbie","Abbigail","Abby","Abdiel","Abdul","Abdullah","Abe","Abel","Abelardo","Abigail","Abigale","Abigayle","Abner","Abraham","Ada","Adah","Adalberto","Adaline","Adam","Adan","Addie","Addison","Adela","Adelbert","Adele","Adelia","Adeline","Adell","Adella","Adelle","Aditya","Adolf","Adolfo","Adolph","Adolphus","Adonis","Adrain","Adrian","Adriana","Adrianna","Adriel","Adrien","Adrienne","Afton","Aglae","Agnes","Agustin","Agustina","Ahmad","Ahmed","Aida","Aidan","Aiden","Aileen","Aimee","Aisha","Aiyana","Akeem","Al","Alaina","Alan","Alana","Alanis","Alanna","Alayna","Alba","Albert","Alberta","Albertha","Alberto","Albin","Albina","Alda","Alden","Alec","Aleen","Alejandra","Alejandrin","Alek","Alena","Alene","Alessandra","Alessandro","Alessia","Aletha","Alex","Alexa","Alexander","Alexandra","Alexandre","Alexandrea","Alexandria","Alexandrine","Alexandro","Alexane","Alexanne","Alexie","Alexis","Alexys","Alexzander","Alf","Alfonso","Alfonzo","Alford","Alfred","Alfreda","Alfredo","Ali","Alia","Alice","Alicia","Alisa","Alisha","Alison","Alivia","Aliya","Aliyah","Aliza","Alize","Allan","Allen","Allene","Allie","Allison","Ally","Alphonso","Alta","Althea","Alva","Alvah","Alvena","Alvera","Alverta","Alvina","Alvis","Alyce","Alycia","Alysa","Alysha","Alyson","Alysson","Amalia","Amanda","Amani","Amara","Amari","Amaya","Amber","Ambrose","Amelia","Amelie","Amely","America","Americo","Amie","Amina","Amir","Amira","Amiya","Amos","Amparo","Amy","Amya","Ana","Anabel","Anabelle","Anahi","Anais","Anastacio","Anastasia","Anderson","Andre","Andreane","Andreanne","Andres","Andrew","Andy","Angel","Angela","Angelica","Angelina","Angeline","Angelita","Angelo","Angie","Angus","Anibal","Anika","Anissa","Anita","Aniya","Aniyah","Anjali","Anna","Annabel","Annabell","Annabelle","Annalise","Annamae","Annamarie","Anne","Annetta","Annette","Annie","Ansel","Ansley","Anthony","Antoinette","Antone","Antonetta","Antonette","Antonia","Antonietta","Antonina","Antonio","Antwan","Antwon","Anya","April","Ara","Araceli","Aracely","Arch","Archibald","Ardella","Arden","Ardith","Arely","Ari","Ariane","Arianna","Aric","Ariel","Arielle","Arjun","Arlene","Arlie","Arlo","Armand","Armando","Armani","Arnaldo","Arne","Arno","Arnold","Arnoldo","Arnulfo","Aron","Art","Arthur","Arturo","Arvel","Arvid","Arvilla","Aryanna","Asa","Asha","Ashlee","Ashleigh","Ashley","Ashly","Ashlynn","Ashton","Ashtyn","Asia","Assunta","Astrid","Athena","Aubree","Aubrey","Audie","Audra","Audreanne","Audrey","August","Augusta","Augustine","Augustus","Aurelia","Aurelie","Aurelio","Aurore","Austen","Austin","Austyn","Autumn","Ava","Avery","Avis","Axel","Ayana","Ayden","Ayla","Aylin","Baby","Bailee","Bailey","Barbara","Barney","Baron","Barrett","Barry","Bart","Bartholome","Barton","Baylee","Beatrice","Beau","Beaulah","Bell","Bella","Belle","Ben","Benedict","Benjamin","Bennett","Bennie","Benny","Benton","Berenice","Bernadette","Bernadine","Bernard","Bernardo","Berneice","Bernhard","Bernice","Bernie","Berniece","Bernita","Berry","Bert","Berta","Bertha","Bertram","Bertrand","Beryl","Bessie","Beth","Bethany","Bethel","Betsy","Bette","Bettie","Betty","Bettye","Beulah","Beverly","Bianka","Bill","Billie","Billy","Birdie","Blair","Blaise","Blake","Blanca","Blanche","Blaze","Bo","Bobbie","Bobby","Bonita","Bonnie","Boris","Boyd","Brad","Braden","Bradford","Bradley","Bradly","Brady","Braeden","Brain","Brandi","Brando","Brandon","Brandt","Brandy","Brandyn","Brannon","Branson","Brant","Braulio","Braxton","Brayan","Breana","Breanna","Breanne","Brenda","Brendan","Brenden","Brendon","Brenna","Brennan","Brennon","Brent","Bret","Brett","Bria","Brian","Briana","Brianne","Brice","Bridget","Bridgette","Bridie","Brielle","Brigitte","Brionna","Brisa","Britney","Brittany","Brock","Broderick","Brody","Brook","Brooke","Brooklyn","Brooks","Brown","Bruce","Bryana","Bryce","Brycen","Bryon","Buck","Bud","Buddy","Buford","Bulah","Burdette","Burley","Burnice","Buster","Cade","Caden","Caesar","Caitlyn","Cale","Caleb","Caleigh","Cali","Calista","Callie","Camden","Cameron","Camila","Camilla","Camille","Camren","Camron","Camryn","Camylle","Candace","Candelario","Candice","Candida","Candido","Cara","Carey","Carissa","Carlee","Carleton","Carley","Carli","Carlie","Carlo","Carlos","Carlotta","Carmel","Carmela","Carmella","Carmelo","Carmen","Carmine","Carol","Carolanne","Carole","Carolina","Caroline","Carolyn","Carolyne","Carrie","Carroll","Carson","Carter","Cary","Casandra","Casey","Casimer","Casimir","Casper","Cassandra","Cassandre","Cassidy","Cassie","Catalina","Caterina","Catharine","Catherine","Cathrine","Cathryn","Cathy","Cayla","Ceasar","Cecelia","Cecil","Cecile","Cecilia","Cedrick","Celestine","Celestino","Celia","Celine","Cesar","Chad","Chadd","Chadrick","Chaim","Chance","Chandler","Chanel","Chanelle","Charity","Charlene","Charles","Charley","Charlie","Charlotte","Chase","Chasity","Chauncey","Chaya","Chaz","Chelsea","Chelsey","Chelsie","Chesley","Chester","Chet","Cheyanne","Cheyenne","Chloe","Chris","Christ","Christa","Christelle","Christian","Christiana","Christina","Christine","Christop","Christophe","Christopher","Christy","Chyna","Ciara","Cicero","Cielo","Cierra","Cindy","Citlalli","Clair","Claire","Clara","Clarabelle","Clare","Clarissa","Clark","Claud","Claude","Claudia","Claudie","Claudine","Clay","Clemens","Clement","Clementina","Clementine","Clemmie","Cleo","Cleora","Cleta","Cletus","Cleve","Cleveland","Clifford","Clifton","Clint","Clinton","Clotilde","Clovis","Cloyd","Clyde","Coby","Cody","Colby","Cole","Coleman","Colin","Colleen","Collin","Colt","Colten","Colton","Columbus","Concepcion","Conner","Connie","Connor","Conor","Conrad","Constance","Constantin","Consuelo","Cooper","Cora","Coralie","Corbin","Cordelia","Cordell","Cordia","Cordie","Corene","Corine","Cornelius","Cornell","Corrine","Cortez","Cortney","Cory","Coty","Courtney","Coy","Craig","Crawford","Creola","Cristal","Cristian","Cristina","Cristobal","Cristopher","Cruz","Crystal","Crystel","Cullen","Curt","Curtis","Cydney","Cynthia","Cyril","Cyrus","Dagmar","Dahlia","Daija","Daisha","Daisy","Dakota","Dale","Dallas","Dallin","Dalton","Damaris","Dameon","Damian","Damien","Damion","Damon","Dan","Dana","Dandre","Dane","D'angelo","Dangelo","Danial","Daniela","Daniella","Danielle","Danika","Dannie","Danny","Dante","Danyka","Daphne","Daphnee","Daphney","Darby","Daren","Darian","Dariana","Darien","Dario","Darion","Darius","Darlene","Daron","Darrel","Darrell","Darren","Darrick","Darrin","Darrion","Darron","Darryl","Darwin","Daryl","Dashawn","Dasia","Dave","David","Davin","Davion","Davon","Davonte","Dawn","Dawson","Dax","Dayana","Dayna","Dayne","Dayton","Dean","Deangelo","Deanna","Deborah","Declan","Dedric","Dedrick","Dee","Deion","Deja","Dejah","Dejon","Dejuan","Delaney","Delbert","Delfina","Delia","Delilah","Dell","Della","Delmer","Delores","Delpha","Delphia","Delphine","Delta","Demarco","Demarcus","Demario","Demetris","Demetrius","Demond","Dena","Denis","Dennis","Deon","Deondre","Deontae","Deonte","Dereck","Derek","Derick","Deron","Derrick","Deshaun","Deshawn","Desiree","Desmond","Dessie","Destany","Destin","Destinee","Destiney","Destini","Destiny","Devan","Devante","Deven","Devin","Devon","Devonte","Devyn","Dewayne","Dewitt","Dexter","Diamond","Diana","Dianna","Diego","Dillan","Dillon","Dimitri","Dina","Dino","Dion","Dixie","Dock","Dolly","Dolores","Domenic","Domenica","Domenick","Domenico","Domingo","Dominic","Dominique","Don","Donald","Donato","Donavon","Donna","Donnell","Donnie","Donny","Dora","Dorcas","Dorian","Doris","Dorothea","Dorothy","Dorris","Dortha","Dorthy","Doug","Douglas","Dovie","Doyle","Drake","Drew","Duane","Dudley","Dulce","Duncan","Durward","Dustin","Dusty","Dwight","Dylan","Earl","Earlene","Earline","Earnest","Earnestine","Easter","Easton","Ebba","Ebony","Ed","Eda","Edd","Eddie","Eden","Edgar","Edgardo","Edison","Edmond","Edmund","Edna","Eduardo","Edward","Edwardo","Edwin","Edwina","Edyth","Edythe","Effie","Efrain","Efren","Eileen","Einar","Eino","Eladio","Elaina","Elbert","Elda","Eldon","Eldora","Eldred","Eldridge","Eleanora","Eleanore","Eleazar","Electa","Elena","Elenor","Elenora","Eleonore","Elfrieda","Eli","Elian","Eliane","Elias","Eliezer","Elijah","Elinor","Elinore","Elisa","Elisabeth","Elise","Eliseo","Elisha","Elissa","Eliza","Elizabeth","Ella","Ellen","Ellie","Elliot","Elliott","Ellis","Ellsworth","Elmer","Elmira","Elmo","Elmore","Elna","Elnora","Elody","Eloisa","Eloise","Elouise","Eloy","Elroy","Elsa","Else","Elsie","Elta","Elton","Elva","Elvera","Elvie","Elvis","Elwin","Elwyn","Elyse","Elyssa","Elza","Emanuel","Emelia","Emelie","Emely","Emerald","Emerson","Emery","Emie","Emil","Emile","Emilia","Emiliano","Emilie","Emilio","Emily","Emma","Emmalee","Emmanuel","Emmanuelle","Emmet","Emmett","Emmie","Emmitt","Emmy","Emory","Ena","Enid","Enoch","Enola","Enos","Enrico","Enrique","Ephraim","Era","Eriberto","Eric","Erica","Erich","Erick","Ericka","Erik","Erika","Erin","Erling","Erna","Ernest","Ernestina","Ernestine","Ernesto","Ernie","Ervin","Erwin","Eryn","Esmeralda","Esperanza","Esta","Esteban","Estefania","Estel","Estell","Estella","Estelle","Estevan","Esther","Estrella","Etha","Ethan","Ethel","Ethelyn","Ethyl","Ettie","Eudora","Eugene","Eugenia","Eula","Eulah","Eulalia","Euna","Eunice","Eusebio","Eva","Evalyn","Evan","Evangeline","Evans","Eve","Eveline","Evelyn","Everardo","Everett","Everette","Evert","Evie","Ewald","Ewell","Ezekiel","Ezequiel","Ezra","Fabian","Fabiola","Fae","Fannie","Fanny","Fatima","Faustino","Fausto","Favian","Fay","Faye","Federico","Felicia","Felicita","Felicity","Felipa","Felipe","Felix","Felton","Fermin","Fern","Fernando","Ferne","Fidel","Filiberto","Filomena","Finn","Fiona","Flavie","Flavio","Fleta","Fletcher","Flo","Florence","Florencio","Florian","Florida","Florine","Flossie","Floy","Floyd","Ford","Forest","Forrest","Foster","Frances","Francesca","Francesco","Francis","Francisca","Francisco","Franco","Frank","Frankie","Franz","Fred","Freda","Freddie","Freddy","Frederic","Frederick","Frederik","Frederique","Fredrick","Fredy","Freeda","Freeman","Freida","Frida","Frieda","Friedrich","Fritz","Furman","Gabe","Gabriel","Gabriella","Gabrielle","Gaetano","Gage","Gail","Gardner","Garett","Garfield","Garland","Garnet","Garnett","Garret","Garrett","Garrick","Garrison","Garry","Garth","Gaston","Gavin","Gay","Gayle","Gaylord","Gene","General","Genesis","Genevieve","Gennaro","Genoveva","Geo","Geoffrey","George","Georgette","Georgiana","Georgianna","Geovanni","Geovanny","Geovany","Gerald","Geraldine","Gerard","Gerardo","Gerda","Gerhard","Germaine","German","Gerry","Gerson","Gertrude","Gia","Gianni","Gideon","Gilbert","Gilberto","Gilda","Giles","Gillian","Gina","Gino","Giovani","Giovanna","Giovanni","Giovanny","Gisselle","Giuseppe","Gladyce","Gladys","Glen","Glenda","Glenna","Glennie","Gloria","Godfrey","Golda","Golden","Gonzalo","Gordon","Grace","Gracie","Graciela","Grady","Graham","Grant","Granville","Grayce","Grayson","Green","Greg","Gregg","Gregoria","Gregorio","Gregory","Greta","Gretchen","Greyson","Griffin","Grover","Guadalupe","Gudrun","Guido","Guillermo","Guiseppe","Gunnar","Gunner","Gus","Gussie","Gust","Gustave","Guy","Gwen","Gwendolyn","Hadley","Hailee","Hailey","Hailie","Hal","Haleigh","Haley","Halie","Halle","Hallie","Hank","Hanna","Hannah","Hans","Hardy","Harley","Harmon","Harmony","Harold","Harrison","Harry","Harvey","Haskell","Hassan","Hassie","Hattie","Haven","Hayden","Haylee","Hayley","Haylie","Hazel","Hazle","Heath","Heather","Heaven","Heber","Hector","Heidi","Helen","Helena","Helene","Helga","Hellen","Helmer","Heloise","Henderson","Henri","Henriette","Henry","Herbert","Herman","Hermann","Hermina","Herminia","Herminio","Hershel","Herta","Hertha","Hester","Hettie","Hilario","Hilbert","Hilda","Hildegard","Hillard","Hillary","Hilma","Hilton","Hipolito","Hiram","Hobart","Holden","Hollie","Hollis","Holly","Hope","Horace","Horacio","Hortense","Hosea","Houston","Howard","Howell","Hoyt","Hubert","Hudson","Hugh","Hulda","Humberto","Hunter","Hyman","Ian","Ibrahim","Icie","Ida","Idell","Idella","Ignacio","Ignatius","Ike","Ila","Ilene","Iliana","Ima","Imani","Imelda","Immanuel","Imogene","Ines","Irma","Irving","Irwin","Isaac","Isabel","Isabell","Isabella","Isabelle","Isac","Isadore","Isai","Isaiah","Isaias","Isidro","Ismael","Isobel","Isom","Israel","Issac","Itzel","Iva","Ivah","Ivory","Ivy","Izabella","Izaiah","Jabari","Jace","Jacey","Jacinthe","Jacinto","Jack","Jackeline","Jackie","Jacklyn","Jackson","Jacky","Jaclyn","Jacquelyn","Jacques","Jacynthe","Jada","Jade","Jaden","Jadon","Jadyn","Jaeden","Jaida","Jaiden","Jailyn","Jaime","Jairo","Jakayla","Jake","Jakob","Jaleel","Jalen","Jalon","Jalyn","Jamaal","Jamal","Jamar","Jamarcus","Jamel","Jameson","Jamey","Jamie","Jamil","Jamir","Jamison","Jammie","Jan","Jana","Janae","Jane","Janelle","Janessa","Janet","Janice","Janick","Janie","Janis","Janiya","Jannie","Jany","Jaquan","Jaquelin","Jaqueline","Jared","Jaren","Jarod","Jaron","Jarred","Jarrell","Jarret","Jarrett","Jarrod","Jarvis","Jasen","Jasmin","Jason","Jasper","Jaunita","Javier","Javon","Javonte","Jay","Jayce","Jaycee","Jayda","Jayde","Jayden","Jaydon","Jaylan","Jaylen","Jaylin","Jaylon","Jayme","Jayne","Jayson","Jazlyn","Jazmin","Jazmyn","Jazmyne","Jean","Jeanette","Jeanie","Jeanne","Jed","Jedediah","Jedidiah","Jeff","Jefferey","Jeffery","Jeffrey","Jeffry","Jena","Jenifer","Jennie","Jennifer","Jennings","Jennyfer","Jensen","Jerad","Jerald","Jeramie","Jeramy","Jerel","Jeremie","Jeremy","Jermain","Jermaine","Jermey","Jerod","Jerome","Jeromy","Jerrell","Jerrod","Jerrold","Jerry","Jess","Jesse","Jessica","Jessie","Jessika","Jessy","Jessyca","Jesus","Jett","Jettie","Jevon","Jewel","Jewell","Jillian","Jimmie","Jimmy","Jo","Joan","Joana","Joanie","Joanne","Joannie","Joanny","Joany","Joaquin","Jocelyn","Jodie","Jody","Joe","Joel","Joelle","Joesph","Joey","Johan","Johann","Johanna","Johathan","John","Johnathan","Johnathon","Johnnie","Johnny","Johnpaul","Johnson","Jolie","Jon","Jonas","Jonatan","Jonathan","Jonathon","Jordan","Jordane","Jordi","Jordon","Jordy","Jordyn","Jorge","Jose","Josefa","Josefina","Joseph","Josephine","Josh","Joshua","Joshuah","Josiah","Josiane","Josianne","Josie","Josue","Jovan","Jovani","Jovanny","Jovany","Joy","Joyce","Juana","Juanita","Judah","Judd","Jude","Judge","Judson","Judy","Jules","Julia","Julian","Juliana","Julianne","Julie","Julien","Juliet","Julio","Julius","June","Junior","Junius","Justen","Justice","Justina","Justine","Juston","Justus","Justyn","Juvenal","Juwan","Kacey","Kaci","Kacie","Kade","Kaden","Kadin","Kaela","Kaelyn","Kaia","Kailee","Kailey","Kailyn","Kaitlin","Kaitlyn","Kale","Kaleb","Kaleigh","Kaley","Kali","Kallie","Kameron","Kamille","Kamren","Kamron","Kamryn","Kane","Kara","Kareem","Karelle","Karen","Kari","Kariane","Karianne","Karina","Karine","Karl","Karlee","Karley","Karli","Karlie","Karolann","Karson","Kasandra","Kasey","Kassandra","Katarina","Katelin","Katelyn","Katelynn","Katharina","Katherine","Katheryn","Kathleen","Kathlyn","Kathryn","Kathryne","Katlyn","Katlynn","Katrina","Katrine","Kattie","Kavon","Kay","Kaya","Kaycee","Kayden","Kayla","Kaylah","Kaylee","Kayleigh","Kayley","Kayli","Kaylie","Kaylin","Keagan","Keanu","Keara","Keaton","Keegan","Keeley","Keely","Keenan","Keira","Keith","Kellen","Kelley","Kelli","Kellie","Kelly","Kelsi","Kelsie","Kelton","Kelvin","Ken","Kendall","Kendra","Kendrick","Kenna","Kennedi","Kennedy","Kenneth","Kennith","Kenny","Kenton","Kenya","Kenyatta","Kenyon","Keon","Keshaun","Keshawn","Keven","Kevin","Kevon","Keyon","Keyshawn","Khalid","Khalil","Kian","Kiana","Kianna","Kiara","Kiarra","Kiel","Kiera","Kieran","Kiley","Kim","Kimberly","King","Kip","Kira","Kirk","Kirsten","Kirstin","Kitty","Kobe","Koby","Kody","Kolby","Kole","Korbin","Korey","Kory","Kraig","Kris","Krista","Kristian","Kristin","Kristina","Kristofer","Kristoffer","Kristopher","Kristy","Krystal","Krystel","Krystina","Kurt","Kurtis","Kyla","Kyle","Kylee","Kyleigh","Kyler","Kylie","Kyra","Lacey","Lacy","Ladarius","Lafayette","Laila","Laisha","Lamar","Lambert","Lamont","Lance","Landen","Lane","Laney","Larissa","Laron","Larry","Larue","Laura","Laurel","Lauren","Laurence","Lauretta","Lauriane","Laurianne","Laurie","Laurine","Laury","Lauryn","Lavada","Lavern","Laverna","Laverne","Lavina","Lavinia","Lavon","Lavonne","Lawrence","Lawson","Layla","Layne","Lazaro","Lea","Leann","Leanna","Leanne","Leatha","Leda","Lee","Leif","Leila","Leilani","Lela","Lelah","Leland","Lelia","Lempi","Lemuel","Lenna","Lennie","Lenny","Lenora","Lenore","Leo","Leola","Leon","Leonard","Leonardo","Leone","Leonel","Leonie","Leonor","Leonora","Leopold","Leopoldo","Leora","Lera","Lesley","Leslie","Lesly","Lessie","Lester","Leta","Letha","Letitia","Levi","Lew","Lewis","Lexi","Lexie","Lexus","Lia","Liam","Liana","Libbie","Libby","Lila","Lilian","Liliana","Liliane","Lilla","Lillian","Lilliana","Lillie","Lilly","Lily","Lilyan","Lina","Lincoln","Linda","Lindsay","Lindsey","Linnea","Linnie","Linwood","Lionel","Lisa","Lisandro","Lisette","Litzy","Liza","Lizeth","Lizzie","Llewellyn","Lloyd","Logan","Lois","Lola","Lolita","Loma","Lon","London","Lonie","Lonnie","Lonny","Lonzo","Lora","Loraine","Loren","Lorena","Lorenz","Lorenza","Lorenzo","Lori","Lorine","Lorna","Lottie","Lou","Louie","Louisa","Lourdes","Louvenia","Lowell","Loy","Loyal","Loyce","Lucas","Luciano","Lucie","Lucienne","Lucile","Lucinda","Lucio","Lucious","Lucius","Lucy","Ludie","Ludwig","Lue","Luella","Luigi","Luis","Luisa","Lukas","Lula","Lulu","Luna","Lupe","Lura","Lurline","Luther","Luz","Lyda","Lydia","Lyla","Lynn","Lyric","Lysanne","Mabel","Mabelle","Mable","Mac","Macey","Maci","Macie","Mack","Mackenzie","Macy","Madaline","Madalyn","Maddison","Madeline","Madelyn","Madelynn","Madge","Madie","Madilyn","Madisen","Madison","Madisyn","Madonna","Madyson","Mae","Maegan","Maeve","Mafalda","Magali","Magdalen","Magdalena","Maggie","Magnolia","Magnus","Maia","Maida","Maiya","Major","Makayla","Makenna","Makenzie","Malachi","Malcolm","Malika","Malinda","Mallie","Mallory","Malvina","Mandy","Manley","Manuel","Manuela","Mara","Marc","Marcel","Marcelina","Marcelino","Marcella","Marcelle","Marcellus","Marcelo","Marcia","Marco","Marcos","Marcus","Margaret","Margarete","Margarett","Margaretta","Margarette","Margarita","Marge","Margie","Margot","Margret","Marguerite","Maria","Mariah","Mariam","Marian","Mariana","Mariane","Marianna","Marianne","Mariano","Maribel","Marie","Mariela","Marielle","Marietta","Marilie","Marilou","Marilyne","Marina","Mario","Marion","Marisa","Marisol","Maritza","Marjolaine","Marjorie","Marjory","Mark","Markus","Marlee","Marlen","Marlene","Marley","Marlin","Marlon","Marques","Marquis","Marquise","Marshall","Marta","Martin","Martina","Martine","Marty","Marvin","Mary","Maryam","Maryjane","Maryse","Mason","Mateo","Mathew","Mathias","Mathilde","Matilda","Matilde","Matt","Matteo","Mattie","Maud","Maude","Maudie","Maureen","Maurice","Mauricio","Maurine","Maverick","Mavis","Max","Maxie","Maxime","Maximilian","Maximillia","Maximillian","Maximo","Maximus","Maxine","Maxwell","May","Maya","Maybell","Maybelle","Maye","Maymie","Maynard","Mayra","Mazie","Mckayla","Mckenna","Mckenzie","Meagan","Meaghan","Meda","Megane","Meggie","Meghan","Mekhi","Melany","Melba","Melisa","Melissa","Mellie","Melody","Melvin","Melvina","Melyna","Melyssa","Mercedes","Meredith","Merl","Merle","Merlin","Merritt","Mertie","Mervin","Meta","Mia","Micaela","Micah","Michael","Michaela","Michale","Micheal","Michel","Michele","Michelle","Miguel","Mikayla","Mike","Mikel","Milan","Miles","Milford","Miller","Millie","Milo","Milton","Mina","Minerva","Minnie","Miracle","Mireille","Mireya","Misael","Missouri","Misty","Mitchel","Mitchell","Mittie","Modesta","Modesto","Mohamed","Mohammad","Mohammed","Moises","Mollie","Molly","Mona","Monica","Monique","Monroe","Monserrat","Monserrate","Montana","Monte","Monty","Morgan","Moriah","Morris","Mortimer","Morton","Mose","Moses","Moshe","Mossie","Mozell","Mozelle","Muhammad","Muriel","Murl","Murphy","Murray","Mustafa","Mya","Myah","Mylene","Myles","Myra","Myriam","Myrl","Myrna","Myron","Myrtice","Myrtie","Myrtis","Myrtle","Nadia","Nakia","Name","Nannie","Naomi","Naomie","Napoleon","Narciso","Nash","Nasir","Nat","Natalia","Natalie","Natasha","Nathan","Nathanael","Nathanial","Nathaniel","Nathen","Nayeli","Neal","Ned","Nedra","Neha","Neil","Nelda","Nella","Nelle","Nellie","Nels","Nelson","Neoma","Nestor","Nettie","Neva","Newell","Newton","Nia","Nicholas","Nicholaus","Nichole","Nick","Nicklaus","Nickolas","Nico","Nicola","Nicolas","Nicole","Nicolette","Nigel","Nikita","Nikki","Nikko","Niko","Nikolas","Nils","Nina","Noah","Noble","Noe","Noel","Noelia","Noemi","Noemie","Noemy","Nola","Nolan","Nona","Nora","Norbert","Norberto","Norene","Norma","Norris","Norval","Norwood","Nova","Novella","Nya","Nyah","Nyasia","Obie","Oceane","Ocie","Octavia","Oda","Odell","Odessa","Odie","Ofelia","Okey","Ola","Olaf","Ole","Olen","Oleta","Olga","Olin","Oliver","Ollie","Oma","Omari","Omer","Ona","Onie","Opal","Ophelia","Ora","Oral","Oran","Oren","Orie","Orin","Orion","Orland","Orlando","Orlo","Orpha","Orrin","Orval","Orville","Osbaldo","Osborne","Oscar","Osvaldo","Oswald","Oswaldo","Otha","Otho","Otilia","Otis","Ottilie","Ottis","Otto","Ova","Owen","Ozella","Pablo","Paige","Palma","Pamela","Pansy","Paolo","Paris","Parker","Pascale","Pasquale","Pat","Patience","Patricia","Patrick","Patsy","Pattie","Paul","Paula","Pauline","Paxton","Payton","Pearl","Pearlie","Pearline","Pedro","Peggie","Penelope","Percival","Percy","Perry","Pete","Peter","Petra","Peyton","Philip","Phoebe","Phyllis","Pierce","Pierre","Pietro","Pink","Pinkie","Piper","Polly","Porter","Precious","Presley","Preston","Price","Prince","Princess","Priscilla","Providenci","Prudence","Queen","Queenie","Quentin","Quincy","Quinn","Quinten","Quinton","Rachael","Rachel","Rachelle","Rae","Raegan","Rafael","Rafaela","Raheem","Rahsaan","Rahul","Raina","Raleigh","Ralph","Ramiro","Ramon","Ramona","Randal","Randall","Randi","Randy","Ransom","Raoul","Raphael","Raphaelle","Raquel","Rashad","Rashawn","Rasheed","Raul","Raven","Ray","Raymond","Raymundo","Reagan","Reanna","Reba","Rebeca","Rebecca","Rebeka","Rebekah","Reece","Reed","Reese","Regan","Reggie","Reginald","Reid","Reilly","Reina","Reinhold","Remington","Rene","Renee","Ressie","Reta","Retha","Retta","Reuben","Reva","Rex","Rey","Reyes","Reymundo","Reyna","Reynold","Rhea","Rhett","Rhianna","Rhiannon","Rhoda","Ricardo","Richard","Richie","Richmond","Rick","Rickey","Rickie","Ricky","Rico","Rigoberto","Riley","Rita","River","Robb","Robbie","Robert","Roberta","Roberto","Robin","Robyn","Rocio","Rocky","Rod","Roderick","Rodger","Rodolfo","Rodrick","Rodrigo","Roel","Rogelio","Roger","Rogers","Rolando","Rollin","Roma","Romaine","Roman","Ron","Ronaldo","Ronny","Roosevelt","Rory","Rosa","Rosalee","Rosalia","Rosalind","Rosalinda","Rosalyn","Rosamond","Rosanna","Rosario","Roscoe","Rose","Rosella","Roselyn","Rosemarie","Rosemary","Rosendo","Rosetta","Rosie","Rosina","Roslyn","Ross","Rossie","Rowan","Rowena","Rowland","Roxane","Roxanne","Roy","Royal","Royce","Rozella","Ruben","Rubie","Ruby","Rubye","Rudolph","Rudy","Rupert","Russ","Russel","Russell","Rusty","Ruth","Ruthe","Ruthie","Ryan","Ryann","Ryder","Rylan","Rylee","Ryleigh","Ryley","Sabina","Sabrina","Sabryna","Sadie","Sadye","Sage","Saige","Sallie","Sally","Salma","Salvador","Salvatore","Sam","Samanta","Samantha","Samara","Samir","Sammie","Sammy","Samson","Sandra","Sandrine","Sandy","Sanford","Santa","Santiago","Santina","Santino","Santos","Sarah","Sarai","Sarina","Sasha","Saul","Savanah","Savanna","Savannah","Savion","Scarlett","Schuyler","Scot","Scottie","Scotty","Seamus","Sean","Sebastian","Sedrick","Selena","Selina","Selmer","Serena","Serenity","Seth","Shad","Shaina","Shakira","Shana","Shane","Shanel","Shanelle","Shania","Shanie","Shaniya","Shanna","Shannon","Shanny","Shanon","Shany","Sharon","Shaun","Shawn","Shawna","Shaylee","Shayna","Shayne","Shea","Sheila","Sheldon","Shemar","Sheridan","Sherman","Sherwood","Shirley","Shyann","Shyanne","Sibyl","Sid","Sidney","Sienna","Sierra","Sigmund","Sigrid","Sigurd","Silas","Sim","Simeon","Simone","Sincere","Sister","Skye","Skyla","Skylar","Sofia","Soledad","Solon","Sonia","Sonny","Sonya","Sophia","Sophie","Spencer","Stacey","Stacy","Stan","Stanford","Stanley","Stanton","Stefan","Stefanie","Stella","Stephan","Stephania","Stephanie","Stephany","Stephen","Stephon","Sterling","Steve","Stevie","Stewart","Stone","Stuart","Summer","Sunny","Susan","Susana","Susanna","Susie","Suzanne","Sven","Syble","Sydnee","Sydney","Sydni","Sydnie","Sylvan","Sylvester","Sylvia","Tabitha","Tad","Talia","Talon","Tamara","Tamia","Tania","Tanner","Tanya","Tara","Taryn","Tate","Tatum","Tatyana","Taurean","Tavares","Taya","Taylor","Teagan","Ted","Telly","Terence","Teresa","Terrance","Terrell","Terrence","Terrill","Terry","Tess","Tessie","Tevin","Thad","Thaddeus","Thalia","Thea","Thelma","Theo","Theodora","Theodore","Theresa","Therese","Theresia","Theron","Thomas","Thora","Thurman","Tia","Tiana","Tianna","Tiara","Tierra","Tiffany","Tillman","Timmothy","Timmy","Timothy","Tina","Tito","Titus","Tobin","Toby","Tod","Tom","Tomas","Tomasa","Tommie","Toney","Toni","Tony","Torey","Torrance","Torrey","Toy","Trace","Tracey","Tracy","Travis","Travon","Tre","Tremaine","Tremayne","Trent","Trenton","Tressa","Tressie","Treva","Trever","Trevion","Trevor","Trey","Trinity","Trisha","Tristian","Tristin","Triston","Troy","Trudie","Trycia","Trystan","Turner","Twila","Tyler","Tyra","Tyree","Tyreek","Tyrel","Tyrell","Tyrese","Tyrique","Tyshawn","Tyson","Ubaldo","Ulices","Ulises","Una","Unique","Urban","Uriah","Uriel","Ursula","Vada","Valentin","Valentina","Valentine","Valerie","Vallie","Van","Vance","Vanessa","Vaughn","Veda","Velda","Vella","Velma","Velva","Vena","Verda","Verdie","Vergie","Verla","Verlie","Vern","Verna","Verner","Vernice","Vernie","Vernon","Verona","Veronica","Vesta","Vicenta","Vicente","Vickie","Vicky","Victor","Victoria","Vida","Vidal","Vilma","Vince","Vincent","Vincenza","Vincenzo","Vinnie","Viola","Violet","Violette","Virgie","Virgil","Virginia","Virginie","Vita","Vito","Viva","Vivian","Viviane","Vivianne","Vivien","Vivienne","Vladimir","Wade","Waino","Waldo","Walker","Wallace","Walter","Walton","Wanda","Ward","Warren","Watson","Wava","Waylon","Wayne","Webster","Weldon","Wellington","Wendell","Wendy","Werner","Westley","Weston","Whitney","Wilber","Wilbert","Wilburn","Wiley","Wilford","Wilfred","Wilfredo","Wilfrid","Wilhelm","Wilhelmine","Will","Willa","Willard","William","Willie","Willis","Willow","Willy","Wilma","Wilmer","Wilson","Wilton","Winfield","Winifred","Winnifred","Winona","Winston","Woodrow","Wyatt","Wyman","Xander","Xavier","Xzavier","Yadira","Yasmeen","Yasmin","Yasmine","Yazmin","Yesenia","Yessenia","Yolanda","Yoshiko","Yvette","Yvonne","Zachariah","Zachary","Zachery","Zack","Zackary","Zackery","Zakary","Zander","Zane","Zaria","Zechariah","Zelda","Zella","Zelma","Zena","Zetta","Zion","Zita","Zoe","Zoey","Zoie","Zoila","Zola","Zora","Zul"];};
360 |
361 | Faker.definitions.last_name = function (){return["Abbott","Abernathy","Abshire","Adams","Altenwerth","Anderson","Ankunding","Armstrong","Auer","Aufderhar","Bahringer","Bailey","Balistreri","Barrows","Bartell","Bartoletti","Barton","Bashirian","Batz","Bauch","Baumbach","Bayer","Beahan","Beatty","Bechtelar","Becker","Bednar","Beer","Beier","Berge","Bergnaum","Bergstrom","Bernhard","Bernier","Bins","Blanda","Blick","Block","Bode","Boehm","Bogan","Bogisich","Borer","Bosco","Botsford","Boyer","Boyle","Bradtke","Brakus","Braun","Breitenberg","Brekke","Brown","Bruen","Buckridge","Carroll","Carter","Cartwright","Casper","Cassin","Champlin","Christiansen","Cole","Collier","Collins","Conn","Connelly","Conroy","Considine","Corkery","Cormier","Corwin","Cremin","Crist","Crona","Cronin","Crooks","Cruickshank","Cummerata","Cummings","Dach","D'Amore","Daniel","Dare","Daugherty","Davis","Deckow","Denesik","Dibbert","Dickens","Dicki","Dickinson","Dietrich","Donnelly","Dooley","Douglas","Doyle","DuBuque","Durgan","Ebert","Effertz","Eichmann","Emard","Emmerich","Erdman","Ernser","Fadel","Fahey","Farrell","Fay","Feeney","Feest","Feil","Ferry","Fisher","Flatley","Frami","Franecki","Friesen","Fritsch","Funk","Gaylord","Gerhold","Gerlach","Gibson","Gislason","Gleason","Gleichner","Glover","Goldner","Goodwin","Gorczany","Gottlieb","Goyette","Grady","Graham","Grant","Green","Greenfelder","Greenholt","Grimes","Gulgowski","Gusikowski","Gutkowski","Gu�ann","Haag","Hackett","Hagenes","Hahn","Haley","Halvorson","Hamill","Hammes","Hand","Hane","Hansen","Harber","Harris","Har�ann","Harvey","Hauck","Hayes","Heaney","Heathcote","Hegmann","Heidenreich","Heller","Herman","Hermann","Hermiston","Herzog","Hessel","Hettinger","Hickle","Hilll","Hills","Hilpert","Hintz","Hirthe","Hodkiewicz","Hoeger","Homenick","Hoppe","Howe","Howell","Hudson","Huel","Huels","Hyatt","Jacobi","Jacobs","Jacobson","Jakubowski","Jaskolski","Jast","Jenkins","Jerde","Jewess","Johns","Johnson","Johnston","Jones","Kassulke","Kautzer","Keebler","Keeling","Kemmer","Kerluke","Kertzmann","Kessler","Kiehn","Kihn","Kilback","King","Kirlin","Klein","Kling","Klocko","Koch","Koelpin","Koepp","Kohler","Konopelski","Koss","Kovacek","Kozey","Krajcik","Kreiger","Kris","Kshlerin","Kub","Kuhic","Kuhlman","Kuhn","Kulas","Kunde","Kunze","Kuphal","Kutch","Kuvalis","Labadie","Lakin","Lang","Langosh","Langworth","Larkin","Larson","Leannon","Lebsack","Ledner","Leffler","Legros","Lehner","Lemke","Lesch","Leuschke","Lind","Lindgren","Littel","Little","Lockman","Lowe","Lubowitz","Lueilwitz","Luettgen","Lynch","Macejkovic","Maggio","Mann","Mante","Marks","Marquardt","Marvin","Mayer","Mayert","McClure","McCullough","McDermott","McGlynn","McKenzie","McLaughlin","Medhurst","Mertz","Metz","Miller","Mills","Mitchell","Moen","Mohr","Monahan","Moore","Morar","Morissette","Mosciski","Mraz","Mueller","Muller","Murazik","Murphy","Murray","Nader","Nicolas","Nienow","Nikolaus","Nitzsche","Nolan","Oberbrunner","O'Connell","O'Conner","O'Hara","O'Keefe","O'Kon","Okuneva","Olson","Ondricka","O'Reilly","Orn","Ortiz","Osinski","Pacocha","Padberg","Pagac","Parisian","Parker","Paucek","Pfannerstill","Pfeffer","Pollich","Pouros","Powlowski","Predovic","Price","Prohaska","Prosacco","Purdy","Quigley","Quitzon","Rath","Ratke","Rau","Raynor","Reichel","Reichert","Reilly","Reinger","Rempel","Renner","Reynolds","Rice","Rippin","Ritchie","Robel","Roberts","Rodriguez","Rogahn","Rohan","Rolfson","Romaguera","Roob","Rosenbaum","Rowe","Ruecker","Runolfsdottir","Runolfsson","Runte","Russel","Rutherford","Ryan","Sanford","Satterfield","Sauer","Sawayn","Schaden","Schaefer","Schamberger","Schiller","Schimmel","Schinner","Schmeler","Schmidt","Schmitt","Schneider","Schoen","Schowalter","Schroeder","Schulist","Schultz","Schumm","Schuppe","Schuster","Senger","Shanahan","Shields","Simonis","Sipes","Skiles","Smith","Smitham","Spencer","Spinka","Sporer","Stamm","Stanton","Stark","Stehr","Steuber","Stiedemann","Stokes","Stoltenberg","Stracke","Streich","Stroman","Strosin","Swaniawski","Swift","Terry","Thiel","Thompson","Tillman","Torp","Torphy","Towne","Toy","Trantow","Tremblay","Treutel","Tromp","Turcotte","Turner","Ullrich","Upton","Vandervort","Veum","Volkman","Von","VonRueden","Waelchi","Walker","Walsh","Walter","Ward","Waters","Watsica","Weber","Wehner","Weimann","Weissnat","Welch","West","White","Wiegand","Wilderman","Wilkinson","Will","Williamson","Willms","Windler","Wintheiser","Wisoky","Wisozk","Witting","Wiza","Wolf","Wolff","Wuckert","Wunsch","Wyman","Yost","Yundt","Zboncak","Zemlak","Ziemann","Zieme","Zulauf"];};
362 |
363 | Faker.definitions.name_prefix = function (){return ["Mr.", "Mrs.", "Ms.", "Miss", "Dr."];};
364 |
365 | Faker.definitions.name_suffix = function (){return ["Jr.", "Sr.", "I", "II", "III", "IV", "V", "MD", "DDS", "PhD", "DVM"];};
366 |
367 | Faker.definitions.us_state = function (){return ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'];};
368 |
369 | Faker.definitions.us_state_abbr = function (){return ["AL", "AK", "AS", "AZ", "AR", "CA", "CO", 'CT', "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY", "AE", "AA", "AP"];};
370 |
371 | Faker.definitions.city_prefix = function (){return ["North", "East", "West", "South", "New", "Lake", "Port"];};
372 |
373 | Faker.definitions.city_suffix = function (){return ["town", "ton", "land", "ville", "berg", "burgh", "borough", "bury", "view", "port", "mouth", "stad", "furt", "chester", "mouth", "fort", "haven", "side", "shire"];};
374 |
375 | Faker.definitions.street_suffix = function (){return ["Alley","Avenue","Branch","Bridge","Brook","Brooks","Burg","Burgs","Bypass","Camp","Canyon","Cape","Causeway","Center","Centers","Circle","Circles","Cliff","Cliffs","Club","Common","Corner","Corners","Course","Court","Courts","Cove","Coves","Creek","Crescent","Crest","Crossing","Crossroad","Curve","Dale","Dam","Divide","Drive","Drive","Drives","Estate","Estates","Expressway","Extension","Extensions","Fall","Falls","Ferry","Field","Fields","Flat","Flats","Ford","Fords","Forest","Forge","Forges","Fork","Forks","Fort","Freeway","Garden","Gardens","Gateway","Glen","Glens","Green","Greens","Grove","Groves","Harbor","Harbors","Haven","Heights","Highway","Hill","Hills","Hollow","Inlet","Inlet","Island","Island","Islands","Islands","Isle","Isle","Junction","Junctions","Key","Keys","Knoll","Knolls","Lake","Lakes","Land","Landing","Lane","Light","Lights","Loaf","Lock","Locks","Locks","Lodge","Lodge","Loop","Mall","Manor","Manors","Meadow","Meadows","Mews","Mill","Mills","Mission","Mission","Motorway","Mount","Mountain","Mountain","Mountains","Mountains","Neck","Orchard","Oval","Overpass","Park","Parks","Parkway","Parkways","Pass","Passage","Path","Pike","Pine","Pines","Place","Plain","Plains","Plains","Plaza","Plaza","Point","Points","Port","Port","Ports","Ports","Prairie","Prairie","Radial","Ramp","Ranch","Rapid","Rapids","Rest","Ridge","Ridges","River","Road","Road","Roads","Roads","Route","Row","Rue","Run","Shoal","Shoals","Shore","Shores","Skyway","Spring","Springs","Springs","Spur","Spurs","Square","Square","Squares","Squares","Station","Station","Stravenue","Stravenue","Stream","Stream","Street","Street","Streets","Summit","Summit","Terrace","Throughway","Trace","Track","Trafficway","Trail","Trail","Tunnel","Tunnel","Turnpike","Turnpike","Underpass","Union","Unions","Valley","Valleys","Via","Viaduct","View","Views","Village","Village","","Villages","Ville","Vista","Vista","Walk","Walks","Wall","Way","Ways","Well","Wells"];};
376 |
377 | Faker.definitions.uk_county = function (){return ['Avon', 'Bedfordshire', 'Berkshire', 'Borders', 'Buckinghamshire', 'Cambridgeshire', 'Central', 'Cheshire', 'Cleveland', 'Clwyd', 'Cornwall', 'County Antrim', 'County Armagh', 'County Down', 'County Fermanagh', 'County Londonderry', 'County Tyrone', 'Cumbria', 'Derbyshire', 'Devon', 'Dorset', 'Dumfries and Galloway', 'Durham', 'Dyfed', 'East Sussex', 'Essex', 'Fife', 'Gloucestershire', 'Grampian', 'Greater Manchester', 'Gwent', 'Gwynedd County', 'Hampshire', 'Herefordshire', 'Hertfordshire', 'Highlands and Islands', 'Humberside', 'Isle of Wight', 'Kent', 'Lancashire', 'Leicestershire', 'Lincolnshire', 'Lothian', 'Merseyside', 'Mid Glamorgan', 'Norfolk', 'North Yorkshire', 'Northamptonshire', 'Northumberland', 'Nottinghamshire', 'Oxfordshire', 'Powys', 'Rutland', 'Shropshire', 'Somerset', 'South Glamorgan', 'South Yorkshire', 'Staffordshire', 'Strathclyde', 'Suffolk', 'Surrey', 'Tayside', 'Tyne and Wear', 'Warwickshire', 'West Glamorgan', 'West Midlands', 'West Sussex', 'West Yorkshire', 'Wiltshire', 'Worcestershire'];};
378 |
379 | Faker.definitions.uk_country = function (){return ['England', 'Scotland', 'Wales', 'Northern Ireland'];};
380 |
381 | Faker.definitions.catch_phrase_adjective = function (){return ["Adaptive", "Advanced", "Ameliorated", "Assimilated", "Automated", "Balanced", "Business-focused", "Centralized", "Cloned", "Compatible", "Configurable", "Cross-group", "Cross-platform", "Customer-focused", "Customizable", "Decentralized", "De-engineered", "Devolved", "Digitized", "Distributed", "Diverse", "Down-sized", "Enhanced", "Enterprise-wide", "Ergonomic", "Exclusive", "Expanded", "Extended", "Face to face", "Focused", "Front-line", "Fully-configurable", "Function-based", "Fundamental", "Future-proofed", "Grass-roots", "Horizontal", "Implemented", "Innovative", "Integrated", "Intuitive", "Inverse", "Managed", "Mandatory", "Monitored", "Multi-channelled", "Multi-lateral", "Multi-layered", "Multi-tiered", "Networked", "Object-based", "Open-architected", "Open-source", "Operative", "Optimized", "Optional", "Organic", "Organized", "Persevering", "Persistent", "Phased", "Polarised", "Pre-emptive", "Proactive", "Profit-focused", "Profound", "Programmable", "Progressive", "Public-key", "Quality-focused", "Reactive", "Realigned", "Re-contextualized", "Re-engineered", "Reduced", "Reverse-engineered", "Right-sized", "Robust", "Seamless", "Secured", "Self-enabling", "Sharable", "Stand-alone", "Streamlined", "Switchable", "Synchronised", "Synergistic", "Synergized", "Team-oriented", "Total", "Triple-buffered", "Universal", "Up-sized", "Upgradable", "User-centric", "User-friendly", "Versatile", "Virtual", "Visionary", "Vision-oriented"];};
382 |
383 | Faker.definitions.catch_phrase_descriptor = function (){return ["24 hour", "24/7", "3rd generation", "4th generation", "5th generation", "6th generation", "actuating", "analyzing", "assymetric", "asynchronous", "attitude-oriented", "background", "bandwidth-monitored", "bi-directional", "bifurcated", "bottom-line", "clear-thinking", "client-driven", "client-server", "coherent", "cohesive", "composite", "context-sensitive", "contextually-based", "content-based", "dedicated", "demand-driven", "didactic", "directional", "discrete", "disintermediate", "dynamic", "eco-centric", "empowering", "encompassing", "even-keeled", "executive", "explicit", "exuding", "fault-tolerant", "foreground", "fresh-thinking", "full-range", "global", "grid-enabled", "heuristic", "high-level", "holistic", "homogeneous", "human-resource", "hybrid", "impactful", "incremental", "intangible", "interactive", "intermediate", "leading edge", "local", "logistical", "maximized", "methodical", "mission-critical", "mobile", "modular", "motivating", "multimedia", "multi-state", "multi-tasking", "national", "needs-based", "neutral", "next generation", "non-volatile", "object-oriented", "optimal", "optimizing", "radical", "real-time", "reciprocal", "regional", "responsive", "scalable", "secondary", "solution-oriented", "stable", "static", "systematic", "systemic", "system-worthy", "tangible", "tertiary", "transitional", "uniform", "upward-trending", "user-facing", "value-added", "web-enabled", "well-modulated", "zero administration", "zero defect", "zero tolerance"];};
384 |
385 | Faker.definitions.catch_phrase_noun = function (){return ["ability", "access", "adapter", "algorithm", "alliance", "analyzer", "application", "approach", "architecture", "archive", "artificial intelligence", "array", "attitude", "benchmark", "budgetary management", "capability", "capacity", "challenge", "circuit", "collaboration", "complexity", "concept", "conglomeration", "contingency", "core", "customer loyalty", "database", "data-warehouse", "definition", "emulation", "encoding", "encryption", "extranet", "firmware", "flexibility", "focus group", "forecast", "frame", "framework", "function", "functionalities", "Graphic Interface", "groupware", "Graphical User Interface", "hardware", "help-desk", "hierarchy", "hub", "implementation", "info-mediaries", "infrastructure", "initiative", "installation", "instruction set", "interface", "internet solution", "intranet", "knowledge user", "knowledge base", "local area network", "leverage", "matrices", "matrix", "methodology", "middleware", "migration", "model", "moderator", "monitoring", "moratorium", "neural-net", "open architecture", "open system", "orchestration", "paradigm", "parallelism", "policy", "portal", "pricing structure", "process improvement", "product", "productivity", "project", "projection", "protocol", "secured line", "service-desk", "software", "solution", "standardization", "strategy", "structure", "success", "superstructure", "support", "synergy", "system engine", "task-force", "throughput", "time-frame", "toolset", "utilisation", "website", "workforce"];};
386 |
387 | Faker.definitions.bs_adjective = function (){return ["implement", "utilize", "integrate", "streamline", "optimize", "evolve", "transform", "embrace", "enable", "orchestrate", "leverage", "reinvent", "aggregate", "architect", "enhance", "incentivize", "morph", "empower", "envisioneer", "monetize", "harness", "facilitate", "seize", "disintermediate", "synergize", "strategize", "deploy", "brand", "grow", "target", "syndicate", "synthesize", "deliver", "mesh", "incubate", "engage", "maximize", "benchmark", "expedite", "reintermediate", "whiteboard", "visualize", "repurpose", "innovate", "scale", "unleash", "drive", "extend", "engineer", "revolutionize", "generate", "exploit", "transition", "e-enable", "iterate", "cultivate", "matrix", "productize", "redefine", "recontextualize"];};
388 |
389 | Faker.definitions.bs_buzz = function (){return ["clicks-and-mortar", "value-added", "vertical", "proactive", "robust", "revolutionary", "scalable", "leading-edge", "innovative", "intuitive", "strategic", "e-business", "mission-critical", "sticky", "one-to-one", "24/7", "end-to-end", "global", "B2B", "B2C", "granular", "frictionless", "virtual", "viral", "dynamic", "24/365", "best-of-breed", "killer", "magnetic", "bleeding-edge", "web-enabled", "interactive", "dot-com", "sexy", "back-end", "real-time", "efficient", "front-end", "distributed", "seamless", "extensible", "turn-key", "world-class", "open-source", "cross-platform", "cross-media", "synergistic", "bricks-and-clicks", "out-of-the-box", "enterprise", "integrated", "impactful", "wireless", "transparent", "next-generation", "cutting-edge", "user-centric", "visionary", "customized", "ubiquitous", "plug-and-play", "collaborative", "compelling", "holistic", "rich"];};
390 |
391 | Faker.definitions.bs_noun = function (){return ["synergies", "web-readiness", "paradigms", "markets", "partnerships", "infrastructures", "platforms", "initiatives", "channels", "eyeballs", "communities", "ROI", "solutions", "e-tailers", "e-services", "action-items", "portals", "niches", "technologies", "content", "vortals", "supply-chains", "convergence", "relationships", "architectures", "interfaces", "e-markets", "e-commerce", "systems", "bandwidth", "infomediaries", "models", "mindshare", "deliverables", "users", "schemas", "networks", "applications", "metrics", "e-business", "functionalities", "experiences", "web services", "methodologies"];};
392 |
393 | Faker.definitions.domain_suffix = function (){return ["co.uk", "com", "us", "uk", "ca", "biz", "info", "name"];};
394 |
395 | Faker.definitions.lorem = function (){return ["alias","consequatur","aut","perferendis","sit","voluptatem","accusantium","doloremque","aperiam","eaque","ipsa","quae","ab","illo","inventore","veritatis","et","quasi","architecto","beatae","vitae","dicta","sunt","explicabo","aspernatur","aut","odit","aut","fugit","sed","quia","consequuntur","magni","dolores","eos","qui","ratione","voluptatem","sequi","nesciunt","neque","dolorem","ipsum","quia","dolor","sit","amet","consectetur","adipisci","velit","sed","quia","non","numquam","eius","modi","tempora","incidunt","ut","labore","et","dolore","magnam","aliquam","quaerat","voluptatem","ut","enim","ad","minima","veniam","quis","nostrum","exercitationem","ullam","corporis","nemo","enim","ipsam","voluptatem","quia","voluptas","sit","suscipit","laboriosam","nisi","ut","aliquid","ex","ea","commodi","consequatur","quis","autem","vel","eum","iure","reprehenderit","qui","in","ea","voluptate","velit","esse","quam","nihil","molestiae","et","iusto","odio","dignissimos","ducimus","qui","blanditiis","praesentium","laudantium","totam","rem","voluptatum","deleniti","atque","corrupti","quos","dolores","et","quas","molestias","excepturi","sint","occaecati","cupiditate","non","provident","sed","ut","perspiciatis","unde","omnis","iste","natus","error","similique","sunt","in","culpa","qui","officia","deserunt","mollitia","animi","id","est","laborum","et","dolorum","fuga","et","harum","quidem","rerum","facilis","est","et","expedita","distinctio","nam","libero","tempore","cum","soluta","nobis","est","eligendi","optio","cumque","nihil","impedit","quo","porro","quisquam","est","qui","minus","id","quod","maxime","placeat","facere","possimus","omnis","voluptas","assumenda","est","omnis","dolor","repellendus","temporibus","autem","quibusdam","et","aut","consequatur","vel","illum","qui","dolorem","eum","fugiat","quo","voluptas","nulla","pariatur","at","vero","eos","et","accusamus","officiis","debitis","aut","rerum","necessitatibus","saepe","eveniet","ut","et","voluptates","repudiandae","sint","et","molestiae","non","recusandae","itaque","earum","rerum","hic","tenetur","a","sapiente","delectus","ut","aut","reiciendis","voluptatibus","maiores","doloribus","asperiores","repellat"];};
396 |
397 | Faker.definitions.phone_formats = function (){return [
398 | '###-###-####',
399 | '(###)###-####',
400 | '1-###-###-####',
401 | '###.###.####',
402 | '###-###-####',
403 | '(###)###-####',
404 | '1-###-###-####',
405 | '###.###.####',
406 | '###-###-#### x###',
407 | '(###)###-#### x###',
408 | '1-###-###-#### x###',
409 | '###.###.#### x###',
410 | '###-###-#### x####',
411 | '(###)###-#### x####',
412 | '1-###-###-#### x####',
413 | '###.###.#### x####',
414 | '###-###-#### x#####',
415 | '(###)###-#### x#####',
416 | '1-###-###-#### x#####',
417 | '###.###.#### x#####'
418 | ];};
419 | var definitions = Faker.definitions;
420 | var Helpers = Faker.Helpers;
421 | if(typeof exports != "undefined"){for(var prop in Faker){exports[prop] = Faker[prop];}}
--------------------------------------------------------------------------------
/app/vendor/backbone-localstorage.js:
--------------------------------------------------------------------------------
1 | // A simple module to replace `Backbone.sync` with *localStorage*-based
2 | // persistence. Models are given GUIDS, and saved into a JSON object. Simple
3 | // as that.
4 |
5 | // Generate four random hex digits.
6 | function S4() {
7 | return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
8 | };
9 |
10 | // Generate a pseudo-GUID by concatenating random hexadecimal.
11 | function guid() {
12 | return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
13 | };
14 |
15 | // Our Store is represented by a single JS object in *localStorage*. Create it
16 | // with a meaningful name, like the name you'd give a table.
17 | var Store = function(name) {
18 | this.name = name;
19 | var store = localStorage.getItem(this.name);
20 | this.data = (store && JSON.parse(store)) || {};
21 | };
22 |
23 | _.extend(Store.prototype, {
24 |
25 | // Save the current state of the **Store** to *localStorage*.
26 | save: function() {
27 | localStorage.setItem(this.name, JSON.stringify(this.data));
28 | },
29 |
30 | // Add a model, giving it a (hopefully)-unique GUID, if it doesn't already
31 | // have an id of it's own.
32 | create: function(model) {
33 | if (!model.id) model.set(model.idAttribute, guid());
34 | this.data[model.id] = model;
35 | this.save();
36 | return model;
37 | },
38 |
39 | // Update a model by replacing its copy in `this.data`.
40 | update: function(model) {
41 | this.data[model.id] = model;
42 | this.save();
43 | return model;
44 | },
45 |
46 | // Retrieve a model from `this.data` by id.
47 | find: function(model) {
48 | return this.data[model.id];
49 | },
50 |
51 | // Return the array of all models currently in storage.
52 | findAll: function() {
53 | return _.values(this.data);
54 | },
55 |
56 | // Delete a model from `this.data`, returning it.
57 | destroy: function(model) {
58 | delete this.data[model.id];
59 | this.save();
60 | return model;
61 | }
62 |
63 | });
64 |
65 | // Override `Backbone.sync` to use delegate to the model or collection's
66 | // *localStorage* property, which should be an instance of `Store`.
67 | Backbone.sync = function(method, model, options) {
68 |
69 | var resp;
70 | var store = model.localStorage || model.collection.localStorage;
71 |
72 | switch (method) {
73 | case "read": resp = model.id ? store.find(model) : store.findAll(); break;
74 | case "create": resp = store.create(model); break;
75 | case "update": resp = store.update(model); break;
76 | case "delete": resp = store.destroy(model); break;
77 | }
78 |
79 | if (resp) {
80 | options.success(resp);
81 | } else {
82 | options.error("Record not found");
83 | }
84 | };
--------------------------------------------------------------------------------
/app/vendor/backbone.js:
--------------------------------------------------------------------------------
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 splice.
22 | var splice = Array.prototype.splice;
23 |
24 | // The top-level namespace. All public Backbone classes and modules will
25 | // be attached to this. Exported for both CommonJS and the browser.
26 | var Backbone;
27 | if (typeof exports !== 'undefined') {
28 | Backbone = exports;
29 | } else {
30 | Backbone = root.Backbone = {};
31 | }
32 |
33 | // Current version of the library. Keep in sync with `package.json`.
34 | Backbone.VERSION = '0.9.2';
35 |
36 | // Require Underscore, if we're on the server, and it's not already present.
37 | var _ = root._;
38 | if (!_ && (typeof require !== 'undefined')) _ = require('underscore');
39 |
40 | // For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable.
41 | Backbone.$ = root.jQuery || root.Zepto || root.ender;
42 |
43 | // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
44 | // to its previous owner. Returns a reference to this Backbone object.
45 | Backbone.noConflict = function() {
46 | root.Backbone = previousBackbone;
47 | return this;
48 | };
49 |
50 | // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option
51 | // will fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and
52 | // set a `X-Http-Method-Override` header.
53 | Backbone.emulateHTTP = false;
54 |
55 | // Turn on `emulateJSON` to support legacy servers that can't deal with direct
56 | // `application/json` requests ... will encode the body as
57 | // `application/x-www-form-urlencoded` instead and will send the model in a
58 | // form param named `model`.
59 | Backbone.emulateJSON = false;
60 |
61 | // Backbone.Events
62 | // -----------------
63 |
64 | // Regular expression used to split event strings
65 | var eventSplitter = /\s+/;
66 |
67 | // A module that can be mixed in to *any object* in order to provide it with
68 | // custom events. You may bind with `on` or remove with `off` callback functions
69 | // to an event; `trigger`-ing an event fires all callbacks in succession.
70 | //
71 | // var object = {};
72 | // _.extend(object, Backbone.Events);
73 | // object.on('expand', function(){ alert('expanded'); });
74 | // object.trigger('expand');
75 | //
76 | var Events = Backbone.Events = {
77 |
78 | // Bind one or more space separated events, `events`, to a `callback`
79 | // function. Passing `"all"` will bind the callback to all events fired.
80 | on: function(events, callback, context) {
81 | var calls, event, list;
82 | if (!callback) return this;
83 |
84 | events = events.split(eventSplitter);
85 | calls = this._callbacks || (this._callbacks = {});
86 |
87 | while (event = events.shift()) {
88 | list = calls[event] || (calls[event] = []);
89 | list.push(callback, context);
90 | }
91 |
92 | return this;
93 | },
94 |
95 | // Remove one or many callbacks. If `context` is null, removes all callbacks
96 | // with that function. If `callback` is null, removes all callbacks for the
97 | // event. If `events` is null, removes all bound callbacks for all events.
98 | off: function(events, callback, context) {
99 | var event, calls, list, i;
100 |
101 | // No events, or removing *all* events.
102 | if (!(calls = this._callbacks)) return this;
103 | if (!(events || callback || context)) {
104 | delete this._callbacks;
105 | return this;
106 | }
107 |
108 | events = events ? events.split(eventSplitter) : _.keys(calls);
109 |
110 | // Loop through the callback list, splicing where appropriate.
111 | while (event = events.shift()) {
112 | if (!(list = calls[event]) || !(callback || context)) {
113 | delete calls[event];
114 | continue;
115 | }
116 |
117 | for (i = list.length - 2; i >= 0; i -= 2) {
118 | if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) {
119 | list.splice(i, 2);
120 | }
121 | }
122 | }
123 |
124 | return this;
125 | },
126 |
127 | // Trigger one or many events, firing all bound callbacks. Callbacks are
128 | // passed the same arguments as `trigger` is, apart from the event name
129 | // (unless you're listening on `"all"`, which will cause your callback to
130 | // receive the true name of the event as the first argument).
131 | trigger: function(events) {
132 | var event, calls, list, i, length, args, all, rest;
133 | if (!(calls = this._callbacks)) return this;
134 |
135 | rest = [];
136 | events = events.split(eventSplitter);
137 |
138 | // Fill up `rest` with the callback arguments. Since we're only copying
139 | // the tail of `arguments`, a loop is much faster than Array#slice.
140 | for (i = 1, length = arguments.length; i < length; i++) {
141 | rest[i - 1] = arguments[i];
142 | }
143 |
144 | // For each event, walk through the list of callbacks twice, first to
145 | // trigger the event, then to trigger any `"all"` callbacks.
146 | while (event = events.shift()) {
147 | // Copy callback lists to prevent modification.
148 | if (all = calls.all) all = all.slice();
149 | if (list = calls[event]) list = list.slice();
150 |
151 | // Execute event callbacks.
152 | if (list) {
153 | for (i = 0, length = list.length; i < length; i += 2) {
154 | list[i].apply(list[i + 1] || this, rest);
155 | }
156 | }
157 |
158 | // Execute "all" callbacks.
159 | if (all) {
160 | args = [event].concat(rest);
161 | for (i = 0, length = all.length; i < length; i += 2) {
162 | all[i].apply(all[i + 1] || this, args);
163 | }
164 | }
165 | }
166 |
167 | return this;
168 | }
169 |
170 | };
171 |
172 | // Aliases for backwards compatibility.
173 | Events.bind = Events.on;
174 | Events.unbind = Events.off;
175 |
176 | // Backbone.Model
177 | // --------------
178 |
179 | // Create a new model, with defined attributes. A client id (`cid`)
180 | // is automatically generated and assigned for you.
181 | var Model = Backbone.Model = function(attributes, options) {
182 | var defaults;
183 | attributes || (attributes = {});
184 | if (options && options.collection) this.collection = options.collection;
185 | if (options && options.parse) attributes = this.parse(attributes);
186 | if (defaults = getValue(this, 'defaults')) {
187 | attributes = _.extend({}, defaults, attributes);
188 | }
189 | this.attributes = {};
190 | this._escapedAttributes = {};
191 | this.cid = _.uniqueId('c');
192 | this.changed = {};
193 | this._silent = {};
194 | this._pending = {};
195 | this.set(attributes, {silent: true});
196 | // Reset change tracking.
197 | this.changed = {};
198 | this._silent = {};
199 | this._pending = {};
200 | this._previousAttributes = _.clone(this.attributes);
201 | this.initialize.apply(this, arguments);
202 | };
203 |
204 | // Attach all inheritable methods to the Model prototype.
205 | _.extend(Model.prototype, Events, {
206 |
207 | // A hash of attributes whose current and previous value differ.
208 | changed: null,
209 |
210 | // A hash of attributes that have silently changed since the last time
211 | // `change` was called. Will become pending attributes on the next call.
212 | _silent: null,
213 |
214 | // A hash of attributes that have changed since the last `'change'` event
215 | // began.
216 | _pending: null,
217 |
218 | // The default name for the JSON `id` attribute is `"id"`. MongoDB and
219 | // CouchDB users may want to set this to `"_id"`.
220 | idAttribute: 'id',
221 |
222 | // Initialize is an empty function by default. Override it with your own
223 | // initialization logic.
224 | initialize: function(){},
225 |
226 | // Return a copy of the model's `attributes` object.
227 | toJSON: function(options) {
228 | return _.clone(this.attributes);
229 | },
230 |
231 | // Proxy `Backbone.sync` by default.
232 | sync: function() {
233 | return Backbone.sync.apply(this, arguments);
234 | },
235 |
236 | // Get the value of an attribute.
237 | get: function(attr) {
238 | return this.attributes[attr];
239 | },
240 |
241 | // Get the HTML-escaped value of an attribute.
242 | escape: function(attr) {
243 | var html;
244 | if (html = this._escapedAttributes[attr]) return html;
245 | var val = this.get(attr);
246 | return this._escapedAttributes[attr] = _.escape(val == null ? '' : '' + val);
247 | },
248 |
249 | // Returns `true` if the attribute contains a value that is not null
250 | // or undefined.
251 | has: function(attr) {
252 | return this.get(attr) != null;
253 | },
254 |
255 | // Set a hash of model attributes on the object, firing `"change"` unless
256 | // you choose to silence it.
257 | set: function(key, value, options) {
258 | var attrs, attr, val;
259 |
260 | // Handle both `"key", value` and `{key: value}` -style arguments.
261 | if (_.isObject(key) || key == null) {
262 | attrs = key;
263 | options = value;
264 | } else {
265 | attrs = {};
266 | attrs[key] = value;
267 | }
268 |
269 | // Extract attributes and options.
270 | options || (options = {});
271 | if (!attrs) return this;
272 | if (attrs instanceof Model) attrs = attrs.attributes;
273 | if (options.unset) for (attr in attrs) attrs[attr] = void 0;
274 |
275 | // Run validation.
276 | if (!this._validate(attrs, options)) return false;
277 |
278 | // Check for changes of `id`.
279 | if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
280 |
281 | var changes = options.changes = {};
282 | var now = this.attributes;
283 | var escaped = this._escapedAttributes;
284 | var prev = this._previousAttributes || {};
285 |
286 | // For each `set` attribute...
287 | for (attr in attrs) {
288 | val = attrs[attr];
289 |
290 | // If the new and current value differ, record the change.
291 | if (!_.isEqual(now[attr], val) || (options.unset && _.has(now, attr))) {
292 | delete escaped[attr];
293 | (options.silent ? this._silent : changes)[attr] = true;
294 | }
295 |
296 | // Update or delete the current value.
297 | options.unset ? delete now[attr] : now[attr] = val;
298 |
299 | // If the new and previous value differ, record the change. If not,
300 | // then remove changes for this attribute.
301 | if (!_.isEqual(prev[attr], val) || (_.has(now, attr) !== _.has(prev, attr))) {
302 | this.changed[attr] = val;
303 | if (!options.silent) this._pending[attr] = true;
304 | } else {
305 | delete this.changed[attr];
306 | delete this._pending[attr];
307 | }
308 | }
309 |
310 | // Fire the `"change"` events.
311 | if (!options.silent) this.change(options);
312 | return this;
313 | },
314 |
315 | // Remove an attribute from the model, firing `"change"` unless you choose
316 | // to silence it. `unset` is a noop if the attribute doesn't exist.
317 | unset: function(attr, options) {
318 | options = _.extend({}, options, {unset: true});
319 | return this.set(attr, null, options);
320 | },
321 |
322 | // Clear all attributes on the model, firing `"change"` unless you choose
323 | // to silence it.
324 | clear: function(options) {
325 | options = _.extend({}, options, {unset: true});
326 | return this.set(_.clone(this.attributes), options);
327 | },
328 |
329 | // Fetch the model from the server. If the server's representation of the
330 | // model differs from its current attributes, they will be overriden,
331 | // triggering a `"change"` event.
332 | fetch: function(options) {
333 | options = options ? _.clone(options) : {};
334 | var model = this;
335 | var success = options.success;
336 | options.success = function(resp, status, xhr) {
337 | if (!model.set(model.parse(resp, xhr), options)) return false;
338 | if (success) success(model, resp, options);
339 | model.trigger('sync', model, resp, options);
340 | };
341 | options.error = Backbone.wrapError(options.error, model, options);
342 | return this.sync('read', this, options);
343 | },
344 |
345 | // Set a hash of model attributes, and sync the model to the server.
346 | // If the server returns an attributes hash that differs, the model's
347 | // state will be `set` again.
348 | save: function(key, value, options) {
349 | var attrs, current, done;
350 |
351 | // Handle both `("key", value)` and `({key: value})` -style calls.
352 | if (_.isObject(key) || key == null) {
353 | attrs = key;
354 | options = value;
355 | } else {
356 | attrs = {};
357 | attrs[key] = value;
358 | }
359 | options = options ? _.clone(options) : {};
360 |
361 | // If we're "wait"-ing to set changed attributes, validate early.
362 | if (options.wait) {
363 | if (!this._validate(attrs, options)) return false;
364 | current = _.clone(this.attributes);
365 | }
366 |
367 | // Regular saves `set` attributes before persisting to the server.
368 | var silentOptions = _.extend({}, options, {silent: true});
369 | if (attrs && !this.set(attrs, options.wait ? silentOptions : options)) {
370 | return false;
371 | }
372 |
373 | // Do not persist invalid models.
374 | if (!attrs && !this.isValid()) return false;
375 |
376 | // After a successful server-side save, the client is (optionally)
377 | // updated with the server-side state.
378 | var model = this;
379 | var success = options.success;
380 | options.success = function(resp, status, xhr) {
381 | done = true;
382 | var serverAttrs = model.parse(resp, xhr);
383 | if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs);
384 | if (!model.set(serverAttrs, options)) return false;
385 | if (success) success(model, resp, options);
386 | model.trigger('sync', model, resp, options);
387 | };
388 |
389 | // Finish configuring and sending the Ajax request.
390 | options.error = Backbone.wrapError(options.error, model, options);
391 | var xhr = this.sync(this.isNew() ? 'create' : 'update', this, options);
392 |
393 | // When using `wait`, reset attributes to original values unless
394 | // `success` has been called already.
395 | if (!done && options.wait) {
396 | this.clear(silentOptions);
397 | this.set(current, silentOptions);
398 | }
399 |
400 | return xhr;
401 | },
402 |
403 | // Destroy this model on the server if it was already persisted.
404 | // Optimistically removes the model from its collection, if it has one.
405 | // If `wait: true` is passed, waits for the server to respond before removal.
406 | destroy: function(options) {
407 | options = options ? _.clone(options) : {};
408 | var model = this;
409 | var success = options.success;
410 |
411 | var destroy = function() {
412 | model.trigger('destroy', model, model.collection, options);
413 | };
414 |
415 | options.success = function(resp) {
416 | if (options.wait || model.isNew()) destroy();
417 | if (success) success(model, resp, options);
418 | if (!model.isNew()) model.trigger('sync', model, resp, options);
419 | };
420 |
421 | if (this.isNew()) {
422 | options.success();
423 | return false;
424 | }
425 |
426 | options.error = Backbone.wrapError(options.error, model, options);
427 | var xhr = this.sync('delete', this, options);
428 | if (!options.wait) destroy();
429 | return xhr;
430 | },
431 |
432 | // Default URL for the model's representation on the server -- if you're
433 | // using Backbone's restful methods, override this to change the endpoint
434 | // that will be called.
435 | url: function() {
436 | var base = getValue(this, 'urlRoot') || getValue(this.collection, 'url') || urlError();
437 | if (this.isNew()) return base;
438 | return base + (base.charAt(base.length - 1) === '/' ? '' : '/') + encodeURIComponent(this.id);
439 | },
440 |
441 | // **parse** converts a response into the hash of attributes to be `set` on
442 | // the model. The default implementation is just to pass the response along.
443 | parse: function(resp, xhr) {
444 | return resp;
445 | },
446 |
447 | // Create a new model with identical attributes to this one.
448 | clone: function() {
449 | return new this.constructor(this.attributes);
450 | },
451 |
452 | // A model is new if it has never been saved to the server, and lacks an id.
453 | isNew: function() {
454 | return this.id == null;
455 | },
456 |
457 | // Call this method to manually fire a `"change"` event for this model and
458 | // a `"change:attribute"` event for each changed attribute.
459 | // Calling this will cause all objects observing the model to update.
460 | change: function(options) {
461 | options || (options = {});
462 | var changing = this._changing;
463 | this._changing = true;
464 |
465 | // Silent changes become pending changes.
466 | for (var attr in this._silent) this._pending[attr] = true;
467 |
468 | // Silent changes are triggered.
469 | var changes = _.extend({}, options.changes, this._silent);
470 | this._silent = {};
471 | for (var attr in changes) {
472 | this.trigger('change:' + attr, this, this.get(attr), options);
473 | }
474 | if (changing) return this;
475 |
476 | // Continue firing `"change"` events while there are pending changes.
477 | while (!_.isEmpty(this._pending)) {
478 | this._pending = {};
479 | this.trigger('change', this, options);
480 | // Pending and silent changes still remain.
481 | for (var attr in this.changed) {
482 | if (this._pending[attr] || this._silent[attr]) continue;
483 | delete this.changed[attr];
484 | }
485 | this._previousAttributes = _.clone(this.attributes);
486 | }
487 |
488 | this._changing = false;
489 | return this;
490 | },
491 |
492 | // Determine if the model has changed since the last `"change"` event.
493 | // If you specify an attribute name, determine if that attribute has changed.
494 | hasChanged: function(attr) {
495 | if (attr == null) return !_.isEmpty(this.changed);
496 | return _.has(this.changed, attr);
497 | },
498 |
499 | // Return an object containing all the attributes that have changed, or
500 | // false if there are no changed attributes. Useful for determining what
501 | // parts of a view need to be updated and/or what attributes need to be
502 | // persisted to the server. Unset attributes will be set to undefined.
503 | // You can also pass an attributes object to diff against the model,
504 | // determining if there *would be* a change.
505 | changedAttributes: function(diff) {
506 | if (!diff) return this.hasChanged() ? _.clone(this.changed) : false;
507 | var val, changed = false, old = this._previousAttributes;
508 | for (var attr in diff) {
509 | if (_.isEqual(old[attr], (val = diff[attr]))) continue;
510 | (changed || (changed = {}))[attr] = val;
511 | }
512 | return changed;
513 | },
514 |
515 | // Get the previous value of an attribute, recorded at the time the last
516 | // `"change"` event was fired.
517 | previous: function(attr) {
518 | if (attr == null || !this._previousAttributes) return null;
519 | return this._previousAttributes[attr];
520 | },
521 |
522 | // Get all of the attributes of the model at the time of the previous
523 | // `"change"` event.
524 | previousAttributes: function() {
525 | return _.clone(this._previousAttributes);
526 | },
527 |
528 | // Check if the model is currently in a valid state. It's only possible to
529 | // get into an *invalid* state if you're using silent changes.
530 | isValid: function() {
531 | return !this.validate || !this.validate(this.attributes);
532 | },
533 |
534 | // Run validation against the next complete set of model attributes,
535 | // returning `true` if all is well. If a specific `error` callback has
536 | // been passed, call that instead of firing the general `"error"` event.
537 | _validate: function(attrs, options) {
538 | if (options.silent || !this.validate) return true;
539 | attrs = _.extend({}, this.attributes, attrs);
540 | var error = this.validate(attrs, options);
541 | if (!error) return true;
542 | if (options && options.error) {
543 | options.error(this, error, options);
544 | } else {
545 | this.trigger('error', this, error, options);
546 | }
547 | return false;
548 | }
549 |
550 | });
551 |
552 | // Backbone.Collection
553 | // -------------------
554 |
555 | // Provides a standard collection class for our sets of models, ordered
556 | // or unordered. If a `comparator` is specified, the Collection will maintain
557 | // its models in sort order, as they're added and removed.
558 | var Collection = Backbone.Collection = function(models, options) {
559 | options || (options = {});
560 | if (options.model) this.model = options.model;
561 | if (options.comparator !== void 0) this.comparator = options.comparator;
562 | this._reset();
563 | this.initialize.apply(this, arguments);
564 | if (models) this.reset(models, {silent: true, parse: options.parse});
565 | };
566 |
567 | // Define the Collection's inheritable methods.
568 | _.extend(Collection.prototype, Events, {
569 |
570 | // The default model for a collection is just a **Backbone.Model**.
571 | // This should be overridden in most cases.
572 | model: Model,
573 |
574 | // Initialize is an empty function by default. Override it with your own
575 | // initialization logic.
576 | initialize: function(){},
577 |
578 | // The JSON representation of a Collection is an array of the
579 | // models' attributes.
580 | toJSON: function(options) {
581 | return this.map(function(model){ return model.toJSON(options); });
582 | },
583 |
584 | // Proxy `Backbone.sync` by default.
585 | sync: function() {
586 | return Backbone.sync.apply(this, arguments);
587 | },
588 |
589 | // Add a model, or list of models to the set. Pass **silent** to avoid
590 | // firing the `add` event for every new model.
591 | add: function(models, options) {
592 | var i, index, length, model, cid, id, cids = {}, ids = {}, dups = [];
593 | options || (options = {});
594 | models = _.isArray(models) ? models.slice() : [models];
595 |
596 | // Begin by turning bare objects into model references, and preventing
597 | // invalid models or duplicate models from being added.
598 | for (i = 0, length = models.length; i < length; i++) {
599 | if (!(model = models[i] = this._prepareModel(models[i], options))) {
600 | throw new Error("Can't add an invalid model to a collection");
601 | }
602 | cid = model.cid;
603 | id = model.id;
604 | if (cids[cid] || this._byCid[cid] || ((id != null) && (ids[id] || this._byId[id]))) {
605 | dups.push(i);
606 | continue;
607 | }
608 | cids[cid] = ids[id] = model;
609 | }
610 |
611 | // Remove duplicates.
612 | i = dups.length;
613 | while (i--) {
614 | dups[i] = models.splice(dups[i], 1)[0];
615 | }
616 |
617 | // Listen to added models' events, and index models for lookup by
618 | // `id` and by `cid`.
619 | for (i = 0, length = models.length; i < length; i++) {
620 | (model = models[i]).on('all', this._onModelEvent, this);
621 | this._byCid[model.cid] = model;
622 | if (model.id != null) this._byId[model.id] = model;
623 | }
624 |
625 | // Insert models into the collection, re-sorting if needed, and triggering
626 | // `add` events unless silenced.
627 | this.length += length;
628 | index = options.at != null ? options.at : this.models.length;
629 | splice.apply(this.models, [index, 0].concat(models));
630 |
631 | // Merge in duplicate models.
632 | if (options.merge) {
633 | for (i = 0, length = dups.length; i < length; i++) {
634 | if (model = this._byId[dups[i].id]) model.set(dups[i], options);
635 | }
636 | }
637 |
638 | // Sort the collection if appropriate.
639 | if (this.comparator && options.at == null) this.sort({silent: true});
640 |
641 | if (options.silent) return this;
642 | for (i = 0, length = this.models.length; i < length; i++) {
643 | if (!cids[(model = this.models[i]).cid]) continue;
644 | options.index = i;
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 | options || (options = {});
739 | if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
740 | var boundComparator = _.bind(this.comparator, this);
741 | if (this.comparator.length === 1) {
742 | this.models = this.sortBy(boundComparator);
743 | } else {
744 | this.models.sort(boundComparator);
745 | }
746 | if (!options.silent) this.trigger('reset', this, options);
747 | return this;
748 | },
749 |
750 | // Pluck an attribute from each model in the collection.
751 | pluck: function(attr) {
752 | return _.map(this.models, function(model){ return model.get(attr); });
753 | },
754 |
755 | // When you have more items than you want to add or remove individually,
756 | // you can reset the entire set with a new list of models, without firing
757 | // any `add` or `remove` events. Fires `reset` when finished.
758 | reset: function(models, options) {
759 | models || (models = []);
760 | options || (options = {});
761 | for (var i = 0, l = this.models.length; i < l; i++) {
762 | this._removeReference(this.models[i]);
763 | }
764 | this._reset();
765 | this.add(models, _.extend({silent: true}, options));
766 | if (!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 | collection.trigger('sync', collection, resp, options);
782 | };
783 | options.error = Backbone.wrapError(options.error, collection, options);
784 | return this.sync('read', this, options);
785 | },
786 |
787 | // Create a new instance of a model in this collection. Add the model to the
788 | // collection immediately, unless `wait: true` is passed, in which case we
789 | // wait for the server to agree.
790 | create: function(model, options) {
791 | var coll = this;
792 | options = options ? _.clone(options) : {};
793 | model = this._prepareModel(model, options);
794 | if (!model) return false;
795 | if (!options.wait) coll.add(model, options);
796 | var success = options.success;
797 | options.success = function(model, resp, options) {
798 | if (options.wait) coll.add(model, options);
799 | if (success) success(model, resp, options);
800 | };
801 | model.save(null, options);
802 | return model;
803 | },
804 |
805 | // **parse** converts a response into a list of models to be added to the
806 | // collection. The default implementation is just to pass it through.
807 | parse: function(resp, xhr) {
808 | return resp;
809 | },
810 |
811 | // Create a new collection with an identical list of models as this one.
812 | clone: function() {
813 | return new this.constructor(this.models);
814 | },
815 |
816 | // Proxy to _'s chain. Can't be proxied the same way the rest of the
817 | // underscore methods are proxied because it relies on the underscore
818 | // constructor.
819 | chain: function() {
820 | return _(this.models).chain();
821 | },
822 |
823 | // Reset all internal state. Called when the collection is reset.
824 | _reset: function(options) {
825 | this.length = 0;
826 | this.models = [];
827 | this._byId = {};
828 | this._byCid = {};
829 | },
830 |
831 | // Prepare a model or hash of attributes to be added to this collection.
832 | _prepareModel: function(attrs, options) {
833 | if (attrs instanceof Model) {
834 | if (!attrs.collection) attrs.collection = this;
835 | return attrs;
836 | }
837 | options || (options = {});
838 | options.collection = this;
839 | var model = new this.model(attrs, options);
840 | if (!model._validate(model.attributes, options)) return false;
841 | return model;
842 | },
843 |
844 | // Internal method to remove a model's ties to a collection.
845 | _removeReference: function(model) {
846 | if (this === model.collection) delete model.collection;
847 | model.off('all', this._onModelEvent, this);
848 | },
849 |
850 | // Internal method called every time a model in the set fires an event.
851 | // Sets need to update their indexes when models change ids. All other
852 | // events simply proxy through. "add" and "remove" events that originate
853 | // in other collections are ignored.
854 | _onModelEvent: function(event, model, collection, options) {
855 | if ((event === 'add' || event === 'remove') && collection !== this) return;
856 | if (event === 'destroy') this.remove(model, options);
857 | if (model && event === 'change:' + model.idAttribute) {
858 | delete this._byId[model.previous(model.idAttribute)];
859 | if (model.id != null) this._byId[model.id] = model;
860 | }
861 | this.trigger.apply(this, arguments);
862 | }
863 |
864 | });
865 |
866 | // Underscore methods that we want to implement on the Collection.
867 | var methods = ['forEach', 'each', 'map', 'reduce', 'reduceRight', 'find',
868 | 'detect', 'filter', 'select', 'reject', 'every', 'all', 'some', 'any',
869 | 'include', 'contains', 'invoke', 'max', 'min', 'sortBy', 'sortedIndex',
870 | 'toArray', 'size', 'first', 'initial', 'rest', 'last', 'without', 'indexOf',
871 | 'shuffle', 'lastIndexOf', 'isEmpty', 'groupBy'];
872 |
873 | // Mix in each Underscore method as a proxy to `Collection#models`.
874 | _.each(methods, function(method) {
875 | Collection.prototype[method] = function() {
876 | return _[method].apply(_, [this.models].concat(_.toArray(arguments)));
877 | };
878 | });
879 |
880 | // Backbone.Router
881 | // -------------------
882 |
883 | // Routers map faux-URLs to actions, and fire events when routes are
884 | // matched. Creating a new one sets its `routes` hash, if not set statically.
885 | var Router = Backbone.Router = function(options) {
886 | options || (options = {});
887 | if (options.routes) this.routes = options.routes;
888 | this._bindRoutes();
889 | this.initialize.apply(this, arguments);
890 | };
891 |
892 | // Cached regular expressions for matching named param parts and splatted
893 | // parts of route strings.
894 | var namedParam = /:\w+/g;
895 | var splatParam = /\*\w+/g;
896 | var escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g;
897 |
898 | // Set up all inheritable **Backbone.Router** properties and methods.
899 | _.extend(Router.prototype, Events, {
900 |
901 | // Initialize is an empty function by default. Override it with your own
902 | // initialization logic.
903 | initialize: function(){},
904 |
905 | // Manually bind a single named route to a callback. For example:
906 | //
907 | // this.route('search/:query/p:num', 'search', function(query, num) {
908 | // ...
909 | // });
910 | //
911 | route: function(route, name, callback) {
912 | Backbone.history || (Backbone.history = new History);
913 | if (!_.isRegExp(route)) route = this._routeToRegExp(route);
914 | if (!callback) callback = this[name];
915 | Backbone.history.route(route, _.bind(function(fragment) {
916 | var args = this._extractParameters(route, fragment);
917 | callback && callback.apply(this, args);
918 | this.trigger.apply(this, ['route:' + name].concat(args));
919 | Backbone.history.trigger('route', this, name, args);
920 | }, this));
921 | return this;
922 | },
923 |
924 | // Simple proxy to `Backbone.history` to save a fragment into the history.
925 | navigate: function(fragment, options) {
926 | Backbone.history.navigate(fragment, options);
927 | },
928 |
929 | // Bind all defined routes to `Backbone.history`. We have to reverse the
930 | // order of the routes here to support behavior where the most general
931 | // routes can be defined at the bottom of the route map.
932 | _bindRoutes: function() {
933 | if (!this.routes) return;
934 | var routes = [];
935 | for (var route in this.routes) {
936 | routes.unshift([route, this.routes[route]]);
937 | }
938 | for (var i = 0, l = routes.length; i < l; i++) {
939 | this.route(routes[i][0], routes[i][1], this[routes[i][1]]);
940 | }
941 | },
942 |
943 | // Convert a route string into a regular expression, suitable for matching
944 | // against the current location hash.
945 | _routeToRegExp: function(route) {
946 | route = route.replace(escapeRegExp, '\\$&')
947 | .replace(namedParam, '([^\/]+)')
948 | .replace(splatParam, '(.*?)');
949 | return new RegExp('^' + route + '$');
950 | },
951 |
952 | // Given a route, and a URL fragment that it matches, return the array of
953 | // extracted parameters.
954 | _extractParameters: function(route, fragment) {
955 | return route.exec(fragment).slice(1);
956 | }
957 |
958 | });
959 |
960 | // Backbone.History
961 | // ----------------
962 |
963 | // Handles cross-browser history management, based on URL fragments. If the
964 | // browser does not support `onhashchange`, falls back to polling.
965 | var History = Backbone.History = function(options) {
966 | this.handlers = [];
967 | _.bindAll(this, 'checkUrl');
968 | this.location = options && options.location || root.location;
969 | this.history = options && options.history || root.history;
970 | };
971 |
972 | // Cached regex for cleaning leading hashes and slashes .
973 | var routeStripper = /^[#\/]/;
974 |
975 | // Cached regex for detecting MSIE.
976 | var isExplorer = /msie [\w.]+/;
977 |
978 | // Cached regex for removing a trailing slash.
979 | var trailingSlash = /\/$/;
980 |
981 | // Has the history handling already been started?
982 | History.started = false;
983 |
984 | // Set up all inheritable **Backbone.History** properties and methods.
985 | _.extend(History.prototype, Events, {
986 |
987 | // The default interval to poll for hash changes, if necessary, is
988 | // twenty times a second.
989 | interval: 50,
990 |
991 | // Gets the true hash value. Cannot use location.hash directly due to bug
992 | // in Firefox where location.hash will always be decoded.
993 | getHash: function(window) {
994 | var match = (window || this).location.href.match(/#(.*)$/);
995 | return match ? match[1] : '';
996 | },
997 |
998 | // Get the cross-browser normalized URL fragment, either from the URL,
999 | // the hash, or the override.
1000 | getFragment: function(fragment, forcePushState) {
1001 | if (fragment == null) {
1002 | if (this._hasPushState || !this._wantsHashChange || forcePushState) {
1003 | fragment = this.location.pathname;
1004 | var root = this.options.root.replace(trailingSlash, '');
1005 | if (!fragment.indexOf(root)) fragment = fragment.substr(root.length);
1006 | } else {
1007 | fragment = this.getHash();
1008 | }
1009 | }
1010 | return decodeURIComponent(fragment.replace(routeStripper, ''));
1011 | },
1012 |
1013 | // Start the hash change handling, returning `true` if the current URL matches
1014 | // an existing route, and `false` otherwise.
1015 | start: function(options) {
1016 | if (History.started) throw new Error("Backbone.history has already been started");
1017 | History.started = true;
1018 |
1019 | // Figure out the initial configuration. Do we need an iframe?
1020 | // Is pushState desired ... is it available?
1021 | this.options = _.extend({}, {root: '/'}, this.options, options);
1022 | this._wantsHashChange = this.options.hashChange !== false;
1023 | this._wantsPushState = !!this.options.pushState;
1024 | this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
1025 | var fragment = this.getFragment();
1026 | var docMode = document.documentMode;
1027 | var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
1028 |
1029 | // Normalize root to always include trailing slash
1030 | if (!trailingSlash.test(this.options.root)) this.options.root += '/';
1031 |
1032 | if (oldIE && this._wantsHashChange) {
1033 | this.iframe = Backbone.$('').hide().appendTo('body')[0].contentWindow;
1034 | this.navigate(fragment);
1035 | }
1036 |
1037 | // Depending on whether we're using pushState or hashes, and whether
1038 | // 'onhashchange' is supported, determine how we check the URL state.
1039 | if (this._hasPushState) {
1040 | Backbone.$(window).bind('popstate', this.checkUrl);
1041 | } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) {
1042 | Backbone.$(window).bind('hashchange', this.checkUrl);
1043 | } else if (this._wantsHashChange) {
1044 | this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
1045 | }
1046 |
1047 | // Determine if we need to change the base url, for a pushState link
1048 | // opened by a non-pushState browser.
1049 | this.fragment = fragment;
1050 | var loc = this.location;
1051 | var atRoot = (loc.pathname.replace(/[^/]$/, '$&/') === this.options.root) && !loc.search;
1052 |
1053 | // If we've started off with a route from a `pushState`-enabled browser,
1054 | // but we're currently in a browser that doesn't support it...
1055 | if (this._wantsHashChange && this._wantsPushState && !this._hasPushState && !atRoot) {
1056 | this.fragment = this.getFragment(null, true);
1057 | this.location.replace(this.options.root + this.location.search + '#' + this.fragment);
1058 | // Return immediately as browser will do redirect to new url
1059 | return true;
1060 |
1061 | // Or if we've started out with a hash-based route, but we're currently
1062 | // in a browser where it could be `pushState`-based instead...
1063 | } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) {
1064 | this.fragment = this.getHash().replace(routeStripper, '');
1065 | this.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment);
1066 | }
1067 |
1068 | if (!this.options.silent) return this.loadUrl();
1069 | },
1070 |
1071 | // Disable Backbone.history, perhaps temporarily. Not useful in a real app,
1072 | // but possibly useful for unit testing Routers.
1073 | stop: function() {
1074 | Backbone.$(window).unbind('popstate', this.checkUrl).unbind('hashchange', this.checkUrl);
1075 | clearInterval(this._checkUrlInterval);
1076 | History.started = false;
1077 | },
1078 |
1079 | // Add a route to be tested when the fragment changes. Routes added later
1080 | // may override previous routes.
1081 | route: function(route, callback) {
1082 | this.handlers.unshift({route: route, callback: callback});
1083 | },
1084 |
1085 | // Checks the current URL to see if it has changed, and if it has,
1086 | // calls `loadUrl`, normalizing across the hidden iframe.
1087 | checkUrl: function(e) {
1088 | var current = this.getFragment();
1089 | if (current === this.fragment && this.iframe) {
1090 | current = this.getFragment(this.getHash(this.iframe));
1091 | }
1092 | if (current === this.fragment) return false;
1093 | if (this.iframe) this.navigate(current);
1094 | this.loadUrl() || this.loadUrl(this.getHash());
1095 | },
1096 |
1097 | // Attempt to load the current URL fragment. If a route succeeds with a
1098 | // match, returns `true`. If no defined routes matches the fragment,
1099 | // returns `false`.
1100 | loadUrl: function(fragmentOverride) {
1101 | var fragment = this.fragment = this.getFragment(fragmentOverride);
1102 | var matched = _.any(this.handlers, function(handler) {
1103 | if (handler.route.test(fragment)) {
1104 | handler.callback(fragment);
1105 | return true;
1106 | }
1107 | });
1108 | return matched;
1109 | },
1110 |
1111 | // Save a fragment into the hash history, or replace the URL state if the
1112 | // 'replace' option is passed. You are responsible for properly URL-encoding
1113 | // the fragment in advance.
1114 | //
1115 | // The options object can contain `trigger: true` if you wish to have the
1116 | // route callback be fired (not usually desirable), or `replace: true`, if
1117 | // you wish to modify the current URL without adding an entry to the history.
1118 | navigate: function(fragment, options) {
1119 | if (!History.started) return false;
1120 | if (!options || options === true) options = {trigger: options};
1121 | var frag = (fragment || '').replace(routeStripper, '');
1122 | if (this.fragment === frag) return;
1123 | this.fragment = frag;
1124 | var url = (frag.indexOf(this.options.root) !== 0 ? this.options.root : '') + frag;
1125 |
1126 | // If pushState is available, we use it to set the fragment as a real URL.
1127 | if (this._hasPushState) {
1128 | this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
1129 |
1130 | // If hash changes haven't been explicitly disabled, update the hash
1131 | // fragment to store history.
1132 | } else if (this._wantsHashChange) {
1133 | this._updateHash(this.location, frag, options.replace);
1134 | if (this.iframe && (frag !== this.getFragment(this.getHash(this.iframe)))) {
1135 | // Opening and closing the iframe tricks IE7 and earlier to push a
1136 | // history entry on hash-tag change. When replace is true, we don't
1137 | // want this.
1138 | if(!options.replace) this.iframe.document.open().close();
1139 | this._updateHash(this.iframe.location, frag, options.replace);
1140 | }
1141 |
1142 | // If you've told us that you explicitly don't want fallback hashchange-
1143 | // based history, then `navigate` becomes a page refresh.
1144 | } else {
1145 | return this.location.assign(url);
1146 | }
1147 | if (options.trigger) this.loadUrl(fragment);
1148 | },
1149 |
1150 | // Update the hash location, either replacing the current entry, or adding
1151 | // a new one to the browser history.
1152 | _updateHash: function(location, fragment, replace) {
1153 | if (replace) {
1154 | location.replace(location.href.replace(/(javascript:|#).*$/, '') + '#' + fragment);
1155 | } else {
1156 | location.hash = fragment;
1157 | }
1158 | }
1159 |
1160 | });
1161 |
1162 | // Backbone.View
1163 | // -------------
1164 |
1165 | // Creating a Backbone.View creates its initial element outside of the DOM,
1166 | // if an existing element is not provided...
1167 | var View = Backbone.View = function(options) {
1168 | this.cid = _.uniqueId('view');
1169 | this._configure(options || {});
1170 | this._ensureElement();
1171 | this.initialize.apply(this, arguments);
1172 | this.delegateEvents();
1173 | };
1174 |
1175 | // Cached regex to split keys for `delegate`.
1176 | var delegateEventSplitter = /^(\S+)\s*(.*)$/;
1177 |
1178 | // List of view options to be merged as properties.
1179 | var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName'];
1180 |
1181 | // Set up all inheritable **Backbone.View** properties and methods.
1182 | _.extend(View.prototype, Events, {
1183 |
1184 | // The default `tagName` of a View's element is `"div"`.
1185 | tagName: 'div',
1186 |
1187 | // jQuery delegate for element lookup, scoped to DOM elements within the
1188 | // current view. This should be prefered to global lookups where possible.
1189 | $: function(selector) {
1190 | return this.$el.find(selector);
1191 | },
1192 |
1193 | // Initialize is an empty function by default. Override it with your own
1194 | // initialization logic.
1195 | initialize: function(){},
1196 |
1197 | // **render** is the core function that your view should override, in order
1198 | // to populate its element (`this.el`), with the appropriate HTML. The
1199 | // convention is for **render** to always return `this`.
1200 | render: function() {
1201 | return this;
1202 | },
1203 |
1204 | // Remove this view from the DOM. Note that the view isn't present in the
1205 | // DOM by default, so calling this method may be a no-op.
1206 | remove: function() {
1207 | this.$el.remove();
1208 | return this;
1209 | },
1210 |
1211 | // For small amounts of DOM Elements, where a full-blown template isn't
1212 | // needed, use **make** to manufacture elements, one at a time.
1213 | //
1214 | // var el = this.make('li', {'class': 'row'}, this.model.escape('title'));
1215 | //
1216 | make: function(tagName, attributes, content) {
1217 | var el = document.createElement(tagName);
1218 | if (attributes) Backbone.$(el).attr(attributes);
1219 | if (content != null) Backbone.$(el).html(content);
1220 | return el;
1221 | },
1222 |
1223 | // Change the view's element (`this.el` property), including event
1224 | // re-delegation.
1225 | setElement: function(element, delegate) {
1226 | if (this.$el) this.undelegateEvents();
1227 | this.$el = element instanceof Backbone.$ ? element : Backbone.$(element);
1228 | this.el = this.$el[0];
1229 | if (delegate !== false) this.delegateEvents();
1230 | return this;
1231 | },
1232 |
1233 | // Set callbacks, where `this.events` is a hash of
1234 | //
1235 | // *{"event selector": "callback"}*
1236 | //
1237 | // {
1238 | // 'mousedown .title': 'edit',
1239 | // 'click .button': 'save'
1240 | // 'click .open': function(e) { ... }
1241 | // }
1242 | //
1243 | // pairs. Callbacks will be bound to the view, with `this` set properly.
1244 | // Uses event delegation for efficiency.
1245 | // Omitting the selector binds the event to `this.el`.
1246 | // This only works for delegate-able events: not `focus`, `blur`, and
1247 | // not `change`, `submit`, and `reset` in Internet Explorer.
1248 | delegateEvents: function(events) {
1249 | if (!(events || (events = getValue(this, 'events')))) return;
1250 | this.undelegateEvents();
1251 | for (var key in events) {
1252 | var method = events[key];
1253 | if (!_.isFunction(method)) method = this[events[key]];
1254 | if (!method) throw new Error('Method "' + events[key] + '" does not exist');
1255 | var match = key.match(delegateEventSplitter);
1256 | var eventName = match[1], selector = match[2];
1257 | method = _.bind(method, this);
1258 | eventName += '.delegateEvents' + this.cid;
1259 | if (selector === '') {
1260 | this.$el.bind(eventName, method);
1261 | } else {
1262 | this.$el.delegate(selector, eventName, method);
1263 | }
1264 | }
1265 | },
1266 |
1267 | // Clears all callbacks previously bound to the view with `delegateEvents`.
1268 | // You usually don't need to use this, but may wish to if you have multiple
1269 | // Backbone views attached to the same DOM element.
1270 | undelegateEvents: function() {
1271 | this.$el.unbind('.delegateEvents' + this.cid);
1272 | },
1273 |
1274 | // Performs the initial configuration of a View with a set of options.
1275 | // Keys with special meaning *(model, collection, id, className)*, are
1276 | // attached directly to the view.
1277 | _configure: function(options) {
1278 | if (this.options) options = _.extend({}, this.options, options);
1279 | for (var i = 0, l = viewOptions.length; i < l; i++) {
1280 | var attr = viewOptions[i];
1281 | if (options[attr]) this[attr] = options[attr];
1282 | }
1283 | this.options = options;
1284 | },
1285 |
1286 | // Ensure that the View has a DOM element to render into.
1287 | // If `this.el` is a string, pass it through `$()`, take the first
1288 | // matching element, and re-assign it to `el`. Otherwise, create
1289 | // an element from the `id`, `className` and `tagName` properties.
1290 | _ensureElement: function() {
1291 | if (!this.el) {
1292 | var attrs = _.extend({}, getValue(this, 'attributes'));
1293 | if (this.id) attrs.id = this.id;
1294 | if (this.className) attrs['class'] = this.className;
1295 | this.setElement(this.make(getValue(this, 'tagName'), attrs), false);
1296 | } else {
1297 | this.setElement(this.el, false);
1298 | }
1299 | }
1300 |
1301 | });
1302 |
1303 | // The self-propagating extend function that Backbone classes use.
1304 | var extend = function(protoProps, classProps) {
1305 | return inherits(this, protoProps, classProps);
1306 | };
1307 |
1308 | // Set up inheritance for the model, collection, and view.
1309 | Model.extend = Collection.extend = Router.extend = View.extend = extend;
1310 |
1311 | // Backbone.sync
1312 | // -------------
1313 |
1314 | // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
1315 | var methodMap = {
1316 | 'create': 'POST',
1317 | 'update': 'PUT',
1318 | 'delete': 'DELETE',
1319 | 'read': 'GET'
1320 | };
1321 |
1322 | // Override this function to change the manner in which Backbone persists
1323 | // models to the server. You will be passed the type of request, and the
1324 | // model in question. By default, makes a RESTful Ajax request
1325 | // to the model's `url()`. Some possible customizations could be:
1326 | //
1327 | // * Use `setTimeout` to batch rapid-fire updates into a single request.
1328 | // * Send up the models as XML instead of JSON.
1329 | // * Persist models via WebSockets instead of Ajax.
1330 | //
1331 | // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests
1332 | // as `POST`, with a `_method` parameter containing the true HTTP method,
1333 | // as well as all requests with the body as `application/x-www-form-urlencoded`
1334 | // instead of `application/json` with the model in a param named `model`.
1335 | // Useful when interfacing with server-side languages like **PHP** that make
1336 | // it difficult to read the body of `PUT` requests.
1337 | Backbone.sync = function(method, model, options) {
1338 | var type = methodMap[method];
1339 |
1340 | // Default options, unless specified.
1341 | options || (options = {});
1342 |
1343 | // Default JSON-request options.
1344 | var params = {type: type, dataType: 'json'};
1345 |
1346 | // Ensure that we have a URL.
1347 | if (!options.url) {
1348 | params.url = getValue(model, 'url') || urlError();
1349 | }
1350 |
1351 | // Ensure that we have the appropriate request data.
1352 | if (!options.data && model && (method === 'create' || method === 'update')) {
1353 | params.contentType = 'application/json';
1354 | params.data = JSON.stringify(model);
1355 | }
1356 |
1357 | // For older servers, emulate JSON by encoding the request into an HTML-form.
1358 | if (Backbone.emulateJSON) {
1359 | params.contentType = 'application/x-www-form-urlencoded';
1360 | params.data = params.data ? {model: params.data} : {};
1361 | }
1362 |
1363 | // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
1364 | // And an `X-HTTP-Method-Override` header.
1365 | if (Backbone.emulateHTTP) {
1366 | if (type === 'PUT' || type === 'DELETE') {
1367 | if (Backbone.emulateJSON) params.data._method = type;
1368 | params.type = 'POST';
1369 | params.beforeSend = function(xhr) {
1370 | xhr.setRequestHeader('X-HTTP-Method-Override', type);
1371 | };
1372 | }
1373 | }
1374 |
1375 | // Don't process data on a non-GET request.
1376 | if (params.type !== 'GET' && !Backbone.emulateJSON) {
1377 | params.processData = false;
1378 | }
1379 |
1380 | // Make the request, allowing the user to override any Ajax options.
1381 | return Backbone.ajax(_.extend(params, options));
1382 | };
1383 |
1384 | // Set the default implementation of `Backbone.ajax` to proxy through to `$`.
1385 | Backbone.ajax = function() {
1386 | return Backbone.$.ajax.apply(Backbone.$, arguments);
1387 | };
1388 |
1389 | // Wrap an optional error callback with a fallback error event.
1390 | Backbone.wrapError = function(onError, originalModel, options) {
1391 | return function(model, resp) {
1392 | resp = model === originalModel ? resp : model;
1393 | if (onError) {
1394 | onError(originalModel, resp, options);
1395 | } else {
1396 | originalModel.trigger('error', originalModel, resp, options);
1397 | }
1398 | };
1399 | };
1400 |
1401 | // Helpers
1402 | // -------
1403 |
1404 | // Shared empty constructor function to aid in prototype-chain creation.
1405 | var ctor = function(){};
1406 |
1407 | // Helper function to correctly set up the prototype chain, for subclasses.
1408 | // Similar to `goog.inherits`, but uses a hash of prototype properties and
1409 | // class properties to be extended.
1410 | var inherits = function(parent, protoProps, staticProps) {
1411 | var child;
1412 |
1413 | // The constructor function for the new subclass is either defined by you
1414 | // (the "constructor" property in your `extend` definition), or defaulted
1415 | // by us to simply call the parent's constructor.
1416 | if (protoProps && protoProps.hasOwnProperty('constructor')) {
1417 | child = protoProps.constructor;
1418 | } else {
1419 | child = function(){ parent.apply(this, arguments); };
1420 | }
1421 |
1422 | // Inherit class (static) properties from parent.
1423 | _.extend(child, parent);
1424 |
1425 | // Set the prototype chain to inherit from `parent`, without calling
1426 | // `parent`'s constructor function.
1427 | ctor.prototype = parent.prototype;
1428 | child.prototype = new ctor();
1429 |
1430 | // Add prototype properties (instance properties) to the subclass,
1431 | // if supplied.
1432 | if (protoProps) _.extend(child.prototype, protoProps);
1433 |
1434 | // Add static properties to the constructor function, if supplied.
1435 | if (staticProps) _.extend(child, staticProps);
1436 |
1437 | // Correctly set child's `prototype.constructor`.
1438 | child.prototype.constructor = child;
1439 |
1440 | // Set a convenience property in case the parent's prototype is needed later.
1441 | child.__super__ = parent.prototype;
1442 |
1443 | return child;
1444 | };
1445 |
1446 | // Helper function to get a value from a Backbone object as a property
1447 | // or as a function.
1448 | var getValue = function(object, prop) {
1449 | if (!(object && object[prop])) return null;
1450 | return _.isFunction(object[prop]) ? object[prop]() : object[prop];
1451 | };
1452 |
1453 | // Throw an error when a URL is needed, and none is supplied.
1454 | var urlError = function() {
1455 | throw new Error('A "url" property or function must be specified');
1456 | };
1457 |
1458 | }).call(this);
1459 |
--------------------------------------------------------------------------------
/app/vendor/underscore.js:
--------------------------------------------------------------------------------
1 | // Underscore.js 1.3.3
2 | // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3 | // Underscore is freely distributable under the MIT license.
4 | // Portions of Underscore are inspired or borrowed from Prototype,
5 | // Oliver Steele's Functional, and John Resig's Micro-Templating.
6 | // For all details and documentation:
7 | // http://documentcloud.github.com/underscore
8 |
9 | (function() {
10 |
11 | // Baseline setup
12 | // --------------
13 |
14 | // Establish the root object, `window` in the browser, or `global` on the server.
15 | var root = this;
16 |
17 | // Save the previous value of the `_` variable.
18 | var previousUnderscore = root._;
19 |
20 | // Establish the object that gets returned to break out of a loop iteration.
21 | var breaker = {};
22 |
23 | // Save bytes in the minified (but not gzipped) version:
24 | var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
25 |
26 | // Create quick reference variables for speed access to core prototypes.
27 | var slice = ArrayProto.slice,
28 | unshift = ArrayProto.unshift,
29 | toString = ObjProto.toString,
30 | hasOwnProperty = ObjProto.hasOwnProperty;
31 |
32 | // All **ECMAScript 5** native function implementations that we hope to use
33 | // are declared here.
34 | var
35 | nativeForEach = ArrayProto.forEach,
36 | nativeMap = ArrayProto.map,
37 | nativeReduce = ArrayProto.reduce,
38 | nativeReduceRight = ArrayProto.reduceRight,
39 | nativeFilter = ArrayProto.filter,
40 | nativeEvery = ArrayProto.every,
41 | nativeSome = ArrayProto.some,
42 | nativeIndexOf = ArrayProto.indexOf,
43 | nativeLastIndexOf = ArrayProto.lastIndexOf,
44 | nativeIsArray = Array.isArray,
45 | nativeKeys = Object.keys,
46 | nativeBind = FuncProto.bind;
47 |
48 | // Create a safe reference to the Underscore object for use below.
49 | var _ = function(obj) { return new wrapper(obj); };
50 |
51 | // Export the Underscore object for **Node.js**, with
52 | // backwards-compatibility for the old `require()` API. If we're in
53 | // the browser, add `_` as a global object via a string identifier,
54 | // for Closure Compiler "advanced" mode.
55 | if (typeof exports !== 'undefined') {
56 | if (typeof module !== 'undefined' && module.exports) {
57 | exports = module.exports = _;
58 | }
59 | exports._ = _;
60 | } else {
61 | root['_'] = _;
62 | }
63 |
64 | // Current version.
65 | _.VERSION = '1.3.3';
66 |
67 | // Collection Functions
68 | // --------------------
69 |
70 | // The cornerstone, an `each` implementation, aka `forEach`.
71 | // Handles objects with the built-in `forEach`, arrays, and raw objects.
72 | // Delegates to **ECMAScript 5**'s native `forEach` if available.
73 | var each = _.each = _.forEach = function(obj, iterator, context) {
74 | if (obj == null) return;
75 | if (nativeForEach && obj.forEach === nativeForEach) {
76 | obj.forEach(iterator, context);
77 | } else if (obj.length === +obj.length) {
78 | for (var i = 0, l = obj.length; i < l; i++) {
79 | if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
80 | }
81 | } else {
82 | for (var key in obj) {
83 | if (_.has(obj, key)) {
84 | if (iterator.call(context, obj[key], key, obj) === breaker) return;
85 | }
86 | }
87 | }
88 | };
89 |
90 | // Return the results of applying the iterator to each element.
91 | // Delegates to **ECMAScript 5**'s native `map` if available.
92 | _.map = _.collect = function(obj, iterator, context) {
93 | var results = [];
94 | if (obj == null) return results;
95 | if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
96 | each(obj, function(value, index, list) {
97 | results[results.length] = iterator.call(context, value, index, list);
98 | });
99 | if (obj.length === +obj.length) results.length = obj.length;
100 | return results;
101 | };
102 |
103 | // **Reduce** builds up a single result from a list of values, aka `inject`,
104 | // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
105 | _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
106 | var initial = arguments.length > 2;
107 | if (obj == null) obj = [];
108 | if (nativeReduce && obj.reduce === nativeReduce) {
109 | if (context) iterator = _.bind(iterator, context);
110 | return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
111 | }
112 | each(obj, function(value, index, list) {
113 | if (!initial) {
114 | memo = value;
115 | initial = true;
116 | } else {
117 | memo = iterator.call(context, memo, value, index, list);
118 | }
119 | });
120 | if (!initial) throw new TypeError('Reduce of empty array with no initial value');
121 | return memo;
122 | };
123 |
124 | // The right-associative version of reduce, also known as `foldr`.
125 | // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
126 | _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
127 | var initial = arguments.length > 2;
128 | if (obj == null) obj = [];
129 | if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
130 | if (context) iterator = _.bind(iterator, context);
131 | return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
132 | }
133 | var reversed = _.toArray(obj).reverse();
134 | if (context && !initial) iterator = _.bind(iterator, context);
135 | return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
136 | };
137 |
138 | // Return the first value which passes a truth test. Aliased as `detect`.
139 | _.find = _.detect = function(obj, iterator, context) {
140 | var result;
141 | any(obj, function(value, index, list) {
142 | if (iterator.call(context, value, index, list)) {
143 | result = value;
144 | return true;
145 | }
146 | });
147 | return result;
148 | };
149 |
150 | // Return all the elements that pass a truth test.
151 | // Delegates to **ECMAScript 5**'s native `filter` if available.
152 | // Aliased as `select`.
153 | _.filter = _.select = function(obj, iterator, context) {
154 | var results = [];
155 | if (obj == null) return results;
156 | if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
157 | each(obj, function(value, index, list) {
158 | if (iterator.call(context, value, index, list)) results[results.length] = value;
159 | });
160 | return results;
161 | };
162 |
163 | // Return all the elements for which a truth test fails.
164 | _.reject = function(obj, iterator, context) {
165 | var results = [];
166 | if (obj == null) return results;
167 | each(obj, function(value, index, list) {
168 | if (!iterator.call(context, value, index, list)) results[results.length] = value;
169 | });
170 | return results;
171 | };
172 |
173 | // Determine whether all of the elements match a truth test.
174 | // Delegates to **ECMAScript 5**'s native `every` if available.
175 | // Aliased as `all`.
176 | _.every = _.all = function(obj, iterator, context) {
177 | var result = true;
178 | if (obj == null) return result;
179 | if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
180 | each(obj, function(value, index, list) {
181 | if (!(result = result && iterator.call(context, value, index, list))) return breaker;
182 | });
183 | return !!result;
184 | };
185 |
186 | // Determine if at least one element in the object matches a truth test.
187 | // Delegates to **ECMAScript 5**'s native `some` if available.
188 | // Aliased as `any`.
189 | var any = _.some = _.any = function(obj, iterator, context) {
190 | iterator || (iterator = _.identity);
191 | var result = false;
192 | if (obj == null) return result;
193 | if (nativeSome && obj.some === nativeSome) return obj.some(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 a given value is included in the array or object using `===`.
201 | // Aliased as `contains`.
202 | _.include = _.contains = function(obj, target) {
203 | var found = false;
204 | if (obj == null) return found;
205 | if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
206 | found = any(obj, function(value) {
207 | return value === target;
208 | });
209 | return found;
210 | };
211 |
212 | // Invoke a method (with arguments) on every item in a collection.
213 | _.invoke = function(obj, method) {
214 | var args = slice.call(arguments, 2);
215 | return _.map(obj, function(value) {
216 | return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
217 | });
218 | };
219 |
220 | // Convenience version of a common use case of `map`: fetching a property.
221 | _.pluck = function(obj, key) {
222 | return _.map(obj, function(value){ return value[key]; });
223 | };
224 |
225 | // Return the maximum element or (element-based computation).
226 | _.max = function(obj, iterator, context) {
227 | if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.max.apply(Math, obj);
228 | if (!iterator && _.isEmpty(obj)) return -Infinity;
229 | var result = {computed : -Infinity};
230 | each(obj, function(value, index, list) {
231 | var computed = iterator ? iterator.call(context, value, index, list) : value;
232 | computed >= result.computed && (result = {value : value, computed : computed});
233 | });
234 | return result.value;
235 | };
236 |
237 | // Return the minimum element (or element-based computation).
238 | _.min = function(obj, iterator, context) {
239 | if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.min.apply(Math, obj);
240 | if (!iterator && _.isEmpty(obj)) return Infinity;
241 | var result = {computed : Infinity};
242 | each(obj, function(value, index, list) {
243 | var computed = iterator ? iterator.call(context, value, index, list) : value;
244 | computed < result.computed && (result = {value : value, computed : computed});
245 | });
246 | return result.value;
247 | };
248 |
249 | // Shuffle an array.
250 | _.shuffle = function(obj) {
251 | var shuffled = [], rand;
252 | each(obj, function(value, index, list) {
253 | rand = Math.floor(Math.random() * (index + 1));
254 | shuffled[index] = shuffled[rand];
255 | shuffled[rand] = value;
256 | });
257 | return shuffled;
258 | };
259 |
260 | // Sort the object's values by a criterion produced by an iterator.
261 | _.sortBy = function(obj, val, context) {
262 | var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
263 | return _.pluck(_.map(obj, function(value, index, list) {
264 | return {
265 | value : value,
266 | criteria : iterator.call(context, value, index, list)
267 | };
268 | }).sort(function(left, right) {
269 | var a = left.criteria, b = right.criteria;
270 | if (a === void 0) return 1;
271 | if (b === void 0) return -1;
272 | return a < b ? -1 : a > b ? 1 : 0;
273 | }), 'value');
274 | };
275 |
276 | // Groups the object's values by a criterion. Pass either a string attribute
277 | // to group by, or a function that returns the criterion.
278 | _.groupBy = function(obj, val) {
279 | var result = {};
280 | var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
281 | each(obj, function(value, index) {
282 | var key = iterator(value, index);
283 | (result[key] || (result[key] = [])).push(value);
284 | });
285 | return result;
286 | };
287 |
288 | // Use a comparator function to figure out at what index an object should
289 | // be inserted so as to maintain order. Uses binary search.
290 | _.sortedIndex = function(array, obj, iterator) {
291 | iterator || (iterator = _.identity);
292 | var low = 0, high = array.length;
293 | while (low < high) {
294 | var mid = (low + high) >> 1;
295 | iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid;
296 | }
297 | return low;
298 | };
299 |
300 | // Safely convert anything iterable into a real, live array.
301 | _.toArray = function(obj) {
302 | if (!obj) return [];
303 | if (_.isArray(obj)) return slice.call(obj);
304 | if (_.isArguments(obj)) return slice.call(obj);
305 | if (obj.toArray && _.isFunction(obj.toArray)) return obj.toArray();
306 | return _.values(obj);
307 | };
308 |
309 | // Return the number of elements in an object.
310 | _.size = function(obj) {
311 | return _.isArray(obj) ? obj.length : _.keys(obj).length;
312 | };
313 |
314 | // Array Functions
315 | // ---------------
316 |
317 | // Get the first element of an array. Passing **n** will return the first N
318 | // values in the array. Aliased as `head` and `take`. The **guard** check
319 | // allows it to work with `_.map`.
320 | _.first = _.head = _.take = function(array, n, guard) {
321 | return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
322 | };
323 |
324 | // Returns everything but the last entry of the array. Especcialy useful on
325 | // the arguments object. Passing **n** will return all the values in
326 | // the array, excluding the last N. The **guard** check allows it to work with
327 | // `_.map`.
328 | _.initial = function(array, n, guard) {
329 | return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
330 | };
331 |
332 | // Get the last element of an array. Passing **n** will return the last N
333 | // values in the array. The **guard** check allows it to work with `_.map`.
334 | _.last = function(array, n, guard) {
335 | if ((n != null) && !guard) {
336 | return slice.call(array, Math.max(array.length - n, 0));
337 | } else {
338 | return array[array.length - 1];
339 | }
340 | };
341 |
342 | // Returns everything but the first entry of the array. Aliased as `tail`.
343 | // Especially useful on the arguments object. Passing an **index** will return
344 | // the rest of the values in the array from that index onward. The **guard**
345 | // check allows it to work with `_.map`.
346 | _.rest = _.tail = function(array, index, guard) {
347 | return slice.call(array, (index == null) || guard ? 1 : index);
348 | };
349 |
350 | // Trim out all falsy values from an array.
351 | _.compact = function(array) {
352 | return _.filter(array, function(value){ return !!value; });
353 | };
354 |
355 | // Return a completely flattened version of an array.
356 | _.flatten = function(array, shallow) {
357 | return _.reduce(array, function(memo, value) {
358 | if (_.isArray(value)) return memo.concat(shallow ? value : _.flatten(value));
359 | memo[memo.length] = value;
360 | return memo;
361 | }, []);
362 | };
363 |
364 | // Return a version of the array that does not contain the specified value(s).
365 | _.without = function(array) {
366 | return _.difference(array, slice.call(arguments, 1));
367 | };
368 |
369 | // Produce a duplicate-free version of the array. If the array has already
370 | // been sorted, you have the option of using a faster algorithm.
371 | // Aliased as `unique`.
372 | _.uniq = _.unique = function(array, isSorted, iterator) {
373 | var initial = iterator ? _.map(array, iterator) : array;
374 | var results = [];
375 | // The `isSorted` flag is irrelevant if the array only contains two elements.
376 | if (array.length < 3) isSorted = true;
377 | _.reduce(initial, function (memo, value, index) {
378 | if (isSorted ? _.last(memo) !== value || !memo.length : !_.include(memo, value)) {
379 | memo.push(value);
380 | results.push(array[index]);
381 | }
382 | return memo;
383 | }, []);
384 | return results;
385 | };
386 |
387 | // Produce an array that contains the union: each distinct element from all of
388 | // the passed-in arrays.
389 | _.union = function() {
390 | return _.uniq(_.flatten(arguments, true));
391 | };
392 |
393 | // Produce an array that contains every item shared between all the
394 | // passed-in arrays. (Aliased as "intersect" for back-compat.)
395 | _.intersection = _.intersect = function(array) {
396 | var rest = slice.call(arguments, 1);
397 | return _.filter(_.uniq(array), function(item) {
398 | return _.every(rest, function(other) {
399 | return _.indexOf(other, item) >= 0;
400 | });
401 | });
402 | };
403 |
404 | // Take the difference between one array and a number of other arrays.
405 | // Only the elements present in just the first array will remain.
406 | _.difference = function(array) {
407 | var rest = _.flatten(slice.call(arguments, 1), true);
408 | return _.filter(array, function(value){ return !_.include(rest, value); });
409 | };
410 |
411 | // Zip together multiple lists into a single array -- elements that share
412 | // an index go together.
413 | _.zip = function() {
414 | var args = slice.call(arguments);
415 | var length = _.max(_.pluck(args, 'length'));
416 | var results = new Array(length);
417 | for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
418 | return results;
419 | };
420 |
421 | // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
422 | // we need this function. Return the position of the first occurrence of an
423 | // item in an array, or -1 if the item is not included in the array.
424 | // Delegates to **ECMAScript 5**'s native `indexOf` if available.
425 | // If the array is large and already in sort order, pass `true`
426 | // for **isSorted** to use binary search.
427 | _.indexOf = function(array, item, isSorted) {
428 | if (array == null) return -1;
429 | var i, l;
430 | if (isSorted) {
431 | i = _.sortedIndex(array, item);
432 | return array[i] === item ? i : -1;
433 | }
434 | if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
435 | for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i;
436 | return -1;
437 | };
438 |
439 | // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
440 | _.lastIndexOf = function(array, item) {
441 | if (array == null) return -1;
442 | if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);
443 | var i = array.length;
444 | while (i--) if (i in array && array[i] === item) return i;
445 | return -1;
446 | };
447 |
448 | // Generate an integer Array containing an arithmetic progression. A port of
449 | // the native Python `range()` function. See
450 | // [the Python documentation](http://docs.python.org/library/functions.html#range).
451 | _.range = function(start, stop, step) {
452 | if (arguments.length <= 1) {
453 | stop = start || 0;
454 | start = 0;
455 | }
456 | step = arguments[2] || 1;
457 |
458 | var len = Math.max(Math.ceil((stop - start) / step), 0);
459 | var idx = 0;
460 | var range = new Array(len);
461 |
462 | while(idx < len) {
463 | range[idx++] = start;
464 | start += step;
465 | }
466 |
467 | return range;
468 | };
469 |
470 | // Function (ahem) Functions
471 | // ------------------
472 |
473 | // Reusable constructor function for prototype setting.
474 | var ctor = function(){};
475 |
476 | // Create a function bound to a given object (assigning `this`, and arguments,
477 | // optionally). Binding with arguments is also known as `curry`.
478 | // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
479 | // We check for `func.bind` first, to fail fast when `func` is undefined.
480 | _.bind = function bind(func, context) {
481 | var bound, args;
482 | if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
483 | if (!_.isFunction(func)) throw new TypeError;
484 | args = slice.call(arguments, 2);
485 | return bound = function() {
486 | if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
487 | ctor.prototype = func.prototype;
488 | var self = new ctor;
489 | var result = func.apply(self, args.concat(slice.call(arguments)));
490 | if (Object(result) === result) return result;
491 | return self;
492 | };
493 | };
494 |
495 | // Bind all of an object's methods to that object. Useful for ensuring that
496 | // all callbacks defined on an object belong to it.
497 | _.bindAll = function(obj) {
498 | var funcs = slice.call(arguments, 1);
499 | if (funcs.length == 0) funcs = _.functions(obj);
500 | each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
501 | return obj;
502 | };
503 |
504 | // Memoize an expensive function by storing its results.
505 | _.memoize = function(func, hasher) {
506 | var memo = {};
507 | hasher || (hasher = _.identity);
508 | return function() {
509 | var key = hasher.apply(this, arguments);
510 | return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
511 | };
512 | };
513 |
514 | // Delays a function for the given number of milliseconds, and then calls
515 | // it with the arguments supplied.
516 | _.delay = function(func, wait) {
517 | var args = slice.call(arguments, 2);
518 | return setTimeout(function(){ return func.apply(null, args); }, wait);
519 | };
520 |
521 | // Defers a function, scheduling it to run after the current call stack has
522 | // cleared.
523 | _.defer = function(func) {
524 | return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
525 | };
526 |
527 | // Returns a function, that, when invoked, will only be triggered at most once
528 | // during a given window of time.
529 | _.throttle = function(func, wait) {
530 | var context, args, timeout, throttling, more, result;
531 | var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
532 | return function() {
533 | context = this; args = arguments;
534 | var later = function() {
535 | timeout = null;
536 | if (more) func.apply(context, args);
537 | whenDone();
538 | };
539 | if (!timeout) timeout = setTimeout(later, wait);
540 | if (throttling) {
541 | more = true;
542 | } else {
543 | result = func.apply(context, args);
544 | }
545 | whenDone();
546 | throttling = true;
547 | return result;
548 | };
549 | };
550 |
551 | // Returns a function, that, as long as it continues to be invoked, will not
552 | // be triggered. The function will be called after it stops being called for
553 | // N milliseconds. If `immediate` is passed, trigger the function on the
554 | // leading edge, instead of the trailing.
555 | _.debounce = function(func, wait, immediate) {
556 | var timeout;
557 | return function() {
558 | var context = this, args = arguments;
559 | var later = function() {
560 | timeout = null;
561 | if (!immediate) func.apply(context, args);
562 | };
563 | if (immediate && !timeout) func.apply(context, args);
564 | clearTimeout(timeout);
565 | timeout = setTimeout(later, wait);
566 | };
567 | };
568 |
569 | // Returns a function that will be executed at most one time, no matter how
570 | // often you call it. Useful for lazy initialization.
571 | _.once = function(func) {
572 | var ran = false, memo;
573 | return function() {
574 | if (ran) return memo;
575 | ran = true;
576 | return memo = func.apply(this, arguments);
577 | };
578 | };
579 |
580 | // Returns the first function passed as an argument to the second,
581 | // allowing you to adjust arguments, run code before and after, and
582 | // conditionally execute the original function.
583 | _.wrap = function(func, wrapper) {
584 | return function() {
585 | var args = [func].concat(slice.call(arguments, 0));
586 | return wrapper.apply(this, args);
587 | };
588 | };
589 |
590 | // Returns a function that is the composition of a list of functions, each
591 | // consuming the return value of the function that follows.
592 | _.compose = function() {
593 | var funcs = arguments;
594 | return function() {
595 | var args = arguments;
596 | for (var i = funcs.length - 1; i >= 0; i--) {
597 | args = [funcs[i].apply(this, args)];
598 | }
599 | return args[0];
600 | };
601 | };
602 |
603 | // Returns a function that will only be executed after being called N times.
604 | _.after = function(times, func) {
605 | if (times <= 0) return func();
606 | return function() {
607 | if (--times < 1) { return func.apply(this, arguments); }
608 | };
609 | };
610 |
611 | // Object Functions
612 | // ----------------
613 |
614 | // Retrieve the names of an object's properties.
615 | // Delegates to **ECMAScript 5**'s native `Object.keys`
616 | _.keys = nativeKeys || function(obj) {
617 | if (obj !== Object(obj)) throw new TypeError('Invalid object');
618 | var keys = [];
619 | for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
620 | return keys;
621 | };
622 |
623 | // Retrieve the values of an object's properties.
624 | _.values = function(obj) {
625 | return _.map(obj, _.identity);
626 | };
627 |
628 | // Return a sorted list of the function names available on the object.
629 | // Aliased as `methods`
630 | _.functions = _.methods = function(obj) {
631 | var names = [];
632 | for (var key in obj) {
633 | if (_.isFunction(obj[key])) names.push(key);
634 | }
635 | return names.sort();
636 | };
637 |
638 | // Extend a given object with all the properties in passed-in object(s).
639 | _.extend = function(obj) {
640 | each(slice.call(arguments, 1), function(source) {
641 | for (var prop in source) {
642 | obj[prop] = source[prop];
643 | }
644 | });
645 | return obj;
646 | };
647 |
648 | // Return a copy of the object only containing the whitelisted properties.
649 | _.pick = function(obj) {
650 | var result = {};
651 | each(_.flatten(slice.call(arguments, 1)), function(key) {
652 | if (key in obj) result[key] = obj[key];
653 | });
654 | return result;
655 | };
656 |
657 | // Fill in a given object with default properties.
658 | _.defaults = function(obj) {
659 | each(slice.call(arguments, 1), function(source) {
660 | for (var prop in source) {
661 | if (obj[prop] == null) obj[prop] = source[prop];
662 | }
663 | });
664 | return obj;
665 | };
666 |
667 | // Create a (shallow-cloned) duplicate of an object.
668 | _.clone = function(obj) {
669 | if (!_.isObject(obj)) return obj;
670 | return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
671 | };
672 |
673 | // Invokes interceptor with the obj, and then returns obj.
674 | // The primary purpose of this method is to "tap into" a method chain, in
675 | // order to perform operations on intermediate results within the chain.
676 | _.tap = function(obj, interceptor) {
677 | interceptor(obj);
678 | return obj;
679 | };
680 |
681 | // Internal recursive comparison function.
682 | function eq(a, b, stack) {
683 | // Identical objects are equal. `0 === -0`, but they aren't identical.
684 | // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
685 | if (a === b) return a !== 0 || 1 / a == 1 / b;
686 | // A strict comparison is necessary because `null == undefined`.
687 | if (a == null || b == null) return a === b;
688 | // Unwrap any wrapped objects.
689 | if (a._chain) a = a._wrapped;
690 | if (b._chain) b = b._wrapped;
691 | // Invoke a custom `isEqual` method if one is provided.
692 | if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b);
693 | if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a);
694 | // Compare `[[Class]]` names.
695 | var className = toString.call(a);
696 | if (className != toString.call(b)) return false;
697 | switch (className) {
698 | // Strings, numbers, dates, and booleans are compared by value.
699 | case '[object String]':
700 | // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
701 | // equivalent to `new String("5")`.
702 | return a == String(b);
703 | case '[object Number]':
704 | // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
705 | // other numeric values.
706 | return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
707 | case '[object Date]':
708 | case '[object Boolean]':
709 | // Coerce dates and booleans to numeric primitive values. Dates are compared by their
710 | // millisecond representations. Note that invalid dates with millisecond representations
711 | // of `NaN` are not equivalent.
712 | return +a == +b;
713 | // RegExps are compared by their source patterns and flags.
714 | case '[object RegExp]':
715 | return a.source == b.source &&
716 | a.global == b.global &&
717 | a.multiline == b.multiline &&
718 | a.ignoreCase == b.ignoreCase;
719 | }
720 | if (typeof a != 'object' || typeof b != 'object') return false;
721 | // Assume equality for cyclic structures. The algorithm for detecting cyclic
722 | // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
723 | var length = stack.length;
724 | while (length--) {
725 | // Linear search. Performance is inversely proportional to the number of
726 | // unique nested structures.
727 | if (stack[length] == a) return true;
728 | }
729 | // Add the first object to the stack of traversed objects.
730 | stack.push(a);
731 | var size = 0, result = true;
732 | // Recursively compare objects and arrays.
733 | if (className == '[object Array]') {
734 | // Compare array lengths to determine if a deep comparison is necessary.
735 | size = a.length;
736 | result = size == b.length;
737 | if (result) {
738 | // Deep compare the contents, ignoring non-numeric properties.
739 | while (size--) {
740 | // Ensure commutative equality for sparse arrays.
741 | if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break;
742 | }
743 | }
744 | } else {
745 | // Objects with different constructors are not equivalent.
746 | if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false;
747 | // Deep compare objects.
748 | for (var key in a) {
749 | if (_.has(a, key)) {
750 | // Count the expected number of properties.
751 | size++;
752 | // Deep compare each member.
753 | if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break;
754 | }
755 | }
756 | // Ensure that both objects contain the same number of properties.
757 | if (result) {
758 | for (key in b) {
759 | if (_.has(b, key) && !(size--)) break;
760 | }
761 | result = !size;
762 | }
763 | }
764 | // Remove the first object from the stack of traversed objects.
765 | stack.pop();
766 | return result;
767 | }
768 |
769 | // Perform a deep comparison to check if two objects are equal.
770 | _.isEqual = function(a, b) {
771 | return eq(a, b, []);
772 | };
773 |
774 | // Is a given array, string, or object empty?
775 | // An "empty" object has no enumerable own-properties.
776 | _.isEmpty = function(obj) {
777 | if (obj == null) return true;
778 | if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
779 | for (var key in obj) if (_.has(obj, key)) return false;
780 | return true;
781 | };
782 |
783 | // Is a given value a DOM element?
784 | _.isElement = function(obj) {
785 | return !!(obj && obj.nodeType == 1);
786 | };
787 |
788 | // Is a given value an array?
789 | // Delegates to ECMA5's native Array.isArray
790 | _.isArray = nativeIsArray || function(obj) {
791 | return toString.call(obj) == '[object Array]';
792 | };
793 |
794 | // Is a given variable an object?
795 | _.isObject = function(obj) {
796 | return obj === Object(obj);
797 | };
798 |
799 | // Is a given variable an arguments object?
800 | _.isArguments = function(obj) {
801 | return toString.call(obj) == '[object Arguments]';
802 | };
803 | if (!_.isArguments(arguments)) {
804 | _.isArguments = function(obj) {
805 | return !!(obj && _.has(obj, 'callee'));
806 | };
807 | }
808 |
809 | // Is a given value a function?
810 | _.isFunction = function(obj) {
811 | return toString.call(obj) == '[object Function]';
812 | };
813 |
814 | // Is a given value a string?
815 | _.isString = function(obj) {
816 | return toString.call(obj) == '[object String]';
817 | };
818 |
819 | // Is a given value a number?
820 | _.isNumber = function(obj) {
821 | return toString.call(obj) == '[object Number]';
822 | };
823 |
824 | // Is a given object a finite number?
825 | _.isFinite = function(obj) {
826 | return _.isNumber(obj) && isFinite(obj);
827 | };
828 |
829 | // Is the given value `NaN`?
830 | _.isNaN = function(obj) {
831 | // `NaN` is the only value for which `===` is not reflexive.
832 | return obj !== obj;
833 | };
834 |
835 | // Is a given value a boolean?
836 | _.isBoolean = function(obj) {
837 | return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
838 | };
839 |
840 | // Is a given value a date?
841 | _.isDate = function(obj) {
842 | return toString.call(obj) == '[object Date]';
843 | };
844 |
845 | // Is the given value a regular expression?
846 | _.isRegExp = function(obj) {
847 | return toString.call(obj) == '[object RegExp]';
848 | };
849 |
850 | // Is a given value equal to null?
851 | _.isNull = function(obj) {
852 | return obj === null;
853 | };
854 |
855 | // Is a given variable undefined?
856 | _.isUndefined = function(obj) {
857 | return obj === void 0;
858 | };
859 |
860 | // Has own property?
861 | _.has = function(obj, key) {
862 | return hasOwnProperty.call(obj, key);
863 | };
864 |
865 | // Utility Functions
866 | // -----------------
867 |
868 | // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
869 | // previous owner. Returns a reference to the Underscore object.
870 | _.noConflict = function() {
871 | root._ = previousUnderscore;
872 | return this;
873 | };
874 |
875 | // Keep the identity function around for default iterators.
876 | _.identity = function(value) {
877 | return value;
878 | };
879 |
880 | // Run a function **n** times.
881 | _.times = function (n, iterator, context) {
882 | for (var i = 0; i < n; i++) iterator.call(context, i);
883 | };
884 |
885 | // Escape a string for HTML interpolation.
886 | _.escape = function(string) {
887 | return (''+string).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/');
888 | };
889 |
890 | // If the value of the named property is a function then invoke it;
891 | // otherwise, return it.
892 | _.result = function(object, property) {
893 | if (object == null) return null;
894 | var value = object[property];
895 | return _.isFunction(value) ? value.call(object) : value;
896 | };
897 |
898 | // Add your own custom functions to the Underscore object, ensuring that
899 | // they're correctly added to the OOP wrapper as well.
900 | _.mixin = function(obj) {
901 | each(_.functions(obj), function(name){
902 | addToWrapper(name, _[name] = obj[name]);
903 | });
904 | };
905 |
906 | // Generate a unique integer id (unique within the entire client session).
907 | // Useful for temporary DOM ids.
908 | var idCounter = 0;
909 | _.uniqueId = function(prefix) {
910 | var id = idCounter++;
911 | return prefix ? prefix + id : id;
912 | };
913 |
914 | // By default, Underscore uses ERB-style template delimiters, change the
915 | // following template settings to use alternative delimiters.
916 | _.templateSettings = {
917 | evaluate : /<%([\s\S]+?)%>/g,
918 | interpolate : /<%=([\s\S]+?)%>/g,
919 | escape : /<%-([\s\S]+?)%>/g
920 | };
921 |
922 | // When customizing `templateSettings`, if you don't want to define an
923 | // interpolation, evaluation or escaping regex, we need one that is
924 | // guaranteed not to match.
925 | var noMatch = /.^/;
926 |
927 | // Certain characters need to be escaped so that they can be put into a
928 | // string literal.
929 | var escapes = {
930 | '\\': '\\',
931 | "'": "'",
932 | 'r': '\r',
933 | 'n': '\n',
934 | 't': '\t',
935 | 'u2028': '\u2028',
936 | 'u2029': '\u2029'
937 | };
938 |
939 | for (var p in escapes) escapes[escapes[p]] = p;
940 | var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
941 | var unescaper = /\\(\\|'|r|n|t|u2028|u2029)/g;
942 |
943 | // Within an interpolation, evaluation, or escaping, remove HTML escaping
944 | // that had been previously added.
945 | var unescape = function(code) {
946 | return code.replace(unescaper, function(match, escape) {
947 | return escapes[escape];
948 | });
949 | };
950 |
951 | // JavaScript micro-templating, similar to John Resig's implementation.
952 | // Underscore templating handles arbitrary delimiters, preserves whitespace,
953 | // and correctly escapes quotes within interpolated code.
954 | _.template = function(text, data, settings) {
955 | settings = _.defaults(settings || {}, _.templateSettings);
956 |
957 | // Compile the template source, taking care to escape characters that
958 | // cannot be included in a string literal and then unescape them in code
959 | // blocks.
960 | var source = "__p+='" + text
961 | .replace(escaper, function(match) {
962 | return '\\' + escapes[match];
963 | })
964 | .replace(settings.escape || noMatch, function(match, code) {
965 | return "'+\n_.escape(" + unescape(code) + ")+\n'";
966 | })
967 | .replace(settings.interpolate || noMatch, function(match, code) {
968 | return "'+\n(" + unescape(code) + ")+\n'";
969 | })
970 | .replace(settings.evaluate || noMatch, function(match, code) {
971 | return "';\n" + unescape(code) + "\n;__p+='";
972 | }) + "';\n";
973 |
974 | // If a variable is not specified, place data values in local scope.
975 | if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
976 |
977 | source = "var __p='';" +
978 | "var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n" +
979 | source + "return __p;\n";
980 |
981 | var render = new Function(settings.variable || 'obj', '_', source);
982 | if (data) return render(data, _);
983 | var template = function(data) {
984 | return render.call(this, data, _);
985 | };
986 |
987 | // Provide the compiled function source as a convenience for build time
988 | // precompilation.
989 | template.source = 'function(' + (settings.variable || 'obj') + '){\n' +
990 | source + '}';
991 |
992 | return template;
993 | };
994 |
995 | // Add a "chain" function, which will delegate to the wrapper.
996 | _.chain = function(obj) {
997 | return _(obj).chain();
998 | };
999 |
1000 | // The OOP Wrapper
1001 | // ---------------
1002 |
1003 | // If Underscore is called as a function, it returns a wrapped object that
1004 | // can be used OO-style. This wrapper holds altered versions of all the
1005 | // underscore functions. Wrapped objects may be chained.
1006 | var wrapper = function(obj) { this._wrapped = obj; };
1007 |
1008 | // Expose `wrapper.prototype` as `_.prototype`
1009 | _.prototype = wrapper.prototype;
1010 |
1011 | // Helper function to continue chaining intermediate results.
1012 | var result = function(obj, chain) {
1013 | return chain ? _(obj).chain() : obj;
1014 | };
1015 |
1016 | // A method to easily add functions to the OOP wrapper.
1017 | var addToWrapper = function(name, func) {
1018 | wrapper.prototype[name] = function() {
1019 | var args = slice.call(arguments);
1020 | unshift.call(args, this._wrapped);
1021 | return result(func.apply(_, args), this._chain);
1022 | };
1023 | };
1024 |
1025 | // Add all of the Underscore functions to the wrapper object.
1026 | _.mixin(_);
1027 |
1028 | // Add all mutator Array functions to the wrapper.
1029 | each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
1030 | var method = ArrayProto[name];
1031 | wrapper.prototype[name] = function() {
1032 | var wrapped = this._wrapped;
1033 | method.apply(wrapped, arguments);
1034 | var length = wrapped.length;
1035 | if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
1036 | return result(wrapped, this._chain);
1037 | };
1038 | });
1039 |
1040 | // Add all accessor Array functions to the wrapper.
1041 | each(['concat', 'join', 'slice'], function(name) {
1042 | var method = ArrayProto[name];
1043 | wrapper.prototype[name] = function() {
1044 | return result(method.apply(this._wrapped, arguments), this._chain);
1045 | };
1046 | });
1047 |
1048 | // Start chaining a wrapped Underscore object.
1049 | wrapper.prototype.chain = function() {
1050 | this._chain = true;
1051 | return this;
1052 | };
1053 |
1054 | // Extracts the result from a wrapped and chained object.
1055 | wrapper.prototype.value = function() {
1056 | return this._wrapped;
1057 | };
1058 |
1059 | }).call(this);
1060 |
--------------------------------------------------------------------------------
/app/views/company_list_item_view.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Company List Item View
4 | * The DOM element for an item in a list of company items.
5 | */
6 |
7 | var CompanyListItemView = Backbone.View.extend({
8 |
9 | initialize: function(options) {
10 | this.marker_view = options.marker_view; //retain instance of google marker
11 | this.model.on('remove', this.remove, this); //subscribe to remove events on model
12 | this.render();
13 | },
14 |
15 | //----------------------------------
16 | // Events and event handlers
17 |
18 | events: {
19 | 'mouseover a': 'show_company_info',
20 | 'mouseout a': 'hide_company_info',
21 | 'click button': 'ask_delete_company',
22 | 'click a.delete': 'delete_company',
23 | 'click a.detail': 'show_company_detail'
24 | },
25 |
26 | show_company_detail : function() {
27 | App.show_content();
28 | },
29 |
30 | // show marker bubble
31 | show_company_info : function() {
32 | this.marker_view.show_company_info.call(this.marker_view.marker);
33 | },
34 |
35 | // hide marker bubble
36 | hide_company_info : function() {
37 | this.marker_view.hide_company_info.call(this.marker_view.marker);
38 | },
39 |
40 | // clicked on "delete". show confirm button.
41 | ask_delete_company : function() {
42 | $('button', this.$el).hide();
43 | $('a.delete', this.$el).fadeIn();
44 | },
45 |
46 | delete_company : function() {
47 | this.model.clear();
48 | },
49 |
50 | // END Events and event handlers
51 | //----------------------------------
52 |
53 | render: function() {
54 | this.$el.html('' + this.model.get('name') + ' confirm');
55 | return this;
56 | },
57 |
58 | remove: function() {
59 | this.$el.html('');
60 | }
61 | });
--------------------------------------------------------------------------------
/app/views/company_list_view.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Company List View
4 | * The DOM element for a list of company items.
5 | */
6 |
7 | var CompanyListView = Backbone.View.extend({
8 |
9 | el: $("#companies_holder"),
10 |
11 | initialize: function(options) {
12 | this.map = options.map;
13 | this.model.on('add', this.added_company, this);
14 |
15 | // initialize position
16 | this.$el.css({display: 'none', right:'20px', top: '120px'}, 2000);
17 | this.$el.fadeIn('500');
18 |
19 | this.list_container = $('#companies_list_holder ul', this.$el);
20 |
21 | this.render();
22 | },
23 |
24 | //----------------------------------
25 | // Events and event handlers
26 |
27 | events: {
28 | 'click #btn_pop_new_company': 'popup_new_company',
29 | 'click #btn_delete_all_companies' : 'delete_all_companies'
30 | },
31 |
32 | // event handler for "new company" action
33 | popup_new_company: function() {
34 | if (Companies.length>15){
35 | alert('limited to 15!');
36 | return;
37 | }
38 | var company = dummy_data_generator.get_dummy_company();
39 | this.model.add_new(company);
40 | },
41 |
42 | // event handler for "delete all companies" action
43 | delete_all_companies: function() {
44 | Companies.remove_all();
45 | },
46 |
47 | // END Events and event handlers
48 | //----------------------------------
49 |
50 | added_company : function(company){
51 | var marker_view = new CompanyMarkerView({ model: company, map: this.map });
52 | var item_view = new CompanyListItemView({ model: company, marker_view : marker_view });
53 | $(this.list_container).append(item_view.render().el);
54 | },
55 |
56 | render: function() {
57 | this.model.each (this.added_company, this);
58 | }
59 | });
--------------------------------------------------------------------------------
/app/views/company_marker_view.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Company Marker View
4 | * The DOM element for a company marker.
5 | */
6 |
7 | var CompanyMarkerView = Backbone.View.extend({
8 |
9 | tagName: "li",
10 |
11 | initialize: function(options) {
12 |
13 | var self = this;
14 |
15 | self.model = options.model;
16 | self.model.on('remove', self.remove, self);
17 |
18 | self.map = options.map;
19 |
20 | var pos = self.model.get('pos');
21 |
22 | self.marker = new google.maps.Marker({
23 | map: self.map,
24 | position: new google.maps.LatLng(pos.lat, pos.lon),
25 | animation: google.maps.Animation.DROP,
26 | icon : 'img/buildings_32x32.png',
27 | title: self.model.name,
28 | descr : self.model.get('descr'),
29 | id : self.model.get('company_id')
30 | });
31 |
32 | self.marker.infowindow = new google.maps.InfoWindow({
33 | content: self.marker.descr
34 | });
35 |
36 | google.maps.event.addListener(self.marker, 'mouseover', self.show_company_info);
37 | google.maps.event.addListener(self.marker, 'mouseout', self.hide_company_info);
38 | google.maps.event.addListener(self.marker, 'click', self.show_company_detail);
39 | },
40 |
41 | //---------------------------------------
42 | // Event handlers for marker events
43 |
44 | show_company_detail : function() {
45 | this.infowindow.close();
46 | App.show_content();
47 | },
48 |
49 | hide_company_info : function() {
50 | this.setIcon('img/buildings_32x32.png');
51 | this.infowindow.close();
52 | },
53 |
54 | show_company_info : function() {
55 | this.setIcon('img/buildings_32x32_selected.png');
56 | this.infowindow.open(this.map, this);
57 | },
58 |
59 | // END Events and event handlers
60 | //----------------------------------
61 |
62 | render: function() { },
63 |
64 | remove : function() {
65 | this.marker.setMap(null);
66 | this.marker = null;
67 | }
68 | });
69 |
--------------------------------------------------------------------------------
/css/style.css:
--------------------------------------------------------------------------------
1 | body{
2 | font: 300 60px "Helvetica Neue", Helvetica, Arial, sans-serif;
3 | color:gray;
4 | }
5 |
6 | #hub header {
7 | position: absolute;
8 | color: #333333;
9 | margin: 5px;
10 | -webkit-font-smoothing: antialiased;
11 | background: #fff;
12 | padding: 10px 10px 5px 10px;
13 |
14 | -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
15 | -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
16 | -ms-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
17 | -o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
18 | box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
19 | -webkit-border-radius: 0 0 5px 5px;
20 | -moz-border-radius: 0 0 5px 5px;
21 | -ms-border-radius: 0 0 5px 5px;
22 | -o-border-radius: 0 0 5px 5px;
23 | border-radius: 0 0 5px 5px;
24 | }
25 |
26 | #hub header h1 {
27 | font: 400 30px "Helvetica Neue", Helvetica, Arial, sans-serif;
28 | text-align: center;
29 | padding: 0 0 10px 0;
30 | }
31 |
32 | #hub header h1 small {
33 | font: 100 20px "Helvetica Neue", Helvetica, Arial, sans-serif;
34 | }
35 |
36 | #main {
37 | display: none;
38 | position:relative;
39 | top:700px;
40 |
41 | background-color: white;
42 | margin: 0 auto;
43 | padding:20px;
44 | }
45 |
46 | #companies_holder{
47 | display:none;
48 | position:absolute;
49 | background-color: white;
50 | padding:15px;
51 |
52 | -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
53 | -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
54 | -ms-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
55 | -o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
56 | box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
57 | -webkit-border-radius: 5px;
58 | -moz-border-radius: 5px;
59 | -ms-border-radius: 5px;
60 | -o-border-radius: 5px;
61 | border-radius: 5px;
62 | }
63 |
64 | #companies_list_holder ul{
65 | list-style-type: none;
66 | margin: 5px 0px;
67 | }
68 |
69 | #companies_list_holder li{
70 | padding:3px;
71 | }
72 |
73 | #companies_list_holder a {
74 |
75 | }
76 |
77 | .nav_controls {
78 | display: none;
79 |
80 | position: absolute;
81 | background: #fff;
82 |
83 | left: 2%;
84 | }
85 |
86 | /*wrapper around the map related controls: show map, etc*/
87 | #map_controls {
88 | padding: 25px;
89 | -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
90 | -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
91 | -ms-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
92 | -o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
93 | box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
94 | -webkit-border-radius: 0 0 5px 5px;
95 | -moz-border-radius: 0 0 5px 5px;
96 | -ms-border-radius: 0 0 5px 5px;
97 | -o-border-radius: 0 0 5px 5px;
98 | border-radius: 0 0 5px 5px;
99 | }
100 |
101 | #content_controls{
102 | padding: 15px;
103 | -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
104 | -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
105 | -ms-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
106 | -o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
107 | box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;
108 | -webkit-border-radius: 0 0 5px 5px;
109 | -moz-border-radius: 0 0 5px 5px;
110 | -ms-border-radius: 0 0 5px 5px;
111 | -o-border-radius: 0 0 5px 5px;
112 | border-radius: 0 0 5px 5px;
113 | }
114 |
115 | #map_canvas{
116 | z-index: -1;
117 | position: absolute;
118 | top: 0;
119 | left: 0;
120 | width: 100%;
121 | height :100%;
122 | }
123 |
--------------------------------------------------------------------------------
/img/buildings_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iloire/backbonejs-googlemaps-demo/6da7143b2fdbcabcf71b67d460d35381e03e60a6/img/buildings_32x32.png
--------------------------------------------------------------------------------
/img/buildings_32x32_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iloire/backbonejs-googlemaps-demo/6da7143b2fdbcabcf71b67d460d35381e03e60a6/img/buildings_32x32_selected.png
--------------------------------------------------------------------------------
/img/glyphicons-halflings-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iloire/backbonejs-googlemaps-demo/6da7143b2fdbcabcf71b67d460d35381e03e60a6/img/glyphicons-halflings-white.png
--------------------------------------------------------------------------------
/img/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iloire/backbonejs-googlemaps-demo/6da7143b2fdbcabcf71b67d460d35381e03e60a6/img/glyphicons-halflings.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Playing with Backbone.js and Google Maps
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | playing with backbone.js and google maps...
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
Lorem ipsum y más lorem (ole!)
39 |
40 |
×
41 |
Demo
42 |
Really simple demo of how to use Backbone.js and Google Maps with a few simple interactions.
43 |
44 |
45 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
Content here
56 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
map div
167 |
168 |
169 |
--------------------------------------------------------------------------------
/screenshots/backbonejs_google_maps01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iloire/backbonejs-googlemaps-demo/6da7143b2fdbcabcf71b67d460d35381e03e60a6/screenshots/backbonejs_google_maps01.png
--------------------------------------------------------------------------------