Skip to content

Commit 09fd67e

Browse files
committed
merge request for both bootstrap v2 and v3 support
1 parent a9bb3cf commit 09fd67e

19 files changed

+9637
-17
lines changed

css/datetimepicker.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@
359359
background: #eeeeee;
360360
}
361361
.input-append.date .add-on i,
362-
.input-prepend.date .add-on i {
362+
.input-prepend.date .add-on i,
363+
.input-group.date .input-group-addon span{
363364
cursor: pointer;
364365
width: 14px;
365366
height: 14px;

css/datetimepicker.min.css

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/bootstrap-datetimepicker.js

+69-7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
* limitations under the License.
2121
* ========================================================= */
2222

23+
/*
24+
* Improvement by CuGBabyBeaR @ 2013-09-12
25+
*
26+
* Make it work in bootstrap v3
27+
*/
28+
29+
2330
!function( $ ) {
2431

2532
function UTCDate(){
@@ -36,6 +43,7 @@
3643
var that = this;
3744

3845
this.element = $(element);
46+
3947
this.language = options.language || this.element.data('date-language') || "en";
4048
this.language = this.language in dates ? this.language : "en";
4149
this.isRTL = dates[this.language].rtl || false;
@@ -44,8 +52,11 @@
4452
this.isInline = false;
4553
this.isVisible = false;
4654
this.isInput = this.element.is('input');
47-
this.component = this.element.is('.date') ? this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar').parent() : false;
48-
this.componentReset = this.element.is('.date') ? this.element.find('.add-on .icon-remove').parent() : false;
55+
56+
this.bootcssVer = this.isInput ? (this.element.is('.form-control') ? 3 : 2) : ( this.bootcssVer = this.element.is('.input-group') ? 3 : 2 );
57+
58+
this.component = this.element.is('.date') ? ( this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-th, .input-group-addon .glyphicon-time, .input-group-addon .glyphicon-calendar').parent() : this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar').parent()) : false;
59+
this.componentReset = this.element.is('.date') ? ( this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-remove').parent() : this.element.find('.add-on .icon-remove').parent()): false;
4960
this.hasInput = this.component && this.element.find('input').length;
5061
if (this.component && this.component.length === 0) {
5162
this.component = false;
@@ -54,8 +65,10 @@
5465
this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || DPGlobal.getDefaultFormat(this.formatType, 'link'), this.formatType);
5566
this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
5667
this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
57-
this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false;
58-
this.initialDate = options.initialDate || new Date();
68+
this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false;
69+
this.initialDate = options.initialDate || new Date();
70+
71+
5972

6073
this._attachEvents();
6174

@@ -128,7 +141,7 @@
128141
this.forceParse = this.element.data('date-force-parse');
129142
}
130143

131-
this.picker = $(DPGlobal.template)
144+
this.picker = $((this.bootcssVer == 3)? DPGlobal.templateV3 : DPGlobal.template)
132145
.appendTo(this.isInline ? this.element : 'body')
133146
.on({
134147
click: $.proxy(this.click, this),
@@ -153,8 +166,14 @@
153166
}
154167
if (this.isRTL){
155168
this.picker.addClass('datetimepicker-rtl');
156-
this.picker.find('.prev i, .next i')
169+
if (this.bootcssVer == 3) {
170+
this.picker.find('.prev span, .next span')
171+
.toggleClass('glyphicon-arrow-left glyphicon-arrow-right');
172+
}else{
173+
this.picker.find('.prev i, .next i')
157174
.toggleClass('icon-arrow-left icon-arrow-right');
175+
};
176+
158177
}
159178
$(document).on('mousedown', function (e) {
160179
// Clicked outside the datetimepicker, hide it
@@ -1523,6 +1542,13 @@
15231542
'<th class="next"><i class="icon-arrow-right"/></th>'+
15241543
'</tr>'+
15251544
'</thead>',
1545+
headTemplateV3: '<thead>'+
1546+
'<tr>'+
1547+
'<th class="prev"><i class="glyphicon glyphicon-arrow-left"></i> </th>'+
1548+
'<th colspan="5" class="switch"></th>'+
1549+
'<th class="next"><i class="glyphicon glyphicon-arrow-right"></i> </th>'+
1550+
'</tr>'+
1551+
'</thead>',
15261552
contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
15271553
footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
15281554
};
@@ -1563,7 +1589,43 @@
15631589
'</table>'+
15641590
'</div>'+
15651591
'</div>';
1566-
1592+
DPGlobal.templateV3 = '<div class="datetimepicker">'+
1593+
'<div class="datetimepicker-minutes">'+
1594+
'<table class=" table-condensed">'+
1595+
DPGlobal.headTemplateV3+
1596+
DPGlobal.contTemplate+
1597+
DPGlobal.footTemplate+
1598+
'</table>'+
1599+
'</div>'+
1600+
'<div class="datetimepicker-hours">'+
1601+
'<table class=" table-condensed">'+
1602+
DPGlobal.headTemplateV3+
1603+
DPGlobal.contTemplate+
1604+
DPGlobal.footTemplate+
1605+
'</table>'+
1606+
'</div>'+
1607+
'<div class="datetimepicker-days">'+
1608+
'<table class=" table-condensed">'+
1609+
DPGlobal.headTemplateV3+
1610+
'<tbody></tbody>'+
1611+
DPGlobal.footTemplate+
1612+
'</table>'+
1613+
'</div>'+
1614+
'<div class="datetimepicker-months">'+
1615+
'<table class="table-condensed">'+
1616+
DPGlobal.headTemplateV3+
1617+
DPGlobal.contTemplate+
1618+
DPGlobal.footTemplate+
1619+
'</table>'+
1620+
'</div>'+
1621+
'<div class="datetimepicker-years">'+
1622+
'<table class="table-condensed">'+
1623+
DPGlobal.headTemplateV3+
1624+
DPGlobal.contTemplate+
1625+
DPGlobal.footTemplate+
1626+
'</table>'+
1627+
'</div>'+
1628+
'</div>';
15671629
$.fn.datetimepicker.DPGlobal = DPGlobal;
15681630

15691631

js/bootstrap-datetimepicker.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

less/datetimepicker.less

+3-1
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,10 @@
407407
.datetimepicker tfoot tr:first-child th:hover {
408408
background: #eeeeee;
409409
}
410+
410411
.input-append.date .add-on i,
411-
.input-prepend.date .add-on i {
412+
.input-prepend.date .add-on i,
413+
.input-group.date .input-group-addon span {
412414
cursor: pointer;
413415
width: 14px;
414416
height: 14px;

0 commit comments

Comments
 (0)