conschedule 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +154 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/config/conschedule_manifest.js +2 -0
  6. data/app/assets/fonts/icomoon.eot +0 -0
  7. data/app/assets/fonts/proxima_nova_100.eot +0 -0
  8. data/app/assets/fonts/proxima_nova_400.eot +0 -0
  9. data/app/assets/fonts/proxima_nova_700.eot +0 -0
  10. data/app/assets/images/conschedule/chosen-sprite-small.png +0 -0
  11. data/app/assets/images/conschedule/chosen-sprite.png +0 -0
  12. data/app/assets/images/conschedule/close.png +0 -0
  13. data/app/assets/images/conschedule/spinner-small.gif +0 -0
  14. data/app/assets/images/conschedule/spinner.gif +0 -0
  15. data/app/assets/javascripts/conschedule/application.js +22 -0
  16. data/app/assets/javascripts/conschedule/calendar.js +467 -0
  17. data/app/assets/javascripts/conschedule/date.js +104 -0
  18. data/app/assets/javascripts/conschedule/form.js +53 -0
  19. data/app/assets/javascripts/conschedule/home.js +149 -0
  20. data/app/assets/javascripts/conschedule/jquery-ui-datepicker.min.js +1674 -0
  21. data/app/assets/javascripts/conschedule/jquery.easing.min.js +44 -0
  22. data/app/assets/javascripts/conschedule/jquery.validate.js +1532 -0
  23. data/app/assets/javascripts/conschedule/js_time_zone.js +1433 -0
  24. data/app/assets/javascripts/conschedule/moment-timezone.js +1209 -0
  25. data/app/assets/javascripts/conschedule/moment.js +4195 -0
  26. data/app/assets/javascripts/conschedule/schedules.js +22 -0
  27. data/app/assets/javascripts/conschedule/time_zones_drop_down.js +609 -0
  28. data/app/assets/stylesheets/conschedule/application.css +4 -0
  29. data/app/assets/stylesheets/conschedule/common.css +816 -0
  30. data/app/assets/stylesheets/conschedule/home.css +2441 -0
  31. data/app/assets/stylesheets/conschedule/main.css +884 -0
  32. data/app/assets/stylesheets/conschedule/schedules.css +4 -0
  33. data/app/controllers/conschedule/application_controller.rb +49 -0
  34. data/app/controllers/conschedule/schedules_controller.rb +125 -0
  35. data/app/helpers/conschedule/application_helper.rb +15 -0
  36. data/app/helpers/conschedule/schedules_helper.rb +43 -0
  37. data/app/jobs/conschedule/application_job.rb +4 -0
  38. data/app/mailers/conschedule/schedules_mailer.rb +46 -0
  39. data/app/models/conschedule/application_record.rb +5 -0
  40. data/app/models/conschedule/schedule.rb +63 -0
  41. data/app/views/conschedule/schedules/_confirmation.html.erb +38 -0
  42. data/app/views/conschedule/schedules/_page_one.html.erb +75 -0
  43. data/app/views/conschedule/schedules/_page_three.html.erb +94 -0
  44. data/app/views/conschedule/schedules/_page_two.html.erb +22 -0
  45. data/app/views/conschedule/schedules/_schedules.html.erb +122 -0
  46. data/app/views/conschedule/schedules/create.js.erb +11 -0
  47. data/app/views/conschedule/schedules/index.html.erb +123 -0
  48. data/app/views/conschedule/schedules/index.js.erb +3 -0
  49. data/app/views/conschedule/schedules/new.html.erb +11 -0
  50. data/app/views/conschedule/schedules_mailer/send_cancel_email_owner.html.erb +61 -0
  51. data/app/views/conschedule/schedules_mailer/send_cancel_email_user.html.erb +29 -0
  52. data/app/views/conschedule/schedules_mailer/send_confirmation_email_owner.html.erb +77 -0
  53. data/app/views/conschedule/schedules_mailer/send_confirmation_email_user.html.erb +30 -0
  54. data/app/views/kaminari/custom_theme/_first_page.html.erb +3 -0
  55. data/app/views/kaminari/custom_theme/_gap.html.erb +1 -0
  56. data/app/views/kaminari/custom_theme/_last_page.html.erb +3 -0
  57. data/app/views/kaminari/custom_theme/_next_page.html.erb +1 -0
  58. data/app/views/kaminari/custom_theme/_page.html.erb +5 -0
  59. data/app/views/kaminari/custom_theme/_paginator.html.erb +23 -0
  60. data/app/views/kaminari/custom_theme/_prev_page.html.erb +1 -0
  61. data/app/views/layouts/conschedule/application.html.erb +14 -0
  62. data/app/views/layouts/conschedule/mailer.html.erb +11 -0
  63. data/app/views/layouts/conschedule/schedules.html.erb +14 -0
  64. data/config/initializers/assets.rb +11 -0
  65. data/config/routes.rb +11 -0
  66. data/db/migrate/20160812085505_create_conschedule_schedules.rb +27 -0
  67. data/lib/conschedule.rb +34 -0
  68. data/lib/conschedule/configuration.rb +25 -0
  69. data/lib/conschedule/engine.rb +5 -0
  70. data/lib/conschedule/gem_dependencies.rb +2 -0
  71. data/lib/conschedule/version.rb +3 -0
  72. data/lib/generators/conschedule/install_generator.rb +23 -0
  73. data/lib/generators/conschedule/views_generator.rb +45 -0
  74. data/lib/generators/templates/README +40 -0
  75. data/lib/generators/templates/initializer.rb +25 -0
  76. data/lib/tasks/conschedule_tasks.rake +4 -0
  77. metadata +182 -0
@@ -0,0 +1,22 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require conschedule/jquery.validate
16
+ //= require conschedule/jquery.easing.min
17
+ //= require conschedule/moment
18
+ //= require conschedule/moment-timezone
19
+ //= require conschedule/js_time_zone
20
+ //= require conschedule/form
21
+ //= require conschedule/time_zones_drop_down
22
+ //= require conschedule/calendar
@@ -0,0 +1,609 @@
1
+ (function ($) {
2
+
3
+ var time_zones_data = {
4
+ "US/Canada": [
5
+ {
6
+ "name":"Pacific Time - US & Canada",
7
+ "identifier":"America/Los_Angeles",
8
+ "standard_title":"Pacific Time - US & Canada"
9
+ },
10
+ {
11
+ "name":"Mountain Time - US & Canada",
12
+ "identifier":"America/Denver",
13
+ "standard_title":"Mountain Time - US & Canada"
14
+ },
15
+ {
16
+ "name":"Central Time - US & Canada",
17
+ "identifier":"America/Chicago",
18
+ "standard_title":"Central Time - US & Canada"
19
+ },
20
+ {
21
+ "name":"Eastern Time - US & Canada",
22
+ "identifier":"America/New_York",
23
+ "standard_title":"Eastern Time - US & Canada"
24
+ },
25
+ {
26
+ "name":"Atlantic Time",
27
+ "identifier":"America/Halifax",
28
+ "standard_title":"Atlantic Time"
29
+ },
30
+ {
31
+ "name":"Alaska Time",
32
+ "identifier":"America/Anchorage",
33
+ "standard_title":"Alaska Time"
34
+ },
35
+ {
36
+ "name":"Arizona Time",
37
+ "identifier":"America/Phoenix",
38
+ "standard_title":"Arizona Time"
39
+ },
40
+ {
41
+ "name":"Newfoundland Time",
42
+ "identifier":"America/St_Johns",
43
+ "standard_title":"Newfoundland Time"
44
+ },
45
+ {
46
+ "name":"Hawaii Time",
47
+ "identifier":"Pacific/Honolulu",
48
+ "standard_title":"Hawaii Time"
49
+ }
50
+ ],
51
+ "America": [
52
+ {
53
+ "name":"America/Adak",
54
+ "identifier":"America/Adak",
55
+ "standard_title":"GMT-10:00 America/Adak"
56
+ },
57
+ {
58
+ "name":"Buenos Aires Time",
59
+ "identifier":"America/Argentina/Buenos_Aires",
60
+ "standard_title":"GMT-03:00 Buenos Aires Time"
61
+ },
62
+ {
63
+ "name":"Asuncion Time",
64
+ "identifier":"America/Asuncion",
65
+ "standard_title":"GMT-04:00 Asuncion Time"
66
+ },
67
+ {
68
+ "name":"Bogota, Jamaica, Lima Time",
69
+ "identifier":"America/Bogota",
70
+ "standard_title":"GMT-05:00 Bogota, Jamaica, Lima Time"
71
+ },
72
+ {
73
+ "name":"America/Campo_Grande",
74
+ "identifier":"America/Campo_Grande",
75
+ "standard_title":"GMT-04:00 America/Campo_Grande"
76
+ },
77
+ {
78
+ "name":"Caracas Time",
79
+ "identifier":"America/Caracas",
80
+ "standard_title":"GMT-04:00 Caracas Time"
81
+ },
82
+ {
83
+ "name":"America/Godthab",
84
+ "identifier":"America/Godthab",
85
+ "standard_title":"GMT-03:00 America/Godthab"
86
+ },
87
+ {
88
+ "name":"Atlantic Time",
89
+ "identifier":"America/Goose_Bay",
90
+ "standard_title":"GMT-04:00 Atlantic Time"
91
+ },
92
+ {
93
+ "name":"Saskatchewan, Guatemala, Costa Rica Time",
94
+ "identifier":"America/Guatemala",
95
+ "standard_title":"GMT-06:00 Saskatchewan, Guatemala, Costa Rica Time"
96
+ },
97
+ {
98
+ "name":"America/Havana",
99
+ "identifier":"America/Havana",
100
+ "standard_title":"GMT-05:00 America/Havana"
101
+ },
102
+ {
103
+ "name":"America/Mazatlan",
104
+ "identifier":"America/Mazatlan",
105
+ "standard_title":"GMT-07:00 America/Mazatlan"
106
+ },
107
+ {
108
+ "name":"Mexico City Time",
109
+ "identifier":"America/Mexico_City",
110
+ "standard_title":"GMT-06:00 Mexico City Time"
111
+ },
112
+ {
113
+ "name":"Montevideo Time",
114
+ "identifier":"America/Montevideo",
115
+ "standard_title":"GMT-03:00 Montevideo Time"
116
+ },
117
+ {
118
+ "name":"America/Miquelon",
119
+ "identifier":"America/Miquelon",
120
+ "standard_title":"GMT-03:00 America/Miquelon"
121
+ },
122
+ {
123
+ "name":"America/Noronha",
124
+ "identifier":"America/Noronha",
125
+ "standard_title":"GMT-02:00 America/Noronha"
126
+ },
127
+
128
+ {
129
+ "name":"Santiago Time",
130
+ "identifier":"America/Santiago",
131
+ "standard_title":"GMT-04:00 Santiago Time"
132
+ },
133
+ {
134
+ "name":"America/Santa_Isabel",
135
+ "identifier":"America/Santa_Isabel",
136
+ "standard_title":"GMT-08:00 America/Santa_Isabel"
137
+ },
138
+ {
139
+ "name":"Atlantic Standard Time",
140
+ "identifier":"America/Santo_Domingo",
141
+ "standard_title":"GMT-04:00 Atlantic Standard Time"
142
+ },
143
+ {
144
+ "name":"Brasilia Time",
145
+ "identifier":"America/Sao_Paulo",
146
+ "standard_title":"GMT-03:00 Brasilia Time"
147
+ }
148
+ ],
149
+ "Africa": [
150
+ {
151
+ "name":"Africa/Cairo",
152
+ "identifier":"Africa/Cairo",
153
+ "standard_title":"GMT+02:00 Africa/Cairo"
154
+ },
155
+ {
156
+ "name":"Central Africa Time",
157
+ "identifier":"Africa/Johannesburg",
158
+ "standard_title":"GMT+02:00 Central Africa Time"
159
+ },
160
+ {
161
+ "name":"West Africa Time",
162
+ "identifier":"Africa/Lagos",
163
+ "standard_title":"GMT+01:00 West Africa Time"
164
+ },
165
+ {
166
+ "name":"Africa/Windhoek",
167
+ "identifier":"Africa/Windhoek",
168
+ "standard_title":"GMT+01:00 Africa/Windhoek"
169
+ }
170
+ ],
171
+ "Asia": [
172
+ {
173
+ "name":"Syria, Jordan Time",
174
+ "identifier":"Asia/Amman",
175
+ "standard_title":"GMT+02:00 Syria, Jordan Time"
176
+ },
177
+ {
178
+ "name":"Baghdad, East Africa Time",
179
+ "identifier":"Asia/Baghdad",
180
+ "standard_title":"GMT+03:00 Baghdad, East Africa Time"
181
+ },
182
+ {
183
+ "name":"Asia/Baku",
184
+ "identifier":"Asia/Baku",
185
+ "standard_title":"GMT+04:00 Asia/Baku"
186
+ },
187
+ {
188
+ "name":"Jordan, Lebanon Time",
189
+ "identifier":"Asia/Beirut",
190
+ "standard_title":"GMT+02:00 Jordan, Lebanon Time"
191
+ },
192
+ {
193
+ "name":"Asia/Damascus",
194
+ "identifier":"Asia/Damascus",
195
+ "standard_title":"GMT+02:00 Asia/Damascus"
196
+ },
197
+ {
198
+ "name":"Asia/Dhaka",
199
+ "identifier":"Asia/Dhaka",
200
+ "standard_title":"GMT+06:00 Asia/Dhaka"
201
+ },
202
+ {
203
+ "name":"Dubai Time",
204
+ "identifier":"Asia/Dubai",
205
+ "standard_title":"GMT+04:00 Dubai Time"
206
+ },
207
+ {
208
+ "name":"Asia/Gaza",
209
+ "identifier":"Asia/Gaza",
210
+ "standard_title":"GMT+02:00 Asia/Gaza"
211
+ },
212
+ {
213
+ "name":"Asia/Irkutsk",
214
+ "identifier":"Asia/Irkutsk",
215
+ "standard_title":"GMT+08:00 Asia/Irkutsk"
216
+ },
217
+ {
218
+ "name":"Indochina Time",
219
+ "identifier":"Asia/Jakarta",
220
+ "standard_title":"GMT+07:00 Indochina Time"
221
+ },
222
+ {
223
+ "name":"Israel Time",
224
+ "identifier":"Asia/Jerusalem",
225
+ "standard_title":"GMT+02:00 Israel Time"
226
+ },
227
+ {
228
+ "name":"Kabul Time",
229
+ "identifier":"Asia/Kabul",
230
+ "standard_title":"GMT+04:30 Kabul Time"
231
+ },
232
+ {
233
+ "name":"Pacific/Majuro",
234
+ "identifier":"Asia/Kamchatka",
235
+ "standard_title":"GMT+12:00 Pacific/Majuro"
236
+ },
237
+ {
238
+ "name":"Pakistan, Maldives Time",
239
+ "identifier":"Asia/Karachi",
240
+ "standard_title":"GMT+05:00 Pakistan, Maldives Time"
241
+ },
242
+ {
243
+ "name":"Kathmandu Time",
244
+ "identifier":"Asia/Kathmandu",
245
+ "standard_title":"GMT+05:45 Kathmandu Time"
246
+ },
247
+ {
248
+ "name":"India, Sri Lanka Time",
249
+ "identifier":"Asia/Kolkata",
250
+ "standard_title":"GMT+05:30 India, Sri Lanka Time"
251
+ },
252
+ {
253
+ "name":"China, Singapore, Perth Time",
254
+ "identifier":"Asia/Krasnoyarsk",
255
+ "standard_title":"GMT+07:00 China, Singapore, Perth Time"
256
+ },
257
+ {
258
+ "name":"Asia/Omsk",
259
+ "identifier":"Asia/Omsk",
260
+ "standard_title":"GMT+06:00 Asia/Omsk"
261
+ },
262
+ {
263
+ "name":"Asia/Rangoon",
264
+ "identifier":"Asia/Rangoon",
265
+ "standard_title":"GMT+06:30 Asia/Rangoon"
266
+ },
267
+ {
268
+ "name":"China, Singapore, Perth",
269
+ "identifier":"Asia/Shanghai",
270
+ "standard_title":"GMT+08:00 China, Singapore, Perth"
271
+ },
272
+ {
273
+ "name":"Tehran Time",
274
+ "identifier":"Asia/Tehran",
275
+ "standard_title":"GMT+03:30 Tehran Time"
276
+ },
277
+ {
278
+ "name":"Japan, Korea Time",
279
+ "identifier":"Asia/Tokyo",
280
+ "standard_title":"GMT+09:00 Japan, Korea Time"
281
+ },
282
+ {
283
+ "name":"Asia/Vladivostok",
284
+ "identifier":"Asia/Vladivostok",
285
+ "standard_title":"GMT+10:00 Asia/Vladivostok"
286
+ },
287
+ {
288
+ "name":"Asia/Yakutsk",
289
+ "identifier":"Asia/Yakutsk",
290
+ "standard_title":"GMT+09:00 Asia/Yakutsk"
291
+ },
292
+ {
293
+ "name":"Asia/Dhaka",
294
+ "identifier":"Asia/Yekaterinburg",
295
+ "standard_title":"GMT+05:00 Asia/Dhaka"
296
+ },
297
+ {
298
+ "name":"Asia/Yerevan",
299
+ "identifier":"Asia/Yerevan",
300
+ "standard_title":"GMT+04:00 Asia/Yerevan"
301
+ }
302
+ ],
303
+ "Atlantic": [
304
+ {
305
+ "name":"Azores Time",
306
+ "identifier":"Atlantic/Azores",
307
+ "standard_title":"GMT-01:00 Azores Time"
308
+ },
309
+ {
310
+ "name":"Cape Verde Time",
311
+ "identifier":"Atlantic/Cape_Verde",
312
+ "standard_title":"GMT-01:00 Cape Verde Time"
313
+ }
314
+ ],
315
+ "Australia": [
316
+ {
317
+ "name":"Adelaide Time",
318
+ "identifier":"Australia/Adelaide",
319
+ "standard_title":"GMT+09:30 Adelaide Time"
320
+ },
321
+ {
322
+ "name":"Brisbane Time",
323
+ "identifier":"Australia/Brisbane",
324
+ "standard_title":"GMT+10:00 Brisbane Time"
325
+ },
326
+ {
327
+ "name":"Australia/Darwin",
328
+ "identifier":"Australia/Darwin",
329
+ "standard_title":"GMT+09:30 Australia/Darwin"
330
+ },
331
+ {
332
+ "name":"Australia/Eucla",
333
+ "identifier":"Australia/Eucla",
334
+ "standard_title":"GMT+08:45 Australia/Eucla"
335
+ },
336
+ {
337
+ "name":"Australia/Lord_Howe",
338
+ "identifier":"Australia/Lord_Howe",
339
+ "standard_title":"GMT+10:30 Australia/Lord_Howe"
340
+ },
341
+ {
342
+ "name":"Australia/Perth",
343
+ "identifier":"Australia/Perth",
344
+ "standard_title":"GMT+08:00 Australia/Perth"
345
+ },
346
+ {
347
+ "name":"Sydney, Melbourne Time",
348
+ "identifier":"Australia/Sydney",
349
+ "standard_title":"GMT+10:00 Sydney, Melbourne Time"
350
+ }
351
+ ],
352
+ "UTC": [
353
+ {
354
+ "name":"UTC Time",
355
+ "identifier":"UTC",
356
+ "standard_title":"GMT+00:00 UTC Time"
357
+ }
358
+ ],
359
+ "Europe": [
360
+ {
361
+ "name":"Central European Time",
362
+ "identifier":"Europe/Berlin",
363
+ "standard_title":"GMT+01:00 Central European Time"
364
+ },
365
+ {
366
+ "name":"Eastern European Time",
367
+ "identifier":"Europe/Helsinki",
368
+ "standard_title":"GMT+02:00 Eastern European Time"
369
+ },
370
+ {
371
+ "name":"UK, Ireland, Lisbon Time",
372
+ "identifier":"Europe/London",
373
+ "standard_title":"GMT+00:00 UK, Ireland, Lisbon Time"
374
+ },
375
+ {
376
+ "name":"Moscow, Minsk Time",
377
+ "identifier":"Europe/Minsk",
378
+ "standard_title":"GMT+03:00 Moscow, Minsk Time"
379
+ },
380
+ {
381
+ "name":"Yerevan Time",
382
+ "identifier":"Europe/Moscow",
383
+ "standard_title":"GMT+03:00 Yerevan Time"
384
+ }
385
+ ],
386
+ "Pacific": [
387
+ {
388
+ "name":"Pacific/Apia",
389
+ "identifier":"Pacific/Apia",
390
+ "standard_title":"GMT+13:00 Pacific/Apia"
391
+ },
392
+ {
393
+ "name":"Auckland Time",
394
+ "identifier":"Pacific/Auckland",
395
+ "standard_title":"GMT+12:00 Auckland Time"
396
+ },
397
+ {
398
+ "name":"Pacific/Chatham",
399
+ "identifier":"Pacific/Chatham",
400
+ "standard_title":"GMT+12:45 Pacific/Chatham"
401
+ },
402
+ {
403
+ "name":"Pacific/Easter",
404
+ "identifier":"Pacific/Easter",
405
+ "standard_title":"GMT-06:00 Pacific/Easter"
406
+ },
407
+ {
408
+ "name":"Pacific/Fiji",
409
+ "identifier":"Pacific/Fiji",
410
+ "standard_title":"GMT+12:00 Pacific/Fiji"
411
+ },
412
+ {
413
+ "name":"Pacific/Gambier",
414
+ "identifier":"Pacific/Gambier",
415
+ "standard_title":"GMT-09:00 Pacific/Gambier"
416
+ },
417
+ {
418
+ "name":"Pacific/Kiritimati",
419
+ "identifier":"Pacific/Kiritimati",
420
+ "standard_title":"GMT+14:00 Pacific/Kiritimati"
421
+ },
422
+ {
423
+ "name":"Pacific/Majuro",
424
+ "identifier":"Pacific/Majuro",
425
+ "standard_title":"GMT+12:00 Pacific/Majuro"
426
+ },
427
+ {
428
+ "name":"Pacific/Marquesas",
429
+ "identifier":"Pacific/Marquesas",
430
+ "standard_title":"GMT-10:30 Pacific/Marquesas"
431
+ },
432
+ {
433
+ "name":"Pacific/Norfolk",
434
+ "identifier":"Pacific/Norfolk",
435
+ "standard_title":"GMT+11:00 Pacific/Norfolk"
436
+ },
437
+ {
438
+ "name":"Pacific/Noumea",
439
+ "identifier":"Pacific/Noumea",
440
+ "standard_title":"GMT+11:00 Pacific/Noumea"
441
+ },
442
+ {
443
+ "name":"Pacific/Pago_Pago",
444
+ "identifier":"Pacific/Pago_Pago",
445
+ "standard_title":"GMT-11:00 Pacific/Pago_Pago"
446
+ },
447
+ {
448
+ "name":"Pacific/Pitcairn",
449
+ "identifier":"Pacific/Pitcairn",
450
+ "standard_title":"GMT-08:00 Pacific/Pitcairn"
451
+ },
452
+ {
453
+ "name":"Pacific/Tarawa",
454
+ "identifier":"Pacific/Tarawa",
455
+ "standard_title":"GMT+12:00 Pacific/Tarawa"
456
+ },
457
+ {
458
+ "name":"Pacific/Tongatapu",
459
+ "identifier":"Pacific/Tongatapu",
460
+ "standard_title":"GMT+13:00 Pacific/Tongatapu"
461
+ }
462
+ ]
463
+ };
464
+
465
+ $.fn.timezonesdropdown = function (options) {
466
+ return this.each(function () {
467
+ timezones($(this), options);
468
+ });
469
+ };
470
+
471
+ function timezones($this, options) {
472
+ var opts = $.extend({}, $.fn.timezonesdropdown.defaults, options);
473
+ var $this = $this;
474
+ var keys = Object.keys(time_zones_data);
475
+ keys.forEach(function(el, i){
476
+ var $el = $('<optgroup label="'+el+'"></optgroup>');
477
+ time_zones_data[el].forEach(function(place, j){
478
+ var value = place.identifier;
479
+ var name = place.standard_title;
480
+ $el.append('<option value="'+value+'">'+name);
481
+ });
482
+ $this.append($el);
483
+ });
484
+ if ( page_info.enable_tz ) {
485
+ var drop_down_arrow = "<div><b></b></div>";
486
+ }
487
+ else {
488
+ var drop_down_arrow = '';
489
+ }
490
+ var template = '<div title="" style="width: 100%;" class="chzn-container chzn-container-single" id="timezone_dropdown_chzn">' +
491
+ '<a href="javascript:void(0)" class="chzn-single" tabindex="-1">' +
492
+ '<span></span>' +
493
+ drop_down_arrow +
494
+ '</a>' +
495
+ '<div class="chzn-drop">' +
496
+ '<div class="chzn-search">' +
497
+ '<input autocomplete="off" type="text" class="chzn-search-input">' +
498
+ '</div>' +
499
+ '</div>' +
500
+ '</div>';
501
+ $this.after(template);
502
+ timeZoneDropDown($this, opts);
503
+ window['time_zone_drop_down' + $this.attr('id')] = setInterval(function () {
504
+ timeZoneDropDown($this, opts)
505
+ }, 60000);
506
+ toggle_drop_down_listeners();
507
+ }
508
+
509
+ function timeZoneDropDown($this, opts) {
510
+ var keys = Object.keys(time_zones_data);
511
+ var $ot = $("<ul class='chzn-results'></ul>");
512
+ keys.forEach(function(el, i){
513
+ var selector = el.toLowerCase().replace('/','_');
514
+ $ot.append('<li style="display: list-item;" class="group-result '+ selector +'">'+el+'</li>');
515
+ time_zones_data[el].forEach(function(place, j){
516
+ var value = place.identifier;
517
+ var name = place.standard_title;
518
+ var current_time = moment(moment.utc().format()).tz(value).format('hh:mm A');
519
+ $ot.append('<li data-tz-selector="'+selector+'"'+'data-timezone-identifier="'+value+'"'+'data-time="'+current_time+'"'+'class="group-option active-result">'+name+'</li>');
520
+ });
521
+ });
522
+ if ( $('.chzn-results').length > 0 ) {
523
+ $('.chzn-results').remove();
524
+ }
525
+ $('.chzn-drop').append($ot);
526
+ filter_options();
527
+ if ( page_info.enable_tz ) {
528
+ bind_event_listener();
529
+ }
530
+ }
531
+
532
+ function toggle_drop_down_listeners() {
533
+ if ( page_info.enable_tz ) {
534
+ $(".chzn-single").click(function() {
535
+ $("#timezone_dropdown_chzn").toggleClass("chzn-container-active chzn-with-drop");
536
+ });
537
+ }
538
+
539
+ $(document).click(function (e)
540
+ {
541
+ var container = $(".timezone");
542
+ if (!container.is(e.target) && container.has(e.target).length === 0)
543
+ {
544
+ if ( $("#timezone_dropdown_chzn").hasClass("chzn-container-active chzn-with-drop") ) {
545
+ $("#timezone_dropdown_chzn").removeClass("chzn-container-active chzn-with-drop")
546
+ }
547
+ }
548
+ });
549
+
550
+ $(".chzn-search-input").keyup(function() {
551
+ filter_options();
552
+ });
553
+ }
554
+
555
+ function bind_event_listener() {
556
+ $("li.group-option").click(function() {
557
+ $('.chzn-single span').html($(this).html());
558
+ $("#schedule_user_tz_offset").val($(this).html());
559
+ var timezone_identifier = $(this).data('timezone-identifier');
560
+ $("#timezonesdropdown").val(timezone_identifier);
561
+ $("#timezone_dropdown_chzn").toggleClass("chzn-container-active chzn-with-drop");
562
+ load_calendar_tz(timezone_identifier);
563
+ });
564
+ }
565
+
566
+ function filter_options() {
567
+ var input_val = $.trim($(".chzn-search-input").val());
568
+ var rgxp;
569
+ var data_set = time_zones_data;
570
+ if ( input_val != "" ) {
571
+ display_group_option();
572
+ $("li.group-result").hide();
573
+ rgxp = new RegExp( input_val, 'i' );
574
+ $("li.group-option").each(function() {
575
+ if ($(this).html().replace('&amp;','&').match(rgxp) == null) {
576
+ $(this).removeClass("active-result");
577
+ }
578
+ });
579
+ $("li.group-option.active-result").each(function() {
580
+ $("li.group-result." + $(this).data("tz-selector")).each(function() {
581
+ if (!$(this).is(':visible')) {
582
+ $(this).css({"display": "list-item"})
583
+ }
584
+ });
585
+ });
586
+ }
587
+ else {
588
+ display_group_option();
589
+ display_group_result();
590
+ }
591
+ }
592
+
593
+ function display_group_option() {
594
+ $("li.group-option").each(function() {
595
+ if ( !$(this).hasClass("active-result") ) {
596
+ $(this).addClass("active-result");
597
+ }
598
+ });
599
+ }
600
+
601
+ function display_group_result() {
602
+ $("li.group-result").each(function() {
603
+ if (!$(this).is(':visible')) {
604
+ $(this).css({"display": "list-item"})
605
+ }
606
+ });
607
+ }
608
+
609
+ }(jQuery));