Skip to content

Commit 0da13ca

Browse files
committed
merge upstream
2 parents a1f371c + cd46d38 commit 0da13ca

28 files changed

+383
-48
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ contributed to by him (yet?)
1010

1111
Attached to a field with the format specified via options:
1212

13-
<input type="text" value="02-16-2012" id="datepicker">
13+
<input type="text" value="02-16-2012" id="datepicker">
1414
######
1515
$('#datepicker').datepicker({
1616
format: 'mm-dd-yyyy'
@@ -140,6 +140,18 @@ Number, String. Default: 0, 'month'
140140

141141
The view that the datepicker should show when it is opened. Accepts values of 0 or 'month' for month view (the default), 1 or 'year' for the 12-month overview, and 2 or 'decade' for the 10-year overview. Useful for date-of-birth datepickers.
142142

143+
### todayBtn
144+
145+
Boolean, "linked". Default: false
146+
147+
If true or "linked", displays a "Today" button at the bottom of the datepicker to select the current date. If true, the "Today" button will only move the current date into view; if "linked", the current date will also be selected.
148+
149+
### todayHighlight
150+
151+
Boolean. Default: false
152+
153+
If true, highlights the current date.
154+
143155
### keyboardNavigation
144156

145157
Boolean. Default: true
@@ -284,7 +296,8 @@ The plugin supports i18n for the month and weekday names and the `weekStart` opt
284296
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
285297
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
286298
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
287-
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
299+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
300+
today: "Today"
288301
};
289302

290303
If your browser (or those of your users) is displaying characters wrong, chances are the browser is loading the javascript file with a non-unicode encoding. Simply add `charset="UTF-8"` to your `script` tag:

build/build.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@white: #fff;
1313
@linkColor: #08c;
1414
@btnPrimaryBackground: @linkColor;
15+
@orange: #f89406;
1516

1617
// Mixins
1718

css/datepicker.css

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,55 @@
8787
color: #999999;
8888
cursor: default;
8989
}
90+
.datepicker td.today,
91+
.datepicker td.today:hover,
92+
.datepicker td.today.disabled,
93+
.datepicker td.today.disabled:hover {
94+
background-color: #fde19a;
95+
background-image: -moz-linear-gradient(top, #fdd49a, #fdf59a);
96+
background-image: -ms-linear-gradient(top, #fdd49a, #fdf59a);
97+
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a));
98+
background-image: -webkit-linear-gradient(top, #fdd49a, #fdf59a);
99+
background-image: -o-linear-gradient(top, #fdd49a, #fdf59a);
100+
background-image: linear-gradient(top, #fdd49a, #fdf59a);
101+
background-repeat: repeat-x;
102+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0);
103+
border-color: #fdf59a #fdf59a #fbed50;
104+
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
105+
filter: progid:dximagetransform.microsoft.gradient(enabled=false);
106+
}
107+
.datepicker td.today:hover,
108+
.datepicker td.today:hover:hover,
109+
.datepicker td.today.disabled:hover,
110+
.datepicker td.today.disabled:hover:hover,
111+
.datepicker td.today:active,
112+
.datepicker td.today:hover:active,
113+
.datepicker td.today.disabled:active,
114+
.datepicker td.today.disabled:hover:active,
115+
.datepicker td.today.active,
116+
.datepicker td.today:hover.active,
117+
.datepicker td.today.disabled.active,
118+
.datepicker td.today.disabled:hover.active,
119+
.datepicker td.today.disabled,
120+
.datepicker td.today:hover.disabled,
121+
.datepicker td.today.disabled.disabled,
122+
.datepicker td.today.disabled:hover.disabled,
123+
.datepicker td.today[disabled],
124+
.datepicker td.today:hover[disabled],
125+
.datepicker td.today.disabled[disabled],
126+
.datepicker td.today.disabled:hover[disabled] {
127+
background-color: #fdf59a;
128+
}
129+
.datepicker td.today:active,
130+
.datepicker td.today:hover:active,
131+
.datepicker td.today.disabled:active,
132+
.datepicker td.today.disabled:hover:active,
133+
.datepicker td.today.active,
134+
.datepicker td.today:hover.active,
135+
.datepicker td.today.disabled.active,
136+
.datepicker td.today.disabled:hover.active {
137+
background-color: #fbf069 \9;
138+
}
90139
.datepicker td.active,
91140
.datepicker td.active:hover,
92141
.datepicker td.active.disabled,
@@ -216,10 +265,12 @@
216265
.datepicker th.switch {
217266
width: 145px;
218267
}
219-
.datepicker thead tr:first-child th {
268+
.datepicker thead tr:first-child th,
269+
.datepicker tfoot tr:first-child th {
220270
cursor: pointer;
221271
}
222-
.datepicker thead tr:first-child th:hover {
272+
.datepicker thead tr:first-child th:hover,
273+
.datepicker tfoot tr:first-child th:hover {
223274
background: #eeeeee;
224275
}
225276
.input-append.date .add-on i,

js/bootstrap-datepicker.js

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
function UTCDate(){
2424
return new Date(Date.UTC.apply(Date, arguments));
2525
}
26+
function UTCToday(){
27+
var today = new Date();
28+
return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
29+
}
2630

2731
// Picker object
2832

@@ -111,6 +115,9 @@
111115
break;
112116
}
113117

118+
this.todayBtn = (options.todayBtn||this.element.data('date-today-btn')||false);
119+
this.todayHighlight = (options.todayHighlight||this.element.data('date-today-highlight')||false);
120+
114121
this.weekStart = ((options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0) % 7);
115122
this.weekEnd = ((this.weekStart + 6) % 7);
116123
this.startDate = -Infinity;
@@ -163,6 +170,24 @@
163170
});
164171
},
165172

173+
getDate: function() {
174+
var d = this.getUTCDate();
175+
return new Date(d.getTime() + (d.getTimezoneOffset()*60000))
176+
},
177+
178+
getUTCDate: function() {
179+
return this.date;
180+
},
181+
182+
setDate: function(d) {
183+
this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
184+
},
185+
186+
setUTCDate: function(d) {
187+
this.date = d;
188+
this.setValue();
189+
},
190+
166191
setValue: function() {
167192
var formatted = this.getFormattedDate();
168193
if (!this.isInput) {
@@ -261,9 +286,13 @@
261286
startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
262287
endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
263288
endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
264-
currentDate = this.date.valueOf();
265-
this.picker.find('.datepicker-days th:eq(1)')
289+
currentDate = this.date.valueOf(),
290+
today = new Date();
291+
this.picker.find('.datepicker-days thead th:eq(1)')
266292
.text(dates[this.language].months[month]+' '+year);
293+
this.picker.find('tfoot th.today')
294+
.text(dates[this.language].today)
295+
.toggle(this.todayBtn);
267296
this.updateNavArrows();
268297
this.fillMonths();
269298
var prevMonth = UTCDate(year, month-1, 28,0,0,0,0),
@@ -285,6 +314,13 @@
285314
} else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
286315
clsName += ' new';
287316
}
317+
// Compare internal UTC date with local today, not UTC today
318+
if (this.todayHighlight &&
319+
prevMonth.getUTCFullYear() == today.getFullYear() &&
320+
prevMonth.getUTCMonth() == today.getMonth() &&
321+
prevMonth.getUTCDate() == today.getDate()) {
322+
clsName += ' today';
323+
}
288324
if (prevMonth.valueOf() == currentDate) {
289325
clsName += ' active';
290326
}
@@ -391,6 +427,17 @@
391427
}
392428
this.fill();
393429
break;
430+
case 'today':
431+
var date = new Date();
432+
date.setUTCHours(0);
433+
date.setUTCMinutes(0);
434+
date.setUTCSeconds(0);
435+
date.setUTCMilliseconds(0);
436+
437+
this.showMode(-2);
438+
var which = this.todayBtn == 'linked' ? null : 'view';
439+
this._setDate(date, which);
440+
break;
394441
}
395442
break;
396443
case 'span':
@@ -435,32 +482,38 @@
435482
month += 1;
436483
}
437484
}
438-
this.date = UTCDate(year, month, day,0,0,0,0);
439-
this.viewDate = UTCDate(year, month, day,0,0,0,0);
440-
this.fill();
441-
this.setValue();
442-
this.element.trigger({
443-
type: 'changeDate',
444-
date: this.date
445-
});
446-
var element;
447-
if (this.isInput) {
448-
element = this.element;
449-
} else if (this.component){
450-
element = this.element.find('input');
451-
}
452-
if (element) {
453-
element.change();
454-
if (this.autoclose) {
455-
this.hide();
456-
}
457-
}
485+
this._setDate(UTCDate(year, month, day,0,0,0,0));
458486
}
459487
break;
460488
}
461489
}
462490
},
463491

492+
_setDate: function(date, which){
493+
if (!which || which == 'date')
494+
this.date = date;
495+
if (!which || which == 'view')
496+
this.viewDate = date;
497+
this.fill();
498+
this.setValue();
499+
this.element.trigger({
500+
type: 'changeDate',
501+
date: this.date
502+
});
503+
var element;
504+
if (this.isInput) {
505+
element = this.element;
506+
} else if (this.component){
507+
element = this.element.find('input');
508+
}
509+
if (element) {
510+
element.change();
511+
if (this.autoclose) {
512+
this.hide();
513+
}
514+
}
515+
},
516+
464517
moveMonth: function(date, dir){
465518
if (!dir) return date;
466519
var new_date = new Date(date.valueOf()),
@@ -632,7 +685,8 @@
632685
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
633686
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
634687
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
635-
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
688+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
689+
today: "Today"
636690
}
637691
}
638692

@@ -781,25 +835,29 @@
781835
'<th class="next"><i class="icon-arrow-right"/></th>'+
782836
'</tr>'+
783837
'</thead>',
784-
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>'
838+
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
839+
footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
785840
};
786841
DPGlobal.template = '<div class="datepicker">'+
787842
'<div class="datepicker-days">'+
788843
'<table class=" table-condensed">'+
789844
DPGlobal.headTemplate+
790845
'<tbody></tbody>'+
846+
DPGlobal.footTemplate+
791847
'</table>'+
792848
'</div>'+
793849
'<div class="datepicker-months">'+
794850
'<table class="table-condensed">'+
795851
DPGlobal.headTemplate+
796852
DPGlobal.contTemplate+
853+
DPGlobal.footTemplate+
797854
'</table>'+
798855
'</div>'+
799856
'<div class="datepicker-years">'+
800857
'<table class="table-condensed">'+
801858
DPGlobal.headTemplate+
802859
DPGlobal.contTemplate+
860+
DPGlobal.footTemplate+
803861
'</table>'+
804862
'</div>'+
805863
'</div>';

js/locales/bootstrap-datepicker.bg.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Bulgarian translation for bootstrap-datepicker
3+
* Apostol Apostolov <apostol.s.apostolov@gmail.com>
4+
*/
5+
;(function($){
6+
$.fn.datepicker.dates['bg'] = {
7+
days: ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота", "Неделя"],
8+
daysShort: ["Нед", "Пон", "Вто", "Сря", "Чет", "Пет", "Съб", "Нед"],
9+
daysMin: ["Н", "П", "В", "С", "Ч", "П", "С", "Н"],
10+
months: ["Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"],
11+
monthsShort: ["Ян", "Фев", "Мар", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Ное", "Дек"],
12+
today: "днес"
13+
};
14+
}(jQuery));

js/locales/bootstrap-datepicker.cs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["Ne", "Po", "Út", "St", "Čt", "Pá", "So", "Ne"],
99
daysMin: ["N", "P", "Ú", "St", "Č", "P", "So", "N"],
1010
months: ["Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"],
11-
monthsShort: ["Led", "Úno", "Bře", "Dub", "Kvě", "Čer", "Čnc", "Srp", "Zář", "Říj", "Lis", "Pro"]
11+
monthsShort: ["Led", "Úno", "Bře", "Dub", "Kvě", "Čer", "Čnc", "Srp", "Zář", "Říj", "Lis", "Pro"],
12+
today: "Dnes"
1213
};
1314
}(jQuery));

js/locales/bootstrap-datepicker.da.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"],
99
daysMin: ["Sø", "Ma", "Ti", "On", "To", "Fr", "Lø", "Sø"],
1010
months: ["Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"],
11-
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"]
11+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
12+
today: "I Dag"
1213
};
1314
}(jQuery));

js/locales/bootstrap-datepicker.de.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam", "Son"],
99
daysMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
1010
months: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
11-
monthsShort: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]
11+
monthsShort: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"],
12+
today: "Heute"
1213
};
1314
}(jQuery));

js/locales/bootstrap-datepicker.es.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb", "Dom"],
99
daysMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do"],
1010
months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
11-
monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"]
11+
monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
12+
today: "Hoy"
1213
};
1314
}(jQuery));

js/locales/bootstrap-datepicker.fi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["sun", "maa", "tii", "kes", "tor", "per", "lau", "sun"],
99
daysMin: ["su", "ma", "ti", "ke", "to", "pe", "la", "su"],
1010
months: ["tammikuu", "helmikuu", "maaliskuu", "huhtikuu", "toukokuu", "kesäkuu", "heinäkuu", "elokuu", "syyskuu", "lokakuu", "marraskuu", "joulukuu"],
11-
monthsShort: ["tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mar", "jou"]
11+
monthsShort: ["tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mar", "jou"],
12+
today: "tänään"
1213
};
1314
}(jQuery));

js/locales/bootstrap-datepicker.fr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"],
99
daysMin: ["D", "L", "Ma", "Me", "J", "V", "S", "D"],
1010
months: ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
11-
monthsShort: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"]
11+
monthsShort: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"],
12+
today: "Aujourd'hui"
1213
};
1314
}(jQuery));

js/locales/bootstrap-datepicker.is.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["Sun", "Mán", "Þri", "Mið", "Fim", "Fös", "Lau", "Sun"],
99
daysMin: ["Su", "Má", "Þr", "Mi", "Fi", "Fö", "La", "Su"],
1010
months: ["Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"],
11-
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maí", "Jún", "Júl", "Ágú", "Sep", "Okt", "Nóv", "Des"]
11+
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maí", "Jún", "Júl", "Ágú", "Sep", "Okt", "Nóv", "Des"],
12+
today: "Í Dag"
1213
};
1314
}(jQuery));

js/locales/bootstrap-datepicker.it.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"],
99
daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"],
1010
months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
11-
monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"]
11+
monthsShort: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"],
12+
today: "Oggi"
1213
};
1314
}(jQuery));

0 commit comments

Comments
 (0)