mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
iframe support
This commit is contained in:
parent
16a1beeef3
commit
962ed78566
@ -523,8 +523,12 @@
|
|||||||
"კვ", "ორშ", "სამშ", "ოთხ", "ხუთ", "პარ", "შაბ"
|
"კვ", "ორშ", "სამშ", "ოთხ", "ხუთ", "პარ", "შაბ"
|
||||||
],
|
],
|
||||||
dayOfWeek: ["კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"]
|
dayOfWeek: ["კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
|
||||||
|
ownerDocument: document,
|
||||||
|
contentWindow: window,
|
||||||
|
|
||||||
value: '',
|
value: '',
|
||||||
rtl: false,
|
rtl: false,
|
||||||
|
|
||||||
@ -630,12 +634,14 @@
|
|||||||
days: locale.dayOfWeek,
|
days: locale.dayOfWeek,
|
||||||
daysShort: locale.dayOfWeekShort,
|
daysShort: locale.dayOfWeekShort,
|
||||||
months: locale.months,
|
months: locale.months,
|
||||||
monthsShort: $.map(locale.months, function(n){ return n.substring(0, 3) }),
|
monthsShort: $.map(locale.months, function(n){ return n.substring(0, 3) })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof DateFormatter === 'function') {
|
||||||
dateHelper = new DateFormatter({
|
dateHelper = new DateFormatter({
|
||||||
dateSettings: $.extend({}, dateFormatterOptionsDefault, opts)
|
dateSettings: $.extend({}, dateFormatterOptionsDefault, opts)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// for locale settings
|
// for locale settings
|
||||||
@ -696,7 +702,7 @@
|
|||||||
Date.prototype.countDaysInMonth = function () {
|
Date.prototype.countDaysInMonth = function () {
|
||||||
return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
|
return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
|
||||||
};
|
};
|
||||||
$.fn.xdsoftScroller = function (percent) {
|
$.fn.xdsoftScroller = function (options, percent) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
var timeboxparent = $(this),
|
var timeboxparent = $(this),
|
||||||
pointerEventToXY = function (e) {
|
pointerEventToXY = function (e) {
|
||||||
@ -760,15 +766,15 @@
|
|||||||
h1 = scrollbar[0].offsetHeight;
|
h1 = scrollbar[0].offsetHeight;
|
||||||
|
|
||||||
if (event.type === 'mousedown' || event.type === 'touchstart') {
|
if (event.type === 'mousedown' || event.type === 'touchstart') {
|
||||||
if (document) {
|
if (options.ownerDocument) {
|
||||||
$(document.body).addClass('xdsoft_noselect');
|
$(options.ownerDocument.body).addClass('xdsoft_noselect');
|
||||||
}
|
}
|
||||||
$([document.body, window]).on('touchend mouseup.xdsoft_scroller', function arguments_callee() {
|
$([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft_scroller', function arguments_callee() {
|
||||||
$([document.body, window]).off('touchend mouseup.xdsoft_scroller', arguments_callee)
|
$([options.ownerDocument.body, options.contentWindow]).off('touchend mouseup.xdsoft_scroller', arguments_callee)
|
||||||
.off('mousemove.xdsoft_scroller', calcOffset)
|
.off('mousemove.xdsoft_scroller', calcOffset)
|
||||||
.removeClass('xdsoft_noselect');
|
.removeClass('xdsoft_noselect');
|
||||||
});
|
});
|
||||||
$(document.body).on('mousemove.xdsoft_scroller', calcOffset);
|
$(options.ownerDocument.body).on('mousemove.xdsoft_scroller', calcOffset);
|
||||||
} else {
|
} else {
|
||||||
touchStart = true;
|
touchStart = true;
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@ -977,14 +983,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
|
select.xdsoftScroller(options, top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
month_picker
|
month_picker
|
||||||
.find('.xdsoft_select')
|
.find('.xdsoft_select')
|
||||||
.xdsoftScroller()
|
.xdsoftScroller(options)
|
||||||
.on('touchstart mousedown.xdsoft', function (event) {
|
.on('touchstart mousedown.xdsoft', function (event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -1146,7 +1152,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!options.timepickerScrollbar) {
|
if (!options.timepickerScrollbar) {
|
||||||
timeboxparent.xdsoftScroller('hide');
|
timeboxparent.xdsoftScroller(options, 'hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.minDate && /^[\+\-](.*)$/.test(options.minDate)) {
|
if (options.minDate && /^[\+\-](.*)$/.test(options.minDate)) {
|
||||||
@ -1223,10 +1229,10 @@
|
|||||||
|
|
||||||
//scroll_element = timepicker.find('.xdsoft_time_box');
|
//scroll_element = timepicker.find('.xdsoft_time_box');
|
||||||
timeboxparent.append(timebox);
|
timeboxparent.append(timebox);
|
||||||
timeboxparent.xdsoftScroller();
|
timeboxparent.xdsoftScroller(options);
|
||||||
|
|
||||||
datetimepicker.on('afterOpen.xdsoft', function () {
|
datetimepicker.on('afterOpen.xdsoft', function () {
|
||||||
timeboxparent.xdsoftScroller();
|
timeboxparent.xdsoftScroller(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
datetimepicker
|
datetimepicker
|
||||||
@ -1484,10 +1490,10 @@
|
|||||||
}
|
}
|
||||||
}(500));
|
}(500));
|
||||||
|
|
||||||
$([document.body, window]).on('touchend mouseup.xdsoft', function arguments_callee2() {
|
$([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft', function arguments_callee2() {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
stop = true;
|
stop = true;
|
||||||
$([document.body, window]).off('touchend mouseup.xdsoft', arguments_callee2);
|
$([options.ownerDocument.body, options.contentWindow]).off('touchend mouseup.xdsoft', arguments_callee2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1526,10 +1532,10 @@
|
|||||||
timer = setTimeout(arguments_callee4, v || period);
|
timer = setTimeout(arguments_callee4, v || period);
|
||||||
}
|
}
|
||||||
}(500));
|
}(500));
|
||||||
$([document.body, window]).on('touchend mouseup.xdsoft', function arguments_callee5() {
|
$([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft', function arguments_callee5() {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
stop = true;
|
stop = true;
|
||||||
$([document.body, window])
|
$([options.ownerDocument.body, options.contentWindow])
|
||||||
.off('touchend mouseup.xdsoft', arguments_callee5);
|
.off('touchend mouseup.xdsoft', arguments_callee5);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1974,11 +1980,11 @@
|
|||||||
left = dateInputOffset.left;
|
left = dateInputOffset.left;
|
||||||
position = "absolute";
|
position = "absolute";
|
||||||
|
|
||||||
windowWidth = $(window).width();
|
windowWidth = $(options.contentWindow).width();
|
||||||
windowHeight = $(window).height();
|
windowHeight = $(options.contentWindow).height();
|
||||||
windowScrollTop = $(window).scrollTop();
|
windowScrollTop = $(options.contentWindow).scrollTop();
|
||||||
|
|
||||||
if ((document.documentElement.clientWidth - dateInputOffset.left) < datepicker.parent().outerWidth(true)) {
|
if ((options.ownerDocument.documentElement.clientWidth - dateInputOffset.left) < datepicker.parent().outerWidth(true)) {
|
||||||
var diff = datepicker.parent().outerWidth(true) - dateInputElem.offsetWidth;
|
var diff = datepicker.parent().outerWidth(true) - dateInputElem.offsetWidth;
|
||||||
left = left - diff;
|
left = left - diff;
|
||||||
}
|
}
|
||||||
@ -1989,13 +1995,13 @@
|
|||||||
|
|
||||||
if (options.fixed) {
|
if (options.fixed) {
|
||||||
verticalPosition -= windowScrollTop;
|
verticalPosition -= windowScrollTop;
|
||||||
left -= $(window).scrollLeft();
|
left -= $(options.contentWindow).scrollLeft();
|
||||||
position = "fixed";
|
position = "fixed";
|
||||||
} else {
|
} else {
|
||||||
dateInputHasFixedAncestor = false;
|
dateInputHasFixedAncestor = false;
|
||||||
|
|
||||||
forEachAncestorOf(dateInputElem, function (ancestorNode) {
|
forEachAncestorOf(dateInputElem, function (ancestorNode) {
|
||||||
if (window.getComputedStyle(ancestorNode).getPropertyValue('position') === 'fixed') {
|
if (options.contentWindow.getComputedStyle(ancestorNode).getPropertyValue('position') === 'fixed') {
|
||||||
dateInputHasFixedAncestor = true;
|
dateInputHasFixedAncestor = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2031,7 +2037,7 @@
|
|||||||
forEachAncestorOf(datetimepickerElem, function (ancestorNode) {
|
forEachAncestorOf(datetimepickerElem, function (ancestorNode) {
|
||||||
var ancestorNodePosition;
|
var ancestorNodePosition;
|
||||||
|
|
||||||
ancestorNodePosition = window.getComputedStyle(ancestorNode).getPropertyValue('position');
|
ancestorNodePosition = options.contentWindow.getComputedStyle(ancestorNode).getPropertyValue('position');
|
||||||
|
|
||||||
if (ancestorNodePosition === 'relative' && windowWidth >= ancestorNode.offsetWidth) {
|
if (ancestorNodePosition === 'relative' && windowWidth >= ancestorNode.offsetWidth) {
|
||||||
left = left - ((windowWidth - ancestorNode.offsetWidth) / 2);
|
left = left - ((windowWidth - ancestorNode.offsetWidth) / 2);
|
||||||
@ -2060,14 +2066,14 @@
|
|||||||
if (onShow !== false) {
|
if (onShow !== false) {
|
||||||
datetimepicker.show();
|
datetimepicker.show();
|
||||||
setPos();
|
setPos();
|
||||||
$(window)
|
$(options.contentWindow)
|
||||||
.off('resize.xdsoft', setPos)
|
.off('resize.xdsoft', setPos)
|
||||||
.on('resize.xdsoft', setPos);
|
.on('resize.xdsoft', setPos);
|
||||||
|
|
||||||
if (options.closeOnWithoutClick) {
|
if (options.closeOnWithoutClick) {
|
||||||
$([document.body, window]).on('touchstart mousedown.xdsoft', function arguments_callee6() {
|
$([options.ownerDocument.body, options.contentWindow]).on('touchstart mousedown.xdsoft', function arguments_callee6() {
|
||||||
datetimepicker.trigger('close.xdsoft');
|
datetimepicker.trigger('close.xdsoft');
|
||||||
$([document.body, window]).off('touchstart mousedown.xdsoft', arguments_callee6);
|
$([options.ownerDocument.body, options.contentWindow]).off('touchstart mousedown.xdsoft', arguments_callee6);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2141,8 +2147,8 @@
|
|||||||
},
|
},
|
||||||
getCaretPos = function (input) {
|
getCaretPos = function (input) {
|
||||||
try {
|
try {
|
||||||
if (document.selection && document.selection.createRange) {
|
if (options.ownerDocument.selection && options.ownerDocument.selection.createRange) {
|
||||||
var range = document.selection.createRange();
|
var range = options.ownerDocument.selection.createRange();
|
||||||
return range.getBookmark().charCodeAt(2) - 2;
|
return range.getBookmark().charCodeAt(2) - 2;
|
||||||
}
|
}
|
||||||
if (input.setSelectionRange) {
|
if (input.setSelectionRange) {
|
||||||
@ -2153,7 +2159,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setCaretPos = function (node, pos) {
|
setCaretPos = function (node, pos) {
|
||||||
node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
|
node = (typeof node === "string" || node instanceof String) ? options.ownerDocument.getElementById(node) : node;
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2304,14 +2310,14 @@
|
|||||||
input
|
input
|
||||||
.data('xdsoft_datetimepicker', null)
|
.data('xdsoft_datetimepicker', null)
|
||||||
.off('.xdsoft');
|
.off('.xdsoft');
|
||||||
$(window).off('resize.xdsoft');
|
$(options.contentWindow).off('resize.xdsoft');
|
||||||
$([window, document.body]).off('mousedown.xdsoft touchstart');
|
$([options.contentWindow, options.ownerDocument.body]).off('mousedown.xdsoft touchstart');
|
||||||
if (input.unmousewheel) {
|
if (input.unmousewheel) {
|
||||||
input.unmousewheel();
|
input.unmousewheel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$(document)
|
$(options.ownerDocument)
|
||||||
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
|
||||||
.on('keydown.xdsoftctrl', function (e) {
|
.on('keydown.xdsoftctrl', function (e) {
|
||||||
if (e.keyCode === CTRLKEY) {
|
if (e.keyCode === CTRLKEY) {
|
||||||
|
Loading…
Reference in New Issue
Block a user