/** * @preserve jquery datetimepicker plugin v2.4.1 * @homepage http://xdsoft.net/jqplugins/datetimepicker/ * (c) 2014, chupurnov valeriy. */ /*global document,window,jquery,settimeout,cleartimeout*/ (function ($) { 'use strict'; var default_options = { i18n: { ar: { // arabic months: [ "كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول" ], dayofweek: [ "ن", "ث", "ع", "خ", "ج", "س", "ح" ] }, ro: { // romanian months: [ "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie" ], dayofweek: [ "l", "ma", "mi", "j", "v", "s", "d" ] }, id: { // indonesian months: [ "januari", "februari", "maret", "april", "mei", "juni", "juli", "agustus", "september", "oktober", "november", "desember" ], dayofweek: [ "min", "sen", "sel", "rab", "kam", "jum", "sab" ] }, bg: { // bulgarian months: [ "януари", "февруари", "март", "април", "май", "юни", "юли", "август", "септември", "октомври", "ноември", "декември" ], dayofweek: [ "нд", "пн", "вт", "ср", "чт", "пт", "сб" ] }, fa: { // persian/farsi months: [ 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند' ], dayofweek: [ 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه' ] }, ru: { // russian months: [ 'январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь' ], dayofweek: [ "вск", "пн", "вт", "ср", "чт", "пт", "сб" ] }, uk: { // ukrainian months: [ 'січень', 'лютий', 'березень', 'квітень', 'травень', 'червень', 'липень', 'серпень', 'вересень', 'жовтень', 'листопад', 'грудень' ], dayofweek: [ "ндл", "пнд", "втр", "срд", "чтв", "птн", "сбт" ] }, en: { // english months: [ "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ], dayofweek: [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ] }, el: { // ελληνικά months: [ "ιανουάριος", "φεβρουάριος", "μάρτιος", "απρίλιος", "μάιος", "ιούνιος", "ιούλιος", "αύγουστος", "σεπτέμβριος", "οκτώβριος", "νοέμβριος", "δεκέμβριος" ], dayofweek: [ "κυρ", "δευ", "τρι", "τετ", "πεμ", "παρ", "σαβ" ] }, de: { // german months: [ 'januar', 'februar', 'märz', 'april', 'mai', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'dezember' ], dayofweek: [ "so", "mo", "di", "mi", "do", "fr", "sa" ] }, nl: { // dutch months: [ "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december" ], dayofweek: [ "zo", "ma", "di", "wo", "do", "vr", "za" ] }, tr: { // turkish months: [ "ocak", "şubat", "mart", "nisan", "mayıs", "haziran", "temmuz", "ağustos", "eylül", "ekim", "kasım", "aralık" ], dayofweek: [ "paz", "pts", "sal", "çar", "per", "cum", "cts" ] }, fr: { //french months: [ "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre" ], dayofweek: [ "dim", "lun", "mar", "mer", "jeu", "ven", "sam" ] }, es: { // spanish months: [ "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre" ], dayofweek: [ "dom", "lun", "mar", "mié", "jue", "vie", "sáb" ] }, th: { // thai months: [ 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม' ], dayofweek: [ 'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.' ] }, pl: { // polish months: [ "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień" ], dayofweek: [ "nd", "pn", "wt", "śr", "cz", "pt", "sb" ] }, pt: { // portuguese months: [ "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro" ], dayofweek: [ "dom", "seg", "ter", "qua", "qui", "sex", "sab" ] }, ch: { // simplified chinese months: [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" ], dayofweek: [ "日", "一", "二", "三", "四", "五", "六" ] }, se: { // swedish months: [ "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december" ], dayofweek: [ "sön", "mån", "tis", "ons", "tor", "fre", "lör" ] }, kr: { // korean months: [ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월" ], dayofweek: [ "일", "월", "화", "수", "목", "금", "토" ] }, it: { // italian months: [ "gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre" ], dayofweek: [ "dom", "lun", "mar", "mer", "gio", "ven", "sab" ] }, da: { // dansk months: [ "january", "februar", "marts", "april", "maj", "juni", "july", "august", "september", "oktober", "november", "december" ], dayofweek: [ "søn", "man", "tir", "ons", "tor", "fre", "lør" ] }, no: { // norwegian months: [ "januar", "februar", "mars", "april", "mai", "juni", "juli", "august", "september", "oktober", "november", "desember" ], dayofweek: [ "søn", "man", "tir", "ons", "tor", "fre", "lør" ] }, ja: { // japanese months: [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" ], dayofweek: [ "日", "月", "火", "水", "木", "金", "土" ] }, vi: { // vietnamese months: [ "tháng 1", "tháng 2", "tháng 3", "tháng 4", "tháng 5", "tháng 6", "tháng 7", "tháng 8", "tháng 9", "tháng 10", "tháng 11", "tháng 12" ], dayofweek: [ "cn", "t2", "t3", "t4", "t5", "t6", "t7" ] }, sl: { // slovenščina months: [ "januar", "februar", "marec", "april", "maj", "junij", "julij", "avgust", "september", "oktober", "november", "december" ], dayofweek: [ "ned", "pon", "tor", "sre", "čet", "pet", "sob" ] }, cs: { // čeština months: [ "leden", "únor", "březen", "duben", "květen", "červen", "červenec", "srpen", "září", "říjen", "listopad", "prosinec" ], dayofweek: [ "ne", "po", "út", "st", "čt", "pá", "so" ] }, hu: { // hungarian months: [ "január", "február", "március", "április", "május", "június", "július", "augusztus", "szeptember", "október", "november", "december" ], dayofweek: [ "va", "hé", "ke", "sze", "cs", "pé", "szo" ] }, az: { //azerbaijanian (azeri) months: [ "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avqust", "sentyabr", "oktyabr", "noyabr", "dekabr" ], dayofweek: [ "b", "be", "ça", "ç", "ca", "c", "ş" ] }, bs: { //bosanski months: [ "januar", "februar", "mart", "april", "maj", "jun", "jul", "avgust", "septembar", "oktobar", "novembar", "decembar" ], dayofweek: [ "ned", "pon", "uto", "sri", "čet", "pet", "sub" ] }, ca: { //català months: [ "gener", "febrer", "març", "abril", "maig", "juny", "juliol", "agost", "setembre", "octubre", "novembre", "desembre" ], dayofweek: [ "dg", "dl", "dt", "dc", "dj", "dv", "ds" ] }, 'en-gb': { //english (british) months: [ "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ], dayofweek: [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ] }, et: { //"eesti" months: [ "jaanuar", "veebruar", "märts", "aprill", "mai", "juuni", "juuli", "august", "september", "oktoober", "november", "detsember" ], dayofweek: [ "p", "e", "t", "k", "n", "r", "l" ] }, eu: { //euskara months: [ "urtarrila", "otsaila", "martxoa", "apirila", "maiatza", "ekaina", "uztaila", "abuztua", "iraila", "urria", "azaroa", "abendua" ], dayofweek: [ "ig.", "al.", "ar.", "az.", "og.", "or.", "la." ] }, fi: { //finnish (suomi) months: [ "tammikuu", "helmikuu", "maaliskuu", "huhtikuu", "toukokuu", "kesäkuu", "heinäkuu", "elokuu", "syyskuu", "lokakuu", "marraskuu", "joulukuu" ], dayofweek: [ "su", "ma", "ti", "ke", "to", "pe", "la" ] }, gl: { //galego months: [ "xan", "feb", "maz", "abr", "mai", "xun", "xul", "ago", "set", "out", "nov", "dec" ], dayofweek: [ "dom", "lun", "mar", "mer", "xov", "ven", "sab" ] }, hr: { //hrvatski months: [ "siječanj", "veljača", "ožujak", "travanj", "svibanj", "lipanj", "srpanj", "kolovoz", "rujan", "listopad", "studeni", "prosinac" ], dayofweek: [ "ned", "pon", "uto", "sri", "čet", "pet", "sub" ] }, ko: { //korean (한국어) months: [ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월" ], dayofweek: [ "일", "월", "화", "수", "목", "금", "토" ] }, lt: { //lithuanian (lietuvių) months: [ "sausio", "vasario", "kovo", "balandžio", "gegužės", "birželio", "liepos", "rugpjūčio", "rugsėjo", "spalio", "lapkričio", "gruodžio" ], dayofweek: [ "sek", "pir", "ant", "tre", "ket", "pen", "šeš" ] }, lv: { //latvian (latviešu) months: [ "janvāris", "februāris", "marts", "aprīlis ", "maijs", "jūnijs", "jūlijs", "augusts", "septembris", "oktobris", "novembris", "decembris" ], dayofweek: [ "sv", "pr", "ot", "tr", "ct", "pk", "st" ] }, mk: { //macedonian (македонски) months: [ "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември" ], dayofweek: [ "нед", "пон", "вто", "сре", "чет", "пет", "саб" ] }, mn: { //mongolian (монгол) months: [ "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар" ], dayofweek: [ "дав", "мяг", "лха", "пүр", "бсн", "бям", "ням" ] }, 'pt-br': { //português(brasil) months: [ "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro" ], dayofweek: [ "dom", "seg", "ter", "qua", "qui", "sex", "sáb" ] }, sk: { //slovenčina months: [ "január", "február", "marec", "apríl", "máj", "jún", "júl", "august", "september", "október", "november", "december" ], dayofweek: [ "ne", "po", "ut", "st", "št", "pi", "so" ] }, sq: { //albanian (shqip) months: [ "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" ], dayofweek: [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ] }, 'sr-yu': { //serbian (srpski) months: [ "januar", "februar", "mart", "april", "maj", "jun", "jul", "avgust", "septembar", "oktobar", "novembar", "decembar" ], dayofweek: [ "ned", "pon", "uto", "sre", "čet", "pet", "sub" ] }, sr: { //serbian cyrillic (српски) months: [ "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар" ], dayofweek: [ "нед", "пон", "уто", "сре", "чет", "пет", "суб" ] }, sv: { //svenska months: [ "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december" ], dayofweek: [ "sön", "mån", "tis", "ons", "tor", "fre", "lör" ] }, 'zh-tw': { //traditional chinese (繁體中文) months: [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" ], dayofweek: [ "日", "一", "二", "三", "四", "五", "六" ] }, zh: { //simplified chinese (简体中文) months: [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" ], dayofweek: [ "日", "一", "二", "三", "四", "五", "六" ] }, he: { //hebrew (עברית) months: [ 'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר' ], dayofweek: [ 'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת' ] }, hy: { // armenian months: [ "հունվար", "փետրվար", "մարտ", "ապրիլ", "մայիս", "հունիս", "հուլիս", "օգոստոս", "սեպտեմբեր", "հոկտեմբեր", "նոյեմբեր", "դեկտեմբեր" ], dayofweek: [ "կի", "երկ", "երք", "չոր", "հնգ", "ուրբ", "շբթ" ] }, kg: { // kyrgyz months: [ 'үчтүн айы', 'бирдин айы', 'жалган куран', 'чын куран', 'бугу', 'кулжа', 'теке', 'баш оона', 'аяк оона', 'тогуздун айы', 'жетинин айы', 'бештин айы' ], dayofweek: [ "жек", "дүй", "шей", "шар", "бей", "жум", "ише" ] } }, value: '', lang: 'en', format: 'y/m/d h:i', formattime: 'h:i', formatdate: 'y/m/d', startdate: false, // new date(), '1986/12/08', '-1970/01/05','-1970/01/05', step: 60, monthchangespinner: true, closeondateselect: false, closeontimeselect: false, closeonwithoutclick: true, closeoninputclick: true, timepicker: true, datepicker: true, weeks: false, defaulttime: false, // use formattime format (ex. '10:00' for formattime: 'h:i') defaultdate: false, // use formatdate format (ex new date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05') mindate: false, maxdate: false, mintime: false, maxtime: false, allowtimes: [], opened: false, inittime: true, inline: false, theme: '', onselectdate: function () {}, onselecttime: function () {}, onchangemonth: function () {}, onchangeyear: function () {}, onchangedatetime: function () {}, onshow: function () {}, onclose: function () {}, ongenerate: function () {}, withoutcopyright: true, inversebutton: false, hours12: false, next: 'xdsoft_next', prev : 'xdsoft_prev', dayofweekstart: 0, parentid: 'body', timeheightintimepicker: 25, timepickerscrollbar: true, todaybutton: true, prevbutton: true, nextbutton: true, defaultselect: true, scrollmonth: true, scrolltime: true, scrollinput: true, lazyinit: false, mask: false, validateonblur: true, allowblank: true, yearstart: 1950, yearend: 2050, monthstart: 0, monthend: 11, style: '', id: '', fixed: false, roundtime: 'round', // ceil, floor classname: '', weekends: [], highlighteddates: [], highlightedperiods: [], disableddates : [], yearoffset: 0, beforeshowday: null, enterliketab: true, showapplybutton: false }; // fix for ie8 if (!array.prototype.indexof) { array.prototype.indexof = function (obj, start) { var i, j; for (i = (start || 0), j = this.length; i < j; i += 1) { if (this[i] === obj) { return i; } } return -1; }; } date.prototype.countdaysinmonth = function () { return new date(this.getfullyear(), this.getmonth() + 1, 0).getdate(); }; $.fn.xdsoftscroller = function (percent) { return this.each(function () { var timeboxparent = $(this), pointereventtoxy = function (e) { var out = {x: 0, y: 0}, touch; if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') { touch = e.originalevent.touches[0] || e.originalevent.changedtouches[0]; out.x = touch.clientx; out.y = touch.clienty; } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') { out.x = e.clientx; out.y = e.clienty; } return out; }, move = 0, timebox, parentheight, height, scrollbar, scroller, maximumoffset = 100, start = false, starty = 0, starttop = 0, h1 = 0, touchstart = false, starttopscroll = 0, calcoffset = function () {}; if (percent === 'hide') { timeboxparent.find('.xdsoft_scrollbar').hide(); return; } if (!$(this).hasclass('xdsoft_scroller_box')) { timebox = timeboxparent.children().eq(0); parentheight = timeboxparent[0].clientheight; height = timebox[0].offsetheight; scrollbar = $('
'); scroller = $('
'); scrollbar.append(scroller); timeboxparent.addclass('xdsoft_scroller_box').append(scrollbar); calcoffset = function calcoffset(event) { var offset = pointereventtoxy(event).y - starty + starttopscroll; if (offset < 0) { offset = 0; } if (offset + scroller[0].offsetheight > h1) { offset = h1 - scroller[0].offsetheight; } timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumoffset ? offset / maximumoffset : 0]); }; scroller .on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) { if (!parentheight) { timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]); } starty = pointereventtoxy(event).y; starttopscroll = parseint(scroller.css('margin-top'), 10); h1 = scrollbar[0].offsetheight; if (event.type === 'mousedown') { if (document) { $(document.body).addclass('xdsoft_noselect'); } $([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() { $([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee) .off('mousemove.xdsoft_scroller', calcoffset) .removeclass('xdsoft_noselect'); }); $(document.body).on('mousemove.xdsoft_scroller', calcoffset); } else { touchstart = true; event.stoppropagation(); event.preventdefault(); } }) .on('touchmove', function (event) { if (touchstart) { event.preventdefault(); calcoffset(event); } }) .on('touchend touchcancel', function (event) { touchstart = false; starttopscroll = 0; }); timeboxparent .on('scroll_element.xdsoft_scroller', function (event, percentage) { if (!parentheight) { timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]); } percentage = percentage > 1 ? 1 : (percentage < 0 || isnan(percentage)) ? 0 : percentage; scroller.css('margin-top', maximumoffset * percentage); settimeout(function () { timebox.css('margintop', -parseint((timebox[0].offsetheight - parentheight) * percentage, 10)); }, 10); }) .on('resize_scroll.xdsoft_scroller', function (event, percentage, notriggerscroll) { var percent, sh; parentheight = timeboxparent[0].clientheight; height = timebox[0].offsetheight; percent = parentheight / height; sh = percent * scrollbar[0].offsetheight; if (percent > 1) { scroller.hide(); } else { scroller.show(); scroller.css('height', parseint(sh > 10 ? sh : 10, 10)); maximumoffset = scrollbar[0].offsetheight - scroller[0].offsetheight; if (notriggerscroll !== true) { timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || math.abs(parseint(timebox.css('margintop'), 10)) / (height - parentheight)]); } } }); timeboxparent.on('mousewheel', function (event) { var top = math.abs(parseint(timebox.css('margintop'), 10)); top = top - (event.deltay * 20); if (top < 0) { top = 0; } timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentheight)]); event.stoppropagation(); return false; }); timeboxparent.on('touchstart', function (event) { start = pointereventtoxy(event); starttop = math.abs(parseint(timebox.css('margintop'), 10)); }); timeboxparent.on('touchmove', function (event) { if (start) { event.preventdefault(); var coord = pointereventtoxy(event); timeboxparent.trigger('scroll_element.xdsoft_scroller', [(starttop - (coord.y - start.y)) / (height - parentheight)]); } }); timeboxparent.on('touchend touchcancel', function (event) { start = false; starttop = 0; }); } timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]); }); }; $.fn.datetimepicker = function (opt) { var key0 = 48, key9 = 57, _key0 = 96, _key9 = 105, ctrlkey = 17, del = 46, enter = 13, esc = 27, backspace = 8, arrowleft = 37, arrowup = 38, arrowright = 39, arrowdown = 40, tab = 9, f5 = 116, akey = 65, ckey = 67, vkey = 86, zkey = 90, ykey = 89, ctrldown = false, options = ($.isplainobject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options), lazyinittimer = 0, createdatetimepicker, destroydatetimepicker, lazyinit = function (input) { input .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initonactioncallback(event) { if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) { return; } cleartimeout(lazyinittimer); lazyinittimer = settimeout(function () { if (!input.data('xdsoft_datetimepicker')) { createdatetimepicker(input); } input .off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initonactioncallback) .trigger('open.xdsoft'); }, 100); }); }; createdatetimepicker = function (input) { var datetimepicker = $('
'), xdsoft_copyright = $(''), datepicker = $('
'), mounth_picker = $('
' + '
' + '
' + '
'), calendar = $('
'), timepicker = $('
'), timeboxparent = timepicker.find('.xdsoft_time_box').eq(0), timebox = $('
'), applybutton = $(''), /*scrollbar = $('
'), scroller = $('
'),*/ monthselect = $('
'), yearselect = $('
'), triggerafteropen = false, xdsoft_datetime, //scroll_element, xchangetimer, timerclick, current_time_index, setpos, timer = 0, timer1 = 0, _xdsoft_datetime; mounth_picker .find('.xdsoft_month span') .after(monthselect); mounth_picker .find('.xdsoft_year span') .after(yearselect); mounth_picker .find('.xdsoft_month,.xdsoft_year') .on('mousedown.xdsoft', function (event) { var select = $(this).find('.xdsoft_select').eq(0), val = 0, top = 0, visible = select.is(':visible'), items, i; mounth_picker .find('.xdsoft_select') .hide(); if (_xdsoft_datetime.currenttime) { val = _xdsoft_datetime.currenttime[$(this).hasclass('xdsoft_month') ? 'getmonth' : 'getfullyear'](); } select[visible ? 'hide' : 'show'](); for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) { if (items.eq(i).data('value') === val) { break; } else { top += items[0].offsetheight; } } select.xdsoftscroller(top / (select.children()[0].offsetheight - (select[0].clientheight))); event.stoppropagation(); return false; }); mounth_picker .find('.xdsoft_select') .xdsoftscroller() .on('mousedown.xdsoft', function (event) { event.stoppropagation(); event.preventdefault(); }) .on('mousedown.xdsoft', '.xdsoft_option', function (event) { if (_xdsoft_datetime.currenttime === undefined || _xdsoft_datetime.currenttime === null) { _xdsoft_datetime.currenttime = _xdsoft_datetime.now(); } var year = _xdsoft_datetime.currenttime.getfullyear(); if (_xdsoft_datetime && _xdsoft_datetime.currenttime) { _xdsoft_datetime.currenttime[$(this).parent().parent().hasclass('xdsoft_monthselect') ? 'setmonth' : 'setfullyear']($(this).data('value')); } $(this).parent().parent().hide(); datetimepicker.trigger('xchange.xdsoft'); if (options.onchangemonth && $.isfunction(options.onchangemonth)) { options.onchangemonth.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input')); } if (year !== _xdsoft_datetime.currenttime.getfullyear() && $.isfunction(options.onchangeyear)) { options.onchangeyear.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input')); } }); datetimepicker.setoptions = function (_options) { options = $.extend(true, {}, options, _options); if (_options.allowtimes && $.isarray(_options.allowtimes) && _options.allowtimes.length) { options.allowtimes = $.extend(true, [], _options.allowtimes); } if (_options.weekends && $.isarray(_options.weekends) && _options.weekends.length) { options.weekends = $.extend(true, [], _options.weekends); } if (_options.highlighteddates && $.isarray(_options.highlighteddates) && _options.highlighteddates.length) { var highlighteddates = new object(); $.each(_options.highlighteddates, function(index, value) { var splitdata = $.map(value.split(','), $.trim), hdate = new highlighteddate(date.parsedate(splitdata[0], options.formatdate), splitdata[1], splitdata[2]), // date, desc, style keydate = hdate.date.dateformat(options.formatdate); if(keydate in highlighteddates) { var exdesc = highlighteddates[keydate].desc; if (exdesc && exdesc.length && hdate.desc && hdate.desc.length) { highlighteddates[keydate].desc = exdesc + "\n" + hdate.desc; } } else { highlighteddates[keydate] = hdate; } }); options.highlighteddates = $.extend(true, [], highlighteddates); } if (_options.highlightedperiods && $.isarray(_options.highlightedperiods) && _options.highlightedperiods.length) { var highlighteddates = $.extend(true, [], options.highlighteddates); $.each(_options.highlightedperiods, function(index, value) { var splitdata = $.map(value.split(','), $.trim), datetest = date.parsedate(splitdata[0], options.formatdate), // start date dateend = date.parsedate(splitdata[1], options.formatdate), desc = splitdata[2], style = splitdata[3]; while (datetest <= dateend) { var hdate = new highlighteddate(datetest, desc, style), keydate = datetest.dateformat(options.formatdate); datetest.setdate(datetest.getdate() + 1); if(keydate in highlighteddates) { var exdesc = highlighteddates[keydate].desc; if (exdesc && exdesc.length && hdate.desc && hdate.desc.length) { highlighteddates[keydate].desc = exdesc + "\n" + hdate.desc; } } else { highlighteddates[keydate] = hdate; } } }); options.highlighteddates = $.extend(true, [], highlighteddates); } if (_options.disableddates && $.isarray(_options.disableddates) && _options.disableddates.length) { options.disableddates = $.extend(true, [], _options.disableddates); } if ((options.open || options.opened) && (!options.inline)) { input.trigger('open.xdsoft'); } if (options.inline) { triggerafteropen = true; datetimepicker.addclass('xdsoft_inline'); input.after(datetimepicker).hide(); } if (options.inversebutton) { options.next = 'xdsoft_prev'; options.prev = 'xdsoft_next'; } if (options.datepicker) { datepicker.addclass('active'); } else { datepicker.removeclass('active'); } if (options.timepicker) { timepicker.addclass('active'); } else { timepicker.removeclass('active'); } if (options.value) { _xdsoft_datetime.setcurrenttime(options.value); if (input && input.val) { input.val(_xdsoft_datetime.str); } } if (isnan(options.dayofweekstart)) { options.dayofweekstart = 0; } else { options.dayofweekstart = parseint(options.dayofweekstart, 10) % 7; } if (!options.timepickerscrollbar) { timeboxparent.xdsoftscroller('hide'); } if (options.mindate && /^-(.*)$/.test(options.mindate)) { options.mindate = _xdsoft_datetime.strtodatetime(options.mindate).dateformat(options.formatdate); } if (options.maxdate && /^\+(.*)$/.test(options.maxdate)) { options.maxdate = _xdsoft_datetime.strtodatetime(options.maxdate).dateformat(options.formatdate); } applybutton.toggle(options.showapplybutton); mounth_picker .find('.xdsoft_today_button') .css('visibility', !options.todaybutton ? 'hidden' : 'visible'); mounth_picker .find('.' + options.prev) .css('visibility', !options.prevbutton ? 'hidden' : 'visible'); mounth_picker .find('.' + options.next) .css('visibility', !options.nextbutton ? 'hidden' : 'visible'); if (options.mask) { var e, getcaretpos = function (input) { try { if (document.selection && document.selection.createrange) { var range = document.selection.createrange(); return range.getbookmark().charcodeat(2) - 2; } if (input.setselectionrange) { return input.selectionstart; } } catch (e) { return 0; } }, setcaretpos = function (node, pos) { node = (typeof node === "string" || node instanceof string) ? document.getelementbyid(node) : node; if (!node) { return false; } if (node.createtextrange) { var textrange = node.createtextrange(); textrange.collapse(true); textrange.moveend('character', pos); textrange.movestart('character', pos); textrange.select(); return true; } if (node.setselectionrange) { node.setselectionrange(pos, pos); return true; } return false; }, isvalidvalue = function (mask, value) { var reg = mask .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1') .replace(/_/g, '{digit+}') .replace(/([0-9]{1})/g, '{digit$1}') .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}') .replace(/\{digit[\+]\}/g, '[0-9_]{1}'); return (new regexp(reg)).test(value); }; input.off('keydown.xdsoft'); if (options.mask === true) { options.mask = options.format .replace(/y/g, '9999') .replace(/f/g, '9999') .replace(/m/g, '19') .replace(/d/g, '39') .replace(/h/g, '29') .replace(/i/g, '59') .replace(/s/g, '59'); } if ($.type(options.mask) === 'string') { if (!isvalidvalue(options.mask, input.val())) { input.val(options.mask.replace(/[0-9]/g, '_')); } input.on('keydown.xdsoft', function (event) { var val = this.value, key = event.which, pos, digit; if (((key >= key0 && key <= key9) || (key >= _key0 && key <= _key9)) || (key === backspace || key === del)) { pos = getcaretpos(this); digit = (key !== backspace && key !== del) ? string.fromcharcode((_key0 <= key && key <= _key9) ? key - key0 : key) : '_'; if ((key === backspace || key === del) && pos) { pos -= 1; digit = '_'; } while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) { pos += (key === backspace || key === del) ? -1 : 1; } val = val.substr(0, pos) + digit + val.substr(pos + 1); if ($.trim(val) === '') { val = options.mask.replace(/[0-9]/g, '_'); } else { if (pos === options.mask.length) { event.preventdefault(); return false; } } pos += (key === backspace || key === del) ? 0 : 1; while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) { pos += (key === backspace || key === del) ? -1 : 1; } if (isvalidvalue(options.mask, val)) { this.value = val; setcaretpos(this, pos); } else if ($.trim(val) === '') { this.value = options.mask.replace(/[0-9]/g, '_'); } else { input.trigger('error_input.xdsoft'); } } else { if (([akey, ckey, vkey, zkey, ykey].indexof(key) !== -1 && ctrldown) || [esc, arrowup, arrowdown, arrowleft, arrowright, f5, ctrlkey, tab, enter].indexof(key) !== -1) { return true; } } event.preventdefault(); return false; }); } } if (options.validateonblur) { input .off('blur.xdsoft') .on('blur.xdsoft', function () { if (options.allowblank && !$.trim($(this).val()).length) { $(this).val(null); datetimepicker.data('xdsoft_datetime').empty(); } else if (!date.parsedate($(this).val(), options.format)) { var splittedhours = +([$(this).val()[0], $(this).val()[1]].join('')), splittedminutes = +([$(this).val()[2], $(this).val()[3]].join('')); // parse the numbers as 0312 => 03:12 if(!options.datepicker && options.timepicker && splittedhours >= 0 && splittedhours < 24 && splittedminutes >= 0 && splittedminutes < 60) { $(this).val([splittedhours, splittedminutes].map(function(item) { return item > 9 ? item : '0' + item }).join(':')); } else { $(this).val((_xdsoft_datetime.now()).dateformat(options.format)); } datetimepicker.data('xdsoft_datetime').setcurrenttime($(this).val()); } else { datetimepicker.data('xdsoft_datetime').setcurrenttime($(this).val()); } datetimepicker.trigger('changedatetime.xdsoft'); }); } options.dayofweekstartprev = (options.dayofweekstart === 0) ? 6 : options.dayofweekstart - 1; datetimepicker .trigger('xchange.xdsoft') .trigger('afteropen.xdsoft'); }; datetimepicker .data('options', options) .on('mousedown.xdsoft', function (event) { event.stoppropagation(); event.preventdefault(); yearselect.hide(); monthselect.hide(); return false; }); //scroll_element = timepicker.find('.xdsoft_time_box'); timeboxparent.append(timebox); timeboxparent.xdsoftscroller(); datetimepicker.on('afteropen.xdsoft', function () { timeboxparent.xdsoftscroller(); }); datetimepicker .append(datepicker) .append(timepicker); if (options.withoutcopyright !== true) { datetimepicker .append(xdsoft_copyright); } datepicker .append(mounth_picker) .append(calendar) .append(applybutton); $(options.parentid) .append(datetimepicker); xdsoft_datetime = function () { var _this = this; _this.now = function (norecursion) { var d = new date(), date, time; if (!norecursion && options.defaultdate) { date = _this.strtodate(options.defaultdate); d.setfullyear(date.getfullyear()); d.setmonth(date.getmonth()); d.setdate(date.getdate()); } if (options.yearoffset) { d.setfullyear(d.getfullyear() + options.yearoffset); } if (!norecursion && options.defaulttime) { time = _this.strtotime(options.defaulttime); d.sethours(time.gethours()); d.setminutes(time.getminutes()); } return d; }; _this.isvaliddate = function (d) { if (object.prototype.tostring.call(d) !== "[object date]") { return false; } return !isnan(d.gettime()); }; _this.setcurrenttime = function (dtime) { _this.currenttime = (typeof dtime === 'string') ? _this.strtodatetime(dtime) : _this.isvaliddate(dtime) ? dtime : _this.now(); datetimepicker.trigger('xchange.xdsoft'); }; _this.empty = function () { _this.currenttime = null; }; _this.getcurrenttime = function (dtime) { return _this.currenttime; }; _this.nextmonth = function () { if (_this.currenttime === undefined || _this.currenttime === null) { _this.currenttime = _this.now(); } var month = _this.currenttime.getmonth() + 1, year; if (month === 12) { _this.currenttime.setfullyear(_this.currenttime.getfullyear() + 1); month = 0; } year = _this.currenttime.getfullyear(); _this.currenttime.setdate( math.min( new date(_this.currenttime.getfullyear(), month + 1, 0).getdate(), _this.currenttime.getdate() ) ); _this.currenttime.setmonth(month); if (options.onchangemonth && $.isfunction(options.onchangemonth)) { options.onchangemonth.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input')); } if (year !== _this.currenttime.getfullyear() && $.isfunction(options.onchangeyear)) { options.onchangeyear.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input')); } datetimepicker.trigger('xchange.xdsoft'); return month; }; _this.prevmonth = function () { if (_this.currenttime === undefined || _this.currenttime === null) { _this.currenttime = _this.now(); } var month = _this.currenttime.getmonth() - 1; if (month === -1) { _this.currenttime.setfullyear(_this.currenttime.getfullyear() - 1); month = 11; } _this.currenttime.setdate( math.min( new date(_this.currenttime.getfullyear(), month + 1, 0).getdate(), _this.currenttime.getdate() ) ); _this.currenttime.setmonth(month); if (options.onchangemonth && $.isfunction(options.onchangemonth)) { options.onchangemonth.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input')); } datetimepicker.trigger('xchange.xdsoft'); return month; }; _this.getweekofyear = function (datetime) { var onejan = new date(datetime.getfullyear(), 0, 1); return math.ceil((((datetime - onejan) / 86400000) + onejan.getday() + 1) / 7); }; _this.strtodatetime = function (sdatetime) { var tmpdate = [], timeoffset, currenttime; if (sdatetime && sdatetime instanceof date && _this.isvaliddate(sdatetime)) { return sdatetime; } tmpdate = /^(\+|\-)(.*)$/.exec(sdatetime); if (tmpdate) { tmpdate[2] = date.parsedate(tmpdate[2], options.formatdate); } if (tmpdate && tmpdate[2]) { timeoffset = tmpdate[2].gettime() - (tmpdate[2].gettimezoneoffset()) * 60000; currenttime = new date((_xdsoft_datetime.now()).gettime() + parseint(tmpdate[1] + '1', 10) * timeoffset); } else { currenttime = sdatetime ? date.parsedate(sdatetime, options.format) : _this.now(); } if (!_this.isvaliddate(currenttime)) { currenttime = _this.now(); } return currenttime; }; _this.strtodate = function (sdate) { if (sdate && sdate instanceof date && _this.isvaliddate(sdate)) { return sdate; } var currenttime = sdate ? date.parsedate(sdate, options.formatdate) : _this.now(true); if (!_this.isvaliddate(currenttime)) { currenttime = _this.now(true); } return currenttime; }; _this.strtotime = function (stime) { if (stime && stime instanceof date && _this.isvaliddate(stime)) { return stime; } var currenttime = stime ? date.parsedate(stime, options.formattime) : _this.now(true); if (!_this.isvaliddate(currenttime)) { currenttime = _this.now(true); } return currenttime; }; _this.str = function () { return _this.currenttime.dateformat(options.format); }; _this.currenttime = this.now(); }; _xdsoft_datetime = new xdsoft_datetime(); applybutton.on('click', function (e) {//pathbrite e.preventdefault(); datetimepicker.data('changed',true); _xdsoft_datetime.setcurrenttime(getcurrentvalue()); input.val(_xdsoft_datetime.str()); datetimepicker.trigger('close.xdsoft'); }); mounth_picker .find('.xdsoft_today_button') .on('mousedown.xdsoft', function () { datetimepicker.data('changed', true); _xdsoft_datetime.setcurrenttime(0); datetimepicker.trigger('afteropen.xdsoft'); }).on('dblclick.xdsoft', function () { input.val(_xdsoft_datetime.str()); datetimepicker.trigger('close.xdsoft'); }); mounth_picker .find('.xdsoft_prev,.xdsoft_next') .on('mousedown.xdsoft', function () { var $this = $(this), timer = 0, stop = false; (function arguments_callee1(v) { if ($this.hasclass(options.next)) { _xdsoft_datetime.nextmonth(); } else if ($this.hasclass(options.prev)) { _xdsoft_datetime.prevmonth(); } if (options.monthchangespinner) { if (!stop) { timer = settimeout(arguments_callee1, v || 100); } } }(500)); $([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() { cleartimeout(timer); stop = true; $([document.body, window]).off('mouseup.xdsoft', arguments_callee2); }); }); timepicker .find('.xdsoft_prev,.xdsoft_next') .on('mousedown.xdsoft', function () { var $this = $(this), timer = 0, stop = false, period = 110; (function arguments_callee4(v) { var pheight = timeboxparent[0].clientheight, height = timebox[0].offsetheight, top = math.abs(parseint(timebox.css('margintop'), 10)); if ($this.hasclass(options.next) && (height - pheight) - options.timeheightintimepicker >= top) { timebox.css('margintop', '-' + (top + options.timeheightintimepicker) + 'px'); } else if ($this.hasclass(options.prev) && top - options.timeheightintimepicker >= 0) { timebox.css('margintop', '-' + (top - options.timeheightintimepicker) + 'px'); } timeboxparent.trigger('scroll_element.xdsoft_scroller', [math.abs(parseint(timebox.css('margintop'), 10) / (height - pheight))]); period = (period > 10) ? 10 : period - 10; if (!stop) { timer = settimeout(arguments_callee4, v || period); } }(500)); $([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() { cleartimeout(timer); stop = true; $([document.body, window]) .off('mouseup.xdsoft', arguments_callee5); }); }); xchangetimer = 0; // base handler - generating a calendar and timepicker datetimepicker .on('xchange.xdsoft', function (event) { cleartimeout(xchangetimer); xchangetimer = settimeout(function () { if (_xdsoft_datetime.currenttime === undefined || _xdsoft_datetime.currenttime === null) { _xdsoft_datetime.currenttime = _xdsoft_datetime.now(); } var table = '', start = new date(_xdsoft_datetime.currenttime.getfullyear(), _xdsoft_datetime.currenttime.getmonth(), 1, 12, 0, 0), i = 0, j, today = _xdsoft_datetime.now(), maxdate = false, mindate = false, d, y, m, w, classes = [], customdatesettings, newrow = true, time = '', h = '', line_time, description; while (start.getday() !== options.dayofweekstart) { start.setdate(start.getdate() - 1); } table += ''; if (options.weeks) { table += ''; } for (j = 0; j < 7; j += 1) { table += ''; } table += ''; table += ''; if (options.maxdate !== false) { maxdate = _xdsoft_datetime.strtodate(options.maxdate); maxdate = new date(maxdate.getfullyear(), maxdate.getmonth(), maxdate.getdate(), 23, 59, 59, 999); } if (options.mindate !== false) { mindate = _xdsoft_datetime.strtodate(options.mindate); mindate = new date(mindate.getfullyear(), mindate.getmonth(), mindate.getdate()); } while (i < _xdsoft_datetime.currenttime.countdaysinmonth() || start.getday() !== options.dayofweekstart || _xdsoft_datetime.currenttime.getmonth() === start.getmonth()) { classes = []; i += 1; d = start.getdate(); y = start.getfullyear(); m = start.getmonth(); w = _xdsoft_datetime.getweekofyear(start); description = ''; classes.push('xdsoft_date'); if (options.beforeshowday && $.isfunction(options.beforeshowday.call)) { customdatesettings = options.beforeshowday.call(datetimepicker, start); } else { customdatesettings = null; } if ((maxdate !== false && start > maxdate) || (mindate !== false && start < mindate) || (customdatesettings && customdatesettings[0] === false)) { classes.push('xdsoft_disabled'); } else if (options.disableddates.indexof(start.dateformat(options.formatdate)) !== -1) { classes.push('xdsoft_disabled'); } if (customdatesettings && customdatesettings[1] !== "") { classes.push(customdatesettings[1]); } if (_xdsoft_datetime.currenttime.getmonth() !== m) { classes.push('xdsoft_other_month'); } if ((options.defaultselect || datetimepicker.data('changed')) && _xdsoft_datetime.currenttime.dateformat(options.formatdate) === start.dateformat(options.formatdate)) { classes.push('xdsoft_current'); } if (today.dateformat(options.formatdate) === start.dateformat(options.formatdate)) { classes.push('xdsoft_today'); } if (start.getday() === 0 || start.getday() === 6 || ~options.weekends.indexof(start.dateformat(options.formatdate))) { classes.push('xdsoft_weekend'); } if (start.dateformat(options.formatdate) in options.highlighteddates) { var hdate = options.highlighteddates[start.dateformat(options.formatdate)]; classes.push(hdate.style === undefined ? 'xdsoft_highlighted_default' : hdate.style); description = hdate.desc === undefined ? '' : hdate.desc; } if (options.beforeshowday && $.isfunction(options.beforeshowday)) { classes.push(options.beforeshowday(start)); } if (newrow) { table += ''; newrow = false; if (options.weeks) { table += ''; } } table += ''; if (start.getday() === options.dayofweekstartprev) { table += ''; newrow = true; } start.setdate(d + 1); } table += '
' + options.i18n[options.lang].dayofweek[(j + options.dayofweekstart) % 7] + '
' + w + '' + '
' + d + '
' + '
'; calendar.html(table); mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currenttime.getmonth()]); mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currenttime.getfullyear()); // generate timebox time = ''; h = ''; m = ''; line_time = function line_time(h, m) { var now = _xdsoft_datetime.now(); now.sethours(h); h = parseint(now.gethours(), 10); now.setminutes(m); m = parseint(now.getminutes(), 10); var optiondatetime = new date(_xdsoft_datetime.currenttime); optiondatetime.sethours(h); optiondatetime.setminutes(m); classes = []; if((options.mindatetime !== false && options.mindatetime > optiondatetime) || (options.maxtime !== false && _xdsoft_datetime.strtotime(options.maxtime).gettime() < now.gettime()) || (options.mintime !== false && _xdsoft_datetime.strtotime(options.mintime).gettime() > now.gettime())) { classes.push('xdsoft_disabled'); } var current_time = new date(_xdsoft_datetime.currenttime); current_time.sethours(parseint(_xdsoft_datetime.currenttime.gethours(), 10)); current_time.setminutes(math[options.roundtime](_xdsoft_datetime.currenttime.getminutes() / options.step) * options.step); if ((options.inittime || options.defaultselect || datetimepicker.data('changed')) && current_time.gethours() === parseint(h, 10) && (options.step > 59 || current_time.getminutes() === parseint(m, 10))) { if (options.defaultselect || datetimepicker.data('changed')) { classes.push('xdsoft_current'); } else if (options.inittime) { classes.push('xdsoft_init_time'); } } if (parseint(today.gethours(), 10) === parseint(h, 10) && parseint(today.getminutes(), 10) === parseint(m, 10)) { classes.push('xdsoft_today'); } time += '
' + now.dateformat(options.formattime) + '
'; }; if (!options.allowtimes || !$.isarray(options.allowtimes) || !options.allowtimes.length) { for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) { for (j = 0; j < 60; j += options.step) { h = (i < 10 ? '0' : '') + i; m = (j < 10 ? '0' : '') + j; line_time(h, m); } } } else { for (i = 0; i < options.allowtimes.length; i += 1) { h = _xdsoft_datetime.strtotime(options.allowtimes[i]).gethours(); m = _xdsoft_datetime.strtotime(options.allowtimes[i]).getminutes(); line_time(h, m); } } timebox.html(time); opt = ''; i = 0; for (i = parseint(options.yearstart, 10) + options.yearoffset; i <= parseint(options.yearend, 10) + options.yearoffset; i += 1) { opt += '
' + i + '
'; } yearselect.children().eq(0) .html(opt); for (i = parseint(options.monthstart), opt = ''; i <= parseint(options.monthend); i += 1) { opt += '
' + options.i18n[options.lang].months[i] + '
'; } monthselect.children().eq(0).html(opt); $(datetimepicker) .trigger('generate.xdsoft'); }, 10); event.stoppropagation(); }) .on('afteropen.xdsoft', function () { if (options.timepicker) { var classtype, pheight, height, top; if (timebox.find('.xdsoft_current').length) { classtype = '.xdsoft_current'; } else if (timebox.find('.xdsoft_init_time').length) { classtype = '.xdsoft_init_time'; } if (classtype) { pheight = timeboxparent[0].clientheight; height = timebox[0].offsetheight; top = timebox.find(classtype).index() * options.timeheightintimepicker + 1; if ((height - pheight) < top) { top = height - pheight; } timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseint(top, 10) / (height - pheight)]); } else { timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]); } } }); timerclick = 0; calendar .on('click.xdsoft', 'td', function (xdevent) { xdevent.stoppropagation(); // prevents closing of pop-ups, modals and flyouts in bootstrap timerclick += 1; var $this = $(this), currenttime = _xdsoft_datetime.currenttime; if (currenttime === undefined || currenttime === null) { _xdsoft_datetime.currenttime = _xdsoft_datetime.now(); currenttime = _xdsoft_datetime.currenttime; } if ($this.hasclass('xdsoft_disabled')) { return false; } currenttime.setdate(1); currenttime.setfullyear($this.data('year')); currenttime.setmonth($this.data('month')); currenttime.setdate($this.data('date')); datetimepicker.trigger('select.xdsoft', [currenttime]); input.val(_xdsoft_datetime.str()); if ((timerclick > 1 || (options.closeondateselect === true || (options.closeondateselect === 0 && !options.timepicker))) && !options.inline) { datetimepicker.trigger('close.xdsoft'); } if (options.onselectdate && $.isfunction(options.onselectdate)) { options.onselectdate.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input'), xdevent); } datetimepicker.data('changed', true); datetimepicker.trigger('xchange.xdsoft'); datetimepicker.trigger('changedatetime.xdsoft'); settimeout(function () { timerclick = 0; }, 200); }); timebox .on('click.xdsoft', 'div', function (xdevent) { xdevent.stoppropagation(); var $this = $(this), currenttime = _xdsoft_datetime.currenttime; if (currenttime === undefined || currenttime === null) { _xdsoft_datetime.currenttime = _xdsoft_datetime.now(); currenttime = _xdsoft_datetime.currenttime; } if ($this.hasclass('xdsoft_disabled')) { return false; } currenttime.sethours($this.data('hour')); currenttime.setminutes($this.data('minute')); datetimepicker.trigger('select.xdsoft', [currenttime]); datetimepicker.data('input').val(_xdsoft_datetime.str()); if (options.inline !== true && options.closeontimeselect === true) { datetimepicker.trigger('close.xdsoft'); } if (options.onselecttime && $.isfunction(options.onselecttime)) { options.onselecttime.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input'), xdevent); } datetimepicker.data('changed', true); datetimepicker.trigger('xchange.xdsoft'); datetimepicker.trigger('changedatetime.xdsoft'); }); datepicker .on('mousewheel.xdsoft', function (event) { if (!options.scrollmonth) { return true; } if (event.deltay < 0) { _xdsoft_datetime.nextmonth(); } else { _xdsoft_datetime.prevmonth(); } return false; }); input .on('mousewheel.xdsoft', function (event) { if (!options.scrollinput) { return true; } if (!options.datepicker && options.timepicker) { current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0; if (current_time_index + event.deltay >= 0 && current_time_index + event.deltay < timebox.children().length) { current_time_index += event.deltay; } if (timebox.children().eq(current_time_index).length) { timebox.children().eq(current_time_index).trigger('mousedown'); } return false; } if (options.datepicker && !options.timepicker) { datepicker.trigger(event, [event.deltay, event.deltax, event.deltay]); if (input.val) { input.val(_xdsoft_datetime.str()); } datetimepicker.trigger('changedatetime.xdsoft'); return false; } }); datetimepicker .on('changedatetime.xdsoft', function (event) { if (options.onchangedatetime && $.isfunction(options.onchangedatetime)) { var $input = datetimepicker.data('input'); options.onchangedatetime.call(datetimepicker, _xdsoft_datetime.currenttime, $input, event); delete options.value; $input.trigger('change'); } }) .on('generate.xdsoft', function () { if (options.ongenerate && $.isfunction(options.ongenerate)) { options.ongenerate.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input')); } if (triggerafteropen) { datetimepicker.trigger('afteropen.xdsoft'); triggerafteropen = false; } }) .on('click.xdsoft', function (xdevent) { xdevent.stoppropagation(); }); 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"; if (options.fixed) { top -= $(window).scrolltop(); left -= $(window).scrollleft(); position = "fixed"; } else { if (top + datetimepicker[0].offsetheight > $(window).height() + $(window).scrolltop()) { top = offset.top - datetimepicker[0].offsetheight + 1; } if (top < 0) { top = 0; } if (left + datetimepicker[0].offsetwidth > $(window).width()) { left = $(window).width() - datetimepicker[0].offsetwidth; } } datetimepicker.css({ left: left, top: top, position: position }); }; datetimepicker .on('open.xdsoft', function (event) { var onshow = true; if (options.onshow && $.isfunction(options.onshow)) { onshow = options.onshow.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input'), event); } if (onshow !== false) { datetimepicker.show(); setpos(); $(window) .off('resize.xdsoft', setpos) .on('resize.xdsoft', setpos); if (options.closeonwithoutclick) { $([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() { datetimepicker.trigger('close.xdsoft'); $([document.body, window]).off('mousedown.xdsoft', arguments_callee6); }); } } }) .on('close.xdsoft', function (event) { var onclose = true; mounth_picker .find('.xdsoft_month,.xdsoft_year') .find('.xdsoft_select') .hide(); if (options.onclose && $.isfunction(options.onclose)) { onclose = options.onclose.call(datetimepicker, _xdsoft_datetime.currenttime, datetimepicker.data('input'), event); } if (onclose !== false && !options.opened && !options.inline) { datetimepicker.hide(); } event.stoppropagation(); }) .on('toggle.xdsoft', function (event) { if (datetimepicker.is(':visible')) { datetimepicker.trigger('close.xdsoft'); } else { datetimepicker.trigger('open.xdsoft'); } }) .data('input', input); timer = 0; timer1 = 0; datetimepicker.data('xdsoft_datetime', _xdsoft_datetime); datetimepicker.setoptions(options); function getcurrentvalue() { var ct = false, time; if (options.startdate) { ct = _xdsoft_datetime.strtodate(options.startdate); } else { ct = options.value || ((input && input.val && input.val()) ? input.val() : ''); if (ct) { ct = _xdsoft_datetime.strtodatetime(ct); } else if (options.defaultdate) { ct = _xdsoft_datetime.strtodate(options.defaultdate); if (options.defaulttime) { time = _xdsoft_datetime.strtotime(options.defaulttime); ct.sethours(time.gethours()); ct.setminutes(time.getminutes()); } } } if (ct && _xdsoft_datetime.isvaliddate(ct)) { datetimepicker.data('changed', true); } else { ct = ''; } return ct || 0; } _xdsoft_datetime.setcurrenttime(getcurrentvalue()); input .data('xdsoft_datetimepicker', datetimepicker) .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) { if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeoninputclick)) { return; } cleartimeout(timer); timer = settimeout(function () { if (input.is(':disabled')) { return; } triggerafteropen = true; _xdsoft_datetime.setcurrenttime(getcurrentvalue()); datetimepicker.trigger('open.xdsoft'); }, 100); }) .on('keydown.xdsoft', function (event) { var val = this.value, elementselector, key = event.which; if ([enter].indexof(key) !== -1 && options.enterliketab) { elementselector = $("input:visible,textarea:visible"); datetimepicker.trigger('close.xdsoft'); elementselector.eq(elementselector.index(this) + 1).focus(); return false; } if ([tab].indexof(key) !== -1) { datetimepicker.trigger('close.xdsoft'); return true; } }); }; destroydatetimepicker = function (input) { var datetimepicker = input.data('xdsoft_datetimepicker'); if (datetimepicker) { datetimepicker.data('xdsoft_datetime', null); datetimepicker.remove(); input .data('xdsoft_datetimepicker', null) .off('.xdsoft'); $(window).off('resize.xdsoft'); $([window, document.body]).off('mousedown.xdsoft'); if (input.unmousewheel) { input.unmousewheel(); } } }; $(document) .off('keydown.xdsoftctrl keyup.xdsoftctrl') .on('keydown.xdsoftctrl', function (e) { if (e.keycode === ctrlkey) { ctrldown = true; } }) .on('keyup.xdsoftctrl', function (e) { if (e.keycode === ctrlkey) { ctrldown = false; } }); return this.each(function () { var datetimepicker = $(this).data('xdsoft_datetimepicker'); if (datetimepicker) { if ($.type(opt) === 'string') { switch (opt) { case 'show': $(this).select().focus(); datetimepicker.trigger('open.xdsoft'); break; case 'hide': datetimepicker.trigger('close.xdsoft'); break; case 'toggle': datetimepicker.trigger('toggle.xdsoft'); break; case 'destroy': destroydatetimepicker($(this)); break; case 'reset': this.value = this.defaultvalue; if (!this.value || !datetimepicker.data('xdsoft_datetime').isvaliddate(date.parsedate(this.value, options.format))) { datetimepicker.data('changed', false); } datetimepicker.data('xdsoft_datetime').setcurrenttime(this.value); break; case 'validate': var $input = datetimepicker.data('input'); $input.trigger('blur.xdsoft'); break; } } else { datetimepicker .setoptions(opt); } return 0; } if ($.type(opt) !== 'string') { if (!options.lazyinit || options.open || options.inline) { createdatetimepicker($(this)); } else { lazyinit($(this)); } } }); }; $.fn.datetimepicker.defaults = default_options; }(jquery)); function highlighteddate(date, desc, style) { this.date = date; this.desc = desc; this.style = style; }; (function () { /*! copyright (c) 2013 brandon aaron (http://brandon.aaron.sh) * licensed under the mit license (license.txt). * * version: 3.1.12 * * requires: jquery 1.2.2+ */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jquery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheeldelta"in g&&(m=g.wheeldelta),"wheeldeltay"in g&&(m=g.wheeldeltay),"wheeldeltax"in g&&(l=-1*g.wheeldeltax),"axis"in g&&g.axis===g.horizontal_axis&&(l=-1*m,m=0),j=0===m?l:m,"deltay"in g&&(m=-1*g.deltay,j=m),"deltax"in g&&(l=g.deltax,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltamode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltamode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=math.max(math.abs(m),math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=math[j>=1?"floor":"ceil"](j/f),l=math[l>=1?"floor":"ceil"](l/f),m=math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeoffset&&this.getboundingclientrect){var s=this.getboundingclientrect();o=b.clientx-s.left,p=b.clienty-s.top}return b.deltax=l,b.deltay=m,b.deltafactor=f,b.offsetx=o,b.offsety=p,b.deltamode=0,h.unshift(b,j,l,m),e&&cleartimeout(e),e=settimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustolddeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","dommousescroll","mozmousepixelscroll"],h="onwheel"in document||document.documentmode>=9?["wheel"]:["mousewheel","dommousescroll","mozmousepixelscroll"],i=array.prototype.slice;if(a.event.fixhooks)for(var j=g.length;j;)a.event.fixhooks[g[--j]]=a.event.mousehooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addeventlistener)for(var c=h.length;c;)this.addeventlistener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getlineheight(this)),a.data(this,"mousewheel-page-height",k.getpageheight(this))},teardown:function(){if(this.removeeventlistener)for(var c=h.length;c;)this.removeeventlistener(h[--c],b,!1);else this.onmousewheel=null;a.removedata(this,"mousewheel-line-height"),a.removedata(this,"mousewheel-page-height")},getlineheight:function(b){var c=a(b),d=c["offsetparent"in a.fn?"offsetparent":"parent"]();return d.length||(d=a("body")),parseint(d.css("fontsize"),10)||parseint(c.css("fontsize"),10)||16},getpageheight:function(b){return a(b).height()},settings:{adjustolddeltas:!0,normalizeoffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); // parse and format library //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/ /* * copyright (c) 2004 baron schwartz * * this program is free software; you can redistribute it and/or modify it * under the terms of the gnu lesser general public license as published by the * free software foundation, version 2.1. * * this program is distributed in the hope that it will be useful, but without * any warranty; without even the implied warranty of merchantability or fitness * for a particular purpose. see the gnu lesser general public license for more * details. */ date.parsefunctions={count:0};date.parseregexes=[];date.formatfunctions={count:0};date.prototype.dateformat=function(b){if(b=="unixtime"){return parseint(this.gettime()/1000);}if(date.formatfunctions[b]==null){date.createnewformat(b);}var a=date.formatfunctions[b];return this[a]();};date.createnewformat=function(format){var funcname="format"+date.formatfunctions.count++;date.formatfunctions[format]=funcname;var codeprefix="date.prototype."+funcname+" = function() {return ";var code="";var special=false;var ch="";for(var i=0;i 0) {";var regex="";var special=false;var ch="";for(var i=0;i 0 && z > 0){\nvar doydate = new date(y,0);\ndoydate.setdate(z);\nm = doydate.getmonth();\nd = doydate.getdate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new date(y, m);}\nelse if (y > 0)\n{return new date(y);}\n}return null;}";date.parseregexes[regexnum]=new regexp("^"+regex+"$",'i');eval(code);};date.formatcodetoregex=function(b,a){switch(b){case"d":return{g:0,c:null,s:"(?:sun|mon|tue|wed|thu|fri|sat)"};case"j":case"d":return{g:1,c:"d = parseint(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+date.daynames.join("|")+")"};case"s":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseint(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"w":return{g:0,c:null,s:"(?:\\d{2})"};case"f":return{g:1,c:"m = parseint(date.monthnumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+date.monthnames.join("|")+")"};case"m":return{g:1,c:"m = parseint(date.monthnumbers[results["+a+"]], 10);\n",s:"(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)"};case"n":case"m":return{g:1,c:"m = parseint(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"l":return{g:0,c:null,s:"(?:1|0)"};case"y":return{g:1,c:"y = parseint(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseint(results["+a+"], 10);\ny = ty > date.y2kyear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"g":case"g":case"h":case"h":return{g:1,c:"h = parseint(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseint(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseint(results["+a+"], 10);\n",s:"(\\d{2})"};case"o":return{g:0,c:null,s:"[+-]\\d{4}"};case"t":return{g:0,c:null,s:"[a-z]{3}"};case"z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:string.escape(b)};}};date.prototype.gettimezone=function(){return this.tostring().replace(/^.*? ([a-z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([a-z])[a-z]+ ([a-z])[a-z]+ ([a-z])[a-z]+\)$/,"$1$2$3");};date.prototype.getgmtoffset=function(){return(this.gettimezoneoffset()>0?"-":"+")+string.leftpad(math.floor(math.abs(this.gettimezoneoffset())/60),2,"0")+string.leftpad(math.abs(this.gettimezoneoffset())%60,2,"0");};date.prototype.getdayofyear=function(){var a=0;date.daysinmonth[1]=this.isleapyear()?29:28;for(var b=0;b