Skip to content

Commit fdd23a3

Browse files
committed
Merge latest master changes into range branch
--HG-- rename : build.less => build/build.less
2 parents 7e85f00 + 0c35494 commit fdd23a3

8 files changed

+161
-12
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ Call the datepicker via javascript:
9090

9191
## Dependencies
9292

93-
Requires bootstrap's dropdown component (`dropdowns.less`).
93+
Requires bootstrap's dropdown component (`dropdowns.less`) for some styles, and bootstrap's sprites (`sprites.less` and associated images) for arrows.
94+
95+
A standalone .css file (including necessary dropdown styles and alternative, text-based arrows) can be generated by running `build/build_standalone.less` through the `lessc` compiler:
96+
97+
$ lessc build/build_standalone.less datepicker.css
9498

9599
## Options
96100

build.less renamed to build/build.less

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
// Datepicker .css buildfile. Includes select mixins/variables from bootstrap
1+
// Datepicker .less buildfile. Includes select mixins/variables from bootstrap
22
// and imports the included datepicker.less to output a minimal datepicker.css
33
//
44
// Usage:
5-
// lessc build.css css/datepicker.css
5+
// lessc build.less datepicker.css
66
//
77
// Variables and mixins copied from bootstrap 2.0.2
8-
//
9-
// Mixins must be included individually, else some (eg, .clearfix) will be
10-
// included in the built .css
118

129
// Variables
1310
@grayLight: #999;
@@ -66,4 +63,4 @@
6663
}
6764
}
6865

69-
@import "less/datepicker.less";
66+
@import "../less/datepicker.less";

build/build_standalone.less

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Datepicker standalone .less buildfile. Includes all necessary mixins/variables/rules from bootstrap
2+
// and imports the included datepicker.less to output a minimal standalone datepicker.css
3+
//
4+
// Usage:
5+
// lessc build_standalone.less datepicker.css
6+
//
7+
// Variables, mixins, and rules copied from bootstrap 2.0.2
8+
9+
@import "build.less";
10+
11+
// Dropdown css
12+
13+
@zindexDropdown: 1000;
14+
@grayDark: #333;
15+
@baseLineHeight: 18px;
16+
@tableBackground: transparent; // overall background-color
17+
@dropdownBackground: @white;
18+
@dropdownBorder: rgba(0,0,0,.2);
19+
@dropdownLinkColor: @grayDark;
20+
@dropdownLinkColorHover: @white;
21+
@dropdownLinkBackgroundHover: @linkColor;
22+
23+
// Drop shadows
24+
.box-shadow(@shadow) {
25+
-webkit-box-shadow: @shadow;
26+
-moz-box-shadow: @shadow;
27+
box-shadow: @shadow;
28+
}
29+
30+
// The dropdown menu (ul)
31+
// ----------------------
32+
.datepicker.dropdown-menu {
33+
position: absolute;
34+
top: 100%;
35+
left: 0;
36+
z-index: @zindexDropdown;
37+
float: left;
38+
display: none; // none by default, but block on "open" of the menu
39+
min-width: 160px;
40+
list-style: none;
41+
background-color: @dropdownBackground;
42+
border: 1px solid #ccc;
43+
border: 1px solid rgba(0,0,0,.2);
44+
.border-radius(5px);
45+
.box-shadow(0 5px 10px rgba(0,0,0,.2));
46+
-webkit-background-clip: padding-box;
47+
-moz-background-clip: padding;
48+
background-clip: padding-box;
49+
*border-right-width: 2px;
50+
*border-bottom-width: 2px;
51+
52+
// Normally inherited from bootstrap's `body`
53+
color: #333333;
54+
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
55+
font-size:13px;
56+
line-height: @baseLineHeight;
57+
58+
th, td {
59+
padding: 4px 5px;
60+
}
61+
}
62+
63+
// Alternative arrows
64+
// May require `charset="UTF-8"` in your `<link>` tag
65+
.datepicker {
66+
.prev, .next {font-style:normal;}
67+
.prev:after {content:"«";}
68+
.next:after {content:"»";}
69+
}

js/bootstrap-datepicker.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
var Datepicker = function(element, options){
2626
this.element = $(element);
27-
this.language = options.language in dates ? options.language : "en";
27+
this.language = options.language||this.element.data('date-language')||"en";
28+
this.language = this.language in dates ? this.language : "en";
2829
this.format = DPGlobal.parseFormat(options.format||this.element.data('date-format')||'mm/dd/yyyy');
2930
this.picker = $(DPGlobal.template)
3031
.appendTo('body')
@@ -34,6 +35,8 @@
3435
});
3536
this.isInput = this.element.is('input');
3637
this.component = this.element.is('.date') ? this.element.find('.add-on') : false;
38+
if(this.component && this.component.length === 0)
39+
this.component = false;
3740

3841
if (this.isInput) {
3942
this.element.on({
@@ -45,6 +48,10 @@
4548
} else {
4649
if (this.component){
4750
this.component.on('click', $.proxy(this.show, this));
51+
var element = this.element.find('input');
52+
element.on({
53+
blur: $.proxy(this._hide, this)
54+
})
4855
} else {
4956
this.element.on('click', $.proxy(this.show, this));
5057
}
@@ -73,8 +80,8 @@
7380
break;
7481
}
7582

76-
this.weekStart = options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0;
77-
this.weekEnd = this.weekStart == 0 ? 6 : this.weekStart - 1;
83+
this.weekStart = ((options.weekStart||this.element.data('date-weekstart')||dates[this.language].weekStart||0) % 7);
84+
this.weekEnd = ((this.weekStart + 6) % 7);
7885
this.startDate = -Infinity;
7986
this.endDate = Infinity;
8087
this.setStartDate(options.startDate||this.element.data('date-startdate'));
@@ -501,7 +508,8 @@
501508
this.show();
502509
return;
503510
}
504-
var dir, day, month;
511+
var dateChanged = false,
512+
dir, day, month;
505513
switch(e.keyCode){
506514
case 27: // escape
507515
this.hide();
@@ -523,6 +531,7 @@
523531
this.setValue();
524532
this.update();
525533
e.preventDefault();
534+
dateChanged = true;
526535
break;
527536
case 38: // up
528537
case 40: // down
@@ -540,12 +549,28 @@
540549
this.setValue();
541550
this.update();
542551
e.preventDefault();
552+
dateChanged = true;
543553
break;
544554
case 13: // enter
545555
this.hide();
546556
e.preventDefault();
547557
break;
548558
}
559+
if (dateChanged){
560+
this.element.trigger({
561+
type: 'changeDate',
562+
date: this.date
563+
});
564+
var element;
565+
if (this.isInput) {
566+
element = this.element;
567+
} else if (this.component){
568+
element = this.element.find('input');
569+
}
570+
if (element) {
571+
element.change();
572+
}
573+
}
549574
},
550575

551576
showMode: function(dir) {
@@ -662,7 +687,9 @@
662687
validParts: /dd?|mm?|MM?|yy(?:yy)?/g,
663688
nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\r]+/g,
664689
parseFormat: function(format){
665-
var separators = format.split(this.validParts),
690+
// IE treats \0 as a string end in inputs (truncating the value),
691+
// so it's a bad format delimiter, anyway
692+
var separators = format.replace(this.validParts, '\0').split('\0'),
666693
parts = format.match(this.validParts);
667694
if (!separators || !separators.length || !parts || parts.length == 0){
668695
throw new Error("Invalid date format.");

js/locales/bootstrap-datepicker.da.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Danish translation for bootstrap-datepicker
3+
* Christian Pedersen <http://github.com/chripede>
4+
*/
5+
;(function($){
6+
$.fn.datepicker.dates['da'] = {
7+
days: ["Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag", "Søndag"],
8+
daysShort: ["Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør", "Søn"],
9+
daysMin: ["Sø", "Ma", "Ti", "On", "To", "Fr", "Lø", "Sø"],
10+
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"]
12+
};
13+
}(jQuery));

js/locales/bootstrap-datepicker.it.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Italian translation for bootstrap-datepicker
3+
* Enrico Rubboli <rubboli@gmail.com>
4+
*/
5+
;(function($){
6+
$.fn.datepicker.dates['it'] = {
7+
days: ["Domenica", "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato", "Domenica"],
8+
daysShort: ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"],
9+
daysMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do"],
10+
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"]
12+
};
13+
}(jQuery));

js/locales/bootstrap-datepicker.nl.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Dutch translation for bootstrap-datepicker
3+
* Reinier Goltstein <mrgoltstein@gmail.com>
4+
*/
5+
;(function($){
6+
$.fn.datepicker.dates['nl'] = {
7+
days: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
8+
daysShort: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
9+
daysMin: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
10+
months: ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
11+
monthsShort: ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"]
12+
};
13+
}(jQuery));

js/locales/bootstrap-datepicker.ru.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Russian translation for bootstrap-datepicker
3+
* Victor Taranenko <darwin@snowdale.com>
4+
*/
5+
;(function($){
6+
$.fn.datepicker.dates['ru'] = {
7+
days: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"],
8+
daysShort: ["Вск", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Вск"],
9+
daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
10+
months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
11+
monthsShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"]
12+
};
13+
}(jQuery));

0 commit comments

Comments
 (0)