jquery-timepicker-rails 1.2.5.0 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +3 -3
- data/jquery-timepicker-rails.gemspec +2 -2
- data/lib/jquery-timepicker-rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.datepair.js +305 -0
- data/vendor/assets/javascripts/jquery.timepicker.js +206 -94
- data/vendor/assets/stylesheets/jquery.timepicker.css +67 -67
- metadata +17 -24
- data/vendor/assets/javascripts/datepair.js +0 -226
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 05a01eddbe0f274448f77ffaa36ada2bc2f75b00
|
4
|
+
data.tar.gz: d52cfce42dfa37d144f673fb90d54c468b870926
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d8021357d8803771eaec9cddb5e42685ba8f340166b0bc7c9c2d0a84b4ac00fca0e2c383b770575b70fa47bd7167dd238a7a152d5a31c233867ef8037ca3920a
|
7
|
+
data.tar.gz: cb87077aac414733be31d7d900de65f2a7819198ecc0e50bcfdc41f52a6163a72a897677b70a8b9b036e9c1b8c08f1a5ea981bb98496725525d211834760b1cb
|
data/README.md
CHANGED
@@ -27,9 +27,9 @@ Add the following stylesheet file to `app/assets/stylesheets/application.css`:
|
|
27
27
|
|
28
28
|
*= require jquery.timepicker.css
|
29
29
|
|
30
|
-
Optionally, you can also use `datepair.js`:
|
30
|
+
Optionally, you can also use `jquery.datepair.js`:
|
31
31
|
|
32
|
-
//= require datepair.js
|
32
|
+
//= require jquery.datepair.js
|
33
33
|
|
34
34
|
Most people will prefer to copy-paste this file in order to customize it.
|
35
35
|
|
@@ -39,4 +39,4 @@ jquery-timepicker depends on jQuery and [bootstrap-datepicker](http://github.com
|
|
39
39
|
|
40
40
|
jquery-timepicker is being developed by [Jon Thornton](http://jonthornton.com/) and is under [MIT license](http://en.wikipedia.org/wiki/MIT_License).
|
41
41
|
|
42
|
-
This gem is also licensed under [MIT license](https://raw.github.com/tkrotoff/jquery-timepicker-rails/master/LICENSE).
|
42
|
+
This gem is also licensed under [MIT license](https://raw.github.com/tkrotoff/jquery-timepicker-rails/master/LICENSE.txt).
|
@@ -6,11 +6,11 @@ require 'jquery-timepicker-rails/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "jquery-timepicker-rails"
|
8
8
|
spec.version = Jquery::Timepicker::Rails::VERSION
|
9
|
-
spec.authors = ["Tanguy Krotoff (jQuery plugin by Jon Thornton)"]
|
9
|
+
spec.authors = ["Tanguy Krotoff (jQuery plugin by Jon Thornton)", "Fabio Cantoni"]
|
10
10
|
spec.email = ["tkrotoff@gmail.com"]
|
11
11
|
spec.description = %q{A jQuery timepicker plugin inspired by Google Calendar}
|
12
12
|
spec.summary = %q{jquery-timepicker packaged for the Rails 3.1+ asset pipeline}
|
13
|
-
spec.homepage = "
|
13
|
+
spec.homepage = "https://github.com/cover/jquery-timepicker-rails"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
@@ -0,0 +1,305 @@
|
|
1
|
+
/************************
|
2
|
+
jquery-datepair v1.2.13
|
3
|
+
http://jonthornton.github.com/jquery-datepair/
|
4
|
+
|
5
|
+
requires jQuery 1.7+
|
6
|
+
************************/
|
7
|
+
|
8
|
+
|
9
|
+
(function (factory) {
|
10
|
+
if (typeof define === 'function' && define.amd) {
|
11
|
+
// AMD. Register as an anonymous module.
|
12
|
+
define(['jquery'], factory);
|
13
|
+
} else {
|
14
|
+
// Browser globals
|
15
|
+
factory(jQuery);
|
16
|
+
}
|
17
|
+
}(function ($) {
|
18
|
+
var _ONE_DAY = 86400000;
|
19
|
+
var _defaults = {
|
20
|
+
startClass: 'start',
|
21
|
+
endClass: 'end',
|
22
|
+
timeClass: 'time',
|
23
|
+
dateClass: 'date',
|
24
|
+
defaultDateDelta: 0,
|
25
|
+
defaultTimeDelta: 3600000,
|
26
|
+
parseTime: function($input){
|
27
|
+
return $input.timepicker('getTime');
|
28
|
+
},
|
29
|
+
updateTime: function($input, dateObj){
|
30
|
+
$input.timepicker('setTime', dateObj);
|
31
|
+
},
|
32
|
+
parseDate: function($input){
|
33
|
+
return $input.datepicker('getDate');
|
34
|
+
},
|
35
|
+
updateDate: function($input, dateObj){
|
36
|
+
$input.datepicker('update', dateObj);
|
37
|
+
},
|
38
|
+
setMinTime: function($input, dateObj){
|
39
|
+
$input.timepicker('option', 'minTime', dateObj);
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
var methods =
|
44
|
+
{
|
45
|
+
init: function(options)
|
46
|
+
{
|
47
|
+
return this.each(function()
|
48
|
+
{
|
49
|
+
var $self = $(this);
|
50
|
+
|
51
|
+
var settings = $.extend({}, _defaults);
|
52
|
+
|
53
|
+
if (options) {
|
54
|
+
settings = $.extend(settings, options);
|
55
|
+
}
|
56
|
+
|
57
|
+
settings = _parseSettings(settings);
|
58
|
+
|
59
|
+
$self.data('datepair-settings', settings);
|
60
|
+
_bindChangeHandler($self);
|
61
|
+
|
62
|
+
// initialize datepair-datedelta
|
63
|
+
var $startDateInput = _getStartDateInput($self);
|
64
|
+
var $endDateInput = _getEndDateInput($self);
|
65
|
+
|
66
|
+
if ($startDateInput.val() && $endDateInput.val()) {
|
67
|
+
var startDate = settings.parseDate($startDateInput);
|
68
|
+
var endDate = settings.parseDate($endDateInput);
|
69
|
+
$self.data('datepair-datedelta', endDate.getTime() - startDate.getTime());
|
70
|
+
}
|
71
|
+
|
72
|
+
// initialize datepair-timedelta
|
73
|
+
var $startTimeInput = _getStartTimeInput($self);
|
74
|
+
var $endTimeInput = _getEndTimeInput($self);
|
75
|
+
|
76
|
+
if ($startTimeInput.val() && $endTimeInput.val()) {
|
77
|
+
var startTime = settings.parseTime($startTimeInput);
|
78
|
+
var endTime = settings.parseTime($endTimeInput);
|
79
|
+
$self.data('datepair-timedelta', endTime.getTime() - startTime.getTime());
|
80
|
+
}
|
81
|
+
|
82
|
+
_updateEndMintime($self);
|
83
|
+
});
|
84
|
+
},
|
85
|
+
|
86
|
+
option: function(key, value)
|
87
|
+
{
|
88
|
+
var self = this;
|
89
|
+
var settings = self.data('datepair-settings');
|
90
|
+
|
91
|
+
if (typeof key == 'object') {
|
92
|
+
settings = $.extend(settings, key);
|
93
|
+
|
94
|
+
} else if (typeof key == 'string' && typeof value != 'undefined') {
|
95
|
+
settings[key] = value;
|
96
|
+
|
97
|
+
} else if (typeof key == 'string') {
|
98
|
+
return settings[key];
|
99
|
+
}
|
100
|
+
|
101
|
+
settings = _parseSettings(settings);
|
102
|
+
|
103
|
+
self.data('datepair-settings', settings);
|
104
|
+
|
105
|
+
return self;
|
106
|
+
},
|
107
|
+
|
108
|
+
remove: function()
|
109
|
+
{
|
110
|
+
var self = this;
|
111
|
+
self.removeData('datepair-settings');
|
112
|
+
self.off('.timepicker');
|
113
|
+
}
|
114
|
+
};
|
115
|
+
|
116
|
+
// private methods
|
117
|
+
|
118
|
+
function _parseSettings(settings)
|
119
|
+
{
|
120
|
+
// if (settings.startClass) {
|
121
|
+
// settings.minTime = _time2int(settings.minTime);
|
122
|
+
// }
|
123
|
+
|
124
|
+
return settings;
|
125
|
+
}
|
126
|
+
|
127
|
+
function _bindChangeHandler($self)
|
128
|
+
{
|
129
|
+
$self.on('change.datepair', null, _inputChanged);
|
130
|
+
}
|
131
|
+
|
132
|
+
function _unbindChangeHandler($self)
|
133
|
+
{
|
134
|
+
$self.off('change.datepair');
|
135
|
+
}
|
136
|
+
|
137
|
+
function _inputChanged(e)
|
138
|
+
{
|
139
|
+
var $self = $(this);
|
140
|
+
|
141
|
+
// temporarily unbind the change handler to prevent triggering this
|
142
|
+
// if we update other inputs
|
143
|
+
_unbindChangeHandler($self);
|
144
|
+
|
145
|
+
var settings = $self.data('datepair-settings');
|
146
|
+
var $target = $(e.target);
|
147
|
+
|
148
|
+
if ($target.val() != '') {
|
149
|
+
if ($target.hasClass(settings.dateClass)) {
|
150
|
+
_dateChanged($self, $target);
|
151
|
+
|
152
|
+
} else if ($target.hasClass(settings.timeClass)) {
|
153
|
+
_timeChanged($self, $target);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
_bindChangeHandler($self);
|
158
|
+
}
|
159
|
+
|
160
|
+
function _getStartDateInput($self)
|
161
|
+
{
|
162
|
+
var settings = $self.data('datepair-settings');
|
163
|
+
return $self.find('.'+settings.startClass+'.'+settings.dateClass);
|
164
|
+
}
|
165
|
+
|
166
|
+
function _getEndDateInput($self)
|
167
|
+
{
|
168
|
+
var settings = $self.data('datepair-settings');
|
169
|
+
return $self.find('.'+settings.endClass+'.'+settings.dateClass);
|
170
|
+
}
|
171
|
+
|
172
|
+
function _getStartTimeInput($self)
|
173
|
+
{
|
174
|
+
var settings = $self.data('datepair-settings');
|
175
|
+
return $self.find('.'+settings.startClass+'.'+settings.timeClass);
|
176
|
+
}
|
177
|
+
|
178
|
+
function _getEndTimeInput($self)
|
179
|
+
{
|
180
|
+
var settings = $self.data('datepair-settings');
|
181
|
+
return $self.find('.'+settings.endClass+'.'+settings.timeClass);
|
182
|
+
}
|
183
|
+
|
184
|
+
function _dateChanged($self, $target)
|
185
|
+
{
|
186
|
+
var settings = $self.data('datepair-settings');
|
187
|
+
|
188
|
+
var $startDateInput = _getStartDateInput($self);
|
189
|
+
var $endDateInput = _getEndDateInput($self);
|
190
|
+
|
191
|
+
if (!$startDateInput.val() || !$endDateInput.val()) {
|
192
|
+
if (settings.defaultDateDelta !== null) {
|
193
|
+
if ($startDateInput.val()) {
|
194
|
+
var startDate = settings.parseDate($startDateInput);
|
195
|
+
var newEnd = new Date(startDate.getTime() + settings.defaultDateDelta * _ONE_DAY);
|
196
|
+
settings.updateDate($endDateInput, newEnd);
|
197
|
+
} else if ($endDateInput.val()) {
|
198
|
+
var endDate = settings.parseDate($endDateInput);
|
199
|
+
var newStart = new Date(endDate.getTime() + settings.defaultDateDelta * _ONE_DAY);
|
200
|
+
settings.updateDate($startDateInput, newStart);
|
201
|
+
}
|
202
|
+
|
203
|
+
$self.data('datepair-datedelta', settings.defaultDateDelta * _ONE_DAY);
|
204
|
+
} else {
|
205
|
+
$self.data('datepair-datedelta', null);
|
206
|
+
}
|
207
|
+
|
208
|
+
_updateEndMintime($self);
|
209
|
+
return;
|
210
|
+
}
|
211
|
+
|
212
|
+
var startDate = settings.parseDate($startDateInput);
|
213
|
+
var endDate = settings.parseDate($endDateInput);
|
214
|
+
|
215
|
+
if ($target.hasClass(settings.startClass)) {
|
216
|
+
var newEndDate = new Date(startDate.getTime()+$self.data('datepair-datedelta'));
|
217
|
+
settings.updateDate($endDateInput, newEndDate);
|
218
|
+
} else if ($target.hasClass(settings.endClass)) {
|
219
|
+
if (endDate < startDate) {
|
220
|
+
$self.data('datepair-datedelta', 0);
|
221
|
+
settings.updateDate($startDateInput, endDate);
|
222
|
+
} else {
|
223
|
+
$self.data('datepair-datedelta', endDate.getTime() - startDate.getTime());
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
_updateEndMintime($self);
|
228
|
+
}
|
229
|
+
|
230
|
+
function _updateEndMintime($self)
|
231
|
+
{
|
232
|
+
var settings = $self.data('datepair-settings');
|
233
|
+
if (typeof settings.setMinTime != 'function') return;
|
234
|
+
|
235
|
+
var startTime;
|
236
|
+
if ($self.data('datepair-datedelta') <= _ONE_DAY || !$self.data('datepair-datedelta')) {
|
237
|
+
var $startTimeInput = _getStartTimeInput($self);
|
238
|
+
var startTime = settings.parseTime($startTimeInput);
|
239
|
+
}
|
240
|
+
|
241
|
+
var $endTimeInput = _getEndTimeInput($self);
|
242
|
+
settings.setMinTime($endTimeInput, startTime);
|
243
|
+
}
|
244
|
+
|
245
|
+
function _timeChanged($self, $target)
|
246
|
+
{
|
247
|
+
var settings = $self.data('datepair-settings');
|
248
|
+
|
249
|
+
var $startTimeInput = _getStartTimeInput($self);
|
250
|
+
var $endTimeInput = _getEndTimeInput($self);
|
251
|
+
|
252
|
+
if (!$startTimeInput.val() || !$endTimeInput.val()) {
|
253
|
+
if (settings.defaultTimeDelta !== null) {
|
254
|
+
if ($startTimeInput.val()) {
|
255
|
+
var startTime = settings.parseTime($startTimeInput);
|
256
|
+
var newEnd = new Date(startTime.getTime() + settings.defaultTimeDelta);
|
257
|
+
settings.updateTime($endTimeInput, newEnd);
|
258
|
+
} else if ($endTimeInput.val()) {
|
259
|
+
var endTime = settings.parseTime($endTimeInput);
|
260
|
+
var newStart = new Date(endDate.getTime() + settings.defaultTimeDelta);
|
261
|
+
settings.updateTime($startTimeInput, newStart);
|
262
|
+
}
|
263
|
+
|
264
|
+
$self.data('datepair-timedelta', settings.defaultTimeDelta);
|
265
|
+
} else {
|
266
|
+
$self.data('datepair-timedelta', null);
|
267
|
+
}
|
268
|
+
|
269
|
+
_updateEndMintime($self);
|
270
|
+
return;
|
271
|
+
}
|
272
|
+
|
273
|
+
var startTime = settings.parseTime($startTimeInput);
|
274
|
+
var endTime = settings.parseTime($endTimeInput);
|
275
|
+
|
276
|
+
if ($target.hasClass(settings.startClass)) {
|
277
|
+
var newEndTime = new Date(startTime.getTime()+$self.data('datepair-timedelta'));
|
278
|
+
settings.updateTime($endTimeInput, newEndTime);
|
279
|
+
endTime = settings.parseTime($endTimeInput);
|
280
|
+
}
|
281
|
+
|
282
|
+
if ((endTime.getTime() - startTime.getTime()) * $self.data('datepair-timedelta') < 0) {
|
283
|
+
var $endDateInput = _getEndDateInput($self);
|
284
|
+
var endDate = settings.parseDate($endDateInput);
|
285
|
+
var offset = (endTime < startTime) ? _ONE_DAY : -1 * _ONE_DAY;
|
286
|
+
|
287
|
+
settings.updateDate($endDateInput, new Date(endDate.getTime() + offset));
|
288
|
+
var newDelta = $self.data('datepair-timedelta') + offset;
|
289
|
+
$self.data('datepair-timedelta', newDelta);
|
290
|
+
}
|
291
|
+
|
292
|
+
$self.data('datepair-timedelta', endTime.getTime() - startTime.getTime());
|
293
|
+
|
294
|
+
_updateEndMintime($self);
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
// Plugin entry
|
299
|
+
$.fn.datepair = function(method)
|
300
|
+
{
|
301
|
+
if(methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); }
|
302
|
+
else if(typeof method === "object" || !method) { return methods.init.apply(this, arguments); }
|
303
|
+
else { $.error("Method "+ method + " does not exist on jQuery.datepair"); }
|
304
|
+
};
|
305
|
+
}));
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/************************
|
2
|
-
jquery-timepicker v1.
|
2
|
+
jquery-timepicker v1.3.3
|
3
3
|
http://jonthornton.github.com/jquery-timepicker/
|
4
4
|
|
5
5
|
requires jQuery 1.7+
|
@@ -28,12 +28,13 @@ requires jQuery 1.7+
|
|
28
28
|
scrollDefaultNow: false,
|
29
29
|
scrollDefaultTime: false,
|
30
30
|
selectOnBlur: false,
|
31
|
-
disableTouchKeyboard:
|
31
|
+
disableTouchKeyboard: false,
|
32
32
|
forceRoundTime: false,
|
33
33
|
appendTo: 'body',
|
34
34
|
disableTimeRanges: [],
|
35
35
|
closeOnWindowScroll: false,
|
36
|
-
|
36
|
+
typeaheadHighlight: true,
|
37
|
+
noneOption: false
|
37
38
|
};
|
38
39
|
var _lang = {
|
39
40
|
decimal: '.',
|
@@ -50,49 +51,52 @@ requires jQuery 1.7+
|
|
50
51
|
{
|
51
52
|
var self = $(this);
|
52
53
|
|
53
|
-
//
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
for (var i=0; i < raw_attrs.length; i++) {
|
59
|
-
attrs[raw_attrs[i].nodeName] = raw_attrs[i].nodeValue;
|
54
|
+
// pick up settings from data attributes
|
55
|
+
var attributeOptions = [];
|
56
|
+
for (key in _defaults) {
|
57
|
+
if (self.data(key)) {
|
58
|
+
attributeOptions[key] = self.data(key);
|
60
59
|
}
|
61
|
-
|
62
|
-
var input = $('<input />', attrs);
|
63
|
-
self.replaceWith(input);
|
64
|
-
self = input;
|
65
60
|
}
|
66
61
|
|
67
|
-
var settings = $.extend({}, _defaults);
|
68
|
-
|
69
|
-
if (options) {
|
70
|
-
settings = $.extend(settings, options);
|
71
|
-
}
|
62
|
+
var settings = $.extend({}, _defaults, attributeOptions, options);
|
72
63
|
|
73
64
|
if (settings.lang) {
|
74
65
|
_lang = $.extend(_lang, settings.lang);
|
75
66
|
}
|
76
67
|
|
77
68
|
settings = _parseSettings(settings);
|
78
|
-
|
79
69
|
self.data('timepicker-settings', settings);
|
80
|
-
self.prop('autocomplete', 'off');
|
81
|
-
self.on('click.timepicker focus.timepicker', methods.show);
|
82
|
-
self.on('change.timepicker', _formatValue);
|
83
|
-
self.on('keydown.timepicker', _keydownhandler);
|
84
|
-
self.on('keyup.timepicker', _keyuphandler);
|
85
70
|
self.addClass('ui-timepicker-input');
|
86
71
|
|
87
|
-
|
72
|
+
if (settings.useSelect) {
|
73
|
+
_render(self);
|
74
|
+
} else {
|
75
|
+
self.prop('autocomplete', 'off');
|
76
|
+
self.on('click.timepicker focus.timepicker', methods.show);
|
77
|
+
self.on('change.timepicker', _formatValue);
|
78
|
+
self.on('keydown.timepicker', _keydownhandler);
|
79
|
+
self.on('keyup.timepicker', _keyuphandler);
|
80
|
+
|
81
|
+
_formatValue.call(self.get(0));
|
82
|
+
}
|
88
83
|
});
|
89
84
|
},
|
90
85
|
|
91
86
|
show: function(e)
|
92
87
|
{
|
88
|
+
if (e) {
|
89
|
+
e.preventDefault();
|
90
|
+
}
|
91
|
+
|
93
92
|
var self = $(this);
|
94
93
|
var settings = self.data('timepicker-settings');
|
95
94
|
|
95
|
+
if (settings.useSelect) {
|
96
|
+
self.data('timepicker-list').focus();
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
|
96
100
|
if (_hideKeyboard(self)) {
|
97
101
|
// block the keyboard on mobile devices
|
98
102
|
self.blur();
|
@@ -154,13 +158,26 @@ requires jQuery 1.7+
|
|
154
158
|
list.scrollTop(0);
|
155
159
|
}
|
156
160
|
|
157
|
-
|
161
|
+
// attach close handlers
|
162
|
+
$(document).on('touchstart.ui-timepicker mousedown.ui-timepicker', _closeHandler);
|
163
|
+
if (settings.closeOnWindowScroll) {
|
164
|
+
$(document).on('scroll.ui-timepicker', _closeHandler);
|
165
|
+
}
|
158
166
|
|
159
167
|
self.trigger('showTimepicker');
|
168
|
+
|
169
|
+
return this;
|
160
170
|
},
|
161
171
|
|
162
172
|
hide: function(e)
|
163
173
|
{
|
174
|
+
var self = $(this);
|
175
|
+
var settings = self.data('timepicker-settings');
|
176
|
+
|
177
|
+
if (settings && settings.useSelect) {
|
178
|
+
self.blur();
|
179
|
+
}
|
180
|
+
|
164
181
|
$('.ui-timepicker-wrapper:visible').each(function() {
|
165
182
|
var list = $(this);
|
166
183
|
var self = list.data('timepicker-input');
|
@@ -173,6 +190,8 @@ requires jQuery 1.7+
|
|
173
190
|
list.hide();
|
174
191
|
self.trigger('hideTimepicker');
|
175
192
|
});
|
193
|
+
|
194
|
+
return this;
|
176
195
|
},
|
177
196
|
|
178
197
|
option: function(key, value)
|
@@ -200,7 +219,11 @@ requires jQuery 1.7+
|
|
200
219
|
self.data('timepicker-list', false);
|
201
220
|
}
|
202
221
|
|
203
|
-
|
222
|
+
if (settings.useSelect) {
|
223
|
+
_render(self);
|
224
|
+
}
|
225
|
+
|
226
|
+
return this;
|
204
227
|
},
|
205
228
|
|
206
229
|
getSecondsFromMidnight: function()
|
@@ -211,12 +234,18 @@ requires jQuery 1.7+
|
|
211
234
|
getTime: function(relative_date)
|
212
235
|
{
|
213
236
|
var self = this;
|
237
|
+
|
238
|
+
var time_string = _getTimeValue(self);
|
239
|
+
if (!time_string) {
|
240
|
+
return null;
|
241
|
+
}
|
242
|
+
|
214
243
|
if (!relative_date) {
|
215
244
|
relative_date = new Date();
|
216
245
|
}
|
217
246
|
|
218
247
|
relative_date.setHours(0, 0, 0, 0);
|
219
|
-
return new Date(relative_date.valueOf() + (_time2int(
|
248
|
+
return new Date(relative_date.valueOf() + (_time2int(time_string)*1000));
|
220
249
|
},
|
221
250
|
|
222
251
|
setTime: function(value)
|
@@ -228,6 +257,8 @@ requires jQuery 1.7+
|
|
228
257
|
if (self.data('timepicker-list')) {
|
229
258
|
_setSelected(self, self.data('timepicker-list'));
|
230
259
|
}
|
260
|
+
|
261
|
+
return this;
|
231
262
|
},
|
232
263
|
|
233
264
|
remove: function()
|
@@ -250,6 +281,8 @@ requires jQuery 1.7+
|
|
250
281
|
}
|
251
282
|
|
252
283
|
self.removeData('timepicker-list');
|
284
|
+
|
285
|
+
return this;
|
253
286
|
}
|
254
287
|
};
|
255
288
|
|
@@ -282,6 +315,17 @@ requires jQuery 1.7+
|
|
282
315
|
settings.disableTimeRanges = settings.disableTimeRanges.sort(function(a, b){
|
283
316
|
return a[0] - b[0];
|
284
317
|
});
|
318
|
+
|
319
|
+
// merge any overlapping ranges
|
320
|
+
for (var i = settings.disableTimeRanges.length-1; i > 0; i--) {
|
321
|
+
if (settings.disableTimeRanges[i][0] <= settings.disableTimeRanges[i-1][1]) {
|
322
|
+
settings.disableTimeRanges[i-1] = [
|
323
|
+
Math.min(settings.disableTimeRanges[i][0], settings.disableTimeRanges[i-1][0]),
|
324
|
+
Math.max(settings.disableTimeRanges[i][1], settings.disableTimeRanges[i-1][1])
|
325
|
+
];
|
326
|
+
settings.disableTimeRanges.splice(i, 1);
|
327
|
+
}
|
328
|
+
}
|
285
329
|
}
|
286
330
|
|
287
331
|
return settings;
|
@@ -297,11 +341,25 @@ requires jQuery 1.7+
|
|
297
341
|
self.data('timepicker-list', false);
|
298
342
|
}
|
299
343
|
|
300
|
-
|
344
|
+
if (settings.useSelect) {
|
345
|
+
list = $('<select />', { 'class': 'ui-timepicker-select' });
|
346
|
+
var wrapped_list = list;
|
347
|
+
} else {
|
348
|
+
list = $('<ul />', { 'class': 'ui-timepicker-list' });
|
301
349
|
|
302
|
-
|
303
|
-
|
350
|
+
var wrapped_list = $('<div />', { 'class': 'ui-timepicker-wrapper', 'tabindex': -1 });
|
351
|
+
wrapped_list.css({'display':'none', 'position': 'absolute' }).append(list);
|
352
|
+
}
|
304
353
|
|
354
|
+
if (settings.noneOption) {
|
355
|
+
var defaultLabel = (settings.useSelect) ? 'Time...' : 'None';
|
356
|
+
var label = (typeof settings.noneOption == 'string') ? settings.noneOption : defaultLabel;
|
357
|
+
if (settings.useSelect) {
|
358
|
+
list.append($('<option value="">'+label+'</option>'));
|
359
|
+
} else {
|
360
|
+
list.append($('<li>'+label+'</li>'));
|
361
|
+
}
|
362
|
+
}
|
305
363
|
|
306
364
|
if (settings.className) {
|
307
365
|
wrapped_list.addClass(settings.className);
|
@@ -325,22 +383,37 @@ requires jQuery 1.7+
|
|
325
383
|
end += _ONE_DAY;
|
326
384
|
}
|
327
385
|
|
386
|
+
if (end === _ONE_DAY-1 && settings.timeFormat.indexOf('H') !== -1) {
|
387
|
+
// show a 24:00 option when using military time
|
388
|
+
end = _ONE_DAY;
|
389
|
+
}
|
390
|
+
|
328
391
|
var dr = settings.disableTimeRanges;
|
329
392
|
var drCur = 0;
|
330
393
|
var drLen = dr.length;
|
331
394
|
|
332
395
|
for (var i=start; i <= end; i += settings.step*60) {
|
333
|
-
var timeInt = i
|
396
|
+
var timeInt = i;
|
397
|
+
var timeString = _int2time(timeInt, settings.timeFormat);
|
334
398
|
|
335
|
-
|
336
|
-
|
337
|
-
|
399
|
+
if (settings.useSelect) {
|
400
|
+
var row = $('<option />', { 'value': timeString });
|
401
|
+
row.text(timeString);
|
402
|
+
} else {
|
403
|
+
var row = $('<li />');
|
404
|
+
row.data('time', (timeInt <= 86400 ? timeInt : timeInt % 86400));
|
405
|
+
row.text(timeString);
|
406
|
+
}
|
338
407
|
|
339
408
|
if ((settings.minTime !== null || settings.durationTime !== null) && settings.showDuration) {
|
340
|
-
var
|
341
|
-
|
342
|
-
|
343
|
-
|
409
|
+
var durationString = _int2duration(i - durStart);
|
410
|
+
if (settings.useSelect) {
|
411
|
+
row.text(row.text()+' ('+durationString+')');
|
412
|
+
} else {
|
413
|
+
var duration = $('<span />', { 'class': 'ui-timepicker-duration' });
|
414
|
+
duration.text(' ('+durationString+')');
|
415
|
+
row.append(duration);
|
416
|
+
}
|
344
417
|
}
|
345
418
|
|
346
419
|
if (drCur < drLen) {
|
@@ -349,7 +422,11 @@ requires jQuery 1.7+
|
|
349
422
|
}
|
350
423
|
|
351
424
|
if (dr[drCur] && timeInt >= dr[drCur][0] && timeInt < dr[drCur][1]) {
|
352
|
-
|
425
|
+
if (settings.useSelect) {
|
426
|
+
row.prop('disabled', true);
|
427
|
+
} else {
|
428
|
+
row.addClass('ui-timepicker-disabled');
|
429
|
+
}
|
353
430
|
}
|
354
431
|
}
|
355
432
|
|
@@ -359,58 +436,76 @@ requires jQuery 1.7+
|
|
359
436
|
wrapped_list.data('timepicker-input', self);
|
360
437
|
self.data('timepicker-list', wrapped_list);
|
361
438
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
// hack: temporarily disable the focus handler
|
374
|
-
// to deal with the fact that IE fires 'focus'
|
375
|
-
// events asynchronously
|
376
|
-
self.off('focus.timepicker');
|
377
|
-
self.on('focus.timepicker-ie-hack', function(){
|
378
|
-
self.off('focus.timepicker-ie-hack');
|
379
|
-
self.on('focus.timepicker', methods.show);
|
439
|
+
if (settings.useSelect) {
|
440
|
+
list.val(_roundTime(self.val(), settings));
|
441
|
+
list.on('focus', function(){
|
442
|
+
$(this).data('timepicker-input').trigger('showTimepicker');
|
443
|
+
});
|
444
|
+
list.on('blur', function(){
|
445
|
+
$(this).data('timepicker-input').trigger('hideTimepicker');
|
446
|
+
});
|
447
|
+
list.on('change', function(){
|
448
|
+
_setTimeValue(self, $(this).val(), 'select');
|
380
449
|
});
|
381
450
|
|
382
|
-
|
383
|
-
|
451
|
+
self.hide().after(list);
|
452
|
+
} else {
|
453
|
+
var appendTo = settings.appendTo;
|
454
|
+
if (typeof appendTo === 'string') {
|
455
|
+
appendTo = $(appendTo);
|
456
|
+
} else if (typeof appendTo === 'function') {
|
457
|
+
appendTo = appendTo(self);
|
384
458
|
}
|
459
|
+
appendTo.append(wrapped_list);
|
460
|
+
_setSelected(self, list);
|
385
461
|
|
386
|
-
|
387
|
-
list.find('li').removeClass('ui-timepicker-selected');
|
388
|
-
$(this).addClass('ui-timepicker-selected');
|
462
|
+
list.on('click', 'li', function(e) {
|
389
463
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
464
|
+
// hack: temporarily disable the focus handler
|
465
|
+
// to deal with the fact that IE fires 'focus'
|
466
|
+
// events asynchronously
|
467
|
+
self.off('focus.timepicker');
|
468
|
+
self.on('focus.timepicker-ie-hack', function(){
|
469
|
+
self.off('focus.timepicker-ie-hack');
|
470
|
+
self.on('focus.timepicker', methods.show);
|
471
|
+
});
|
396
472
|
|
397
|
-
|
398
|
-
|
399
|
-
|
473
|
+
if (!_hideKeyboard(self)) {
|
474
|
+
self[0].focus();
|
475
|
+
}
|
476
|
+
|
477
|
+
// make sure only the clicked row is selected
|
478
|
+
list.find('li').removeClass('ui-timepicker-selected');
|
479
|
+
$(this).addClass('ui-timepicker-selected');
|
480
|
+
|
481
|
+
if (_selectValue(self)) {
|
482
|
+
self.trigger('hideTimepicker');
|
483
|
+
wrapped_list.hide();
|
484
|
+
}
|
485
|
+
});
|
486
|
+
}
|
400
487
|
}
|
401
488
|
|
402
|
-
function
|
489
|
+
function _roundTime(time, settings)
|
403
490
|
{
|
404
|
-
if (
|
405
|
-
|
491
|
+
if (!$.isNumeric(time)) {
|
492
|
+
time = _time2int(time);
|
493
|
+
}
|
494
|
+
|
495
|
+
if (time === null) {
|
496
|
+
return null;
|
406
497
|
} else {
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
}
|
498
|
+
var step = settings.step*60;
|
499
|
+
// round to the nearest step
|
500
|
+
return _int2time(Math.round(time / step) * step, settings.timeFormat);
|
411
501
|
}
|
412
502
|
}
|
413
503
|
|
504
|
+
function _generateBaseDate()
|
505
|
+
{
|
506
|
+
return new Date(1970, 1, 1, 0, 0, 0);
|
507
|
+
}
|
508
|
+
|
414
509
|
// event handler to decide whether to close timepicker
|
415
510
|
function _closeHandler(e)
|
416
511
|
{
|
@@ -418,8 +513,7 @@ requires jQuery 1.7+
|
|
418
513
|
var input = target.closest('.ui-timepicker-input');
|
419
514
|
if (input.length === 0 && target.closest('.ui-timepicker-wrapper').length === 0) {
|
420
515
|
methods.hide();
|
421
|
-
$(
|
422
|
-
$(window).unbind('.ui-timepicker');
|
516
|
+
$(document).unbind('.ui-timepicker');
|
423
517
|
}
|
424
518
|
}
|
425
519
|
|
@@ -550,12 +644,17 @@ requires jQuery 1.7+
|
|
550
644
|
|
551
645
|
function _setTimeValue(self, value, source)
|
552
646
|
{
|
553
|
-
if (self.
|
554
|
-
self.
|
555
|
-
|
556
|
-
|
647
|
+
if (self.is('input')) {
|
648
|
+
self.val(value);
|
649
|
+
|
650
|
+
var settings = self.data('timepicker-settings');
|
651
|
+
if (settings.useSelect) {
|
652
|
+
self.data('timepicker-list').val(_roundTime(value, settings));
|
557
653
|
}
|
654
|
+
}
|
558
655
|
|
656
|
+
if (self.data('ui-timepicker-value') != value) {
|
657
|
+
self.data('ui-timepicker-value', value);
|
559
658
|
if (source == 'select') {
|
560
659
|
self.trigger('selectTime').trigger('changeTime').trigger('change');
|
561
660
|
} else if (source != 'error') {
|
@@ -583,7 +682,7 @@ requires jQuery 1.7+
|
|
583
682
|
self.focus();
|
584
683
|
}
|
585
684
|
} else {
|
586
|
-
return
|
685
|
+
return true;
|
587
686
|
}
|
588
687
|
}
|
589
688
|
|
@@ -653,15 +752,10 @@ requires jQuery 1.7+
|
|
653
752
|
break;
|
654
753
|
|
655
754
|
default:
|
656
|
-
return
|
755
|
+
return true;
|
657
756
|
}
|
658
757
|
}
|
659
758
|
|
660
|
-
function _screenInput(e, self)
|
661
|
-
{
|
662
|
-
return !self.data('timepicker-settings').disableTextInput || e.ctrlKey || e.altKey || e.metaKey || (e.keyCode != 2 && e.keyCode < 46);
|
663
|
-
}
|
664
|
-
|
665
759
|
/*
|
666
760
|
* Time typeahead
|
667
761
|
*/
|
@@ -674,6 +768,11 @@ requires jQuery 1.7+
|
|
674
768
|
return true;
|
675
769
|
}
|
676
770
|
|
771
|
+
if (!self.data('timepicker-settings').typeaheadHighlight) {
|
772
|
+
list.find('li').removeClass('ui-timepicker-selected');
|
773
|
+
return true;
|
774
|
+
}
|
775
|
+
|
677
776
|
switch (e.keyCode) {
|
678
777
|
|
679
778
|
case 96: // numpad numerals
|
@@ -769,6 +868,11 @@ requires jQuery 1.7+
|
|
769
868
|
}
|
770
869
|
|
771
870
|
var time = new Date(_baseDate.valueOf() + (seconds*1000));
|
871
|
+
|
872
|
+
if (isNaN(time.getTime())) {
|
873
|
+
return;
|
874
|
+
}
|
875
|
+
|
772
876
|
var output = '';
|
773
877
|
var hour, code;
|
774
878
|
|
@@ -806,6 +910,7 @@ requires jQuery 1.7+
|
|
806
910
|
|
807
911
|
case 'H':
|
808
912
|
hour = time.getHours();
|
913
|
+
if (seconds === _ONE_DAY) hour = 24;
|
809
914
|
output += (hour > 9) ? hour : '0'+hour;
|
810
915
|
break;
|
811
916
|
|
@@ -883,7 +988,14 @@ requires jQuery 1.7+
|
|
883
988
|
// Plugin entry
|
884
989
|
$.fn.timepicker = function(method)
|
885
990
|
{
|
886
|
-
if(
|
991
|
+
if (!this.length) return this;
|
992
|
+
if (methods[method]) {
|
993
|
+
// check if this element is a timepicker
|
994
|
+
if (!this.hasClass('ui-timepicker-input')) {
|
995
|
+
return this;
|
996
|
+
}
|
997
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
998
|
+
}
|
887
999
|
else if(typeof method === "object" || !method) { return methods.init.apply(this, arguments); }
|
888
1000
|
else { $.error("Method "+ method + " does not exist on jQuery.timepicker"); }
|
889
1001
|
};
|
@@ -1,67 +1,67 @@
|
|
1
|
-
.ui-timepicker-wrapper {
|
2
|
-
overflow-y: auto;
|
3
|
-
height: 150px;
|
4
|
-
width: 6.5em;
|
5
|
-
background: #fff;
|
6
|
-
border: 1px solid #ddd;
|
7
|
-
-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);
|
8
|
-
-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);
|
9
|
-
box-shadow:0 5px 10px rgba(0,0,0,0.2);
|
10
|
-
outline: none;
|
11
|
-
z-index: 10001;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
.ui-timepicker-wrapper.ui-timepicker-with-duration {
|
16
|
-
width: 11em;
|
17
|
-
}
|
18
|
-
|
19
|
-
.ui-timepicker-list {
|
20
|
-
margin: 0;
|
21
|
-
padding: 0;
|
22
|
-
list-style: none;
|
23
|
-
}
|
24
|
-
|
25
|
-
.ui-timepicker-duration {
|
26
|
-
margin-left: 5px; color: #888;
|
27
|
-
}
|
28
|
-
|
29
|
-
.ui-timepicker-list:hover .ui-timepicker-duration {
|
30
|
-
color: #888;
|
31
|
-
}
|
32
|
-
|
33
|
-
.ui-timepicker-list li {
|
34
|
-
padding: 3px 0 3px 5px;
|
35
|
-
cursor: pointer;
|
36
|
-
white-space: nowrap;
|
37
|
-
color: #000;
|
38
|
-
list-style: none;
|
39
|
-
margin: 0;
|
40
|
-
}
|
41
|
-
|
42
|
-
.ui-timepicker-list:hover .ui-timepicker-selected {
|
43
|
-
background: #fff; color: #000;
|
44
|
-
}
|
45
|
-
|
46
|
-
li.ui-timepicker-selected,
|
47
|
-
.ui-timepicker-list li:hover,
|
48
|
-
.ui-timepicker-list .ui-timepicker-selected:hover {
|
49
|
-
background: #1980EC; color: #fff;
|
50
|
-
}
|
51
|
-
|
52
|
-
li.ui-timepicker-selected .ui-timepicker-duration,
|
53
|
-
.ui-timepicker-list li:hover .ui-timepicker-duration {
|
54
|
-
color: #ccc;
|
55
|
-
}
|
56
|
-
|
57
|
-
.ui-timepicker-list li.ui-timepicker-disabled,
|
58
|
-
.ui-timepicker-list li.ui-timepicker-disabled:hover,
|
59
|
-
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
|
60
|
-
color: #888;
|
61
|
-
cursor: default;
|
62
|
-
}
|
63
|
-
|
64
|
-
.ui-timepicker-list li.ui-timepicker-disabled:hover,
|
65
|
-
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
|
66
|
-
background: #f2f2f2;
|
67
|
-
}
|
1
|
+
.ui-timepicker-wrapper {
|
2
|
+
overflow-y: auto;
|
3
|
+
height: 150px;
|
4
|
+
width: 6.5em;
|
5
|
+
background: #fff;
|
6
|
+
border: 1px solid #ddd;
|
7
|
+
-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);
|
8
|
+
-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);
|
9
|
+
box-shadow:0 5px 10px rgba(0,0,0,0.2);
|
10
|
+
outline: none;
|
11
|
+
z-index: 10001;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.ui-timepicker-wrapper.ui-timepicker-with-duration {
|
16
|
+
width: 11em;
|
17
|
+
}
|
18
|
+
|
19
|
+
.ui-timepicker-list {
|
20
|
+
margin: 0;
|
21
|
+
padding: 0;
|
22
|
+
list-style: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
.ui-timepicker-duration {
|
26
|
+
margin-left: 5px; color: #888;
|
27
|
+
}
|
28
|
+
|
29
|
+
.ui-timepicker-list:hover .ui-timepicker-duration {
|
30
|
+
color: #888;
|
31
|
+
}
|
32
|
+
|
33
|
+
.ui-timepicker-list li {
|
34
|
+
padding: 3px 0 3px 5px;
|
35
|
+
cursor: pointer;
|
36
|
+
white-space: nowrap;
|
37
|
+
color: #000;
|
38
|
+
list-style: none;
|
39
|
+
margin: 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
.ui-timepicker-list:hover .ui-timepicker-selected {
|
43
|
+
background: #fff; color: #000;
|
44
|
+
}
|
45
|
+
|
46
|
+
li.ui-timepicker-selected,
|
47
|
+
.ui-timepicker-list li:hover,
|
48
|
+
.ui-timepicker-list .ui-timepicker-selected:hover {
|
49
|
+
background: #1980EC; color: #fff;
|
50
|
+
}
|
51
|
+
|
52
|
+
li.ui-timepicker-selected .ui-timepicker-duration,
|
53
|
+
.ui-timepicker-list li:hover .ui-timepicker-duration {
|
54
|
+
color: #ccc;
|
55
|
+
}
|
56
|
+
|
57
|
+
.ui-timepicker-list li.ui-timepicker-disabled,
|
58
|
+
.ui-timepicker-list li.ui-timepicker-disabled:hover,
|
59
|
+
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
|
60
|
+
color: #888;
|
61
|
+
cursor: default;
|
62
|
+
}
|
63
|
+
|
64
|
+
.ui-timepicker-list li.ui-timepicker-disabled:hover,
|
65
|
+
.ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
|
66
|
+
background: #f2f2f2;
|
67
|
+
}
|
metadata
CHANGED
@@ -1,62 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-timepicker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tanguy Krotoff (jQuery plugin by Jon Thornton)
|
8
|
+
- Fabio Cantoni
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
17
|
requirements:
|
19
|
-
- -
|
18
|
+
- - ">="
|
20
19
|
- !ruby/object:Gem::Version
|
21
20
|
version: 3.1.0
|
22
21
|
type: :runtime
|
23
22
|
prerelease: false
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
|
-
- -
|
25
|
+
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
27
|
version: 3.1.0
|
30
28
|
- !ruby/object:Gem::Dependency
|
31
29
|
name: bundler
|
32
30
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
31
|
requirements:
|
35
|
-
- - ~>
|
32
|
+
- - "~>"
|
36
33
|
- !ruby/object:Gem::Version
|
37
34
|
version: '1.3'
|
38
35
|
type: :development
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
|
-
- - ~>
|
39
|
+
- - "~>"
|
44
40
|
- !ruby/object:Gem::Version
|
45
41
|
version: '1.3'
|
46
42
|
- !ruby/object:Gem::Dependency
|
47
43
|
name: rake
|
48
44
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
45
|
requirements:
|
51
|
-
- -
|
46
|
+
- - ">="
|
52
47
|
- !ruby/object:Gem::Version
|
53
48
|
version: '0'
|
54
49
|
type: :development
|
55
50
|
prerelease: false
|
56
51
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
52
|
requirements:
|
59
|
-
- -
|
53
|
+
- - ">="
|
60
54
|
- !ruby/object:Gem::Version
|
61
55
|
version: '0'
|
62
56
|
description: A jQuery timepicker plugin inspired by Google Calendar
|
@@ -66,7 +60,7 @@ executables: []
|
|
66
60
|
extensions: []
|
67
61
|
extra_rdoc_files: []
|
68
62
|
files:
|
69
|
-
- .gitignore
|
63
|
+
- ".gitignore"
|
70
64
|
- Gemfile
|
71
65
|
- LICENSE.txt
|
72
66
|
- README.md
|
@@ -74,32 +68,31 @@ files:
|
|
74
68
|
- jquery-timepicker-rails.gemspec
|
75
69
|
- lib/jquery-timepicker-rails.rb
|
76
70
|
- lib/jquery-timepicker-rails/version.rb
|
77
|
-
- vendor/assets/javascripts/datepair.js
|
71
|
+
- vendor/assets/javascripts/jquery.datepair.js
|
78
72
|
- vendor/assets/javascripts/jquery.timepicker.js
|
79
73
|
- vendor/assets/stylesheets/jquery.timepicker.css
|
80
|
-
homepage:
|
74
|
+
homepage: https://github.com/cover/jquery-timepicker-rails
|
81
75
|
licenses:
|
82
76
|
- MIT
|
77
|
+
metadata: {}
|
83
78
|
post_install_message:
|
84
79
|
rdoc_options: []
|
85
80
|
require_paths:
|
86
81
|
- lib
|
87
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
83
|
requirements:
|
90
|
-
- -
|
84
|
+
- - ">="
|
91
85
|
- !ruby/object:Gem::Version
|
92
86
|
version: '0'
|
93
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
88
|
requirements:
|
96
|
-
- -
|
89
|
+
- - ">="
|
97
90
|
- !ruby/object:Gem::Version
|
98
91
|
version: '0'
|
99
92
|
requirements: []
|
100
93
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
94
|
+
rubygems_version: 2.2.0
|
102
95
|
signing_key:
|
103
|
-
specification_version:
|
96
|
+
specification_version: 4
|
104
97
|
summary: jquery-timepicker packaged for the Rails 3.1+ asset pipeline
|
105
98
|
test_files: []
|
@@ -1,226 +0,0 @@
|
|
1
|
-
$(function() {
|
2
|
-
var DATEPICKER_FORMAT = 'yyyy-m-d';
|
3
|
-
var TIMEPICKER_FORMAT = 'g:ia';
|
4
|
-
var DATE_FORMAT = 'Y-n-j'; // for this format see http://php.net/manual/function.date.php
|
5
|
-
|
6
|
-
$('.datepair input.date').each(function(){
|
7
|
-
var $this = $(this);
|
8
|
-
|
9
|
-
$this.datepicker({
|
10
|
-
'format': DATEPICKER_FORMAT,
|
11
|
-
'autoclose': true
|
12
|
-
});
|
13
|
-
|
14
|
-
if ($this.hasClass('start') || $this.hasClass('end')) {
|
15
|
-
$this.on('changeDate change', doDatepair);
|
16
|
-
}
|
17
|
-
|
18
|
-
});
|
19
|
-
|
20
|
-
$('.datepair input.time').each(function() {
|
21
|
-
var $this = $(this);
|
22
|
-
|
23
|
-
$this.timepicker({
|
24
|
-
'showDuration': true,
|
25
|
-
'timeFormat': TIMEPICKER_FORMAT,
|
26
|
-
'scrollDefaultNow': true
|
27
|
-
});
|
28
|
-
|
29
|
-
if ($this.hasClass('start') || $this.hasClass('end')) {
|
30
|
-
$this.on('changeTime change', doDatepair);
|
31
|
-
}
|
32
|
-
|
33
|
-
if ($this.hasClass('end')) {
|
34
|
-
$this.on('focus', function(){$('.ui-timepicker-with-duration').scrollTop(0);});
|
35
|
-
}
|
36
|
-
|
37
|
-
});
|
38
|
-
|
39
|
-
$('.datepair').each(initDatepair);
|
40
|
-
|
41
|
-
function initDatepair()
|
42
|
-
{
|
43
|
-
var container = $(this);
|
44
|
-
|
45
|
-
var startDateInput = container.find('input.start.date');
|
46
|
-
var endDateInput = container.find('input.end.date');
|
47
|
-
var dateDelta = 0;
|
48
|
-
|
49
|
-
if (startDateInput.length && endDateInput.length) {
|
50
|
-
var startDate = parseDate(startDateInput.val(), DATEPICKER_FORMAT);
|
51
|
-
var endDate = parseDate(endDateInput.val(), DATEPICKER_FORMAT);
|
52
|
-
|
53
|
-
dateDelta = endDate.getTime() - startDate.getTime();
|
54
|
-
container.data('dateDelta', dateDelta);
|
55
|
-
}
|
56
|
-
|
57
|
-
var startTimeInput = container.find('input.start.time');
|
58
|
-
var endTimeInput = container.find('input.end.time');
|
59
|
-
|
60
|
-
if (startTimeInput.length && endTimeInput.length) {
|
61
|
-
var startInt = startTimeInput.timepicker('getSecondsFromMidnight');
|
62
|
-
var endInt = endTimeInput.timepicker('getSecondsFromMidnight');
|
63
|
-
|
64
|
-
container.data('timeDelta', endInt - startInt);
|
65
|
-
|
66
|
-
if (dateDelta < 86400000) {
|
67
|
-
endTimeInput.timepicker('option', 'minTime', startInt);
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
function doDatepair()
|
73
|
-
{
|
74
|
-
var target = $(this);
|
75
|
-
if (target.val() == '') {
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
|
79
|
-
var container = target.closest('.datepair');
|
80
|
-
|
81
|
-
if (target.hasClass('date')) {
|
82
|
-
updateDatePair(target, container);
|
83
|
-
|
84
|
-
} else if (target.hasClass('time')) {
|
85
|
-
updateTimePair(target, container);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
function updateDatePair(target, container)
|
90
|
-
{
|
91
|
-
var start = container.find('input.start.date');
|
92
|
-
var end = container.find('input.end.date');
|
93
|
-
if (!start.length || !end.length) {
|
94
|
-
return;
|
95
|
-
}
|
96
|
-
|
97
|
-
var startDate = parseDate(start.val(), DATEPICKER_FORMAT);
|
98
|
-
var endDate = parseDate(end.val(), DATEPICKER_FORMAT);
|
99
|
-
|
100
|
-
var oldDelta = container.data('dateDelta');
|
101
|
-
|
102
|
-
if (!isNaN(oldDelta) && oldDelta !== null && target.hasClass('start')) {
|
103
|
-
var newEnd = new Date(startDate.getTime()+oldDelta);
|
104
|
-
end.val(newEnd.format(DATE_FORMAT));
|
105
|
-
end.datepicker('update');
|
106
|
-
return;
|
107
|
-
|
108
|
-
} else {
|
109
|
-
var newDelta = endDate.getTime() - startDate.getTime();
|
110
|
-
|
111
|
-
if (newDelta < 0) {
|
112
|
-
newDelta = 0;
|
113
|
-
|
114
|
-
if (target.hasClass('start')) {
|
115
|
-
end.val(start.val());
|
116
|
-
end.datepicker('update');
|
117
|
-
} else if (target.hasClass('end')) {
|
118
|
-
start.val(end.val());
|
119
|
-
start.datepicker('update');
|
120
|
-
}
|
121
|
-
}
|
122
|
-
|
123
|
-
if (newDelta < 86400000) {
|
124
|
-
var startTimeVal = container.find('input.start.time').val();
|
125
|
-
|
126
|
-
if (startTimeVal) {
|
127
|
-
container.find('input.end.time').timepicker('option', {'minTime': startTimeVal});
|
128
|
-
}
|
129
|
-
} else {
|
130
|
-
container.find('input.end.time').timepicker('option', {'minTime': null});
|
131
|
-
}
|
132
|
-
|
133
|
-
container.data('dateDelta', newDelta);
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
function updateTimePair(target, container)
|
138
|
-
{
|
139
|
-
var start = container.find('input.start.time');
|
140
|
-
var end = container.find('input.end.time');
|
141
|
-
|
142
|
-
if (!start.length) {
|
143
|
-
return;
|
144
|
-
}
|
145
|
-
|
146
|
-
var startInt = start.timepicker('getSecondsFromMidnight');
|
147
|
-
var dateDelta = container.data('dateDelta');
|
148
|
-
|
149
|
-
if (target.hasClass('start') && (!dateDelta || dateDelta < 86400000)) {
|
150
|
-
end.timepicker('option', 'minTime', startInt);
|
151
|
-
}
|
152
|
-
|
153
|
-
if (!end.length) {
|
154
|
-
return;
|
155
|
-
}
|
156
|
-
|
157
|
-
var endInt = end.timepicker('getSecondsFromMidnight');
|
158
|
-
var oldDelta = container.data('timeDelta');
|
159
|
-
|
160
|
-
var endDateAdvance = 0;
|
161
|
-
var newDelta;
|
162
|
-
|
163
|
-
if (oldDelta && target.hasClass('start')) {
|
164
|
-
// lock the duration and advance the end time
|
165
|
-
|
166
|
-
var newEnd = (startInt+oldDelta)%86400;
|
167
|
-
|
168
|
-
if (newEnd < 0) {
|
169
|
-
newEnd += 86400;
|
170
|
-
}
|
171
|
-
|
172
|
-
end.timepicker('setTime', newEnd);
|
173
|
-
newDelta = newEnd - startInt;
|
174
|
-
} else if (startInt !== null && endInt !== null) {
|
175
|
-
newDelta = endInt - startInt;
|
176
|
-
} else {
|
177
|
-
return;
|
178
|
-
}
|
179
|
-
|
180
|
-
container.data('timeDelta', newDelta);
|
181
|
-
|
182
|
-
if (newDelta < 0 && (!oldDelta || oldDelta > 0)) {
|
183
|
-
// overnight time span. advance the end date 1 day
|
184
|
-
endDateAdvance = 86400000;
|
185
|
-
|
186
|
-
} else if (newDelta > 0 && oldDelta < 0) {
|
187
|
-
// switching from overnight to same-day time span. decrease the end date 1 day
|
188
|
-
endDateAdvance = -86400000;
|
189
|
-
}
|
190
|
-
|
191
|
-
var startInput = container.find('.start.date');
|
192
|
-
var endInput = container.find('.end.date');
|
193
|
-
|
194
|
-
if (startInput.val() && !endInput.val()) {
|
195
|
-
endInput.val(startInput.val());
|
196
|
-
endInput.datepicker('update');
|
197
|
-
dateDelta = 0;
|
198
|
-
container.data('dateDelta', 0);
|
199
|
-
}
|
200
|
-
|
201
|
-
if (endDateAdvance != 0) {
|
202
|
-
if (dateDelta || dateDelta === 0) {
|
203
|
-
var endDate = parseDate(endInput.val(), DATEPICKER_FORMAT);
|
204
|
-
var newEnd = new Date(endDate.getTime() + endDateAdvance);
|
205
|
-
endInput.val(newEnd.format(DATE_FORMAT));
|
206
|
-
endInput.datepicker('update');
|
207
|
-
container.data('dateDelta', dateDelta + endDateAdvance);
|
208
|
-
}
|
209
|
-
}
|
210
|
-
}
|
211
|
-
});
|
212
|
-
|
213
|
-
function parseDate(input, format) {
|
214
|
-
if (input == '')
|
215
|
-
return new Date('');
|
216
|
-
|
217
|
-
format = format || 'yyyy-mm-dd'; // default format
|
218
|
-
var parts = input.match(/(\d+)/g), i = 0, fmt = {};
|
219
|
-
// extract date-part indexes from the format
|
220
|
-
format.replace(/(yyyy|dd?|mm?)/g, function(part) { fmt[part] = i++; });
|
221
|
-
|
222
|
-
return new Date(parts[fmt['yyyy']], parts[fmt['mm'] == undefined ? fmt['m'] : fmt['mm']]-1, parts[fmt['dd'] == undefined ? fmt['d'] : fmt['dd']]);
|
223
|
-
}
|
224
|
-
|
225
|
-
// Simulates PHP's date function
|
226
|
-
Date.prototype.format=function(format){var returnStr='';var replace=Date.replaceChars;for(var i=0;i<format.length;i++){var curChar=format.charAt(i);if(replace[curChar]){returnStr+=replace[curChar].call(this);}else{returnStr+=curChar;}}return returnStr;};Date.replaceChars={shortMonths:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],longMonths:['January','February','March','April','May','June','July','August','September','October','November','December'],shortDays:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],longDays:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d:function(){return(this.getDate()<10?'0':'')+this.getDate();},D:function(){return Date.replaceChars.shortDays[this.getDay()];},j:function(){return this.getDate();},l:function(){return Date.replaceChars.longDays[this.getDay()];},N:function(){return this.getDay()+1;},S:function(){return(this.getDate()%10==1&&this.getDate()!=11?'st':(this.getDate()%10==2&&this.getDate()!=12?'nd':(this.getDate()%10==3&&this.getDate()!=13?'rd':'th')));},w:function(){return this.getDay();},z:function(){return"Not Yet Supported";},W:function(){return"Not Yet Supported";},F:function(){return Date.replaceChars.longMonths[this.getMonth()];},m:function(){return(this.getMonth()<9?'0':'')+(this.getMonth()+1);},M:function(){return Date.replaceChars.shortMonths[this.getMonth()];},n:function(){return this.getMonth()+1;},t:function(){return"Not Yet Supported";},L:function(){return(((this.getFullYear()%4==0)&&(this.getFullYear()%100!=0))||(this.getFullYear()%400==0))?'1':'0';},o:function(){return"Not Supported";},Y:function(){return this.getFullYear();},y:function(){return(''+this.getFullYear()).substr(2);},a:function(){return this.getHours()<12?'am':'pm';},A:function(){return this.getHours()<12?'AM':'PM';},B:function(){return"Not Yet Supported";},g:function(){return this.getHours()%12||12;},G:function(){return this.getHours();},h:function(){return((this.getHours()%12||12)<10?'0':'')+(this.getHours()%12||12);},H:function(){return(this.getHours()<10?'0':'')+this.getHours();},i:function(){return(this.getMinutes()<10?'0':'')+this.getMinutes();},s:function(){return(this.getSeconds()<10?'0':'')+this.getSeconds();},e:function(){return"Not Yet Supported";},I:function(){return"Not Supported";},O:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()/60))+'00';},P:function(){return(-this.getTimezoneOffset()<0?'-':'+')+(Math.abs(this.getTimezoneOffset()/60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()/60))+':'+(Math.abs(this.getTimezoneOffset()%60)<10?'0':'')+(Math.abs(this.getTimezoneOffset()%60));},T:function(){var m=this.getMonth();this.setMonth(0);var result=this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/,'$1');this.setMonth(m);return result;},Z:function(){return-this.getTimezoneOffset()*60;},c:function(){return this.format("Y-m-d")+"T"+this.format("H:i:sP");},r:function(){return this.toString();},U:function(){return this.getTime()/1000;}};
|