Skip to content

Commit

Permalink
add insideParent property
Browse files Browse the repository at this point in the history
  • Loading branch information
degtyarevmaksim committed Jan 16, 2019
1 parent 2801f1a commit ebc3c86
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
20 changes: 14 additions & 6 deletions build/jquery.datetimepicker.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ var datetimepickerFactory = function ($) {
beforeShowDay: null,

enterLikeTab: true,
showApplyButton: false
showApplyButton: false,
insideParent: false,
};

var dateHelper = null,
Expand Down Expand Up @@ -1355,8 +1356,11 @@ var datetimepickerFactory = function ($) {
.append(calendar)
.append(applyButton);

$(options.parentID)
.append(datetimepicker);
if (options.insideParent) {
$(input).parent().append(datetimepicker);
} else {
$(options.parentID).append(datetimepicker);
}

XDSoft_datetime = function () {
var _this = this;
Expand Down Expand Up @@ -2182,7 +2186,7 @@ var datetimepickerFactory = function ($) {
}
});

if (dateInputHasFixedAncestor) {
if (dateInputHasFixedAncestor && !options.insideParent) {
position = 'fixed';

//If the picker won't fit entirely within the viewport then display it above the date input.
Expand Down Expand Up @@ -2222,12 +2226,16 @@ var datetimepickerFactory = function ($) {

datetimepickerCss = {
position: position,
left: left,
left: options.insideParent ? dateInputElem.offsetLeft : left,
top: '', //Initialize to prevent previous values interfering with new ones.
bottom: '' //Initialize to prevent previous values interfering with new ones.
};

datetimepickerCss[verticalAnchorEdge] = verticalPosition;
if (options.insideParent) {
datetimepickerCss[verticalAnchorEdge] = dateInputElem.offsetTop + dateInputElem.offsetHeight;
} else {
datetimepickerCss[verticalAnchorEdge] = verticalPosition;
}

datetimepicker.css(datetimepickerCss);
};
Expand Down
2 changes: 1 addition & 1 deletion build/jquery.datetimepicker.full.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/jquery.datetimepicker.min.js

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions jquery.datetimepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@ var datetimepickerFactory = function ($) {
beforeShowDay: null,

enterLikeTab: true,
showApplyButton: false
showApplyButton: false,
insideParent: false,
};

var dateHelper = null,
Expand Down Expand Up @@ -1346,8 +1347,11 @@ var datetimepickerFactory = function ($) {
.append(calendar)
.append(applyButton);

$(options.parentID)
.append(datetimepicker);
if (options.insideParent) {
$(input).parent().append(datetimepicker);
} else {
$(options.parentID).append(datetimepicker);
}

XDSoft_datetime = function () {
var _this = this;
Expand Down Expand Up @@ -2173,7 +2177,7 @@ var datetimepickerFactory = function ($) {
}
});

if (dateInputHasFixedAncestor) {
if (dateInputHasFixedAncestor && !options.insideParent) {
position = 'fixed';

//If the picker won't fit entirely within the viewport then display it above the date input.
Expand Down Expand Up @@ -2213,12 +2217,16 @@ var datetimepickerFactory = function ($) {

datetimepickerCss = {
position: position,
left: left,
left: options.insideParent ? dateInputElem.offsetLeft : left,
top: '', //Initialize to prevent previous values interfering with new ones.
bottom: '' //Initialize to prevent previous values interfering with new ones.
};

datetimepickerCss[verticalAnchorEdge] = verticalPosition;
if (options.insideParent) {
datetimepickerCss[verticalAnchorEdge] = dateInputElem.offsetTop + dateInputElem.offsetHeight;
} else {
datetimepickerCss[verticalAnchorEdge] = verticalPosition;
}

datetimepicker.css(datetimepickerCss);
};
Expand Down

0 comments on commit ebc3c86

Please sign in to comment.