beautiful_scaffold 1.0.0.pre → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +9 -0
  3. data/Gemfile +1 -9
  4. data/README.rdoc +1 -1
  5. data/beautiful_scaffold.gemspec +1 -1
  6. data/lib/generators/beautiful_locale_generator.rb +24 -3
  7. data/lib/generators/beautiful_scaffold_common_methods.rb +47 -10
  8. data/lib/generators/beautiful_scaffold_generator.rb +61 -40
  9. data/lib/generators/templates/app/assets/javascripts/application-bs.js +3 -2
  10. data/lib/generators/templates/app/assets/javascripts/beautiful_scaffold.js +37 -1
  11. data/lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js +23 -44
  12. data/lib/generators/templates/app/assets/stylesheets/application-bs.css +1 -2
  13. data/lib/generators/templates/app/assets/stylesheets/beautiful-scaffold.css.scss +25 -1
  14. data/lib/generators/templates/app/controllers/base.rb +17 -7
  15. data/lib/generators/templates/app/controllers/master_base.rb +39 -25
  16. data/lib/generators/templates/app/helpers/beautiful_helper.rb +23 -9
  17. data/lib/generators/templates/app/helpers/model_helper.rb +14 -3
  18. data/lib/generators/templates/app/initializers/ransack.rb +16 -0
  19. data/lib/generators/templates/app/views/_mass_inserting.html.erb +3 -2
  20. data/lib/generators/templates/app/views/_modal_columns.html.erb +2 -2
  21. data/lib/generators/templates/app/views/index.html.erb +25 -3
  22. data/lib/generators/templates/app/views/layout.html.erb +0 -11
  23. data/lib/generators/templates/app/views/partials/_index_search.html.erb +1 -1
  24. data/lib/generators/templates/app/views/partials/_index_search_default_fields.html.erb +1 -1
  25. data/lib/generators/templates/app/views/treeview.html.erb +4 -4
  26. metadata +5 -6
  27. data/lib/generators/templates/app/assets/javascripts/bootstrap-datepicker.js +0 -834
  28. data/lib/generators/templates/app/assets/javascripts/bootstrap-timepicker.js +0 -797
@@ -1,797 +0,0 @@
1
- /* =========================================================
2
- * bootstrap-timepicker.js
3
- * http://www.github.com/jdewit/bootstrap-timepicker
4
- * =========================================================
5
- * Copyright 2012
6
- *
7
- * Created By:
8
- * Joris de Wit @joris_dewit
9
- *
10
- * Contributions By:
11
- * Gilbert @mindeavor
12
- * Koen Punt info@koenpunt.nl
13
- * Nek
14
- * Chris Martin
15
- * Dominic Barnes contact@dominicbarnes.us
16
- * Rivsc (http://blog.escarworld.com for Beautiful-Scaffold) same behavior as datepicker
17
- *
18
- * Licensed under the Apache License, Version 2.0 (the "License");
19
- * you may not use this file except in compliance with the License.
20
- * You may obtain a copy of the License at
21
- *
22
- * http://www.apache.org/licenses/LICENSE-2.0
23
- *
24
- * Unless required by applicable law or agreed to in writing, software
25
- * distributed under the License is distributed on an "AS IS" BASIS,
26
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
- * See the License for the specific language governing permissions and
28
- * limitations under the License.
29
- * ========================================================= */
30
-
31
- !function($) {
32
-
33
- "use strict"; // jshint ;_;
34
-
35
- /* TIMEPICKER PUBLIC CLASS DEFINITION
36
- * ================================== */
37
- var Timepicker = function(element, options) {
38
- this.$element = $(element);
39
- this.options = $.extend({}, $.fn.timepicker.defaults, options, this.$element.data());
40
- this.minuteStep = this.options.minuteStep || this.minuteStep;
41
- this.secondStep = this.options.secondStep || this.secondStep;
42
- this.showMeridian = this.options.showMeridian || this.showMeridian;
43
- this.showSeconds = this.options.showSeconds || this.showSeconds;
44
- this.showInputs = this.options.showInputs || this.showInputs;
45
- this.disableFocus = this.options.disableFocus || this.disableFocus;
46
- this.template = this.options.template || this.template;
47
- this.modalBackdrop = this.options.modalBackdrop || this.modalBackdrop;
48
- this.defaultTime = this.options.defaultTime || this.defaultTime;
49
- this.open = false;
50
- this.init();
51
- };
52
-
53
- Timepicker.prototype = {
54
-
55
- constructor: Timepicker
56
-
57
- , init: function () {
58
- if (this.$element.parent().hasClass('input-group')) {
59
- this.$element.parent('.input-group').find('.input-group-addon').on('click', $.proxy(this.showWidget, this));
60
- this.$element.on('click', $.proxy(this.showWidget, this));
61
- this.$element.on({
62
- focus: $.proxy(this.highlightUnit, this),
63
- click: $.proxy(this.highlightUnit, this),
64
- keypress: $.proxy(this.elementKeypress, this),
65
- blur: $.proxy(this.updateFromElementVal, this)
66
- });
67
-
68
- } else {
69
- if (this.template) {
70
- this.$element.on({
71
- focus: $.proxy(this.showWidget, this),
72
- click: $.proxy(this.showWidget, this),
73
- blur: $.proxy(this.updateFromElementVal, this)
74
- });
75
- } else {
76
- this.$element.on({
77
- focus: $.proxy(this.highlightUnit, this),
78
- click: $.proxy(this.highlightUnit, this),
79
- keypress: $.proxy(this.elementKeypress, this),
80
- blur: $.proxy(this.updateFromElementVal, this)
81
- });
82
- }
83
- }
84
-
85
-
86
- this.$widget = $(this.getTemplate()).appendTo('body');
87
-
88
- this.$widget.on('click', $.proxy(this.widgetClick, this));
89
-
90
- if (this.showInputs) {
91
- this.$widget.find('input').on({
92
- click: function() { this.select(); },
93
- keypress: $.proxy(this.widgetKeypress, this),
94
- change: $.proxy(this.updateFromWidgetInputs, this)
95
- });
96
- }
97
-
98
- this.setDefaultTime(this.defaultTime);
99
- }
100
-
101
- , showWidget: function(e) {
102
- e.stopPropagation();
103
- e.preventDefault();
104
-
105
- if (this.open) {
106
- return;
107
- }
108
-
109
- this.$element.trigger('show');
110
-
111
- if (this.disableFocus) {
112
- this.$element.blur();
113
- }
114
-
115
- var pos = $.extend({}, this.$element.offset(), {
116
- height: this.$element[0].offsetHeight
117
- });
118
-
119
- this.updateFromElementVal();
120
-
121
- $('html')
122
- .trigger('click.timepicker.data-api')
123
- .one('click.timepicker.data-api', $.proxy(this.hideWidget, this));
124
-
125
- if (this.template === 'modal') {
126
- this.$widget.modal('show').on('hidden', $.proxy(this.hideWidget, this));
127
- } else {
128
- this.$widget.css({
129
- top: pos.top + pos.height
130
- , left: pos.left
131
- })
132
-
133
- if (!this.open) {
134
- this.$widget.addClass('open');
135
- }
136
- }
137
-
138
- this.open = true;
139
- this.$element.trigger('shown');
140
- }
141
-
142
- , hideWidget: function(){
143
- this.$element.trigger('hide');
144
-
145
- if (this.template === 'modal') {
146
- this.$widget.modal('hide');
147
- } else {
148
- this.$widget.removeClass('open');
149
- }
150
- this.open = false;
151
- this.$element.trigger('hidden');
152
- }
153
-
154
- , widgetClick: function(e) {
155
- e.stopPropagation();
156
- e.preventDefault();
157
-
158
- var action = $(e.target).closest('a').data('action');
159
- if (action) {
160
- this[action]();
161
- this.update();
162
- }
163
- }
164
-
165
- , widgetKeypress: function(e) {
166
- var input = $(e.target).closest('input').attr('name');
167
-
168
- switch (e.keyCode) {
169
- case 9: //tab
170
- if (this.showMeridian) {
171
- if (input == 'meridian') {
172
- this.hideWidget();
173
- }
174
- } else {
175
- if (this.showSeconds) {
176
- if (input == 'second') {
177
- this.hideWidget();
178
- }
179
- } else {
180
- if (input == 'minute') {
181
- this.hideWidget();
182
- }
183
- }
184
- }
185
- break;
186
- case 27: // escape
187
- this.hideWidget();
188
- break;
189
- case 38: // up arrow
190
- switch (input) {
191
- case 'hour':
192
- this.incrementHour();
193
- break;
194
- case 'minute':
195
- this.incrementMinute();
196
- break;
197
- case 'second':
198
- this.incrementSecond();
199
- break;
200
- case 'meridian':
201
- this.toggleMeridian();
202
- break;
203
- }
204
- this.update();
205
- break;
206
- case 40: // down arrow
207
- switch (input) {
208
- case 'hour':
209
- this.decrementHour();
210
- break;
211
- case 'minute':
212
- this.decrementMinute();
213
- break;
214
- case 'second':
215
- this.decrementSecond();
216
- break;
217
- case 'meridian':
218
- this.toggleMeridian();
219
- break;
220
- }
221
- this.update();
222
- break;
223
- }
224
- }
225
-
226
- , elementKeypress: function(e) {
227
- var input = this.$element.get(0);
228
- switch (e.keyCode) {
229
- case 0: //input
230
- break;
231
- case 9: //tab
232
- this.updateFromElementVal();
233
- if (this.showMeridian) {
234
- if (this.highlightedUnit != 'meridian') {
235
- e.preventDefault();
236
- this.highlightNextUnit();
237
- }
238
- } else {
239
- if (this.showSeconds) {
240
- if (this.highlightedUnit != 'second') {
241
- e.preventDefault();
242
- this.highlightNextUnit();
243
- }
244
- } else {
245
- if (this.highlightedUnit != 'minute') {
246
- e.preventDefault();
247
- this.highlightNextUnit();
248
- }
249
- }
250
- }
251
- break;
252
- case 27: // escape
253
- this.updateFromElementVal();
254
- break;
255
- case 37: // left arrow
256
- this.updateFromElementVal();
257
- this.highlightPrevUnit();
258
- break;
259
- case 38: // up arrow
260
- switch (this.highlightedUnit) {
261
- case 'hour':
262
- this.incrementHour();
263
- break;
264
- case 'minute':
265
- this.incrementMinute();
266
- break;
267
- case 'second':
268
- this.incrementSecond();
269
- break;
270
- case 'meridian':
271
- this.toggleMeridian();
272
- break;
273
- }
274
- this.updateElement();
275
- break;
276
- case 39: // right arrow
277
- this.updateFromElementVal();
278
- this.highlightNextUnit();
279
- break;
280
- case 40: // down arrow
281
- switch (this.highlightedUnit) {
282
- case 'hour':
283
- this.decrementHour();
284
- break;
285
- case 'minute':
286
- this.decrementMinute();
287
- break;
288
- case 'second':
289
- this.decrementSecond();
290
- break;
291
- case 'meridian':
292
- this.toggleMeridian();
293
- break;
294
- }
295
- this.updateElement();
296
- break;
297
- }
298
-
299
- if (e.keyCode !== 0 && e.keyCode !== 8 && e.keyCode !== 9 && e.keyCode !== 46) {
300
- e.preventDefault();
301
- }
302
-
303
- }
304
-
305
- , setValues: function(time) {
306
- if (this.showMeridian) {
307
- var arr = time.split(' ');
308
- var timeArray = arr[0].split(':');
309
- this.meridian = arr[1];
310
- } else {
311
- var timeArray = time.split(':');
312
- }
313
-
314
- this.hour = parseInt(timeArray[0], 10);
315
- this.minute = parseInt(timeArray[1], 10);
316
- this.second = parseInt(timeArray[2], 10);
317
-
318
- if (isNaN(this.hour)) {
319
- this.hour = 1;
320
- }
321
- if (isNaN(this.minute)) {
322
- this.minute = 0;
323
- }
324
-
325
- if (this.showMeridian) {
326
- if (this.hour > 12) {
327
- this.hour = 12;
328
- } else if (this.hour < 1) {
329
- this.hour = 1;
330
- }
331
-
332
- if (this.meridian == 'am' || this.meridian == 'a') {
333
- this.meridian = 'AM';
334
- } else if (this.meridian == 'pm' || this.meridian == 'p') {
335
- this.meridian = 'PM';
336
- }
337
-
338
- if (this.meridian != 'AM' && this.meridian != 'PM') {
339
- this.meridian = 'AM';
340
- }
341
- }
342
-
343
- if (this.minute < 0) {
344
- this.minute = 0;
345
- } else if (this.minute > 60) {
346
- this.minute = 60;
347
- }
348
-
349
- if (this.showSeconds) {
350
- if (isNaN(this.second)) {
351
- this.second = 0;
352
- } else if (this.second < 0) {
353
- this.second = 0;
354
- } else if (this.second > 60) {
355
- this.second = 60;
356
- }
357
- }
358
-
359
- this.updateElement();
360
- this.updateWidget();
361
- }
362
-
363
- , setMeridian: function(meridian) {
364
- if (meridian == 'a' || meridian == 'am' || meridian == 'AM' ) {
365
- this.meridian = 'AM';
366
- } else if (meridian == 'p' || meridian == 'pm' || meridian == 'PM' ) {
367
- this.meridian = 'PM';
368
- } else {
369
- this.updateWidget();
370
- }
371
-
372
- this.updateElement();
373
- }
374
-
375
- , setDefaultTime: function(defaultTime){
376
- if (defaultTime) {
377
- if (defaultTime === 'current') {
378
- var dTime = new Date();
379
- var hours = dTime.getHours();
380
- var minutes = Math.floor(dTime.getMinutes() / this.minuteStep) * this.minuteStep;
381
- var seconds = Math.floor(dTime.getSeconds() / this.secondStep) * this.secondStep;
382
- var meridian = "AM";
383
- if (this.showMeridian) {
384
- if (hours === 0) {
385
- hours = 12;
386
- } else if (hours >= 12) {
387
- if (hours > 12) {
388
- hours = hours - 12;
389
- }
390
- meridian = "PM";
391
- } else {
392
- meridian = "AM";
393
- }
394
- }
395
- this.hour = hours;
396
- this.minute = minutes;
397
- this.second = seconds;
398
- this.meridian = meridian;
399
- } else if (defaultTime === 'value') {
400
- this.setValues(this.$element.val());
401
- } else {
402
- this.setValues(defaultTime);
403
- }
404
- this.update();
405
- } else {
406
- this.hour = 0;
407
- this.minute = 0;
408
- this.second = 0;
409
- }
410
- }
411
-
412
- , formatTime: function(hour, minute, second, meridian) {
413
- hour = hour < 10 ? '0' + hour : hour;
414
- minute = minute < 10 ? '0' + minute : minute;
415
- second = second < 10 ? '0' + second : second;
416
-
417
- return hour + ':' + minute + (this.showSeconds ? ':' + second : '') + (this.showMeridian ? ' ' + meridian : '');
418
- }
419
-
420
- , getTime: function() {
421
- return this.formatTime(this.hour, this.minute, this.second, this.meridian);
422
- }
423
-
424
- , setTime: function(time) {
425
- this.setValues(time);
426
- this.update();
427
- }
428
-
429
- , update: function() {
430
- this.updateElement();
431
- this.updateWidget();
432
- }
433
-
434
- , updateElement: function() {
435
- var time = this.getTime();
436
-
437
- this.$element.val(time).change();
438
-
439
- switch (this.highlightedUnit) {
440
- case 'hour':
441
- this.highlightHour();
442
- break;
443
- case 'minute':
444
- this.highlightMinute();
445
- break;
446
- case 'second':
447
- this.highlightSecond();
448
- break;
449
- case 'meridian':
450
- this.highlightMeridian();
451
- break;
452
- }
453
-
454
- }
455
-
456
- , updateWidget: function() {
457
- if (this.showInputs) {
458
- this.$widget.find('input.bootstrap-timepicker-hour').val(this.hour < 10 ? '0' + this.hour : this.hour);
459
- this.$widget.find('input.bootstrap-timepicker-minute').val(this.minute < 10 ? '0' + this.minute : this.minute);
460
- if (this.showSeconds) {
461
- this.$widget.find('input.bootstrap-timepicker-second').val(this.second < 10 ? '0' + this.second : this.second);
462
- }
463
- if (this.showMeridian) {
464
- this.$widget.find('input.bootstrap-timepicker-meridian').val(this.meridian);
465
- }
466
- } else {
467
- this.$widget.find('span.bootstrap-timepicker-hour').text(this.hour);
468
- this.$widget.find('span.bootstrap-timepicker-minute').text(this.minute < 10 ? '0' + this.minute : this.minute);
469
- if (this.showSeconds) {
470
- this.$widget.find('span.bootstrap-timepicker-second').text(this.second < 10 ? '0' + this.second : this.second);
471
- }
472
- if (this.showMeridian) {
473
- this.$widget.find('span.bootstrap-timepicker-meridian').text(this.meridian);
474
- }
475
- }
476
- }
477
-
478
- , updateFromElementVal: function (e) {
479
- var time = this.$element.val();
480
- if (time) {
481
- this.setValues(time);
482
- this.updateWidget();
483
- }
484
- }
485
-
486
- , updateFromWidgetInputs: function () {
487
- var time = $('input.bootstrap-timepicker-hour').val() + ':' +
488
- $('input.bootstrap-timepicker-minute').val() +
489
- (this.showSeconds ?
490
- ':' + $('input.bootstrap-timepicker-second').val()
491
- : '') +
492
- (this.showMeridian ?
493
- ' ' + $('input.bootstrap-timepicker-meridian').val()
494
- : '');
495
-
496
- this.setValues(time);
497
- }
498
-
499
- , getCursorPosition: function() {
500
- var input = this.$element.get(0);
501
-
502
- if ('selectionStart' in input) {
503
- // Standard-compliant browsers
504
- return input.selectionStart;
505
- } else if (document.selection) {
506
- // IE fix
507
- input.focus();
508
- var sel = document.selection.createRange();
509
- var selLen = document.selection.createRange().text.length;
510
- sel.moveStart('character', - input.value.length);
511
-
512
- return sel.text.length - selLen;
513
- }
514
- }
515
-
516
- , highlightUnit: function () {
517
- var input = this.$element.get(0);
518
-
519
- this.position = this.getCursorPosition();
520
- if (this.position >= 0 && this.position <= 2) {
521
- this.highlightHour();
522
- } else if (this.position >= 3 && this.position <= 5) {
523
- this.highlightMinute();
524
- } else if (this.position >= 6 && this.position <= 8) {
525
- if (this.showSeconds) {
526
- this.highlightSecond();
527
- } else {
528
- this.highlightMeridian();
529
- }
530
- } else if (this.position >= 9 && this.position <= 11) {
531
- this.highlightMeridian();
532
- }
533
- }
534
-
535
- , highlightNextUnit: function() {
536
- switch (this.highlightedUnit) {
537
- case 'hour':
538
- this.highlightMinute();
539
- break;
540
- case 'minute':
541
- if (this.showSeconds) {
542
- this.highlightSecond();
543
- } else {
544
- this.highlightMeridian();
545
- }
546
- break;
547
- case 'second':
548
- this.highlightMeridian();
549
- break;
550
- case 'meridian':
551
- this.highlightHour();
552
- break;
553
- }
554
- }
555
-
556
- , highlightPrevUnit: function() {
557
- switch (this.highlightedUnit) {
558
- case 'hour':
559
- this.highlightMeridian();
560
- break;
561
- case 'minute':
562
- this.highlightHour();
563
- break;
564
- case 'second':
565
- this.highlightMinute();
566
- break;
567
- case 'meridian':
568
- if (this.showSeconds) {
569
- this.highlightSecond();
570
- } else {
571
- this.highlightMinute();
572
- }
573
- break;
574
- }
575
- }
576
-
577
- , highlightHour: function() {
578
- this.highlightedUnit = 'hour';
579
- //this.$element.get(0).setSelectionRange(0,2);
580
- }
581
-
582
- , highlightMinute: function() {
583
- this.highlightedUnit = 'minute';
584
- //this.$element.get(0).setSelectionRange(3,5);
585
- }
586
-
587
- , highlightSecond: function() {
588
- this.highlightedUnit = 'second';
589
- //this.$element.get(0).setSelectionRange(6,8);
590
- }
591
-
592
- , highlightMeridian: function() {
593
- this.highlightedUnit = 'meridian';
594
- if (this.showSeconds) {
595
- //this.$element.get(0).setSelectionRange(9,11);
596
- } else {
597
- //this.$element.get(0).setSelectionRange(6,8);
598
- }
599
- }
600
-
601
- , incrementHour: function() {
602
- if (this.showMeridian) {
603
- if (this.hour === 11) {
604
- this.toggleMeridian();
605
- } else if (this.hour === 12) {
606
- return this.hour = 1;
607
- }
608
- }
609
- if (this.hour === 23) {
610
- return this.hour = 0;
611
- }
612
- this.hour = this.hour + 1;
613
- }
614
-
615
- , decrementHour: function() {
616
- if (this.showMeridian) {
617
- if (this.hour === 1) {
618
- return this.hour = 12;
619
- }
620
- else if (this.hour === 12) {
621
- this.toggleMeridian();
622
- }
623
- }
624
- if (this.hour === 0) {
625
- return this.hour = 23;
626
- }
627
- this.hour = this.hour - 1;
628
- }
629
-
630
- , incrementMinute: function() {
631
- var newVal = this.minute + this.minuteStep - (this.minute % this.minuteStep);
632
- if (newVal > 59) {
633
- this.incrementHour();
634
- this.minute = newVal - 60;
635
- } else {
636
- this.minute = newVal;
637
- }
638
- }
639
-
640
- , decrementMinute: function() {
641
- var newVal = this.minute - this.minuteStep;
642
- if (newVal < 0) {
643
- this.decrementHour();
644
- this.minute = newVal + 60;
645
- } else {
646
- this.minute = newVal;
647
- }
648
- }
649
-
650
- , incrementSecond: function() {
651
- var newVal = this.second + this.secondStep - (this.second % this.secondStep);
652
- if (newVal > 59) {
653
- this.incrementMinute();
654
- this.second = newVal - 60;
655
- } else {
656
- this.second = newVal;
657
- }
658
- }
659
-
660
- , decrementSecond: function() {
661
- var newVal = this.second - this.secondStep;
662
- if (newVal < 0) {
663
- this.decrementMinute();
664
- this.second = newVal + 60;
665
- } else {
666
- this.second = newVal;
667
- }
668
- }
669
-
670
- , toggleMeridian: function() {
671
- this.meridian = this.meridian === 'AM' ? 'PM' : 'AM';
672
-
673
- this.update();
674
- }
675
-
676
- , getTemplate: function() {
677
- if (this.options.templates[this.options.template]) {
678
- return this.options.templates[this.options.template];
679
- }
680
- if (this.showInputs) {
681
- var hourTemplate = '<input type="text" name="hour" class="bootstrap-timepicker-hour" maxlength="2"/>';
682
- var minuteTemplate = '<input type="text" name="minute" class="bootstrap-timepicker-minute" maxlength="2"/>';
683
- var secondTemplate = '<input type="text" name="second" class="bootstrap-timepicker-second" maxlength="2"/>';
684
- var meridianTemplate = '<input type="text" name="meridian" class="bootstrap-timepicker-meridian" maxlength="2"/>';
685
- } else {
686
- var hourTemplate = '<span class="bootstrap-timepicker-hour"></span>';
687
- var minuteTemplate = '<span class="bootstrap-timepicker-minute"></span>';
688
- var secondTemplate = '<span class="bootstrap-timepicker-second"></span>';
689
- var meridianTemplate = '<span class="bootstrap-timepicker-meridian"></span>';
690
- }
691
- var templateContent = '<table class="'+ (this.showSeconds ? 'show-seconds' : '') +' '+ (this.showMeridian ? 'show-meridian' : '') +'">'+
692
- '<tr>'+
693
- '<td><a href="#" data-action="incrementHour"><i class="fa fa-chevron-up"></i></a></td>'+
694
- '<td class="separator">&nbsp;</td>'+
695
- '<td><a href="#" data-action="incrementMinute"><i class="fa fa-chevron-up"></i></a></td>'+
696
- (this.showSeconds ?
697
- '<td class="separator">&nbsp;</td>'+
698
- '<td><a href="#" data-action="incrementSecond"><i class="fa fa-chevron-up"></i></a></td>'
699
- : '') +
700
- (this.showMeridian ?
701
- '<td class="separator">&nbsp;</td>'+
702
- '<td class="meridian-column"><a href="#" data-action="toggleMeridian"><i class="fa fa-chevron-up"></i></a></td>'
703
- : '') +
704
- '</tr>'+
705
- '<tr>'+
706
- '<td>'+ hourTemplate +'</td> '+
707
- '<td class="separator">:</td>'+
708
- '<td>'+ minuteTemplate +'</td> '+
709
- (this.showSeconds ?
710
- '<td class="separator">:</td>'+
711
- '<td>'+ secondTemplate +'</td>'
712
- : '') +
713
- (this.showMeridian ?
714
- '<td class="separator">&nbsp;</td>'+
715
- '<td>'+ meridianTemplate +'</td>'
716
- : '') +
717
- '</tr>'+
718
- '<tr>'+
719
- '<td><a href="#" data-action="decrementHour"><i class="fa fa-chevron-down"></i></a></td>'+
720
- '<td class="separator"></td>'+
721
- '<td><a href="#" data-action="decrementMinute"><i class="fa fa-chevron-down"></i></a></td>'+
722
- (this.showSeconds ?
723
- '<td class="separator">&nbsp;</td>'+
724
- '<td><a href="#" data-action="decrementSecond"><i class="fa fa-chevron-down"></i></a></td>'
725
- : '') +
726
- (this.showMeridian ?
727
- '<td class="separator">&nbsp;</td>'+
728
- '<td><a href="#" data-action="toggleMeridian"><i class="fa fa-chevron-down"></i></a></td>'
729
- : '') +
730
- '</tr>'+
731
- '</table>';
732
-
733
- var template;
734
- switch(this.options.template) {
735
- case 'modal':
736
- template = '<div class="bootstrap-timepicker modal fade in" style="top: 30%; margin-top: 0;" data-backdrop="'+ (this.modalBackdrop ? 'true' : 'false') +'">'+
737
- '<div class="modal-dialog">'+
738
- '<div class="modal-content">'+
739
- '<div class="modal-header">'+
740
- '<a href="#" class="close" data-dismiss="modal">×</a>'+
741
- '<h3>Pick a Time</h3>'+
742
- '</div>'+
743
- '<div class="modal-content">'+
744
- templateContent +
745
- '</div>'+
746
- '<div class="modal-footer">'+
747
- '<a href="#" class="btn btn-primary" data-dismiss="modal">Ok</a>'+
748
- '</div>'+
749
- '</div>'+
750
- '</div>'+
751
- '</div>';
752
-
753
- break;
754
- case 'dropdown':
755
- template = '<div class="bootstrap-timepicker dropdown-menu">'+
756
- templateContent +
757
- '</div>';
758
- break;
759
-
760
- }
761
- return template;
762
- }
763
- };
764
-
765
-
766
- /* TIMEPICKER PLUGIN DEFINITION
767
- * =========================== */
768
-
769
- $.fn.timepicker = function (option) {
770
- return this.each(function () {
771
- var $this = $(this)
772
- , data = $this.data('timepicker')
773
- , options = typeof option == 'object' && option;
774
- if (!data) {
775
- $this.data('timepicker', (data = new Timepicker(this, options)));
776
- }
777
- if (typeof option == 'string') {
778
- data[option]();
779
- }
780
- })
781
- }
782
-
783
- $.fn.timepicker.defaults = {
784
- minuteStep: 15
785
- , secondStep: 15
786
- , disableFocus: false
787
- , defaultTime: 'current'
788
- , showSeconds: false
789
- , showInputs: true
790
- , showMeridian: true
791
- , template: 'dropdown'
792
- , modalBackdrop: false
793
- , templates: {} // set custom templates
794
- }
795
-
796
- $.fn.timepicker.Constructor = Timepicker
797
- }(window.jQuery);