Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Side-by-side support #184

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/css/bootstrap-datetimepicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
border-top: 1px solid #ddd !important;
}*/
}
.bootstrap-datetimepicker-widget.timepicker-sbs{
width: 600px;
}
.bootstrap-datetimepicker-widget .btn {
padding: 6px;
}
Expand Down
46 changes: 27 additions & 19 deletions src/js/bootstrap-datetimepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
if (typeof moment === 'undefined') {
alert("momentjs is requried");
throw new Error('momentjs is required');
};
}

var dpgId = 0,

Expand All @@ -68,7 +68,8 @@
enabledDates: false,
icons: {},
useStrict: false,
direction: "auto"
direction: "auto",
sideBySide:false
},

icons = {
Expand Down Expand Up @@ -144,7 +145,7 @@
}
}

picker.widget = $(getTemplate(picker.options.pickDate, picker.options.pickTime, picker.options.collapse)).appendTo('body');
picker.widget = $(getTemplate(picker)).appendTo('body');
picker.minViewMode = picker.options.minViewMode || picker.element.data('date-minviewmode') || 0;
if (typeof picker.minViewMode === 'string') {
switch (picker.minViewMode) {
Expand Down Expand Up @@ -857,22 +858,29 @@
else return '0' + string;
},

getTemplate = function (pickDate, pickTime, collapse) {
if (pickDate && pickTime) {
return (
'<div class="bootstrap-datetimepicker-widget dropdown-menu" style="z-index:9999 !important;">' +
'<ul class="list-unstyled">' +
'<li' + (collapse ? ' class="collapse in"' : '') + '>' +
'<div class="datepicker">' + dpGlobal.template + '</div>' +
'</li>' +
'<li class="picker-switch accordion-toggle"><a class="btn" style="width:100%"><span class="' + picker.options.icons.time + '"></span></a></li>' +
'<li' + (collapse ? ' class="collapse"' : '') + '>' +
'<div class="timepicker">' + tpGlobal.getTemplate() + '</div>' +
'</li>' +
'</ul>' +
'</div>'
);
} else if (pickTime) {
getTemplate = function (picker) {
if (picker.options.pickDate && picker.options.pickTime) {
var ret='';
ret='<div class="bootstrap-datetimepicker-widget'+(picker.options.sideBySide ?' timepicker-sbs':'')+' dropdown-menu" style="z-index:9999 !important;">';
if(picker.options.sideBySide){
ret +='<div class="row">'+
'<div class="col-sm-6 datepicker">' + dpGlobal.template + '</div>'+
'<div class="col-sm-6 timepicker">' + tpGlobal.getTemplate() + '</div>'+
'</div>';
}else{
ret +='<ul class="list-unstyled">' +
'<li' + (picker.options.collapse ? ' class="collapse in"' : '') + '>' +
'<div class="datepicker">' + dpGlobal.template + '</div>' +
'</li>' +
'<li class="picker-switch accordion-toggle"><a class="btn" style="width:100%"><span class="' + picker.options.icons.time + '"></span></a></li>' +
'<li' + (picker.options.collapse ? ' class="collapse"' : '') + '>' +
'<div class="timepicker">' + tpGlobal.getTemplate() + '</div>' +
'</li>' +
'</ul>';
}
ret +='</div>';
return ret;
} else if (picker.options.pickTime) {
return (
'<div class="bootstrap-datetimepicker-widget dropdown-menu">' +
'<div class="timepicker">' + tpGlobal.getTemplate() + '</div>' +
Expand Down
4 changes: 4 additions & 0 deletions src/less/bootstrap-datetimepicker.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
margin-top: 1px;
z-index: 99999;
border-radius: 4px;

&.timepicker-sbs{
width: 600px;
}

.btn {
padding:6px;
Expand Down