active_frontend 13.3.0 → 14.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.fasterer.yml +19 -0
- data/.reek +27 -0
- data/.rubocop.yml +38 -0
- data/.scss-lint.yml +27 -0
- data/Rakefile +1 -1
- data/active_frontend.gemspec +21 -18
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/fonts/.DS_Store +0 -0
- data/app/assets/fonts/dripicons/.DS_Store +0 -0
- data/app/assets/fonts/dripicons/dripicons.woff +0 -0
- data/app/assets/fonts/fakt-pro/.DS_Store +0 -0
- data/app/assets/fonts/fakt-pro/fakt-pro-bold.woff +0 -0
- data/app/assets/fonts/fakt-pro/fakt-pro-normal.woff +0 -0
- data/app/assets/fonts/fakt-pro/fakt-pro-semibold.woff +0 -0
- data/app/assets/fonts/fakt-pro/fakt-pro-semilight.woff +0 -0
- data/app/assets/fonts/fakt-soft-pro/.DS_Store +0 -0
- data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-bold.woff +0 -0
- data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-normal.woff +0 -0
- data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-semibold.woff +0 -0
- data/app/assets/fonts/fakt-soft-pro/fakt-soft-pro-semilight.woff +0 -0
- data/app/assets/images/.DS_Store +0 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/placeholders/.DS_Store +0 -0
- data/app/assets/images/placeholders/camera-large.png +0 -0
- data/app/assets/images/placeholders/camera-small.png +0 -0
- data/app/assets/images/placeholders/camera.png +0 -0
- data/app/assets/images/placeholders/document-large.png +0 -0
- data/app/assets/images/placeholders/document-small.png +0 -0
- data/app/assets/images/placeholders/document.png +0 -0
- data/app/assets/images/placeholders/photo-large.png +0 -0
- data/app/assets/images/placeholders/{picture-small.png → photo-small.png} +0 -0
- data/app/assets/images/placeholders/photo.png +0 -0
- data/app/assets/images/placeholders/store-large.png +0 -0
- data/app/assets/images/placeholders/store-small.png +0 -0
- data/app/assets/images/placeholders/store.png +0 -0
- data/app/assets/images/placeholders/user-large.png +0 -0
- data/app/assets/images/placeholders/user-small.png +0 -0
- data/app/assets/images/placeholders/user.png +0 -0
- data/app/helpers/active_frontend_helper.rb +22 -37
- data/lib/.DS_Store +0 -0
- data/lib/active_frontend.rb +3 -4
- data/lib/active_frontend/.DS_Store +0 -0
- data/lib/active_frontend/version.rb +1 -1
- data/lib/generators/active_frontend/install_generator.rb +3 -3
- data/lib/generators/active_frontend/templates/install.js +35 -30
- data/lib/generators/active_frontend/templates/install.scss +55 -58
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/active_frontend.js +35 -30
- data/vendor/assets/javascripts/base/_affix.js +170 -0
- data/vendor/assets/javascripts/base/_alert.js +80 -0
- data/vendor/assets/javascripts/base/_animation.js +106 -0
- data/vendor/assets/javascripts/base/_button.js +123 -0
- data/vendor/assets/javascripts/base/_carousel.js +237 -0
- data/vendor/assets/javascripts/base/_collapse.js +200 -0
- data/vendor/assets/javascripts/base/_colorpicker.js +147 -0
- data/vendor/assets/javascripts/base/_datepicker.js +1411 -0
- data/vendor/assets/javascripts/base/_dropdown.js +154 -0
- data/vendor/assets/javascripts/base/_filepicker.js +235 -0
- data/vendor/assets/javascripts/base/_hoverdown.js +116 -0
- data/vendor/assets/javascripts/base/_layout.js +126 -0
- data/vendor/assets/javascripts/base/_list.js +103 -0
- data/vendor/assets/javascripts/{_modal.js → base/_modal.js} +170 -167
- data/vendor/assets/javascripts/base/_popover.js +101 -0
- data/vendor/assets/javascripts/base/_scrollspy.js +161 -0
- data/vendor/assets/javascripts/base/_switch.js +160 -0
- data/vendor/assets/javascripts/base/_tab.js +139 -0
- data/vendor/assets/javascripts/base/_table.js +224 -0
- data/vendor/assets/javascripts/base/_timeago.js +270 -0
- data/vendor/assets/javascripts/base/_timepicker.js +541 -0
- data/vendor/assets/javascripts/base/_tooltip.js +525 -0
- data/vendor/assets/javascripts/base/_tour.js +268 -0
- data/vendor/assets/javascripts/base/_transition.js +52 -0
- data/vendor/assets/javascripts/base/_typeahead.js +362 -0
- data/vendor/assets/javascripts/extensions/_calendar.js +4709 -0
- data/vendor/assets/javascripts/extensions/_chart.js +9371 -0
- data/vendor/assets/javascripts/extensions/_map.js +2153 -0
- data/vendor/assets/stylesheets/.DS_Store +0 -0
- data/vendor/assets/stylesheets/{_mixin.scss → _utility.scss} +96 -10
- data/vendor/assets/stylesheets/_variable.scss +201 -19
- data/vendor/assets/stylesheets/active_frontend.scss +55 -58
- data/vendor/assets/stylesheets/blocks/_anchor.scss +15 -0
- data/vendor/assets/stylesheets/blocks/_button.scss +278 -0
- data/vendor/assets/stylesheets/blocks/_code.scss +144 -0
- data/vendor/assets/stylesheets/blocks/_common.scss +127 -0
- data/vendor/assets/stylesheets/blocks/_form.scss +508 -0
- data/vendor/assets/stylesheets/blocks/_icon.scss +359 -0
- data/vendor/assets/stylesheets/blocks/_list.scss +76 -0
- data/vendor/assets/stylesheets/blocks/_multimedia.scss +62 -0
- data/vendor/assets/stylesheets/blocks/_reset.scss +179 -0
- data/vendor/assets/stylesheets/blocks/_table.scss +211 -0
- data/vendor/assets/stylesheets/blocks/_typography.scss +204 -0
- data/vendor/assets/stylesheets/components/_ad.scss +78 -0
- data/vendor/assets/stylesheets/components/_affix.scss +14 -0
- data/vendor/assets/stylesheets/components/_alert.scss +50 -0
- data/vendor/assets/stylesheets/components/_animation.scss +1670 -0
- data/vendor/assets/stylesheets/components/_breadcrumb.scss +17 -0
- data/vendor/assets/stylesheets/components/_calendar.scss +213 -0
- data/vendor/assets/stylesheets/components/_card.scss +30 -0
- data/vendor/assets/stylesheets/components/_carousel.scss +135 -0
- data/vendor/assets/stylesheets/components/_chart.scss +10 -0
- data/vendor/assets/stylesheets/components/_collapse.scss +17 -0
- data/vendor/assets/stylesheets/components/_colorpicker.scss +38 -0
- data/vendor/assets/stylesheets/components/_datepicker.scss +80 -0
- data/vendor/assets/stylesheets/components/_dropmenu.scss +151 -0
- data/vendor/assets/stylesheets/components/_footer.scss +11 -0
- data/vendor/assets/stylesheets/components/_grid.scss +144 -0
- data/vendor/assets/stylesheets/components/_header.scss +99 -0
- data/vendor/assets/stylesheets/components/_label_and_badge.scss +57 -0
- data/vendor/assets/stylesheets/components/_layout.scss +63 -0
- data/vendor/assets/stylesheets/components/_map.scss +14 -0
- data/vendor/assets/stylesheets/components/_milestone.scss +49 -0
- data/vendor/assets/stylesheets/components/_missive.scss +40 -0
- data/vendor/assets/stylesheets/components/_modal.scss +126 -0
- data/vendor/assets/stylesheets/components/_nav_and_tab.scss +202 -0
- data/vendor/assets/stylesheets/components/_navbar.scss +66 -0
- data/vendor/assets/stylesheets/components/_pagination.scss +79 -0
- data/vendor/assets/stylesheets/components/_placeholder.scss +23 -0
- data/vendor/assets/stylesheets/components/_popover.scss +167 -0
- data/vendor/assets/stylesheets/components/_progress.scss +62 -0
- data/vendor/assets/stylesheets/components/_sidebar.scss +74 -0
- data/vendor/assets/stylesheets/components/_spinner.scss +83 -0
- data/vendor/assets/stylesheets/components/_switch.scss +150 -0
- data/vendor/assets/stylesheets/components/_timepicker.scss +30 -0
- data/vendor/assets/stylesheets/components/_tooltip.scss +93 -0
- data/vendor/assets/stylesheets/components/_transition.scss +12 -0
- data/vendor/assets/stylesheets/components/_typeahead.scss +18 -0
- metadata +150 -94
- data/app/assets/fonts/gotham/gotham-bold.woff +0 -0
- data/app/assets/fonts/gotham/gotham-book.woff +0 -0
- data/app/assets/fonts/gotham/gotham-light.woff +0 -0
- data/app/assets/fonts/gotham/gotham-medium.woff +0 -0
- data/app/assets/fonts/gotham/gotham-rounded-bold.woff +0 -0
- data/app/assets/fonts/gotham/gotham-rounded-book.woff +0 -0
- data/app/assets/fonts/gotham/gotham-rounded-light.woff +0 -0
- data/app/assets/fonts/gotham/gotham-rounded-medium.woff +0 -0
- data/app/assets/images/placeholders/archive-large.png +0 -0
- data/app/assets/images/placeholders/archive-small.png +0 -0
- data/app/assets/images/placeholders/archive.png +0 -0
- data/app/assets/images/placeholders/picture-large.png +0 -0
- data/app/assets/images/placeholders/picture.png +0 -0
- data/vendor/assets/javascripts/_affix.js +0 -153
- data/vendor/assets/javascripts/_alert.js +0 -85
- data/vendor/assets/javascripts/_animation.js +0 -103
- data/vendor/assets/javascripts/_button.js +0 -107
- data/vendor/assets/javascripts/_carousel.js +0 -228
- data/vendor/assets/javascripts/_chart.js +0 -3742
- data/vendor/assets/javascripts/_collapse.js +0 -202
- data/vendor/assets/javascripts/_color_picker.js +0 -108
- data/vendor/assets/javascripts/_date_picker.js +0 -1650
- data/vendor/assets/javascripts/_dropdown.js +0 -156
- data/vendor/assets/javascripts/_file_input.js +0 -71
- data/vendor/assets/javascripts/_hoverdown.js +0 -109
- data/vendor/assets/javascripts/_inputmask.js +0 -341
- data/vendor/assets/javascripts/_loader.js +0 -361
- data/vendor/assets/javascripts/_map.js +0 -2401
- data/vendor/assets/javascripts/_popover.js +0 -99
- data/vendor/assets/javascripts/_scrollspy.js +0 -163
- data/vendor/assets/javascripts/_slider.js +0 -1572
- data/vendor/assets/javascripts/_sort.js +0 -1432
- data/vendor/assets/javascripts/_swoggle.js +0 -415
- data/vendor/assets/javascripts/_tab.js +0 -146
- data/vendor/assets/javascripts/_tablespy.js +0 -1883
- data/vendor/assets/javascripts/_time_ago.js +0 -206
- data/vendor/assets/javascripts/_time_picker.js +0 -1088
- data/vendor/assets/javascripts/_tooltip.js +0 -504
- data/vendor/assets/javascripts/_transition.js +0 -50
- data/vendor/assets/javascripts/_typeahead.js +0 -366
- data/vendor/assets/stylesheets/_ad.scss +0 -63
- data/vendor/assets/stylesheets/_affix.scss +0 -14
- data/vendor/assets/stylesheets/_alert.scss +0 -114
- data/vendor/assets/stylesheets/_animation.scss +0 -1370
- data/vendor/assets/stylesheets/_breadcrumb.scss +0 -100
- data/vendor/assets/stylesheets/_button.scss +0 -386
- data/vendor/assets/stylesheets/_canvas.scss +0 -182
- data/vendor/assets/stylesheets/_carousel.scss +0 -158
- data/vendor/assets/stylesheets/_chart.scss +0 -15
- data/vendor/assets/stylesheets/_code.scss +0 -150
- data/vendor/assets/stylesheets/_collapse.scss +0 -14
- data/vendor/assets/stylesheets/_color.scss +0 -55
- data/vendor/assets/stylesheets/_colorpicker.scss +0 -63
- data/vendor/assets/stylesheets/_datepicker.scss +0 -122
- data/vendor/assets/stylesheets/_dropdown.scss +0 -248
- data/vendor/assets/stylesheets/_footer.scss +0 -71
- data/vendor/assets/stylesheets/_form.scss +0 -661
- data/vendor/assets/stylesheets/_grid.scss +0 -184
- data/vendor/assets/stylesheets/_header.scss +0 -156
- data/vendor/assets/stylesheets/_icon.scss +0 -362
- data/vendor/assets/stylesheets/_image.scss +0 -33
- data/vendor/assets/stylesheets/_label_and_badge.scss +0 -104
- data/vendor/assets/stylesheets/_link.scss +0 -55
- data/vendor/assets/stylesheets/_list.scss +0 -122
- data/vendor/assets/stylesheets/_loader.scss +0 -71
- data/vendor/assets/stylesheets/_map.scss +0 -44
- data/vendor/assets/stylesheets/_missive.scss +0 -74
- data/vendor/assets/stylesheets/_modal.scss +0 -204
- data/vendor/assets/stylesheets/_nav_and_tab.scss +0 -230
- data/vendor/assets/stylesheets/_navbar.scss +0 -73
- data/vendor/assets/stylesheets/_pagination.scss +0 -79
- data/vendor/assets/stylesheets/_panel.scss +0 -80
- data/vendor/assets/stylesheets/_placeholder.scss +0 -63
- data/vendor/assets/stylesheets/_popover.scss +0 -128
- data/vendor/assets/stylesheets/_progress.scss +0 -86
- data/vendor/assets/stylesheets/_reset.scss +0 -140
- data/vendor/assets/stylesheets/_sidebar.scss +0 -148
- data/vendor/assets/stylesheets/_slider.scss +0 -151
- data/vendor/assets/stylesheets/_spinner.scss +0 -572
- data/vendor/assets/stylesheets/_subheader.scss +0 -112
- data/vendor/assets/stylesheets/_swoggle.scss +0 -120
- data/vendor/assets/stylesheets/_table.scss +0 -210
- data/vendor/assets/stylesheets/_timepicker.scss +0 -77
- data/vendor/assets/stylesheets/_toolbar.scss +0 -130
- data/vendor/assets/stylesheets/_tooltip.scss +0 -105
- data/vendor/assets/stylesheets/_transition.scss +0 -11
- data/vendor/assets/stylesheets/_trunk.scss +0 -147
- data/vendor/assets/stylesheets/_typeahead.scss +0 -18
- data/vendor/assets/stylesheets/_typography.scss +0 -233
@@ -0,0 +1,541 @@
|
|
1
|
+
+function ($) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
// TIMEPICKER PUBLIC CLASS DEFINITION
|
5
|
+
// ==================================
|
6
|
+
|
7
|
+
var Timepicker = function (element, options) {
|
8
|
+
this.$element = $(element);
|
9
|
+
this.options = $.extend({}, Timepicker.DEFAULTS, options);
|
10
|
+
|
11
|
+
this.$active = false;
|
12
|
+
this.$widget = $(this.initWidget()).on('click', $.proxy(this.clickWidget, this));
|
13
|
+
|
14
|
+
this.init();
|
15
|
+
};
|
16
|
+
|
17
|
+
Timepicker.VERSION = '1.0.0';
|
18
|
+
Timepicker.DEFAULTS = {
|
19
|
+
menu: '<div class="timepicker dropmenu caret"></div>',
|
20
|
+
meridian: true,
|
21
|
+
seconds: false,
|
22
|
+
step: 5,
|
23
|
+
text: {
|
24
|
+
am: 'AM',
|
25
|
+
pm: 'PM'
|
26
|
+
},
|
27
|
+
time: 'current'
|
28
|
+
};
|
29
|
+
|
30
|
+
Timepicker.prototype.constructor = Timepicker;
|
31
|
+
|
32
|
+
Timepicker.prototype.init = function () {
|
33
|
+
this.$element.on({
|
34
|
+
'focus.bs.timepicker': $.proxy(this.showWidget, this),
|
35
|
+
'click.bs.timepicker': $.proxy(this.showWidget, this),
|
36
|
+
'blur.bs.timepicker': $.proxy(this.setVal, this)
|
37
|
+
});
|
38
|
+
|
39
|
+
this.setDefaultTime(this.options.time);
|
40
|
+
};
|
41
|
+
|
42
|
+
Timepicker.prototype.clickWidget = function (e) {
|
43
|
+
e.stopPropagation();
|
44
|
+
e.preventDefault();
|
45
|
+
|
46
|
+
var $input = $(e.target);
|
47
|
+
var action = $input.closest('a').data('action');
|
48
|
+
|
49
|
+
if (action) this[action]();
|
50
|
+
|
51
|
+
this.update();
|
52
|
+
|
53
|
+
if ($input.is('input')) $input.get(0).setSelectionRange(0,2);
|
54
|
+
};
|
55
|
+
|
56
|
+
Timepicker.prototype.initWidget = function () {
|
57
|
+
var contentTemplate = '<table>' +
|
58
|
+
'<tr>' +
|
59
|
+
'<td><a href="#" data-action="incrementHour"><i class="icon-chevron-up"></i></a></td>' +
|
60
|
+
'<td class="separator"> </td>' +
|
61
|
+
'<td><a href="#" data-action="incrementMinute"><i class="icon-chevron-up"></i></a></td>' +
|
62
|
+
(this.options.seconds ?
|
63
|
+
'<td class="separator"> </td>' +
|
64
|
+
'<td><a href="#" data-action="incrementSecond"><i class="icon-chevron-up"></i></a></td>'
|
65
|
+
: '') +
|
66
|
+
(this.options.meridian ?
|
67
|
+
'<td class="separator"> </td>' +
|
68
|
+
'<td class="meridian-column"><a href="#" data-action="toggleMeridian"><i class="icon-chevron-up"></i></a></td>' :
|
69
|
+
'') +
|
70
|
+
'</tr>' +
|
71
|
+
'<tr>' +
|
72
|
+
'<td><span class="timepicker-hour"></span></td>' +
|
73
|
+
'<td class="separator">:</td>' +
|
74
|
+
'<td><span class="timepicker-minute"></span></td>' +
|
75
|
+
(this.options.seconds ?
|
76
|
+
'<td class="separator">:</td>' +
|
77
|
+
'<td><span class="timepicker-second"></span></td>' :
|
78
|
+
'') +
|
79
|
+
(this.options.meridian ?
|
80
|
+
'<td class="separator"> </td>' +
|
81
|
+
'<td><span class="timepicker-meridian"></span></td>' :
|
82
|
+
'') +
|
83
|
+
'</tr>' +
|
84
|
+
'<tr>' +
|
85
|
+
'<td><a href="#" data-action="decrementHour"><i class="icon-chevron-down"></i></a></td>' +
|
86
|
+
'<td class="separator"></td>' +
|
87
|
+
'<td><a href="#" data-action="decrementMinute"><i class="icon-chevron-down"></i></a></td>' +
|
88
|
+
(this.options.seconds ?
|
89
|
+
'<td class="separator"> </td>' +
|
90
|
+
'<td><a href="#" data-action="decrementSecond"><i class="icon-chevron-down"></i></a></td>' :
|
91
|
+
'') +
|
92
|
+
(this.options.meridian ?
|
93
|
+
'<td class="separator"> </td>' +
|
94
|
+
'<td><a href="#" data-action="toggleMeridian"><i class="icon-chevron-down"></i></a></td>' :
|
95
|
+
'') +
|
96
|
+
'</tr>' +
|
97
|
+
'</table>';
|
98
|
+
|
99
|
+
return $(this.options.menu).html(contentTemplate);
|
100
|
+
};
|
101
|
+
|
102
|
+
Timepicker.prototype.showWidget = function () {
|
103
|
+
if (this.$active) return;
|
104
|
+
if (this.$element.prop('disabled') || this.$element.prop('readonly')) return;
|
105
|
+
if (this.$widget.is(':visible')) return;
|
106
|
+
|
107
|
+
this.$container = $('<span>')
|
108
|
+
.addClass('btn-group dropdown open bsTimepicker')
|
109
|
+
.css({
|
110
|
+
height: 0,
|
111
|
+
position: 'absolute',
|
112
|
+
width: 0
|
113
|
+
});
|
114
|
+
|
115
|
+
this.$container.append(this.$widget);
|
116
|
+
this.$element.after(this.$container);
|
117
|
+
this.$active = true;
|
118
|
+
|
119
|
+
var _self = this;
|
120
|
+
$(document).on('mousedown.bs.timepicker, touchend.bs.timepicker', function (e) {
|
121
|
+
if (!(_self.$element.parent().find(e.target).length ||
|
122
|
+
_self.$widget.is(e.target) ||
|
123
|
+
_self.$widget.find(e.target).length)) {
|
124
|
+
_self.hideWidget();
|
125
|
+
}
|
126
|
+
});
|
127
|
+
|
128
|
+
this.$element.trigger({
|
129
|
+
type: 'show.bs.timepicker',
|
130
|
+
time: {
|
131
|
+
value: this.getTime(),
|
132
|
+
hours: this.hour,
|
133
|
+
minutes: this.minute,
|
134
|
+
seconds: this.second,
|
135
|
+
meridian: this.meridian
|
136
|
+
}
|
137
|
+
});
|
138
|
+
|
139
|
+
if (this.hour === '') {
|
140
|
+
if (this.options.time) {
|
141
|
+
this.setDefaultTime(this.options.time);
|
142
|
+
} else {
|
143
|
+
this.setTime('0:0:0');
|
144
|
+
}
|
145
|
+
}
|
146
|
+
};
|
147
|
+
|
148
|
+
Timepicker.prototype.hideWidget = function () {
|
149
|
+
if (!this.$active) return;
|
150
|
+
if (!this.$widget.is(':visible')) return;
|
151
|
+
|
152
|
+
this.$element.trigger({
|
153
|
+
type: 'hide.bs.timepicker',
|
154
|
+
time: {
|
155
|
+
value: this.getTime(),
|
156
|
+
hours: this.hour,
|
157
|
+
minutes: this.minute,
|
158
|
+
seconds: this.second,
|
159
|
+
meridian: this.meridian
|
160
|
+
}
|
161
|
+
});
|
162
|
+
|
163
|
+
$(document).off('mousedown.bs.timepicker, touchend.bs.timepicker');
|
164
|
+
this.$widget.detach();
|
165
|
+
this.$container.remove();
|
166
|
+
this.$active = false;
|
167
|
+
};
|
168
|
+
|
169
|
+
Timepicker.prototype.getTime = function () {
|
170
|
+
if (this.hour === '') return '';
|
171
|
+
|
172
|
+
return this.hour +
|
173
|
+
':' +
|
174
|
+
(this.minute.toString().length === 1 ? '0' + this.minute : this.minute) +
|
175
|
+
(this.options.seconds ? ':' + (this.second.toString().length === 1 ? '0' + this.second : this.second) : '') +
|
176
|
+
(this.options.meridian ? ' ' + this.meridian : '');
|
177
|
+
};
|
178
|
+
|
179
|
+
Timepicker.prototype.setDefaultTime = function (time) {
|
180
|
+
if (!this.$element.val()) {
|
181
|
+
if (time === 'current') {
|
182
|
+
var dTime = new Date();
|
183
|
+
var hours = dTime.getHours();
|
184
|
+
var minutes = dTime.getMinutes();
|
185
|
+
var seconds = dTime.getSeconds();
|
186
|
+
var meridian = this.options.text.am;
|
187
|
+
|
188
|
+
if (seconds !== 0) {
|
189
|
+
seconds = Math.ceil(dTime.getSeconds() / this.options.step) * this.options.step;
|
190
|
+
|
191
|
+
if (seconds === 60) {
|
192
|
+
minutes += 1;
|
193
|
+
seconds = 0;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
if (minutes !== 0) {
|
197
|
+
minutes = Math.ceil(dTime.getMinutes() / this.options.step) * this.options.step;
|
198
|
+
|
199
|
+
if (minutes === 60) {
|
200
|
+
hours += 1;
|
201
|
+
minutes = 0;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
if (this.options.meridian) {
|
205
|
+
if (hours === 0) {
|
206
|
+
hours = 12;
|
207
|
+
} else if (hours >= 12) {
|
208
|
+
if (hours > 12) {
|
209
|
+
hours = hours - 12;
|
210
|
+
}
|
211
|
+
meridian = this.options.text.pm;
|
212
|
+
} else {
|
213
|
+
meridian = this.options.text.am;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
this.hour = hours;
|
218
|
+
this.minute = minutes;
|
219
|
+
this.second = seconds;
|
220
|
+
this.meridian = meridian;
|
221
|
+
|
222
|
+
this.update();
|
223
|
+
|
224
|
+
} else if (time === false) {
|
225
|
+
this.hour = 0;
|
226
|
+
this.minute = 0;
|
227
|
+
this.second = 0;
|
228
|
+
this.meridian = this.options.text.am;
|
229
|
+
} else {
|
230
|
+
this.setTime(time);
|
231
|
+
}
|
232
|
+
} else {
|
233
|
+
this.setVal();
|
234
|
+
}
|
235
|
+
};
|
236
|
+
|
237
|
+
Timepicker.prototype.setTime = function (time, ignoreWidget) {
|
238
|
+
if (!time) {
|
239
|
+
this.clear();
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
|
243
|
+
var timeArray, hour, minute, second, meridian;
|
244
|
+
|
245
|
+
if (typeof time === 'object' && time.getMonth){
|
246
|
+
hour = time.getHours();
|
247
|
+
minute = time.getMinutes();
|
248
|
+
second = time.getSeconds();
|
249
|
+
|
250
|
+
if (this.options.meridian){
|
251
|
+
meridian = this.options.text.am;
|
252
|
+
|
253
|
+
if (hour > 12){
|
254
|
+
meridian = this.options.text.pm;
|
255
|
+
hour = hour % 12;
|
256
|
+
}
|
257
|
+
if (hour === 12){
|
258
|
+
meridian = this.options.text.pm;
|
259
|
+
}
|
260
|
+
}
|
261
|
+
} else {
|
262
|
+
if (time.match(/p/i) !== null) {
|
263
|
+
meridian = this.options.text.pm;
|
264
|
+
} else {
|
265
|
+
meridian = this.options.text.am;
|
266
|
+
}
|
267
|
+
|
268
|
+
time = time.replace(/[^0-9\:]/g, '');
|
269
|
+
timeArray = time.split(':');
|
270
|
+
|
271
|
+
hour = timeArray[0] ? timeArray[0].toString() : timeArray.toString();
|
272
|
+
minute = timeArray[1] ? timeArray[1].toString() : '';
|
273
|
+
second = timeArray[2] ? timeArray[2].toString() : '';
|
274
|
+
|
275
|
+
if (hour.length > 4) {
|
276
|
+
second = hour.substr(4, 2);
|
277
|
+
}
|
278
|
+
if (hour.length > 2) {
|
279
|
+
minute = hour.substr(2, 2);
|
280
|
+
hour = hour.substr(0, 2);
|
281
|
+
}
|
282
|
+
if (minute.length > 2) {
|
283
|
+
second = minute.substr(2, 2);
|
284
|
+
minute = minute.substr(0, 2);
|
285
|
+
}
|
286
|
+
if (second.length > 2) {
|
287
|
+
second = second.substr(2, 2);
|
288
|
+
}
|
289
|
+
|
290
|
+
hour = parseInt(hour, 10);
|
291
|
+
minute = parseInt(minute, 10);
|
292
|
+
second = parseInt(second, 10);
|
293
|
+
|
294
|
+
if (isNaN(hour)) {
|
295
|
+
hour = 0;
|
296
|
+
}
|
297
|
+
if (isNaN(minute)) {
|
298
|
+
minute = 0;
|
299
|
+
}
|
300
|
+
if (isNaN(second)) {
|
301
|
+
second = 0;
|
302
|
+
}
|
303
|
+
if (this.options.meridian) {
|
304
|
+
if (hour < 1) {
|
305
|
+
hour = 1;
|
306
|
+
} else if (hour > 12) {
|
307
|
+
hour = 12;
|
308
|
+
}
|
309
|
+
} else {
|
310
|
+
if (hour >= 24) {
|
311
|
+
hour = 23;
|
312
|
+
} else if (hour < 0) {
|
313
|
+
hour = 0;
|
314
|
+
}
|
315
|
+
if (hour < 13 && meridian === this.options.text.pm) {
|
316
|
+
hour = hour + 12;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
if (minute < 0) {
|
320
|
+
minute = 0;
|
321
|
+
} else if (minute >= 60) {
|
322
|
+
minute = 59;
|
323
|
+
}
|
324
|
+
if (this.options.seconds) {
|
325
|
+
if (isNaN(second)) {
|
326
|
+
second = 0;
|
327
|
+
} else if (second < 0) {
|
328
|
+
second = 0;
|
329
|
+
} else if (second >= 60) {
|
330
|
+
second = 59;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
|
335
|
+
this.hour = hour;
|
336
|
+
this.minute = minute;
|
337
|
+
this.second = second;
|
338
|
+
this.meridian = meridian;
|
339
|
+
|
340
|
+
this.update(ignoreWidget);
|
341
|
+
};
|
342
|
+
|
343
|
+
Timepicker.prototype.setVal = function () {
|
344
|
+
this.setTime(this.$element.val());
|
345
|
+
};
|
346
|
+
|
347
|
+
Timepicker.prototype.clear = function () {
|
348
|
+
this.hour = '';
|
349
|
+
this.minute = '';
|
350
|
+
this.second = '';
|
351
|
+
this.meridian = '';
|
352
|
+
|
353
|
+
this.$element.val('');
|
354
|
+
};
|
355
|
+
|
356
|
+
Timepicker.prototype.toggleMeridian = function () {
|
357
|
+
this.meridian = this.meridian === this.options.text.am ?
|
358
|
+
this.options.text.pm :
|
359
|
+
this.options.text.am;
|
360
|
+
};
|
361
|
+
|
362
|
+
Timepicker.prototype.decrementHour = function () {
|
363
|
+
if (this.options.meridian) {
|
364
|
+
if (this.hour === 1) {
|
365
|
+
this.hour = 12;
|
366
|
+
} else if (this.hour === 12) {
|
367
|
+
this.hour--;
|
368
|
+
return this.toggleMeridian();
|
369
|
+
} else if (this.hour === 0) {
|
370
|
+
this.hour = 11;
|
371
|
+
return this.toggleMeridian();
|
372
|
+
} else {
|
373
|
+
this.hour--;
|
374
|
+
}
|
375
|
+
} else {
|
376
|
+
if (this.hour <= 0) {
|
377
|
+
this.hour = 23;
|
378
|
+
} else {
|
379
|
+
this.hour--;
|
380
|
+
}
|
381
|
+
}
|
382
|
+
};
|
383
|
+
|
384
|
+
Timepicker.prototype.decrementMinute = function (step) {
|
385
|
+
var newVal;
|
386
|
+
|
387
|
+
if (step) {
|
388
|
+
newVal = this.minute - step;
|
389
|
+
} else {
|
390
|
+
newVal = this.minute - this.options.step;
|
391
|
+
}
|
392
|
+
|
393
|
+
if (newVal < 0) {
|
394
|
+
this.decrementHour();
|
395
|
+
this.minute = newVal + 60;
|
396
|
+
} else {
|
397
|
+
this.minute = newVal;
|
398
|
+
}
|
399
|
+
};
|
400
|
+
|
401
|
+
Timepicker.prototype.decrementSecond = function () {
|
402
|
+
var newVal = this.second - this.options.step;
|
403
|
+
|
404
|
+
if (newVal < 0) {
|
405
|
+
this.decrementMinute(true);
|
406
|
+
this.second = newVal + 60;
|
407
|
+
} else {
|
408
|
+
this.second = newVal;
|
409
|
+
}
|
410
|
+
};
|
411
|
+
|
412
|
+
Timepicker.prototype.incrementHour = function () {
|
413
|
+
if (this.options.meridian) {
|
414
|
+
if (this.hour === 11) {
|
415
|
+
this.hour++;
|
416
|
+
return this.toggleMeridian();
|
417
|
+
} else if (this.hour === 12) {
|
418
|
+
this.hour = 0;
|
419
|
+
}
|
420
|
+
}
|
421
|
+
if (this.hour === 23) {
|
422
|
+
this.hour = 0;
|
423
|
+
return;
|
424
|
+
}
|
425
|
+
|
426
|
+
this.hour++;
|
427
|
+
};
|
428
|
+
|
429
|
+
Timepicker.prototype.incrementMinute = function (step) {
|
430
|
+
var newVal;
|
431
|
+
|
432
|
+
if (step) {
|
433
|
+
newVal = this.minute + step;
|
434
|
+
} else {
|
435
|
+
newVal = this.minute + this.options.step - (this.minute % this.options.step);
|
436
|
+
}
|
437
|
+
if (newVal > 59) {
|
438
|
+
this.incrementHour();
|
439
|
+
this.minute = newVal - 60;
|
440
|
+
} else {
|
441
|
+
this.minute = newVal;
|
442
|
+
}
|
443
|
+
};
|
444
|
+
|
445
|
+
Timepicker.prototype.incrementSecond = function () {
|
446
|
+
var newVal = this.second + this.options.step - (this.second % this.options.step);
|
447
|
+
|
448
|
+
if (newVal > 59) {
|
449
|
+
this.incrementMinute(true);
|
450
|
+
this.second = newVal - 60;
|
451
|
+
} else {
|
452
|
+
this.second = newVal;
|
453
|
+
}
|
454
|
+
};
|
455
|
+
|
456
|
+
Timepicker.prototype.update = function (ignoreWidget) {
|
457
|
+
this.updateElement();
|
458
|
+
|
459
|
+
if (!ignoreWidget) this.updateWidget();
|
460
|
+
|
461
|
+
this.$element.trigger({
|
462
|
+
type: 'change.bs.timepicker',
|
463
|
+
time: {
|
464
|
+
value: this.getTime(),
|
465
|
+
hours: this.hour,
|
466
|
+
minutes: this.minute,
|
467
|
+
seconds: this.second,
|
468
|
+
meridian: this.meridian
|
469
|
+
}
|
470
|
+
});
|
471
|
+
};
|
472
|
+
|
473
|
+
Timepicker.prototype.updateElement = function () {
|
474
|
+
this.$element
|
475
|
+
.val(this.getTime())
|
476
|
+
.change();
|
477
|
+
};
|
478
|
+
|
479
|
+
Timepicker.prototype.updateWidget = function () {
|
480
|
+
if (this.$widget === false) return;
|
481
|
+
|
482
|
+
var hour = this.hour;
|
483
|
+
var minute = this.minute.toString().length === 1 ? '0' + this.minute : this.minute;
|
484
|
+
var second = this.second.toString().length === 1 ? '0' + this.second : this.second;
|
485
|
+
|
486
|
+
this.$widget.find('span.timepicker-hour').text(hour);
|
487
|
+
this.$widget.find('span.timepicker-minute').text(minute);
|
488
|
+
|
489
|
+
if (this.options.seconds) this.$widget.find('span.timepicker-second').text(second);
|
490
|
+
if (this.options.meridian) this.$widget.find('span.timepicker-meridian').text(this.meridian);
|
491
|
+
};
|
492
|
+
|
493
|
+
Timepicker.prototype.updateFromWidgetInputs = function () {
|
494
|
+
if (this.$widget === false) return;
|
495
|
+
|
496
|
+
var time = this.$widget.find('input.timepicker-hour').val() +
|
497
|
+
':' +
|
498
|
+
this.$widget.find('input.timepicker-minute').val() +
|
499
|
+
(this.options.seconds ? ':' + this.$widget.find('input.timepicker-second').val() : '') +
|
500
|
+
(this.options.meridian ? this.$widget.find('input.timepicker-meridian').val() : '');
|
501
|
+
|
502
|
+
this.setTime(time, true);
|
503
|
+
};
|
504
|
+
|
505
|
+
// TIMEPICKER PLUGIN DEFINITION
|
506
|
+
// ============================
|
507
|
+
|
508
|
+
function Plugin(option) {
|
509
|
+
return this.each(function () {
|
510
|
+
var $this = $(this);
|
511
|
+
var data = $this.data('bs.timepicker');
|
512
|
+
var options = typeof option === 'object' && option;
|
513
|
+
|
514
|
+
if (!data) $this.data('bs.timepicker', (data = new Timepicker(this, options)));
|
515
|
+
if (typeof option === 'string') data[option]();
|
516
|
+
});
|
517
|
+
}
|
518
|
+
|
519
|
+
var old = $.fn.timepicker;
|
520
|
+
|
521
|
+
$.fn.timepicker = Plugin;
|
522
|
+
$.fn.timepicker.Constructor = Timepicker;
|
523
|
+
|
524
|
+
// TIMEPICKER NO CONFLICT
|
525
|
+
// ======================
|
526
|
+
|
527
|
+
$.fn.timepicker.noConflict = function () {
|
528
|
+
$.fn.timepicker = old;
|
529
|
+
return this;
|
530
|
+
};
|
531
|
+
|
532
|
+
// TIMEPICKER DATA-API
|
533
|
+
// ===================
|
534
|
+
|
535
|
+
$(document).on('focus.bs.timepicker.data-api click.bs.timepicker.data-api', '[data-toggle="timepicker"]', function (e) {
|
536
|
+
var $this = $(this);
|
537
|
+
if ($this.data('timepicker')) return;
|
538
|
+
Plugin.call($this, $this.data());
|
539
|
+
});
|
540
|
+
|
541
|
+
}(jQuery);
|