bootstrap-datepicker-rails 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +7 -1
- data/Rakefile +8 -0
- data/lib/bootstrap-datepicker-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-datepicker.js +275 -239
- data/vendor/assets/stylesheets/bootstrap-datepicker.css +125 -110
- metadata +10 -10
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -58,7 +58,7 @@ $('.datepicker').datepicker()
|
|
58
58
|
|
59
59
|
String. Default: 'mm/dd/yyyy'
|
60
60
|
|
61
|
-
The date format, combination of d, dd, m, mm, yy, yyy.
|
61
|
+
The date format, combination of d, dd, m, mm, M, MM, yy, yyy.
|
62
62
|
|
63
63
|
#### weekStart
|
64
64
|
|
@@ -78,6 +78,12 @@ String. Default: End of time
|
|
78
78
|
|
79
79
|
The latest date that may be selected; all later dates will be disabled.
|
80
80
|
|
81
|
+
#### autoclose
|
82
|
+
|
83
|
+
Boolean. Default: false
|
84
|
+
|
85
|
+
Whether or not to close the datepicker immediately when a date is selected.
|
86
|
+
|
81
87
|
### Markup
|
82
88
|
|
83
89
|
Format a component.
|
data/Rakefile
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require File.expand_path('../lib/bootstrap-datepicker-rails/version', __FILE__)
|
3
3
|
|
4
|
+
desc "Update assets"
|
5
|
+
task 'update' do
|
6
|
+
system("rm -rf bootstrap-datepicker")
|
7
|
+
system("git clone git://github.com/eternicode/bootstrap-datepicker.git")
|
8
|
+
system("cp bootstrap-datepicker/css/datepicker.css vendor/assets/stylesheets/bootstrap-datepicker.css")
|
9
|
+
system("cp bootstrap-datepicker/js/bootstrap-datepicker.js vendor/assets/javascripts/bootstrap-datepicker.js")
|
10
|
+
end
|
11
|
+
|
4
12
|
desc "Build the gem"
|
5
13
|
task "build" do
|
6
14
|
system("gem build bootstrap-datepicker-rails.gemspec")
|
@@ -1,38 +1,38 @@
|
|
1
1
|
/* =========================================================
|
2
|
-
* bootstrap-datepicker.js
|
3
|
-
* http://www.eyecon.ro/bootstrap-datepicker
|
4
|
-
* =========================================================
|
5
|
-
* Copyright 2012 Stefan Petre
|
6
|
-
*
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
* you may not use this file except in compliance with the License.
|
9
|
-
* You may obtain a copy of the License at
|
10
|
-
*
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
*
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
* See the License for the specific language governing permissions and
|
17
|
-
* limitations under the License.
|
18
|
-
* ========================================================= */
|
19
|
-
|
2
|
+
* bootstrap-datepicker.js
|
3
|
+
* http://www.eyecon.ro/bootstrap-datepicker
|
4
|
+
* =========================================================
|
5
|
+
* Copyright 2012 Stefan Petre
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ========================================================= */
|
19
|
+
|
20
20
|
!function( $ ) {
|
21
|
-
|
21
|
+
|
22
22
|
// Picker object
|
23
|
-
|
23
|
+
|
24
24
|
var Datepicker = function(element, options){
|
25
25
|
this.element = $(element);
|
26
26
|
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
|
27
27
|
this.picker = $(DPGlobal.template)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
.appendTo('body')
|
29
|
+
.on({
|
30
|
+
click: $.proxy(this.click, this),
|
31
|
+
mousedown: $.proxy(this.mousedown, this)
|
32
|
+
});
|
33
33
|
this.isInput = this.element.is('input');
|
34
34
|
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
|
35
|
-
|
35
|
+
|
36
36
|
if (this.isInput) {
|
37
37
|
this.element.on({
|
38
38
|
focus: $.proxy(this.show, this),
|
@@ -47,6 +47,13 @@
|
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
50
|
+
this.autoclose = false;
|
51
|
+
if ('autoclose' in options) {
|
52
|
+
this.autoclose = options.autoclose;
|
53
|
+
} else if ('dateAutoclose' in this.element.data()) {
|
54
|
+
this.autoclose = this.element.data('date-autoclose');
|
55
|
+
}
|
56
|
+
|
50
57
|
this.viewMode = 0;
|
51
58
|
this.weekStart = options.weekStart||this.element.data('date-weekstart')||0;
|
52
59
|
this.weekEnd = this.weekStart == 0 ? 6 : this.weekStart - 1;
|
@@ -59,7 +66,7 @@
|
|
59
66
|
this.update();
|
60
67
|
this.showMode();
|
61
68
|
};
|
62
|
-
|
69
|
+
|
63
70
|
Datepicker.prototype = {
|
64
71
|
constructor: Datepicker,
|
65
72
|
|
@@ -87,25 +94,25 @@
|
|
87
94
|
// event triggers a hide before the click event can stop propagation.
|
88
95
|
if ($.browser.msie) {
|
89
96
|
var t = this, args = arguments;
|
90
|
-
|
97
|
+
|
91
98
|
function cancel_hide(){
|
92
99
|
clearTimeout(hide_timeout);
|
93
100
|
e.target.focus();
|
94
101
|
t.picker.off('click', cancel_hide);
|
95
102
|
}
|
96
|
-
|
103
|
+
|
97
104
|
function do_hide(){
|
98
105
|
t.hide.apply(t, args);
|
99
106
|
t.picker.off('click', cancel_hide);
|
100
107
|
}
|
101
|
-
|
108
|
+
|
102
109
|
this.picker.on('click', cancel_hide);
|
103
110
|
var hide_timeout = setTimeout(do_hide, 100);
|
104
111
|
} else {
|
105
112
|
return this.hide.apply(this, arguments);
|
106
113
|
}
|
107
114
|
},
|
108
|
-
|
115
|
+
|
109
116
|
hide: function(){
|
110
117
|
this.picker.hide();
|
111
118
|
$(window).off('resize', this.place);
|
@@ -120,7 +127,7 @@
|
|
120
127
|
date: this.date
|
121
128
|
});
|
122
129
|
},
|
123
|
-
|
130
|
+
|
124
131
|
setValue: function() {
|
125
132
|
var formated = DPGlobal.formatDate(this.date, this.format);
|
126
133
|
if (!this.isInput) {
|
@@ -132,7 +139,7 @@
|
|
132
139
|
this.element.prop('value', formated);
|
133
140
|
}
|
134
141
|
},
|
135
|
-
|
142
|
+
|
136
143
|
setStartDate: function(startDate){
|
137
144
|
this.startDate = startDate||-Infinity;
|
138
145
|
if (this.startDate !== -Infinity) {
|
@@ -141,7 +148,7 @@
|
|
141
148
|
this.update();
|
142
149
|
this.updateNavArrows();
|
143
150
|
},
|
144
|
-
|
151
|
+
|
145
152
|
setEndDate: function(endDate){
|
146
153
|
this.endDate = endDate||Infinity;
|
147
154
|
if (this.endDate !== Infinity) {
|
@@ -150,7 +157,7 @@
|
|
150
157
|
this.update();
|
151
158
|
this.updateNavArrows();
|
152
159
|
},
|
153
|
-
|
160
|
+
|
154
161
|
place: function(){
|
155
162
|
var offset = this.component ? this.component.offset() : this.element.offset();
|
156
163
|
this.picker.css({
|
@@ -158,7 +165,7 @@
|
|
158
165
|
left: offset.left
|
159
166
|
});
|
160
167
|
},
|
161
|
-
|
168
|
+
|
162
169
|
update: function(){
|
163
170
|
this.date = DPGlobal.parseDate(
|
164
171
|
this.isInput ? this.element.prop('value') : this.element.data('date'),
|
@@ -173,7 +180,7 @@
|
|
173
180
|
}
|
174
181
|
this.fill();
|
175
182
|
},
|
176
|
-
|
183
|
+
|
177
184
|
fillDow: function(){
|
178
185
|
var dowCnt = this.weekStart;
|
179
186
|
var html = '<tr>';
|
@@ -183,7 +190,7 @@
|
|
183
190
|
html += '</tr>';
|
184
191
|
this.picker.find('.datepicker-days thead').append(html);
|
185
192
|
},
|
186
|
-
|
193
|
+
|
187
194
|
fillMonths: function(){
|
188
195
|
var html = '';
|
189
196
|
var i = 0
|
@@ -192,22 +199,22 @@
|
|
192
199
|
}
|
193
200
|
this.picker.find('.datepicker-months td').html(html);
|
194
201
|
},
|
195
|
-
|
202
|
+
|
196
203
|
fill: function() {
|
197
204
|
var d = new Date(this.viewDate),
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
+
year = d.getFullYear(),
|
206
|
+
month = d.getMonth(),
|
207
|
+
startYear = this.startDate !== -Infinity ? this.startDate.getFullYear() : -Infinity,
|
208
|
+
startMonth = this.startDate !== -Infinity ? this.startDate.getMonth() : -Infinity,
|
209
|
+
endYear = this.endDate !== Infinity ? this.endDate.getFullYear() : Infinity,
|
210
|
+
endMonth = this.endDate !== Infinity ? this.endDate.getMonth() : Infinity,
|
211
|
+
currentDate = this.date.valueOf();
|
205
212
|
this.picker.find('.datepicker-days th:eq(1)')
|
206
|
-
|
213
|
+
.text(DPGlobal.dates.months[month]+' '+year);
|
207
214
|
this.updateNavArrows();
|
208
215
|
this.fillMonths();
|
209
216
|
var prevMonth = new Date(year, month-1, 28,0,0,0,0),
|
210
|
-
|
217
|
+
day = DPGlobal.getDaysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
|
211
218
|
prevMonth.setDate(day);
|
212
219
|
prevMonth.setDate(day - (prevMonth.getDay() - this.weekStart + 7)%7);
|
213
220
|
var nextMonth = new Date(prevMonth);
|
@@ -239,12 +246,12 @@
|
|
239
246
|
}
|
240
247
|
this.picker.find('.datepicker-days tbody').empty().append(html.join(''));
|
241
248
|
var currentYear = this.date.getFullYear();
|
242
|
-
|
249
|
+
|
243
250
|
var months = this.picker.find('.datepicker-months')
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
251
|
+
.find('th:eq(1)')
|
252
|
+
.text(year)
|
253
|
+
.end()
|
254
|
+
.find('span').removeClass('active');
|
248
255
|
if (currentYear == year) {
|
249
256
|
months.eq(this.date.getMonth()).addClass('active');
|
250
257
|
}
|
@@ -261,10 +268,10 @@
|
|
261
268
|
html = '';
|
262
269
|
year = parseInt(year/10, 10) * 10;
|
263
270
|
var yearCont = this.picker.find('.datepicker-years')
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
271
|
+
.find('th:eq(1)')
|
272
|
+
.text(year + '-' + (year + 9))
|
273
|
+
.end()
|
274
|
+
.find('td');
|
268
275
|
year -= 1;
|
269
276
|
for (var i = -1; i < 11; i++) {
|
270
277
|
html += '<span class="year'+(i == -1 || i == 10 ? ' old' : '')+(currentYear == year ? ' active' : '')+(year < startYear || year > endYear ? ' disabled' : '')+'">'+year+'</span>';
|
@@ -275,37 +282,37 @@
|
|
275
282
|
|
276
283
|
updateNavArrows: function() {
|
277
284
|
var d = new Date(this.viewDate),
|
278
|
-
|
279
|
-
|
285
|
+
year = d.getFullYear(),
|
286
|
+
month = d.getMonth();
|
280
287
|
switch (this.viewMode) {
|
281
288
|
case 0:
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
289
|
+
if (this.startDate !== -Infinity && year <= this.startDate.getFullYear() && month <= this.startDate.getMonth()) {
|
290
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
291
|
+
} else {
|
292
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
293
|
+
}
|
294
|
+
if (this.endDate !== Infinity && year >= this.endDate.getFullYear() && month >= this.endDate.getMonth()) {
|
295
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
296
|
+
} else {
|
297
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
298
|
+
}
|
299
|
+
break;
|
293
300
|
case 1:
|
294
301
|
case 2:
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
302
|
+
if (this.startDate !== -Infinity && year <= this.startDate.getFullYear()) {
|
303
|
+
this.picker.find('.prev').css({visibility: 'hidden'});
|
304
|
+
} else {
|
305
|
+
this.picker.find('.prev').css({visibility: 'visible'});
|
306
|
+
}
|
307
|
+
if (this.endDate !== Infinity && year >= this.endDate.getFullYear()) {
|
308
|
+
this.picker.find('.next').css({visibility: 'hidden'});
|
309
|
+
} else {
|
310
|
+
this.picker.find('.next').css({visibility: 'visible'});
|
311
|
+
}
|
312
|
+
break;
|
306
313
|
}
|
307
314
|
},
|
308
|
-
|
315
|
+
|
309
316
|
click: function(e) {
|
310
317
|
e.stopPropagation();
|
311
318
|
e.preventDefault();
|
@@ -313,78 +320,85 @@
|
|
313
320
|
if (target.length == 1) {
|
314
321
|
switch(target[0].nodeName.toLowerCase()) {
|
315
322
|
case 'th':
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
323
|
+
switch(target[0].className) {
|
324
|
+
case 'switch':
|
325
|
+
this.showMode(1);
|
326
|
+
break;
|
327
|
+
case 'prev':
|
328
|
+
case 'next':
|
329
|
+
this.viewDate['set'+DPGlobal.modes[this.viewMode].navFnc].call(
|
330
|
+
this.viewDate,
|
331
|
+
this.viewDate['get'+DPGlobal.modes[this.viewMode].navFnc].call(this.viewDate) +
|
332
|
+
DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1)
|
333
|
+
);
|
334
|
+
this.fill();
|
335
|
+
break;
|
336
|
+
}
|
328
337
|
break;
|
329
|
-
}
|
330
|
-
break;
|
331
338
|
case 'span':
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
+
if (!target.is('.disabled')) {
|
340
|
+
if (target.is('.month')) {
|
341
|
+
var month = target.parent().find('span').index(target);
|
342
|
+
this.viewDate.setMonth(month);
|
343
|
+
} else {
|
344
|
+
var year = parseInt(target.text(), 10)||0;
|
345
|
+
this.viewDate.setFullYear(year);
|
346
|
+
}
|
347
|
+
this.showMode(-1);
|
348
|
+
this.fill();
|
339
349
|
}
|
340
|
-
|
341
|
-
this.fill();
|
342
|
-
}
|
343
|
-
break;
|
350
|
+
break;
|
344
351
|
case 'td':
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
352
|
+
if (target.is('.day') && !target.is('.disabled')){
|
353
|
+
var day = parseInt(target.text(), 10)||1;
|
354
|
+
var year = this.viewDate.getFullYear(),
|
355
|
+
month = this.viewDate.getMonth();
|
356
|
+
if (target.is('.old')) {
|
357
|
+
if (month == 0) {
|
358
|
+
month = 11;
|
359
|
+
year -= 1;
|
360
|
+
} else {
|
361
|
+
month -= 1;
|
362
|
+
}
|
363
|
+
} else if (target.is('.new')) {
|
364
|
+
if (month == 11) {
|
365
|
+
month = 0;
|
366
|
+
year += 1;
|
367
|
+
} else {
|
368
|
+
month += 1;
|
369
|
+
}
|
355
370
|
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
371
|
+
this.date = new Date(year, month, day,0,0,0,0);
|
372
|
+
this.viewDate = new Date(year, month, day,0,0,0,0);
|
373
|
+
this.fill();
|
374
|
+
this.setValue();
|
375
|
+
this.element.trigger({
|
376
|
+
type: 'changeDate',
|
377
|
+
date: this.date
|
378
|
+
});
|
379
|
+
var element;
|
380
|
+
if (this.isInput) {
|
381
|
+
element = this.element;
|
382
|
+
} else if (this.component){
|
383
|
+
element = this.element.find('input');
|
384
|
+
}
|
385
|
+
if (element) {
|
386
|
+
element.change();
|
387
|
+
if (this.autoclose) {
|
388
|
+
element.blur();
|
389
|
+
}
|
362
390
|
}
|
363
391
|
}
|
364
|
-
|
365
|
-
this.viewDate = new Date(year, month, day,0,0,0,0);
|
366
|
-
this.fill();
|
367
|
-
this.setValue();
|
368
|
-
this.element.trigger({
|
369
|
-
type: 'changeDate',
|
370
|
-
date: this.date
|
371
|
-
});
|
372
|
-
if (this.isInput) {
|
373
|
-
this.element.change();
|
374
|
-
} else if (this.component){
|
375
|
-
this.element.find('input').change();
|
376
|
-
}
|
377
|
-
}
|
378
|
-
break;
|
392
|
+
break;
|
379
393
|
}
|
380
394
|
}
|
381
395
|
},
|
382
|
-
|
396
|
+
|
383
397
|
mousedown: function(e){
|
384
398
|
e.stopPropagation();
|
385
399
|
e.preventDefault();
|
386
400
|
},
|
387
|
-
|
401
|
+
|
388
402
|
showMode: function(dir) {
|
389
403
|
if (dir) {
|
390
404
|
this.viewMode = Math.max(0, Math.min(2, this.viewMode + dir));
|
@@ -393,14 +407,14 @@
|
|
393
407
|
this.updateNavArrows();
|
394
408
|
}
|
395
409
|
};
|
396
|
-
|
410
|
+
|
397
411
|
$.fn.datepicker = function ( option ) {
|
398
412
|
var args = Array.apply(null, arguments);
|
399
413
|
args.shift();
|
400
414
|
return this.each(function () {
|
401
415
|
var $this = $(this),
|
402
|
-
|
403
|
-
|
416
|
+
data = $this.data('datepicker'),
|
417
|
+
options = typeof option == 'object' && option;
|
404
418
|
if (!data) {
|
405
419
|
$this.data('datepicker', (data = new Datepicker(this, $.extend({}, $.fn.datepicker.defaults,options))));
|
406
420
|
}
|
@@ -411,116 +425,138 @@
|
|
411
425
|
$.fn.datepicker.defaults = {
|
412
426
|
};
|
413
427
|
$.fn.datepicker.Constructor = Datepicker;
|
414
|
-
|
428
|
+
|
415
429
|
var DPGlobal = {
|
416
430
|
modes: [
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
},
|
422
|
-
{
|
423
|
-
clsName: 'months',
|
424
|
-
navFnc: 'FullYear',
|
425
|
-
navStep: 1
|
426
|
-
},
|
427
|
-
{
|
428
|
-
clsName: 'years',
|
429
|
-
navFnc: 'FullYear',
|
430
|
-
navStep: 10
|
431
|
-
}],
|
432
|
-
dates:{
|
433
|
-
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
434
|
-
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
435
|
-
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
436
|
-
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
437
|
-
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
438
|
-
},
|
439
|
-
isLeapYear: function (year) {
|
440
|
-
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
431
|
+
{
|
432
|
+
clsName: 'days',
|
433
|
+
navFnc: 'Month',
|
434
|
+
navStep: 1
|
441
435
|
},
|
442
|
-
|
443
|
-
|
436
|
+
{
|
437
|
+
clsName: 'months',
|
438
|
+
navFnc: 'FullYear',
|
439
|
+
navStep: 1
|
444
440
|
},
|
445
|
-
|
446
|
-
|
441
|
+
{
|
442
|
+
clsName: 'years',
|
443
|
+
navFnc: 'FullYear',
|
444
|
+
navStep: 10
|
445
|
+
}],
|
446
|
+
dates:{
|
447
|
+
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
448
|
+
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
449
|
+
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
450
|
+
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
451
|
+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
452
|
+
},
|
453
|
+
isLeapYear: function (year) {
|
454
|
+
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
|
455
|
+
},
|
456
|
+
getDaysInMonth: function (year, month) {
|
457
|
+
return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
|
458
|
+
},
|
459
|
+
parseFormat: function(format){
|
460
|
+
var separator = format.match(/[.\/ -].*?/),
|
447
461
|
parts = format.split(/\W+/);
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
462
|
+
if (!separator || !parts || parts.length == 0){
|
463
|
+
throw new Error("Invalid date format.");
|
464
|
+
}
|
465
|
+
return {separator: separator, parts: parts};
|
466
|
+
},
|
467
|
+
parseDate: function(date, format) {
|
468
|
+
if (date instanceof Date) return date;
|
469
|
+
var parts = date.split(format.separator),
|
456
470
|
date = new Date(1970, 1, 1, 0, 0, 0),
|
457
|
-
val;
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
471
|
+
val, filtered;
|
472
|
+
if (parts.length == format.parts.length) {
|
473
|
+
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
474
|
+
val = parseInt(parts[i], 10)||1;
|
475
|
+
switch(format.parts[i]) {
|
476
|
+
case 'MM':
|
477
|
+
filtered = $(this.dates.months).filter(function(){
|
478
|
+
var m = this.slice(0, parts[i].length),
|
479
|
+
p = parts[i].slice(0, m.length);
|
480
|
+
return m == p;
|
481
|
+
});
|
482
|
+
val = $.inArray(filtered[0], this.dates.months) + 1;
|
483
|
+
break;
|
484
|
+
case 'M':
|
485
|
+
filtered = $(this.dates.monthsShort).filter(function(){
|
486
|
+
var m = this.slice(0, parts[i].length),
|
487
|
+
p = parts[i].slice(0, m.length);
|
488
|
+
return m == p;
|
489
|
+
});
|
490
|
+
val = $.inArray(filtered[0], this.dates.monthsShort) + 1;
|
491
|
+
break;
|
492
|
+
}
|
493
|
+
switch(format.parts[i]) {
|
494
|
+
case 'dd':
|
495
|
+
case 'd':
|
464
496
|
date.setDate(val);
|
465
497
|
break;
|
466
|
-
|
467
|
-
|
498
|
+
case 'mm':
|
499
|
+
case 'm':
|
500
|
+
case 'MM':
|
501
|
+
case 'M':
|
468
502
|
date.setMonth(val - 1);
|
469
503
|
break;
|
470
|
-
|
504
|
+
case 'yy':
|
471
505
|
date.setFullYear(2000 + val);
|
472
506
|
break;
|
473
|
-
|
507
|
+
case 'yyyy':
|
474
508
|
date.setFullYear(val);
|
475
509
|
break;
|
476
|
-
}
|
477
510
|
}
|
478
511
|
}
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
'<
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
512
|
+
}
|
513
|
+
return date;
|
514
|
+
},
|
515
|
+
formatDate: function(date, format){
|
516
|
+
var val = {
|
517
|
+
d: date.getDate(),
|
518
|
+
m: date.getMonth() + 1,
|
519
|
+
M: this.dates.monthsShort[date.getMonth()],
|
520
|
+
MM: this.dates.months[date.getMonth()],
|
521
|
+
yy: date.getFullYear().toString().substring(2),
|
522
|
+
yyyy: date.getFullYear()
|
523
|
+
};
|
524
|
+
val.dd = (val.d < 10 ? '0' : '') + val.d;
|
525
|
+
val.mm = (val.m < 10 ? '0' : '') + val.m;
|
526
|
+
var date = [];
|
527
|
+
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
528
|
+
date.push(val[format.parts[i]]);
|
529
|
+
}
|
530
|
+
return date.join(format.separator);
|
531
|
+
},
|
532
|
+
headTemplate: '<thead>'+
|
533
|
+
'<tr>'+
|
534
|
+
'<th class="prev"><i class="icon-arrow-left"/></th>'+
|
535
|
+
'<th colspan="5" class="switch"></th>'+
|
536
|
+
'<th class="next"><i class="icon-arrow-right"/></th>'+
|
537
|
+
'</tr>'+
|
538
|
+
'</thead>',
|
539
|
+
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
|
540
|
+
};
|
541
|
+
DPGlobal.template = '<div class="datepicker dropdown-menu">'+
|
542
|
+
'<div class="datepicker-days">'+
|
543
|
+
'<table class=" table-condensed">'+
|
544
|
+
DPGlobal.headTemplate+
|
545
|
+
'<tbody></tbody>'+
|
546
|
+
'</table>'+
|
547
|
+
'</div>'+
|
548
|
+
'<div class="datepicker-months">'+
|
549
|
+
'<table class="table-condensed">'+
|
550
|
+
DPGlobal.headTemplate+
|
551
|
+
DPGlobal.contTemplate+
|
552
|
+
'</table>'+
|
553
|
+
'</div>'+
|
554
|
+
'<div class="datepicker-years">'+
|
555
|
+
'<table class="table-condensed">'+
|
556
|
+
DPGlobal.headTemplate+
|
557
|
+
DPGlobal.contTemplate+
|
558
|
+
'</table>'+
|
559
|
+
'</div>'+
|
560
|
+
'</div>';
|
525
561
|
|
526
|
-
|
562
|
+
}( window.jQuery )
|
@@ -1,89 +1,102 @@
|
|
1
1
|
/*!
|
2
|
-
* Datepicker for Bootstrap
|
3
|
-
*
|
4
|
-
* Copyright 2012 Stefan Petre
|
5
|
-
* Licensed under the Apache License v2.0
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
-
*
|
8
|
-
*/
|
2
|
+
* Datepicker for Bootstrap
|
3
|
+
*
|
4
|
+
* Copyright 2012 Stefan Petre
|
5
|
+
* Licensed under the Apache License v2.0
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
*
|
8
|
+
*/
|
9
9
|
.datepicker {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
top: 0;
|
11
|
+
left: 0;
|
12
|
+
padding: 4px;
|
13
|
+
margin-top: 1px;
|
14
|
+
-webkit-border-radius: 4px;
|
15
|
+
-moz-border-radius: 4px;
|
16
|
+
border-radius: 4px;
|
17
|
+
/*.dow {
|
18
|
+
border-top: 1px solid #ddd !important;
|
19
19
|
}*/
|
20
|
+
|
20
21
|
}
|
21
22
|
.datepicker:before {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
content: '';
|
24
|
+
display: inline-block;
|
25
|
+
border-left: 7px solid transparent;
|
26
|
+
border-right: 7px solid transparent;
|
27
|
+
border-bottom: 7px solid #ccc;
|
28
|
+
border-bottom-color: rgba(0, 0, 0, 0.2);
|
29
|
+
position: absolute;
|
30
|
+
top: -7px;
|
31
|
+
left: 6px;
|
31
32
|
}
|
32
33
|
.datepicker:after {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
content: '';
|
35
|
+
display: inline-block;
|
36
|
+
border-left: 6px solid transparent;
|
37
|
+
border-right: 6px solid transparent;
|
38
|
+
border-bottom: 6px solid #ffffff;
|
39
|
+
position: absolute;
|
40
|
+
top: -6px;
|
41
|
+
left: 7px;
|
41
42
|
}
|
42
43
|
.datepicker > div {
|
43
|
-
|
44
|
+
display: none;
|
44
45
|
}
|
45
|
-
.datepicker
|
46
|
-
|
47
|
-
|
46
|
+
.datepicker.days div.datepicker-days {
|
47
|
+
display: block;
|
48
|
+
}
|
49
|
+
.datepicker.months div.datepicker-months {
|
50
|
+
display: block;
|
51
|
+
}
|
52
|
+
.datepicker.years div.datepicker-years {
|
53
|
+
display: block;
|
48
54
|
}
|
49
|
-
.datepicker
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
.datepicker table {
|
56
|
+
width: 100%;
|
57
|
+
margin: 0;
|
58
|
+
}
|
59
|
+
.datepicker td,
|
60
|
+
.datepicker th {
|
61
|
+
text-align: center;
|
62
|
+
width: 20px;
|
63
|
+
height: 20px;
|
64
|
+
-webkit-border-radius: 4px;
|
65
|
+
-moz-border-radius: 4px;
|
66
|
+
border-radius: 4px;
|
56
67
|
}
|
57
68
|
.datepicker td.day:hover {
|
58
|
-
|
59
|
-
|
69
|
+
background: #eeeeee;
|
70
|
+
cursor: pointer;
|
60
71
|
}
|
61
|
-
.datepicker td.old,
|
62
|
-
|
72
|
+
.datepicker td.old,
|
73
|
+
.datepicker td.new {
|
74
|
+
color: #999999;
|
63
75
|
}
|
64
|
-
.datepicker td.disabled,
|
65
|
-
|
66
|
-
|
67
|
-
|
76
|
+
.datepicker td.disabled,
|
77
|
+
.datepicker td.disabled:hover {
|
78
|
+
background: none;
|
79
|
+
color: #999999;
|
80
|
+
cursor: default;
|
68
81
|
}
|
69
82
|
.datepicker td.active,
|
70
83
|
.datepicker td.active:hover,
|
71
84
|
.datepicker td.active.disabled,
|
72
85
|
.datepicker td.active.disabled:hover {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
86
|
+
background-color: #006dcc;
|
87
|
+
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
88
|
+
background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
|
89
|
+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
90
|
+
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
91
|
+
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
92
|
+
background-image: linear-gradient(top, #0088cc, #0044cc);
|
93
|
+
background-repeat: repeat-x;
|
94
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
|
95
|
+
border-color: #0044cc #0044cc #002a80;
|
96
|
+
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
97
|
+
filter: progid:dximagetransform.microsoft.gradient(enabled=false);
|
98
|
+
color: #fff;
|
99
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
87
100
|
}
|
88
101
|
.datepicker td.active:hover,
|
89
102
|
.datepicker td.active:hover:hover,
|
@@ -105,7 +118,7 @@
|
|
105
118
|
.datepicker td.active:hover[disabled],
|
106
119
|
.datepicker td.active.disabled[disabled],
|
107
120
|
.datepicker td.active.disabled:hover[disabled] {
|
108
|
-
|
121
|
+
background-color: #0044cc;
|
109
122
|
}
|
110
123
|
.datepicker td.active:active,
|
111
124
|
.datepicker td.active:hover:active,
|
@@ -115,46 +128,47 @@
|
|
115
128
|
.datepicker td.active:hover.active,
|
116
129
|
.datepicker td.active.disabled.active,
|
117
130
|
.datepicker td.active.disabled:hover.active {
|
118
|
-
|
131
|
+
background-color: #003399 \9;
|
119
132
|
}
|
120
133
|
.datepicker td span {
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
134
|
+
display: block;
|
135
|
+
width: 47px;
|
136
|
+
height: 54px;
|
137
|
+
line-height: 54px;
|
138
|
+
float: left;
|
139
|
+
margin: 2px;
|
140
|
+
cursor: pointer;
|
141
|
+
-webkit-border-radius: 4px;
|
142
|
+
-moz-border-radius: 4px;
|
143
|
+
border-radius: 4px;
|
131
144
|
}
|
132
145
|
.datepicker td span:hover {
|
133
|
-
|
146
|
+
background: #eeeeee;
|
134
147
|
}
|
135
|
-
.datepicker td span.disabled,
|
136
|
-
|
137
|
-
|
138
|
-
|
148
|
+
.datepicker td span.disabled,
|
149
|
+
.datepicker td span.disabled:hover {
|
150
|
+
background: none;
|
151
|
+
color: #999999;
|
152
|
+
cursor: default;
|
139
153
|
}
|
140
154
|
.datepicker td span.active,
|
141
155
|
.datepicker td span.active:hover,
|
142
156
|
.datepicker td span.active.disabled,
|
143
157
|
.datepicker td span.active.disabled:hover {
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
+
background-color: #006dcc;
|
159
|
+
background-image: -moz-linear-gradient(top, #0088cc, #0044cc);
|
160
|
+
background-image: -ms-linear-gradient(top, #0088cc, #0044cc);
|
161
|
+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));
|
162
|
+
background-image: -webkit-linear-gradient(top, #0088cc, #0044cc);
|
163
|
+
background-image: -o-linear-gradient(top, #0088cc, #0044cc);
|
164
|
+
background-image: linear-gradient(top, #0088cc, #0044cc);
|
165
|
+
background-repeat: repeat-x;
|
166
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);
|
167
|
+
border-color: #0044cc #0044cc #002a80;
|
168
|
+
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
|
169
|
+
filter: progid:dximagetransform.microsoft.gradient(enabled=false);
|
170
|
+
color: #fff;
|
171
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
|
158
172
|
}
|
159
173
|
.datepicker td span.active:hover,
|
160
174
|
.datepicker td span.active:hover:hover,
|
@@ -176,7 +190,7 @@
|
|
176
190
|
.datepicker td span.active:hover[disabled],
|
177
191
|
.datepicker td span.active.disabled[disabled],
|
178
192
|
.datepicker td span.active.disabled:hover[disabled] {
|
179
|
-
|
193
|
+
background-color: #0044cc;
|
180
194
|
}
|
181
195
|
.datepicker td span.active:active,
|
182
196
|
.datepicker td span.active:hover:active,
|
@@ -186,23 +200,24 @@
|
|
186
200
|
.datepicker td span.active:hover.active,
|
187
201
|
.datepicker td span.active.disabled.active,
|
188
202
|
.datepicker td span.active.disabled:hover.active {
|
189
|
-
|
203
|
+
background-color: #003399 \9;
|
190
204
|
}
|
191
205
|
.datepicker td span.old {
|
192
|
-
|
206
|
+
color: #999999;
|
193
207
|
}
|
194
208
|
.datepicker th.switch {
|
195
|
-
|
209
|
+
width: 145px;
|
196
210
|
}
|
197
211
|
.datepicker thead tr:first-child th {
|
198
|
-
|
212
|
+
cursor: pointer;
|
199
213
|
}
|
200
214
|
.datepicker thead tr:first-child th:hover {
|
201
|
-
|
202
|
-
}
|
203
|
-
.input-append.date .add-on i,
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
215
|
+
background: #eeeeee;
|
216
|
+
}
|
217
|
+
.input-append.date .add-on i,
|
218
|
+
.input-prepend.date .add-on i {
|
219
|
+
display: block;
|
220
|
+
cursor: pointer;
|
221
|
+
width: 16px;
|
222
|
+
height: 16px;
|
223
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-datepicker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &70298307018260 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70298307018260
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70298307021480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70298307021480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70298306700540 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70298306700540
|
47
47
|
description: A date picker for Twitter Bootstrap
|
48
48
|
email:
|
49
49
|
- siotopo@gmail.com
|
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash:
|
79
|
+
hash: 601702732678368938
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 601702732678368938
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.17
|