build new release

This commit is contained in:
Socheat Sok 2017-04-25 11:21:44 +07:00
parent 0e5cf097ef
commit d6f14b915a
3 changed files with 163 additions and 113 deletions

View File

@ -1,8 +1,10 @@
/*! /*!
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017
* @version 1.3.3 * @version 1.3.4
* *
* Date formatter utility library that allows formatting date/time variables or Date objects using PHP DateTime format. * Date formatter utility library that allows formatting date/time variables or Date objects using PHP DateTime format.
* This library is a standalone javascript library and does not depend on other libraries or plugins like jQuery.
*
* @see http://php.net/manual/en/function.date.php * @see http://php.net/manual/en/function.date.php
* *
* For more JQuery plugins visit http://plugins.krajee.com * For more JQuery plugins visit http://plugins.krajee.com
@ -12,15 +14,16 @@ var DateFormatter;
(function () { (function () {
"use strict"; "use strict";
var _compare, _lpad, _extend, defaultSettings, DAY, HOUR; var _compare, _lpad, _extend, _indexOf, defaultSettings, DAY, HOUR;
DAY = 1000 * 60 * 60 * 24; DAY = 1000 * 60 * 60 * 24;
HOUR = 3600; HOUR = 3600;
_compare = function (str1, str2) { _compare = function (str1, str2) {
return typeof(str1) === 'string' && typeof(str2) === 'string' && str1.toLowerCase() === str2.toLowerCase(); return typeof(str1) === 'string' && typeof(str2) === 'string' && str1.toLowerCase() === str2.toLowerCase();
}; };
_lpad = function (value, length, char) { _lpad = function (value, length, chr) {
var chr = char || '0', val = value.toString(); var val = value.toString();
chr = chr || '0';
return val.length < length ? _lpad(chr + val, length) : val; return val.length < length ? _lpad(chr + val, length) : val;
}; };
_extend = function (out) { _extend = function (out) {
@ -43,6 +46,14 @@ var DateFormatter;
} }
return out; return out;
}; };
_indexOf = function (val, arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].toLowerCase() === val.toLowerCase()) {
return i;
}
}
return -1;
};
defaultSettings = { defaultSettings = {
dateSettings: { dateSettings: {
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
@ -77,25 +88,35 @@ var DateFormatter;
DateFormatter.prototype = { DateFormatter.prototype = {
constructor: DateFormatter, constructor: DateFormatter,
getMonth: function (val) {
var self = this, i;
i = _indexOf(val, self.dateSettings.monthsShort) + 1;
if (i === 0) {
i = _indexOf(val, self.dateSettings.months) + 1;
}
return i;
},
parseDate: function (vDate, vFormat) { parseDate: function (vDate, vFormat) {
var self = this, vFormatParts, vDateParts, i, vDateFlag = false, vTimeFlag = false, vDatePart, iDatePart, var self = this, vFormatParts, vDateParts, i, vDateFlag = false, vTimeFlag = false, vDatePart, iDatePart,
vSettings = self.dateSettings, vMonth, vMeriIndex, vMeriOffset, len, mer, vSettings = self.dateSettings, vMonth, vMeriIndex, vMeriOffset, len, mer,
out = {date: null, year: null, month: null, day: null, hour: 0, min: 0, sec: 0}; out = {date: null, year: null, month: null, day: null, hour: 0, min: 0, sec: 0};
if (!vDate) { if (!vDate) {
return undefined; return null;
} }
if (vDate instanceof Date) { if (vDate instanceof Date) {
return vDate; return vDate;
} }
if (typeof vDate === 'number') {
return new Date(vDate);
}
if (vFormat === 'U') { if (vFormat === 'U') {
i = parseInt(vDate); i = parseInt(vDate);
return i ? new Date(i * 1000) : vDate; return i ? new Date(i * 1000) : vDate;
} }
if (typeof vDate !== 'string') { switch (typeof vDate) {
return ''; case 'number':
return new Date(vDate);
case 'string':
break;
default:
return null;
} }
vFormatParts = vFormat.match(self.validParts); vFormatParts = vFormat.match(self.validParts);
if (!vFormatParts || vFormatParts.length === 0) { if (!vFormatParts || vFormatParts.length === 0) {
@ -108,11 +129,11 @@ var DateFormatter;
switch (vFormatParts[i]) { switch (vFormatParts[i]) {
case 'y': case 'y':
case 'Y': case 'Y':
len = vDatePart.length; if (iDatePart) {
if (len === 2) { len = vDatePart.length;
out.year = parseInt((iDatePart < 70 ? '20' : '19') + vDatePart); out.year = len === 2 ? parseInt((iDatePart < 70 ? '20' : '19') + vDatePart) : iDatePart;
} else if (len === 4) { } else {
out.year = iDatePart; return null;
} }
vDateFlag = true; vDateFlag = true;
break; break;
@ -120,18 +141,18 @@ var DateFormatter;
case 'n': case 'n':
case 'M': case 'M':
case 'F': case 'F':
if (isNaN(vDatePart)) { if (isNaN(iDatePart)) {
vMonth = vSettings.monthsShort.indexOf(vDatePart); vMonth = self.getMonth(vDatePart);
if (vMonth > -1) { if (vMonth > 0) {
out.month = vMonth + 1; out.month = vMonth;
} } else {
vMonth = vSettings.months.indexOf(vDatePart); return null;
if (vMonth > -1) {
out.month = vMonth + 1;
} }
} else { } else {
if (iDatePart >= 1 && iDatePart <= 12) { if (iDatePart >= 1 && iDatePart <= 12) {
out.month = iDatePart; out.month = iDatePart;
} else {
return null;
} }
} }
vDateFlag = true; vDateFlag = true;
@ -140,6 +161,8 @@ var DateFormatter;
case 'j': case 'j':
if (iDatePart >= 1 && iDatePart <= 31) { if (iDatePart >= 1 && iDatePart <= 31) {
out.day = iDatePart; out.day = iDatePart;
} else {
return null;
} }
vDateFlag = true; vDateFlag = true;
break; break;
@ -148,16 +171,22 @@ var DateFormatter;
vMeriIndex = (vFormatParts.indexOf('a') > -1) ? vFormatParts.indexOf('a') : vMeriIndex = (vFormatParts.indexOf('a') > -1) ? vFormatParts.indexOf('a') :
(vFormatParts.indexOf('A') > -1) ? vFormatParts.indexOf('A') : -1; (vFormatParts.indexOf('A') > -1) ? vFormatParts.indexOf('A') : -1;
mer = vDateParts[vMeriIndex]; mer = vDateParts[vMeriIndex];
if (vMeriIndex > -1) { if (vMeriIndex !== -1) {
vMeriOffset = _compare(mer, vSettings.meridiem[0]) ? 0 : vMeriOffset = _compare(mer, vSettings.meridiem[0]) ? 0 :
(_compare(mer, vSettings.meridiem[1]) ? 12 : -1); (_compare(mer, vSettings.meridiem[1]) ? 12 : -1);
if (iDatePart >= 1 && iDatePart <= 12 && vMeriOffset > -1) { if (iDatePart >= 1 && iDatePart <= 12 && vMeriOffset !== -1) {
out.hour = iDatePart + vMeriOffset; out.hour = iDatePart % 12 === 0 ? vMeriOffset : iDatePart + vMeriOffset;
} else if (iDatePart >= 0 && iDatePart <= 23) { } else {
out.hour = iDatePart; if (iDatePart >= 0 && iDatePart <= 23) {
out.hour = iDatePart;
}
}
} else {
if (iDatePart >= 0 && iDatePart <= 23) {
out.hour = iDatePart;
} else {
return null;
} }
} else if (iDatePart >= 0 && iDatePart <= 23) {
out.hour = iDatePart;
} }
vTimeFlag = true; vTimeFlag = true;
break; break;
@ -165,18 +194,24 @@ var DateFormatter;
case 'H': case 'H':
if (iDatePart >= 0 && iDatePart <= 23) { if (iDatePart >= 0 && iDatePart <= 23) {
out.hour = iDatePart; out.hour = iDatePart;
} else {
return null;
} }
vTimeFlag = true; vTimeFlag = true;
break; break;
case 'i': case 'i':
if (iDatePart >= 0 && iDatePart <= 59) { if (iDatePart >= 0 && iDatePart <= 59) {
out.min = iDatePart; out.min = iDatePart;
} else {
return null;
} }
vTimeFlag = true; vTimeFlag = true;
break; break;
case 's': case 's':
if (iDatePart >= 0 && iDatePart <= 59) { if (iDatePart >= 0 && iDatePart <= 59) {
out.sec = iDatePart; out.sec = iDatePart;
} else {
return null;
} }
vTimeFlag = true; vTimeFlag = true;
break; break;
@ -186,7 +221,7 @@ var DateFormatter;
out.date = new Date(out.year, out.month - 1, out.day, out.hour, out.min, out.sec, 0); out.date = new Date(out.year, out.month - 1, out.day, out.hour, out.min, out.sec, 0);
} else { } else {
if (vTimeFlag !== true) { if (vTimeFlag !== true) {
return false; return null;
} }
out.date = new Date(0, 0, 0, out.hour, out.min, out.sec, 0); out.date = new Date(0, 0, 0, out.hour, out.min, out.sec, 0);
} }
@ -196,8 +231,8 @@ var DateFormatter;
if (typeof vDateStr !== 'string') { if (typeof vDateStr !== 'string') {
return vDateStr; return vDateStr;
} }
var self = this, vParts = vDateStr.replace(self.separators, '\0').split('\0'), vPattern = /^[djmn]/g, var self = this, vParts = vDateStr.replace(self.separators, '\0').split('\0'), vPattern = /^[djmn]/g, len,
vFormatParts = vFormat.match(self.validParts), vDate = new Date(), vDigit = 0, vYear, i, iPart, iSec; vFormatParts = vFormat.match(self.validParts), vDate = new Date(), vDigit = 0, vYear, i, n, iPart, iSec;
if (!vPattern.test(vFormatParts[0])) { if (!vPattern.test(vFormatParts[0])) {
return vDateStr; return vDateStr;
@ -207,6 +242,9 @@ var DateFormatter;
vDigit = 2; vDigit = 2;
iPart = vParts[i]; iPart = vParts[i];
iSec = parseInt(iPart.substr(0, 2)); iSec = parseInt(iPart.substr(0, 2));
if (isNaN(iSec)) {
return null;
}
switch (i) { switch (i) {
case 0: case 0:
if (vFormatParts[0] === 'm' || vFormatParts[0] === 'n') { if (vFormatParts[0] === 'm' || vFormatParts[0] === 'n') {
@ -224,13 +262,13 @@ var DateFormatter;
break; break;
case 2: case 2:
vYear = vDate.getFullYear(); vYear = vDate.getFullYear();
if (iPart.length < 4) { len = iPart.length;
vDate.setFullYear(parseInt(vYear.toString().substr(0, 4 - iPart.length) + iPart)); vDigit = len < 4 ? len : 4;
vDigit = iPart.length; vYear = parseInt(len < 4 ? vYear.toString().substr(0, 4 - len) + iPart : iPart.substr(0, 4));
} else { if (!vYear) {
vDate.setFullYear = parseInt(iPart.substr(0, 4)); return null;
vDigit = 4;
} }
vDate.setFullYear(vYear);
break; break;
case 3: case 3:
vDate.setHours(iSec); vDate.setHours(iSec);
@ -242,14 +280,15 @@ var DateFormatter;
vDate.setSeconds(iSec); vDate.setSeconds(iSec);
break; break;
} }
if (iPart.substr(vDigit).length > 0) { n = iPart.substr(vDigit);
vParts.splice(i + 1, 0, iPart.substr(vDigit)); if (n.length > 0) {
vParts.splice(i + 1, 0, n);
} }
} }
return vDate; return vDate;
}, },
parseFormat: function (vChar, vDate) { parseFormat: function (vChar, vDate) {
var self = this, vSettings = self.dateSettings, fmt, backspace = /\\?(.?)/gi, doFormat = function (t, s) { var self = this, vSettings = self.dateSettings, fmt, backslash = /\\?(.?)/gi, doFormat = function (t, s) {
return fmt[t] ? fmt[t]() : s; return fmt[t] ? fmt[t]() : s;
}; };
fmt = { fmt = {
@ -479,14 +518,6 @@ var DateFormatter;
var str = /\((.*)\)/.exec(String(vDate))[1]; var str = /\((.*)\)/.exec(String(vDate))[1];
return str || 'Coordinated Universal Time'; return str || 'Coordinated Universal Time';
}, },
/**
* Timezone abbreviation: `e.g. EST, MDT, ...`
* @return {string}
*/
T: function () {
var str = (String(vDate).match(self.tzParts) || [""]).pop().replace(self.tzClip, "");
return str || 'UTC';
},
/** /**
* DST observed? `0 or 1` * DST observed? `0 or 1`
* @return {number} * @return {number}
@ -512,6 +543,14 @@ var DateFormatter;
var O = fmt.O(); var O = fmt.O();
return (O.substr(0, 3) + ':' + O.substr(3, 2)); return (O.substr(0, 3) + ':' + O.substr(3, 2));
}, },
/**
* Timezone abbreviation: `e.g. EST, MDT, ...`
* @return {string}
*/
T: function () {
var str = (String(vDate).match(self.tzParts) || [""]).pop().replace(self.tzClip, "");
return str || 'UTC';
},
/** /**
* Timezone offset in seconds: `-43200...50400` * Timezone offset in seconds: `-43200...50400`
* @return {number} * @return {number}
@ -528,14 +567,14 @@ var DateFormatter;
* @return {string} * @return {string}
*/ */
c: function () { c: function () {
return 'Y-m-d\\TH:i:sP'.replace(backspace, doFormat); return 'Y-m-d\\TH:i:sP'.replace(backslash, doFormat);
}, },
/** /**
* RFC 2822 date * RFC 2822 date
* @return {string} * @return {string}
*/ */
r: function () { r: function () {
return 'D, d M Y H:i:s O'.replace(backspace, doFormat); return 'D, d M Y H:i:s O'.replace(backslash, doFormat);
}, },
/** /**
* Seconds since UNIX epoch * Seconds since UNIX epoch
@ -548,23 +587,27 @@ var DateFormatter;
return doFormat(vChar, vChar); return doFormat(vChar, vChar);
}, },
formatDate: function (vDate, vFormat) { formatDate: function (vDate, vFormat) {
var self = this, i, n, len, str, vChar, vDateStr = ''; var self = this, i, n, len, str, vChar, vDateStr = '', BACKSLASH = '\\';
if (typeof vDate === 'string') { if (typeof vDate === 'string') {
vDate = self.parseDate(vDate, vFormat); vDate = self.parseDate(vDate, vFormat);
if (vDate === false) { if (!vDate) {
return false; return null;
} }
} }
if (vDate instanceof Date) { if (vDate instanceof Date) {
len = vFormat.length; len = vFormat.length;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
vChar = vFormat.charAt(i); vChar = vFormat.charAt(i);
if (vChar === 'S') { if (vChar === 'S' || vChar === BACKSLASH) {
continue;
}
if (i > 0 && vFormat.charAt(i - 1) === BACKSLASH) {
vDateStr += vChar;
continue; continue;
} }
str = self.parseFormat(vChar, vDate); str = self.parseFormat(vChar, vDate);
if (i !== (len - 1) && self.intParts.test(vChar) && vFormat.charAt(i + 1) === 'S') { if (i !== (len - 1) && self.intParts.test(vChar) && vFormat.charAt(i + 1) === 'S') {
n = parseInt(str); n = parseInt(str) || 0;
str += self.dateSettings.ordinal(n); str += self.dateSettings.ordinal(n);
} }
vDateStr += str; vDateStr += str;
@ -574,7 +617,8 @@ var DateFormatter;
return ''; return '';
} }
}; };
})();/** })();
/**
* @preserve jQuery DateTimePicker plugin v2.5.4 * @preserve jQuery DateTimePicker plugin v2.5.4
* @homepage http://xdsoft.net/jqplugins/datetimepicker/ * @homepage http://xdsoft.net/jqplugins/datetimepicker/
* @author Chupurnov Valeriy (<chupurnov@gmail.com>) * @author Chupurnov Valeriy (<chupurnov@gmail.com>)
@ -593,9 +637,6 @@ var DateFormatter;
} }
}(function ($) { }(function ($) {
'use strict'; 'use strict';
var currentlyScrollingTimeDiv = false;
var default_options = { var default_options = {
i18n: { i18n: {
ar: { // Arabic ar: { // Arabic
@ -776,6 +817,13 @@ var DateFormatter;
"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör" "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
] ]
}, },
km: { // Khmer
months: [
"មករា​", "កុម្ភៈ", "មិនា​", "មេសា​", "ឧសភា​", "មិថុនា​", "កក្កដា​", "សីហា​", "កញ្ញា​", "តុលា​", "វិច្ឋិកា​", "ធ្នូ​"
],
dayOfWeekShort: ["អាទិ​", "ចន្ទ​", "អង្គារ​", "ពុធ​", "ព្រហ​​", "សុក្រ​", "សៅរ៍"],
dayOfWeek: ["អាទិត្យ​", "ចន្ទ​", "អង្គារ​", "ពុធ​", "ព្រហស្បតិ៍​", "សុក្រ​", "សៅរ៍"]
},
kr: { // Korean kr: { // Korean
months: [ months: [
"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월" "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
@ -1102,8 +1150,12 @@ var DateFormatter;
"კვ", "ორშ", "სამშ", "ოთხ", "ხუთ", "პარ", "შაბ" "კვ", "ორშ", "სამშ", "ოთხ", "ხუთ", "პარ", "შაბ"
], ],
dayOfWeek: ["კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"] dayOfWeek: ["კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"]
}, }
}, },
ownerDocument: document,
contentWindow: window,
value: '', value: '',
rtl: false, rtl: false,
@ -1209,12 +1261,14 @@ var DateFormatter;
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) })
}; };
dateHelper = new DateFormatter({ if (typeof DateFormatter === 'function') {
dateSettings: $.extend({}, dateFormatterOptionsDefault, opts) dateHelper = new DateFormatter({
}); dateSettings: $.extend({}, dateFormatterOptionsDefault, opts)
});
}
}; };
// for locale settings // for locale settings
@ -1275,7 +1329,7 @@ var DateFormatter;
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) {
@ -1339,15 +1393,15 @@ var DateFormatter;
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();
@ -1556,14 +1610,14 @@ var DateFormatter;
} }
} }
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();
@ -1725,7 +1779,7 @@ var DateFormatter;
} }
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)) {
@ -1802,10 +1856,10 @@ var DateFormatter;
//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
@ -2063,10 +2117,10 @@ var DateFormatter;
} }
}(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);
}); });
}); });
@ -2105,10 +2159,10 @@ var DateFormatter;
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);
}); });
}); });
@ -2413,13 +2467,8 @@ var DateFormatter;
}); });
timebox timebox
.on('touchmove', 'div', function () { currentlyScrollingTimeDiv = true; })
.on('touchend click.xdsoft', 'div', function (xdevent) { .on('touchend click.xdsoft', 'div', function (xdevent) {
xdevent.stopPropagation(); xdevent.stopPropagation();
if (currentlyScrollingTimeDiv) {
currentlyScrollingTimeDiv = false;
return;
}
var $this = $(this), var $this = $(this),
currentTime = _xdsoft_datetime.currentTime; currentTime = _xdsoft_datetime.currentTime;
@ -2558,11 +2607,11 @@ var DateFormatter;
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;
} }
@ -2573,13 +2622,13 @@ var DateFormatter;
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;
} }
@ -2615,7 +2664,7 @@ var DateFormatter;
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);
@ -2644,14 +2693,14 @@ var DateFormatter;
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);
}); });
} }
} }
@ -2725,8 +2774,8 @@ var DateFormatter;
}, },
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) {
@ -2737,7 +2786,7 @@ var DateFormatter;
} }
}, },
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;
} }
@ -2888,14 +2937,14 @@ var DateFormatter;
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) {
@ -2969,6 +3018,7 @@ var DateFormatter;
this.style = style; this.style = style;
} }
})); }));
/*! /*!
* jQuery Mousewheel 3.1.13 * jQuery Mousewheel 3.1.13
* *

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long