Fix getComputedStyle for ie8

This commit is contained in:
Valeriy 2015-07-03 14:26:21 +05:00
parent 89668464a1
commit 72ff0b43e5
4 changed files with 49 additions and 24 deletions

View File

@ -1,6 +1,6 @@
{
"name": "datetimepicker",
"version": "2.4.4",
"version": "2.4.5",
"main": [
"jquery.datetimepicker.js",
"jquery.datetimepicker.css"

View File

@ -1,6 +1,6 @@
{
"name": "datetimepicker",
"version": "2.4.4",
"version": "2.4.5",
"title": "jQuery Date and Time picker",
"description": "jQuery plugin for date, time, or datetime manipulation in form",
"keywords": [

View File

@ -1,5 +1,5 @@
/**
* @preserve jQuery DateTimePicker plugin v2.4.4
* @preserve jQuery DateTimePicker plugin v2.4.5
* @homepage http://xdsoft.net/jqplugins/datetimepicker/
* (c) 2014, Chupurnov Valeriy.
*/
@ -529,6 +529,24 @@
showApplyButton: false
};
// fix for ie8
if (!window.getComputedStyle) {
window.getComputedStyle = function (el, pseudo) {
this.el = el;
this.getPropertyValue = function (prop) {
var re = /(\-([a-z]){1})/g;
if (prop === 'float') {
prop = 'styleFloat';
}
if (re.test(prop)) {
prop = prop.replace(re, function (a, b, c) {
return c.toUpperCase();
});
}
return el.currentStyle[prop] || null;
};
return this;
};
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (obj, start) {
var i, j;
@ -773,9 +791,15 @@
timer1 = 0,
_xdsoft_datetime;
if (options.id) datetimepicker.attr('id', options.id);
if (options.style) datetimepicker.attr('style', options.style);
if (options.weeks) datetimepicker.addClass('xdsoft_showweeks');
if (options.id) {
datetimepicker.attr('id', options.id);
}
if (options.style) {
datetimepicker.attr('style', options.style);
}
if (options.weeks) {
datetimepicker.addClass('xdsoft_showweeks');
}
datetimepicker.addClass('xdsoft_' + options.theme);
datetimepicker.addClass(options.className);
@ -1347,14 +1371,14 @@
_xdsoft_datetime.setCurrentTime(0);
datetimepicker.trigger('afterOpen.xdsoft');
}).on('dblclick.xdsoft', function () {
var currentDate = _xdsoft_datetime.getCurrentTime();
var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
var minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
if (currentDate < minDate) {
return;
}
var maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
if (currentDate > maxDate) {
return;
@ -1794,7 +1818,7 @@
current_time_index = 0;
setPos = function () {
var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute";
var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute", node;
if (options.fixed) {
top -= $(window).scrollTop();
left -= $(window).scrollLeft();
@ -1810,14 +1834,15 @@
left = $(window).width() - datetimepicker[0].offsetWidth;
}
}
var node = datetimepicker[0]
node = datetimepicker[0];
do {
node = node.parentNode;
if (window.getComputedStyle(node).getPropertyValue('position') === 'relative' && $(window).width() >= node.offsetWidth) {
left = left - (($(window).width() - node.offsetWidth)/2)
break
left = left - (($(window).width() - node.offsetWidth) / 2);
break;
}
} while(node.nodeName != 'HTML')
} while (node.nodeName !== 'HTML');
datetimepicker.css({
left: left,
top: top,

View File

@ -1,6 +1,6 @@
{
"name": "jquery-datetimepicker",
"version": "2.4.4",
"version": "2.4.5",
"description": "jQuery Plugin DateTimePicker it is DatePicker and TimePicker in one",
"main": "jquery.datetimepicker.js",
"scripts": {