bootstrap-datepicker-rails 0.4 → 0.5
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.
- data/.rvmrc +48 -0
- data/README.md +6 -141
- data/lib/bootstrap-datepicker-rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrap-datepicker.js +106 -5
- data/vendor/assets/stylesheets/bootstrap-datepicker.css +1 -0
- metadata +27 -11
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p125@bootstrap-datepicker-rails"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.11.2" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/README.md
CHANGED
@@ -12,6 +12,10 @@ bootstrap-datepicker-rails project integrates Datepicker with Rails 3 assets pip
|
|
12
12
|
|
13
13
|
http://github.com/Nerian/bootstrap-datepicker-rails
|
14
14
|
|
15
|
+
It also integrates the improvements made by Andrew Rowls.
|
16
|
+
|
17
|
+
https://github.com/eternicode/bootstrap-datepicker
|
18
|
+
|
15
19
|
## Rails > 3.1
|
16
20
|
Include bootstrap-datepicker-rails in Gemfile;
|
17
21
|
|
@@ -33,7 +37,7 @@ and run bundle install.
|
|
33
37
|
Add necessary stylesheet file to app/assets/stylesheets/application.css
|
34
38
|
|
35
39
|
``` css
|
36
|
-
*=bootstrap-datepicker
|
40
|
+
*= require bootstrap-datepicker
|
37
41
|
```
|
38
42
|
|
39
43
|
## Javascripts
|
@@ -52,147 +56,8 @@ Just call datepicker() with any selector.
|
|
52
56
|
$('.datepicker').datepicker()
|
53
57
|
```
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
#### format
|
58
|
-
|
59
|
-
String. Default: 'mm/dd/yyyy'
|
60
|
-
|
61
|
-
The date format, combination of d, dd, m, mm, M, MM, yy, yyy.
|
62
|
-
|
63
|
-
#### weekStart
|
64
|
-
|
65
|
-
Integer. Default: 0
|
66
|
-
|
67
|
-
Day of the week start. 0 (Sunday) to 6 (Saturday)
|
68
|
-
|
69
|
-
#### startDate
|
70
|
-
|
71
|
-
String. Default: Beginning of time
|
72
|
-
|
73
|
-
The earliest date that may be selected; all earlier dates will be disabled.
|
74
|
-
|
75
|
-
#### endDate
|
76
|
-
|
77
|
-
String. Default: End of time
|
78
|
-
|
79
|
-
The latest date that may be selected; all later dates will be disabled.
|
80
|
-
|
81
|
-
#### autoclose
|
82
|
-
|
83
|
-
Boolean. Default: false
|
84
|
-
|
85
|
-
Whether or not to close the datepicker immediately when a date is selected.
|
86
|
-
|
87
|
-
### Markup
|
88
|
-
|
89
|
-
Format a component.
|
90
|
-
|
91
|
-
```html
|
92
|
-
<div class="input-append date" id="datepicker" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
|
93
|
-
<input class="span2" size="16" type="text" value="12-02-2012">
|
94
|
-
<span class="add-on"><i class="icon-th"></i></span>
|
95
|
-
</div>
|
96
|
-
```
|
97
|
-
|
98
|
-
### Methods
|
99
|
-
|
100
|
-
#### .datepicker(options)
|
101
|
-
|
102
|
-
Initializes an datepicker.
|
103
|
-
|
104
|
-
#### show
|
105
|
-
|
106
|
-
Arguments: None
|
107
|
-
|
108
|
-
Show the datepicker.
|
109
|
-
|
110
|
-
```javascript
|
111
|
-
$('#datepicker').datepicker('show');
|
112
|
-
```
|
113
|
-
|
114
|
-
#### hide
|
115
|
-
|
116
|
-
Arguments: None
|
117
|
-
|
118
|
-
Hide the datepicker.
|
119
|
-
|
120
|
-
```javascript
|
121
|
-
$('#datepicker').datepicker('hide');
|
122
|
-
```
|
123
|
-
|
124
|
-
#### update
|
59
|
+
There are a lot of options you can pass to datepicker(). They are documented at [https://github.com/eternicode/bootstrap-datepicker](https://github.com/eternicode/bootstrap-datepicker)
|
125
60
|
|
126
|
-
Arguments: None
|
127
|
-
|
128
|
-
Update the datepicker with the current input value.
|
129
|
-
|
130
|
-
```javascript
|
131
|
-
$('#datepicker').datepicker('update');
|
132
|
-
```
|
133
|
-
|
134
|
-
#### setStartDate
|
135
|
-
|
136
|
-
Arguments:
|
137
|
-
|
138
|
-
* startDate (String)
|
139
|
-
|
140
|
-
Sets a new lower date limit on the datepicker.
|
141
|
-
|
142
|
-
```javascript
|
143
|
-
$('#datepicker').datepicker('setStartDate', '2012-01-01');
|
144
|
-
```
|
145
|
-
Omit startDate (or provide an otherwise falsey value) to unset the limit.
|
146
|
-
|
147
|
-
```javascript
|
148
|
-
$('#datepicker').datepicker('setStartDate');
|
149
|
-
$('#datepicker').datepicker('setStartDate', null);
|
150
|
-
```
|
151
|
-
|
152
|
-
#### setEndDate
|
153
|
-
|
154
|
-
Arguments:
|
155
|
-
|
156
|
-
* endDate (String)
|
157
|
-
|
158
|
-
Sets a new upper date limit on the datepicker.
|
159
|
-
|
160
|
-
```javascript
|
161
|
-
$('#datepicker').datepicker('setEndDate', '2012-12-31');
|
162
|
-
```
|
163
|
-
|
164
|
-
Omit endDate (or provide an otherwise falsey value) to unset the limit.
|
165
|
-
|
166
|
-
```javascript
|
167
|
-
$('#datepicker').datepicker('setEndDate');
|
168
|
-
$('#datepicker').datepicker('setEndDate', null);
|
169
|
-
```
|
170
|
-
|
171
|
-
### Events
|
172
|
-
|
173
|
-
Datepicker class exposes a few events for manipulating the dates.
|
174
|
-
|
175
|
-
#### show
|
176
|
-
|
177
|
-
Fired when the date picker is displayed.
|
178
|
-
|
179
|
-
#### hide
|
180
|
-
|
181
|
-
Fired when the date picker is hidden.
|
182
|
-
|
183
|
-
#### changeDate
|
184
|
-
|
185
|
-
Fired when the date is changed.
|
186
|
-
|
187
|
-
```javascript
|
188
|
-
$('#date-end')
|
189
|
-
.datepicker()
|
190
|
-
.on('changeDate', function(ev){
|
191
|
-
if (ev.date.valueOf() < date-start-display.valueOf()){
|
192
|
-
....
|
193
|
-
}
|
194
|
-
});
|
195
|
-
```
|
196
61
|
|
197
62
|
## License
|
198
63
|
Copyright (c) 2011 Gonzalo Rodríguez-Baltanás Díaz
|
@@ -3,6 +3,7 @@
|
|
3
3
|
* http://www.eyecon.ro/bootstrap-datepicker
|
4
4
|
* =========================================================
|
5
5
|
* Copyright 2012 Stefan Petre
|
6
|
+
* Improvements by Andrew Rowls
|
6
7
|
*
|
7
8
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
* you may not use this file except in compliance with the License.
|
@@ -37,7 +38,8 @@
|
|
37
38
|
this.element.on({
|
38
39
|
focus: $.proxy(this.show, this),
|
39
40
|
blur: $.proxy(this._hide, this),
|
40
|
-
keyup: $.proxy(this.update, this)
|
41
|
+
keyup: $.proxy(this.update, this),
|
42
|
+
keydown: $.proxy(this.keydown, this)
|
41
43
|
});
|
42
44
|
} else {
|
43
45
|
if (this.component){
|
@@ -113,7 +115,7 @@
|
|
113
115
|
}
|
114
116
|
},
|
115
117
|
|
116
|
-
hide: function(){
|
118
|
+
hide: function(e){
|
117
119
|
this.picker.hide();
|
118
120
|
$(window).off('resize', this.place);
|
119
121
|
this.viewMode = 0;
|
@@ -121,7 +123,8 @@
|
|
121
123
|
if (!this.isInput) {
|
122
124
|
$(document).off('mousedown', this.hide);
|
123
125
|
}
|
124
|
-
|
126
|
+
if (e && e.currentTarget.value)
|
127
|
+
this.setValue();
|
125
128
|
this.element.trigger({
|
126
129
|
type: 'hide',
|
127
130
|
date: this.date
|
@@ -398,6 +401,103 @@
|
|
398
401
|
e.stopPropagation();
|
399
402
|
e.preventDefault();
|
400
403
|
},
|
404
|
+
|
405
|
+
moveMonth: function(date, dir){
|
406
|
+
if (!dir) return date;
|
407
|
+
var new_date = new Date(date.valueOf()),
|
408
|
+
day = new_date.getDate(),
|
409
|
+
month = new_date.getMonth(),
|
410
|
+
mag = Math.abs(dir),
|
411
|
+
new_month, test;
|
412
|
+
dir = dir > 0 ? 1 : -1;
|
413
|
+
if (mag == 1){
|
414
|
+
test = dir == -1
|
415
|
+
// If going back one month, make sure month is not current month
|
416
|
+
// (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
|
417
|
+
? function(){ return new_date.getMonth() == month; }
|
418
|
+
// If going forward one month, make sure month is as expected
|
419
|
+
// (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
|
420
|
+
: function(){ return new_date.getMonth() != new_month; };
|
421
|
+
new_month = month + dir;
|
422
|
+
new_date.setMonth(new_month);
|
423
|
+
// Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
|
424
|
+
if (new_month < 0 || new_month > 11)
|
425
|
+
new_month = (new_month + 12) % 12;
|
426
|
+
} else {
|
427
|
+
// For magnitudes >1, move one month at a time...
|
428
|
+
for (var i=0; i<mag; i++)
|
429
|
+
// ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
|
430
|
+
new_date = this.moveMonth(new_date, dir);
|
431
|
+
// ...then reset the day, keeping it in the new month
|
432
|
+
new_month = new_date.getMonth();
|
433
|
+
new_date.setDate(day);
|
434
|
+
test = function(){ return new_month != new_date.getMonth(); };
|
435
|
+
}
|
436
|
+
// Common date-resetting loop -- if date is beyond end of month, make it
|
437
|
+
// end of month
|
438
|
+
while (test()){
|
439
|
+
new_date.setDate(--day);
|
440
|
+
new_date.setMonth(new_month);
|
441
|
+
}
|
442
|
+
return new_date;
|
443
|
+
},
|
444
|
+
|
445
|
+
moveYear: function(date, dir){
|
446
|
+
return this.moveMonth(date, dir*12);
|
447
|
+
},
|
448
|
+
|
449
|
+
keydown: function(e){
|
450
|
+
if (this.picker.is(':not(:visible)')){
|
451
|
+
if (e.keyCode == 27) // allow escape to hide and re-show picker
|
452
|
+
this.show();
|
453
|
+
return;
|
454
|
+
}
|
455
|
+
var dir, day, month;
|
456
|
+
switch(e.keyCode){
|
457
|
+
case 27: // escape
|
458
|
+
this.hide();
|
459
|
+
e.preventDefault();
|
460
|
+
break;
|
461
|
+
case 37: // left
|
462
|
+
case 39: // right
|
463
|
+
dir = e.keyCode == 37 ? -1 : 1;
|
464
|
+
if (e.ctrlKey){
|
465
|
+
this.date = this.moveYear(this.date, dir);
|
466
|
+
this.viewDate = this.moveYear(this.viewDate, dir);
|
467
|
+
} else if (e.shiftKey){
|
468
|
+
this.date = this.moveMonth(this.date, dir);
|
469
|
+
this.viewDate = this.moveMonth(this.viewDate, dir);
|
470
|
+
} else {
|
471
|
+
this.date.setDate(this.date.getDate() + dir);
|
472
|
+
this.viewDate.setDate(this.viewDate.getDate() + dir);
|
473
|
+
}
|
474
|
+
this.setValue();
|
475
|
+
this.update();
|
476
|
+
e.preventDefault();
|
477
|
+
break;
|
478
|
+
case 38: // up
|
479
|
+
case 40: // down
|
480
|
+
dir = e.keyCode == 38 ? -1 : 1;
|
481
|
+
if (e.ctrlKey){
|
482
|
+
this.date = this.moveYear(this.date, dir);
|
483
|
+
this.viewDate = this.moveYear(this.viewDate, dir);
|
484
|
+
} else if (e.shiftKey){
|
485
|
+
this.date = this.moveMonth(this.date, dir);
|
486
|
+
this.viewDate = this.moveMonth(this.viewDate, dir);
|
487
|
+
} else {
|
488
|
+
this.date.setDate(this.date.getDate() + dir * 7);
|
489
|
+
this.viewDate.setDate(this.viewDate.getDate() + dir * 7);
|
490
|
+
}
|
491
|
+
this.setValue();
|
492
|
+
this.update();
|
493
|
+
e.preventDefault();
|
494
|
+
break;
|
495
|
+
case 13: // enter
|
496
|
+
this.hide();
|
497
|
+
e.preventDefault();
|
498
|
+
break;
|
499
|
+
}
|
500
|
+
},
|
401
501
|
|
402
502
|
showMode: function(dir) {
|
403
503
|
if (dir) {
|
@@ -466,9 +566,10 @@
|
|
466
566
|
},
|
467
567
|
parseDate: function(date, format) {
|
468
568
|
if (date instanceof Date) return date;
|
469
|
-
var parts = date.split(format.separator),
|
470
|
-
date = new Date(
|
569
|
+
var parts = date ? date.split(format.separator) : [],
|
570
|
+
date = new Date(),
|
471
571
|
val, filtered;
|
572
|
+
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
|
472
573
|
if (parts.length == format.parts.length) {
|
473
574
|
for (var i=0, cnt = format.parts.length; i < cnt; i++) {
|
474
575
|
val = parseInt(parts[i], 10)||1;
|
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.5'
|
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-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: bundler
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '1.0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description: A date picker for Twitter Bootstrap
|
48
63
|
email:
|
49
64
|
- siotopo@gmail.com
|
@@ -52,6 +67,7 @@ extensions: []
|
|
52
67
|
extra_rdoc_files: []
|
53
68
|
files:
|
54
69
|
- .gitignore
|
70
|
+
- .rvmrc
|
55
71
|
- Gemfile
|
56
72
|
- README.md
|
57
73
|
- Rakefile
|
@@ -76,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
92
|
version: '0'
|
77
93
|
segments:
|
78
94
|
- 0
|
79
|
-
hash:
|
95
|
+
hash: -3256137021559220675
|
80
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
97
|
none: false
|
82
98
|
requirements:
|
@@ -85,10 +101,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
101
|
version: '0'
|
86
102
|
segments:
|
87
103
|
- 0
|
88
|
-
hash:
|
104
|
+
hash: -3256137021559220675
|
89
105
|
requirements: []
|
90
106
|
rubyforge_project:
|
91
|
-
rubygems_version: 1.8.
|
107
|
+
rubygems_version: 1.8.19
|
92
108
|
signing_key:
|
93
109
|
specification_version: 3
|
94
110
|
summary: A date picker for Twitter Bootstrap
|