"OdenseTrack" is a school assignment/project from AspIT https://aspit.dfine.net/odensetrack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jquery.datetimepicker.full.js 108KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911
  1. /*!
  2. * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2016
  3. * @version 1.3.4
  4. *
  5. * Date formatter utility library that allows formatting date/time variables or Date objects using PHP DateTime format.
  6. * @see http://php.net/manual/en/function.date.php
  7. *
  8. * For more JQuery plugins visit http://plugins.krajee.com
  9. * For more Yii related demos visit http://demos.krajee.com
  10. */var DateFormatter;!function(){"use strict";var t,e,r,n,a,u,i;u=864e5,i=3600,t=function(t,e){return"string"==typeof t&&"string"==typeof e&&t.toLowerCase()===e.toLowerCase()},e=function(t,r,n){var a=n||"0",u=t.toString();return u.length<r?e(a+u,r):u},r=function(t){var e,n;for(t=t||{},e=1;e<arguments.length;e++)if(n=arguments[e])for(var a in n)n.hasOwnProperty(a)&&("object"==typeof n[a]?r(t[a],n[a]):t[a]=n[a]);return t},n=function(t,e){for(var r=0;r<e.length;r++)if(e[r].toLowerCase()===t.toLowerCase())return r;return-1},a={dateSettings:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridiem:["AM","PM"],ordinal:function(t){var e=t%10,r={1:"st",2:"nd",3:"rd"};return 1!==Math.floor(t%100/10)&&r[e]?r[e]:"th"}},separators:/[ \-+\/\.T:@]/g,validParts:/[dDjlNSwzWFmMntLoYyaABgGhHisueTIOPZcrU]/g,intParts:/[djwNzmnyYhHgGis]/g,tzParts:/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,tzClip:/[^-+\dA-Z]/g},DateFormatter=function(t){var e=this,n=r(a,t);e.dateSettings=n.dateSettings,e.separators=n.separators,e.validParts=n.validParts,e.intParts=n.intParts,e.tzParts=n.tzParts,e.tzClip=n.tzClip},DateFormatter.prototype={constructor:DateFormatter,getMonth:function(t){var e,r=this;return e=n(t,r.dateSettings.monthsShort)+1,0===e&&(e=n(t,r.dateSettings.months)+1),e},parseDate:function(e,r){var n,a,u,i,s,o,c,f,l,h,d=this,g=!1,m=!1,p=d.dateSettings,y={date:null,year:null,month:null,day:null,hour:0,min:0,sec:0};if(!e)return null;if(e instanceof Date)return e;if("U"===r)return u=parseInt(e),u?new Date(1e3*u):e;switch(typeof e){case"number":return new Date(e);case"string":break;default:return null}if(n=r.match(d.validParts),!n||0===n.length)throw new Error("Invalid date format definition.");for(a=e.replace(d.separators,"\x00").split("\x00"),u=0;u<a.length;u++)switch(i=a[u],s=parseInt(i),n[u]){case"y":case"Y":if(!s)return null;l=i.length,y.year=2===l?parseInt((70>s?"20":"19")+i):s,g=!0;break;case"m":case"n":case"M":case"F":if(isNaN(s)){if(o=d.getMonth(i),!(o>0))return null;y.month=o}else{if(!(s>=1&&12>=s))return null;y.month=s}g=!0;break;case"d":case"j":if(!(s>=1&&31>=s))return null;y.day=s,g=!0;break;case"g":case"h":if(c=n.indexOf("a")>-1?n.indexOf("a"):n.indexOf("A")>-1?n.indexOf("A"):-1,h=a[c],c>-1)f=t(h,p.meridiem[0])?0:t(h,p.meridiem[1])?12:-1,s>=1&&12>=s&&f>-1?y.hour=s+f-1:s>=0&&23>=s&&(y.hour=s);else{if(!(s>=0&&23>=s))return null;y.hour=s}m=!0;break;case"G":case"H":if(!(s>=0&&23>=s))return null;y.hour=s,m=!0;break;case"i":if(!(s>=0&&59>=s))return null;y.min=s,m=!0;break;case"s":if(!(s>=0&&59>=s))return null;y.sec=s,m=!0}if(g===!0&&y.year&&y.month&&y.day)y.date=new Date(y.year,y.month-1,y.day,y.hour,y.min,y.sec,0);else{if(m!==!0)return null;y.date=new Date(0,0,0,y.hour,y.min,y.sec,0)}return y.date},guessDate:function(t,e){if("string"!=typeof t)return t;var r,n,a,u,i,s,o=this,c=t.replace(o.separators,"\x00").split("\x00"),f=/^[djmn]/g,l=e.match(o.validParts),h=new Date,d=0;if(!f.test(l[0]))return t;for(a=0;a<c.length;a++){if(d=2,i=c[a],s=parseInt(i.substr(0,2)),isNaN(s))return null;switch(a){case 0:"m"===l[0]||"n"===l[0]?h.setMonth(s-1):h.setDate(s);break;case 1:"m"===l[0]||"n"===l[0]?h.setDate(s):h.setMonth(s-1);break;case 2:if(n=h.getFullYear(),r=i.length,d=4>r?r:4,n=parseInt(4>r?n.toString().substr(0,4-r)+i:i.substr(0,4)),!n)return null;h.setFullYear(n);break;case 3:h.setHours(s);break;case 4:h.setMinutes(s);break;case 5:h.setSeconds(s)}u=i.substr(d),u.length>0&&c.splice(a+1,0,u)}return h},parseFormat:function(t,r){var n,a=this,s=a.dateSettings,o=/\\?(.?)/gi,c=function(t,e){return n[t]?n[t]():e};return n={d:function(){return e(n.j(),2)},D:function(){return s.daysShort[n.w()]},j:function(){return r.getDate()},l:function(){return s.days[n.w()]},N:function(){return n.w()||7},w:function(){return r.getDay()},z:function(){var t=new Date(n.Y(),n.n()-1,n.j()),e=new Date(n.Y(),0,1);return Math.round((t-e)/u)},W:function(){var t=new Date(n.Y(),n.n()-1,n.j()-n.N()+3),r=new Date(t.getFullYear(),0,4);return e(1+Math.round((t-r)/u/7),2)},F:function(){return s.months[r.getMonth()]},m:function(){return e(n.n(),2)},M:function(){return s.monthsShort[r.getMonth()]},n:function(){return r.getMonth()+1},t:function(){return new Date(n.Y(),n.n(),0).getDate()},L:function(){var t=n.Y();return t%4===0&&t%100!==0||t%400===0?1:0},o:function(){var t=n.n(),e=n.W(),r=n.Y();return r+(12===t&&9>e?1:1===t&&e>9?-1:0)},Y:function(){return r.getFullYear()},y:function(){return n.Y().toString().slice(-2)},a:function(){return n.A().toLowerCase()},A:function(){var t=n.G()<12?0:1;return s.meridiem[t]},B:function(){var t=r.getUTCHours()*i,n=60*r.getUTCMinutes(),a=r.getUTCSeconds();return e(Math.floor((t+n+a+i)/86.4)%1e3,3)},g:function(){return n.G()%12||12},G:function(){return r.getHours()},h:function(){return e(n.g(),2)},H:function(){return e(n.G(),2)},i:function(){return e(r.getMinutes(),2)},s:function(){return e(r.getSeconds(),2)},u:function(){return e(1e3*r.getMilliseconds(),6)},e:function(){var t=/\((.*)\)/.exec(String(r))[1];return t||"Coordinated Universal Time"},I:function(){var t=new Date(n.Y(),0),e=Date.UTC(n.Y(),0),r=new Date(n.Y(),6),a=Date.UTC(n.Y(),6);return t-e!==r-a?1:0},O:function(){var t=r.getTimezoneOffset(),n=Math.abs(t);return(t>0?"-":"+")+e(100*Math.floor(n/60)+n%60,4)},P:function(){var t=n.O();return t.substr(0,3)+":"+t.substr(3,2)},T:function(){var t=(String(r).match(a.tzParts)||[""]).pop().replace(a.tzClip,"");return t||"UTC"},Z:function(){return 60*-r.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(o,c)},r:function(){return"D, d M Y H:i:s O".replace(o,c)},U:function(){return r.getTime()/1e3||0}},c(t,t)},formatDate:function(t,e){var r,n,a,u,i,s=this,o="",c="\\";if("string"==typeof t&&(t=s.parseDate(t,e),!t))return null;if(t instanceof Date){for(a=e.length,r=0;a>r;r++)i=e.charAt(r),"S"!==i&&i!==c&&(r>0&&e.charAt(r-1)===c?o+=i:(u=s.parseFormat(i,t),r!==a-1&&s.intParts.test(i)&&"S"===e.charAt(r+1)&&(n=parseInt(u)||0,u+=s.dateSettings.ordinal(n)),o+=u));return o}return""}}}();/**
  11. * @preserve jQuery DateTimePicker
  12. * @homepage http://xdsoft.net/jqplugins/datetimepicker/
  13. * @author Chupurnov Valeriy (<chupurnov@gmail.com>)
  14. */
  15. /**
  16. * @param {jQuery} $
  17. */
  18. var datetimepickerFactory = function ($) {
  19. 'use strict';
  20. var default_options = {
  21. i18n: {
  22. ar: { // Arabic
  23. months: [
  24. "كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
  25. ],
  26. dayOfWeekShort: [
  27. "ن", "ث", "ع", "خ", "ج", "س", "ح"
  28. ],
  29. dayOfWeek: ["الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت", "الأحد"]
  30. },
  31. ro: { // Romanian
  32. months: [
  33. "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"
  34. ],
  35. dayOfWeekShort: [
  36. "Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ"
  37. ],
  38. dayOfWeek: ["Duminică", "Luni", "Marţi", "Miercuri", "Joi", "Vineri", "Sâmbătă"]
  39. },
  40. id: { // Indonesian
  41. months: [
  42. "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
  43. ],
  44. dayOfWeekShort: [
  45. "Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"
  46. ],
  47. dayOfWeek: ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
  48. },
  49. is: { // Icelandic
  50. months: [
  51. "Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"
  52. ],
  53. dayOfWeekShort: [
  54. "Sun", "Mán", "Þrið", "Mið", "Fim", "Fös", "Lau"
  55. ],
  56. dayOfWeek: ["Sunnudagur", "Mánudagur", "Þriðjudagur", "Miðvikudagur", "Fimmtudagur", "Föstudagur", "Laugardagur"]
  57. },
  58. bg: { // Bulgarian
  59. months: [
  60. "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
  61. ],
  62. dayOfWeekShort: [
  63. "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  64. ],
  65. dayOfWeek: ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота"]
  66. },
  67. fa: { // Persian/Farsi
  68. months: [
  69. 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
  70. ],
  71. dayOfWeekShort: [
  72. 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
  73. ],
  74. dayOfWeek: ["یک‌شنبه", "دوشنبه", "سه‌شنبه", "چهارشنبه", "پنج‌شنبه", "جمعه", "شنبه", "یک‌شنبه"]
  75. },
  76. ru: { // Russian
  77. months: [
  78. 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
  79. ],
  80. dayOfWeekShort: [
  81. "Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  82. ],
  83. dayOfWeek: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"]
  84. },
  85. uk: { // Ukrainian
  86. months: [
  87. 'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
  88. ],
  89. dayOfWeekShort: [
  90. "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
  91. ],
  92. dayOfWeek: ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота"]
  93. },
  94. en: { // English
  95. months: [
  96. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  97. ],
  98. dayOfWeekShort: [
  99. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  100. ],
  101. dayOfWeek: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  102. },
  103. el: { // Ελληνικά
  104. months: [
  105. "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
  106. ],
  107. dayOfWeekShort: [
  108. "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
  109. ],
  110. dayOfWeek: ["Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"]
  111. },
  112. de: { // German
  113. months: [
  114. 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
  115. ],
  116. dayOfWeekShort: [
  117. "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
  118. ],
  119. dayOfWeek: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]
  120. },
  121. nl: { // Dutch
  122. months: [
  123. "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
  124. ],
  125. dayOfWeekShort: [
  126. "zo", "ma", "di", "wo", "do", "vr", "za"
  127. ],
  128. dayOfWeek: ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"]
  129. },
  130. tr: { // Turkish
  131. months: [
  132. "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
  133. ],
  134. dayOfWeekShort: [
  135. "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
  136. ],
  137. dayOfWeek: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"]
  138. },
  139. fr: { //French
  140. months: [
  141. "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
  142. ],
  143. dayOfWeekShort: [
  144. "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
  145. ],
  146. dayOfWeek: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
  147. },
  148. es: { // Spanish
  149. months: [
  150. "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
  151. ],
  152. dayOfWeekShort: [
  153. "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
  154. ],
  155. dayOfWeek: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"]
  156. },
  157. th: { // Thai
  158. months: [
  159. 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
  160. ],
  161. dayOfWeekShort: [
  162. 'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
  163. ],
  164. dayOfWeek: ["อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัส", "ศุกร์", "เสาร์", "อาทิตย์"]
  165. },
  166. pl: { // Polish
  167. months: [
  168. "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
  169. ],
  170. dayOfWeekShort: [
  171. "nd", "pn", "wt", "śr", "cz", "pt", "sb"
  172. ],
  173. dayOfWeek: ["niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"]
  174. },
  175. pt: { // Portuguese
  176. months: [
  177. "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  178. ],
  179. dayOfWeekShort: [
  180. "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
  181. ],
  182. dayOfWeek: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"]
  183. },
  184. ch: { // Simplified Chinese
  185. months: [
  186. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  187. ],
  188. dayOfWeekShort: [
  189. "日", "一", "二", "三", "四", "五", "六"
  190. ]
  191. },
  192. se: { // Swedish
  193. months: [
  194. "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
  195. ],
  196. dayOfWeekShort: [
  197. "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  198. ]
  199. },
  200. km: { // Khmer (ភាសាខ្មែរ)
  201. months: [
  202. "មករា​", "កុម្ភៈ", "មិនា​", "មេសា​", "ឧសភា​", "មិថុនា​", "កក្កដា​", "សីហា​", "កញ្ញា​", "តុលា​", "វិច្ឆិកា", "ធ្នូ​"
  203. ],
  204. dayOfWeekShort: ["អាទិ​", "ច័ន្ទ​", "អង្គារ​", "ពុធ​", "ព្រហ​​", "សុក្រ​", "សៅរ៍"],
  205. dayOfWeek: ["អាទិត្យ​", "ច័ន្ទ​", "អង្គារ​", "ពុធ​", "ព្រហស្បតិ៍​", "សុក្រ​", "សៅរ៍"]
  206. },
  207. kr: { // Korean
  208. months: [
  209. "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  210. ],
  211. dayOfWeekShort: [
  212. "일", "월", "화", "수", "목", "금", "토"
  213. ],
  214. dayOfWeek: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"]
  215. },
  216. it: { // Italian
  217. months: [
  218. "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
  219. ],
  220. dayOfWeekShort: [
  221. "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
  222. ],
  223. dayOfWeek: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"]
  224. },
  225. da: { // Dansk
  226. months: [
  227. "Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"
  228. ],
  229. dayOfWeekShort: [
  230. "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  231. ],
  232. dayOfWeek: ["søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"]
  233. },
  234. no: { // Norwegian
  235. months: [
  236. "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
  237. ],
  238. dayOfWeekShort: [
  239. "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  240. ],
  241. dayOfWeek: ['Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag']
  242. },
  243. ja: { // Japanese
  244. months: [
  245. "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
  246. ],
  247. dayOfWeekShort: [
  248. "日", "月", "火", "水", "木", "金", "土"
  249. ],
  250. dayOfWeek: ["日曜", "月曜", "火曜", "水曜", "木曜", "金曜", "土曜"]
  251. },
  252. vi: { // Vietnamese
  253. months: [
  254. "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"
  255. ],
  256. dayOfWeekShort: [
  257. "CN", "T2", "T3", "T4", "T5", "T6", "T7"
  258. ],
  259. dayOfWeek: ["Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy"]
  260. },
  261. sl: { // Slovenščina
  262. months: [
  263. "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
  264. ],
  265. dayOfWeekShort: [
  266. "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
  267. ],
  268. dayOfWeek: ["Nedelja", "Ponedeljek", "Torek", "Sreda", "Četrtek", "Petek", "Sobota"]
  269. },
  270. cs: { // Čeština
  271. months: [
  272. "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
  273. ],
  274. dayOfWeekShort: [
  275. "Ne", "Po", "Út", "St", "Čt", "Pá", "So"
  276. ]
  277. },
  278. hu: { // Hungarian
  279. months: [
  280. "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
  281. ],
  282. dayOfWeekShort: [
  283. "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
  284. ],
  285. dayOfWeek: ["vasárnap", "hétfő", "kedd", "szerda", "csütörtök", "péntek", "szombat"]
  286. },
  287. az: { //Azerbaijanian (Azeri)
  288. months: [
  289. "Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"
  290. ],
  291. dayOfWeekShort: [
  292. "B", "Be", "Ça", "Ç", "Ca", "C", "Ş"
  293. ],
  294. dayOfWeek: ["Bazar", "Bazar ertəsi", "Çərşənbə axşamı", "Çərşənbə", "Cümə axşamı", "Cümə", "Şənbə"]
  295. },
  296. bs: { //Bosanski
  297. months: [
  298. "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  299. ],
  300. dayOfWeekShort: [
  301. "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  302. ],
  303. dayOfWeek: ["Nedjelja","Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"]
  304. },
  305. ca: { //Català
  306. months: [
  307. "Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
  308. ],
  309. dayOfWeekShort: [
  310. "Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds"
  311. ],
  312. dayOfWeek: ["Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte"]
  313. },
  314. 'en-GB': { //English (British)
  315. months: [
  316. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  317. ],
  318. dayOfWeekShort: [
  319. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  320. ],
  321. dayOfWeek: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  322. },
  323. et: { //"Eesti"
  324. months: [
  325. "Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"
  326. ],
  327. dayOfWeekShort: [
  328. "P", "E", "T", "K", "N", "R", "L"
  329. ],
  330. dayOfWeek: ["Pühapäev", "Esmaspäev", "Teisipäev", "Kolmapäev", "Neljapäev", "Reede", "Laupäev"]
  331. },
  332. eu: { //Euskara
  333. months: [
  334. "Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua"
  335. ],
  336. dayOfWeekShort: [
  337. "Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La."
  338. ],
  339. dayOfWeek: ['Igandea', 'Astelehena', 'Asteartea', 'Asteazkena', 'Osteguna', 'Ostirala', 'Larunbata']
  340. },
  341. fi: { //Finnish (Suomi)
  342. months: [
  343. "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
  344. ],
  345. dayOfWeekShort: [
  346. "Su", "Ma", "Ti", "Ke", "To", "Pe", "La"
  347. ],
  348. dayOfWeek: ["sunnuntai", "maanantai", "tiistai", "keskiviikko", "torstai", "perjantai", "lauantai"]
  349. },
  350. gl: { //Galego
  351. months: [
  352. "Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec"
  353. ],
  354. dayOfWeekShort: [
  355. "Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab"
  356. ],
  357. dayOfWeek: ["Domingo", "Luns", "Martes", "Mércores", "Xoves", "Venres", "Sábado"]
  358. },
  359. hr: { //Hrvatski
  360. months: [
  361. "Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
  362. ],
  363. dayOfWeekShort: [
  364. "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  365. ],
  366. dayOfWeek: ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"]
  367. },
  368. ko: { //Korean (한국어)
  369. months: [
  370. "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  371. ],
  372. dayOfWeekShort: [
  373. "일", "월", "화", "수", "목", "금", "토"
  374. ],
  375. dayOfWeek: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"]
  376. },
  377. lt: { //Lithuanian (lietuvių)
  378. months: [
  379. "Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio"
  380. ],
  381. dayOfWeekShort: [
  382. "Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš"
  383. ],
  384. dayOfWeek: ["Sekmadienis", "Pirmadienis", "Antradienis", "Trečiadienis", "Ketvirtadienis", "Penktadienis", "Šeštadienis"]
  385. },
  386. lv: { //Latvian (Latviešu)
  387. months: [
  388. "Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"
  389. ],
  390. dayOfWeekShort: [
  391. "Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St"
  392. ],
  393. dayOfWeek: ["Svētdiena", "Pirmdiena", "Otrdiena", "Trešdiena", "Ceturtdiena", "Piektdiena", "Sestdiena"]
  394. },
  395. mk: { //Macedonian (Македонски)
  396. months: [
  397. "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"
  398. ],
  399. dayOfWeekShort: [
  400. "нед", "пон", "вто", "сре", "чет", "пет", "саб"
  401. ],
  402. dayOfWeek: ["Недела", "Понеделник", "Вторник", "Среда", "Четврток", "Петок", "Сабота"]
  403. },
  404. mn: { //Mongolian (Монгол)
  405. months: [
  406. "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"
  407. ],
  408. dayOfWeekShort: [
  409. "Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням"
  410. ],
  411. dayOfWeek: ["Даваа", "Мягмар", "Лхагва", "Пүрэв", "Баасан", "Бямба", "Ням"]
  412. },
  413. 'pt-BR': { //Português(Brasil)
  414. months: [
  415. "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  416. ],
  417. dayOfWeekShort: [
  418. "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"
  419. ],
  420. dayOfWeek: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"]
  421. },
  422. sk: { //Slovenčina
  423. months: [
  424. "Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
  425. ],
  426. dayOfWeekShort: [
  427. "Ne", "Po", "Ut", "St", "Št", "Pi", "So"
  428. ],
  429. dayOfWeek: ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota"]
  430. },
  431. sq: { //Albanian (Shqip)
  432. months: [
  433. "Janar", "Shkurt", "Mars", "Prill", "Maj", "Qershor", "Korrik", "Gusht", "Shtator", "Tetor", "Nëntor", "Dhjetor"
  434. ],
  435. dayOfWeekShort: [
  436. "Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Shtu"
  437. ],
  438. dayOfWeek: ["E Diel", "E Hënë", "E Martē", "E Mërkurë", "E Enjte", "E Premte", "E Shtunë"]
  439. },
  440. 'sr-YU': { //Serbian (Srpski)
  441. months: [
  442. "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  443. ],
  444. dayOfWeekShort: [
  445. "Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub"
  446. ],
  447. dayOfWeek: ["Nedelja","Ponedeljak", "Utorak", "Sreda", "Četvrtak", "Petak", "Subota"]
  448. },
  449. sr: { //Serbian Cyrillic (Српски)
  450. months: [
  451. "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"
  452. ],
  453. dayOfWeekShort: [
  454. "нед", "пон", "уто", "сре", "чет", "пет", "суб"
  455. ],
  456. dayOfWeek: ["Недеља","Понедељак", "Уторак", "Среда", "Четвртак", "Петак", "Субота"]
  457. },
  458. sv: { //Svenska
  459. months: [
  460. "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
  461. ],
  462. dayOfWeekShort: [
  463. "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  464. ],
  465. dayOfWeek: ["Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag"]
  466. },
  467. 'zh-TW': { //Traditional Chinese (繁體中文)
  468. months: [
  469. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  470. ],
  471. dayOfWeekShort: [
  472. "日", "一", "二", "三", "四", "五", "六"
  473. ],
  474. dayOfWeek: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  475. },
  476. zh: { //Simplified Chinese (简体中文)
  477. months: [
  478. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  479. ],
  480. dayOfWeekShort: [
  481. "日", "一", "二", "三", "四", "五", "六"
  482. ],
  483. dayOfWeek: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  484. },
  485. ug:{ // Uyghur(ئۇيغۇرچە)
  486. months: [
  487. "1-ئاي","2-ئاي","3-ئاي","4-ئاي","5-ئاي","6-ئاي","7-ئاي","8-ئاي","9-ئاي","10-ئاي","11-ئاي","12-ئاي"
  488. ],
  489. dayOfWeek: [
  490. "يەكشەنبە", "دۈشەنبە","سەيشەنبە","چارشەنبە","پەيشەنبە","جۈمە","شەنبە"
  491. ]
  492. },
  493. he: { //Hebrew (עברית)
  494. months: [
  495. 'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'
  496. ],
  497. dayOfWeekShort: [
  498. 'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'
  499. ],
  500. dayOfWeek: ["ראשון", "שני", "שלישי", "רביעי", "חמישי", "שישי", "שבת", "ראשון"]
  501. },
  502. hy: { // Armenian
  503. months: [
  504. "Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
  505. ],
  506. dayOfWeekShort: [
  507. "Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
  508. ],
  509. dayOfWeek: ["Կիրակի", "Երկուշաբթի", "Երեքշաբթի", "Չորեքշաբթի", "Հինգշաբթի", "Ուրբաթ", "Շաբաթ"]
  510. },
  511. kg: { // Kyrgyz
  512. months: [
  513. 'Үчтүн айы', 'Бирдин айы', 'Жалган Куран', 'Чын Куран', 'Бугу', 'Кулжа', 'Теке', 'Баш Оона', 'Аяк Оона', 'Тогуздун айы', 'Жетинин айы', 'Бештин айы'
  514. ],
  515. dayOfWeekShort: [
  516. "Жек", "Дүй", "Шей", "Шар", "Бей", "Жум", "Ише"
  517. ],
  518. dayOfWeek: [
  519. "Жекшемб", "Дүйшөмб", "Шейшемб", "Шаршемб", "Бейшемби", "Жума", "Ишенб"
  520. ]
  521. },
  522. rm: { // Romansh
  523. months: [
  524. "Schaner", "Favrer", "Mars", "Avrigl", "Matg", "Zercladur", "Fanadur", "Avust", "Settember", "October", "November", "December"
  525. ],
  526. dayOfWeekShort: [
  527. "Du", "Gli", "Ma", "Me", "Gie", "Ve", "So"
  528. ],
  529. dayOfWeek: [
  530. "Dumengia", "Glindesdi", "Mardi", "Mesemna", "Gievgia", "Venderdi", "Sonda"
  531. ]
  532. },
  533. ka: { // Georgian
  534. months: [
  535. 'იანვარი', 'თებერვალი', 'მარტი', 'აპრილი', 'მაისი', 'ივნისი', 'ივლისი', 'აგვისტო', 'სექტემბერი', 'ოქტომბერი', 'ნოემბერი', 'დეკემბერი'
  536. ],
  537. dayOfWeekShort: [
  538. "კვ", "ორშ", "სამშ", "ოთხ", "ხუთ", "პარ", "შაბ"
  539. ],
  540. dayOfWeek: ["კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"]
  541. }
  542. },
  543. ownerDocument: document,
  544. contentWindow: window,
  545. value: '',
  546. rtl: false,
  547. format: 'Y/m/d H:i',
  548. formatTime: 'H:i',
  549. formatDate: 'Y/m/d',
  550. startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
  551. step: 60,
  552. monthChangeSpinner: true,
  553. closeOnDateSelect: false,
  554. closeOnTimeSelect: true,
  555. closeOnWithoutClick: true,
  556. closeOnInputClick: true,
  557. openOnFocus: true,
  558. timepicker: true,
  559. datepicker: true,
  560. weeks: false,
  561. defaultTime: false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
  562. defaultDate: false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
  563. minDate: false,
  564. maxDate: false,
  565. minTime: false,
  566. maxTime: false,
  567. minDateTime: false,
  568. maxDateTime: false,
  569. allowTimes: [],
  570. opened: false,
  571. initTime: true,
  572. inline: false,
  573. theme: '',
  574. touchMovedThreshold: 5,
  575. onSelectDate: function () {},
  576. onSelectTime: function () {},
  577. onChangeMonth: function () {},
  578. onGetWeekOfYear: function () {},
  579. onChangeYear: function () {},
  580. onChangeDateTime: function () {},
  581. onShow: function () {},
  582. onClose: function () {},
  583. onGenerate: function () {},
  584. withoutCopyright: true,
  585. inverseButton: false,
  586. hours12: false,
  587. next: 'xdsoft_next',
  588. prev : 'xdsoft_prev',
  589. dayOfWeekStart: 0,
  590. parentID: 'body',
  591. timeHeightInTimePicker: 25,
  592. timepickerScrollbar: true,
  593. todayButton: true,
  594. prevButton: true,
  595. nextButton: true,
  596. defaultSelect: true,
  597. scrollMonth: true,
  598. scrollTime: true,
  599. scrollInput: true,
  600. lazyInit: false,
  601. mask: false,
  602. validateOnBlur: true,
  603. allowBlank: true,
  604. yearStart: 1950,
  605. yearEnd: 2050,
  606. monthStart: 0,
  607. monthEnd: 11,
  608. style: '',
  609. id: '',
  610. fixed: false,
  611. roundTime: 'round', // ceil, floor
  612. className: '',
  613. weekends: [],
  614. highlightedDates: [],
  615. highlightedPeriods: [],
  616. allowDates : [],
  617. allowDateRe : null,
  618. disabledDates : [],
  619. disabledWeekDays: [],
  620. yearOffset: 0,
  621. beforeShowDay: null,
  622. enterLikeTab: true,
  623. showApplyButton: false,
  624. insideParent: false,
  625. };
  626. var dateHelper = null,
  627. defaultDateHelper = null,
  628. globalLocaleDefault = 'en',
  629. globalLocale = 'en';
  630. var dateFormatterOptionsDefault = {
  631. meridiem: ['AM', 'PM']
  632. };
  633. var initDateFormatter = function(){
  634. var locale = default_options.i18n[globalLocale],
  635. opts = {
  636. days: locale.dayOfWeek,
  637. daysShort: locale.dayOfWeekShort,
  638. months: locale.months,
  639. monthsShort: $.map(locale.months, function(n){ return n.substring(0, 3) })
  640. };
  641. if (typeof DateFormatter === 'function') {
  642. dateHelper = defaultDateHelper = new DateFormatter({
  643. dateSettings: $.extend({}, dateFormatterOptionsDefault, opts)
  644. });
  645. }
  646. };
  647. var dateFormatters = {
  648. moment: {
  649. default_options:{
  650. format: 'YYYY/MM/DD HH:mm',
  651. formatDate: 'YYYY/MM/DD',
  652. formatTime: 'HH:mm',
  653. },
  654. formatter: {
  655. parseDate: function (date, format) {
  656. if(isFormatStandard(format)){
  657. return defaultDateHelper.parseDate(date, format);
  658. }
  659. var d = moment(date, format);
  660. return d.isValid() ? d.toDate() : false;
  661. },
  662. formatDate: function (date, format) {
  663. if(isFormatStandard(format)){
  664. return defaultDateHelper.formatDate(date, format);
  665. }
  666. return moment(date).format(format);
  667. },
  668. formatMask: function(format){
  669. return format
  670. .replace(/Y{4}/g, '9999')
  671. .replace(/Y{2}/g, '99')
  672. .replace(/M{2}/g, '19')
  673. .replace(/D{2}/g, '39')
  674. .replace(/H{2}/g, '29')
  675. .replace(/m{2}/g, '59')
  676. .replace(/s{2}/g, '59');
  677. },
  678. }
  679. }
  680. }
  681. // for locale settings
  682. $.datetimepicker = {
  683. setLocale: function(locale){
  684. var newLocale = default_options.i18n[locale] ? locale : globalLocaleDefault;
  685. if (globalLocale !== newLocale) {
  686. globalLocale = newLocale;
  687. // reinit date formatter
  688. initDateFormatter();
  689. }
  690. },
  691. setDateFormatter: function(dateFormatter) {
  692. if(typeof dateFormatter === 'string' && dateFormatters.hasOwnProperty(dateFormatter)){
  693. var df = dateFormatters[dateFormatter];
  694. $.extend(default_options, df.default_options);
  695. dateHelper = df.formatter;
  696. }
  697. else {
  698. dateHelper = dateFormatter;
  699. }
  700. },
  701. };
  702. var standardFormats = {
  703. RFC_2822: 'D, d M Y H:i:s O',
  704. ATOM: 'Y-m-d\TH:i:sP',
  705. ISO_8601: 'Y-m-d\TH:i:sO',
  706. RFC_822: 'D, d M y H:i:s O',
  707. RFC_850: 'l, d-M-y H:i:s T',
  708. RFC_1036: 'D, d M y H:i:s O',
  709. RFC_1123: 'D, d M Y H:i:s O',
  710. RSS: 'D, d M Y H:i:s O',
  711. W3C: 'Y-m-d\TH:i:sP'
  712. }
  713. var isFormatStandard = function(format){
  714. return Object.values(standardFormats).indexOf(format) === -1 ? false : true;
  715. }
  716. $.extend($.datetimepicker, standardFormats);
  717. // first init date formatter
  718. initDateFormatter();
  719. // fix for ie8
  720. if (!window.getComputedStyle) {
  721. window.getComputedStyle = function (el) {
  722. this.el = el;
  723. this.getPropertyValue = function (prop) {
  724. var re = /(-([a-z]))/g;
  725. if (prop === 'float') {
  726. prop = 'styleFloat';
  727. }
  728. if (re.test(prop)) {
  729. prop = prop.replace(re, function (a, b, c) {
  730. return c.toUpperCase();
  731. });
  732. }
  733. return el.currentStyle[prop] || null;
  734. };
  735. return this;
  736. };
  737. }
  738. if (!Array.prototype.indexOf) {
  739. Array.prototype.indexOf = function (obj, start) {
  740. var i, j;
  741. for (i = (start || 0), j = this.length; i < j; i += 1) {
  742. if (this[i] === obj) { return i; }
  743. }
  744. return -1;
  745. };
  746. }
  747. Date.prototype.countDaysInMonth = function () {
  748. return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
  749. };
  750. $.fn.xdsoftScroller = function (options, percent) {
  751. return this.each(function () {
  752. var timeboxparent = $(this),
  753. pointerEventToXY = function (e) {
  754. var out = {x: 0, y: 0},
  755. touch;
  756. if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
  757. touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
  758. out.x = touch.clientX;
  759. out.y = touch.clientY;
  760. } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
  761. out.x = e.clientX;
  762. out.y = e.clientY;
  763. }
  764. return out;
  765. },
  766. timebox,
  767. parentHeight,
  768. height,
  769. scrollbar,
  770. scroller,
  771. maximumOffset = 100,
  772. start = false,
  773. startY = 0,
  774. startTop = 0,
  775. h1 = 0,
  776. touchStart = false,
  777. startTopScroll = 0,
  778. calcOffset = function () {};
  779. if (percent === 'hide') {
  780. timeboxparent.find('.xdsoft_scrollbar').hide();
  781. return;
  782. }
  783. if (!$(this).hasClass('xdsoft_scroller_box')) {
  784. timebox = timeboxparent.children().eq(0);
  785. parentHeight = timeboxparent[0].clientHeight;
  786. height = timebox[0].offsetHeight;
  787. scrollbar = $('<div class="xdsoft_scrollbar"></div>');
  788. scroller = $('<div class="xdsoft_scroller"></div>');
  789. scrollbar.append(scroller);
  790. timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
  791. calcOffset = function calcOffset(event) {
  792. var offset = pointerEventToXY(event).y - startY + startTopScroll;
  793. if (offset < 0) {
  794. offset = 0;
  795. }
  796. if (offset + scroller[0].offsetHeight > h1) {
  797. offset = h1 - scroller[0].offsetHeight;
  798. }
  799. timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
  800. };
  801. scroller
  802. .on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
  803. if (!parentHeight) {
  804. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  805. }
  806. startY = pointerEventToXY(event).y;
  807. startTopScroll = parseInt(scroller.css('margin-top'), 10);
  808. h1 = scrollbar[0].offsetHeight;
  809. if (event.type === 'mousedown' || event.type === 'touchstart') {
  810. if (options.ownerDocument) {
  811. $(options.ownerDocument.body).addClass('xdsoft_noselect');
  812. }
  813. $([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft_scroller', function arguments_callee() {
  814. $([options.ownerDocument.body, options.contentWindow]).off('touchend mouseup.xdsoft_scroller', arguments_callee)
  815. .off('mousemove.xdsoft_scroller', calcOffset)
  816. .removeClass('xdsoft_noselect');
  817. });
  818. $(options.ownerDocument.body).on('mousemove.xdsoft_scroller', calcOffset);
  819. } else {
  820. touchStart = true;
  821. event.stopPropagation();
  822. event.preventDefault();
  823. }
  824. })
  825. .on('touchmove', function (event) {
  826. if (touchStart) {
  827. event.preventDefault();
  828. calcOffset(event);
  829. }
  830. })
  831. .on('touchend touchcancel', function () {
  832. touchStart = false;
  833. startTopScroll = 0;
  834. });
  835. timeboxparent
  836. .on('scroll_element.xdsoft_scroller', function (event, percentage) {
  837. if (!parentHeight) {
  838. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
  839. }
  840. percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
  841. scroller.css('margin-top', maximumOffset * percentage);
  842. setTimeout(function () {
  843. timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
  844. }, 10);
  845. })
  846. .on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
  847. var percent, sh;
  848. parentHeight = timeboxparent[0].clientHeight;
  849. height = timebox[0].offsetHeight;
  850. percent = parentHeight / height;
  851. sh = percent * scrollbar[0].offsetHeight;
  852. if (percent > 1) {
  853. scroller.hide();
  854. } else {
  855. scroller.show();
  856. scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
  857. maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
  858. if (noTriggerScroll !== true) {
  859. timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
  860. }
  861. }
  862. });
  863. timeboxparent.on('mousewheel', function (event) {
  864. var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  865. top = top - (event.deltaY * 20);
  866. if (top < 0) {
  867. top = 0;
  868. }
  869. timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
  870. event.stopPropagation();
  871. return false;
  872. });
  873. timeboxparent.on('touchstart', function (event) {
  874. start = pointerEventToXY(event);
  875. startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
  876. });
  877. timeboxparent.on('touchmove', function (event) {
  878. if (start) {
  879. event.preventDefault();
  880. var coord = pointerEventToXY(event);
  881. timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
  882. }
  883. });
  884. timeboxparent.on('touchend touchcancel', function () {
  885. start = false;
  886. startTop = 0;
  887. });
  888. }
  889. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  890. });
  891. };
  892. $.fn.datetimepicker = function (opt, opt2) {
  893. var result = this,
  894. KEY0 = 48,
  895. KEY9 = 57,
  896. _KEY0 = 96,
  897. _KEY9 = 105,
  898. CTRLKEY = 17,
  899. CMDKEY = 91,
  900. DEL = 46,
  901. ENTER = 13,
  902. ESC = 27,
  903. BACKSPACE = 8,
  904. ARROWLEFT = 37,
  905. ARROWUP = 38,
  906. ARROWRIGHT = 39,
  907. ARROWDOWN = 40,
  908. TAB = 9,
  909. F5 = 116,
  910. AKEY = 65,
  911. CKEY = 67,
  912. VKEY = 86,
  913. ZKEY = 90,
  914. YKEY = 89,
  915. ctrlDown = false,
  916. cmdDown = false,
  917. options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
  918. lazyInitTimer = 0,
  919. createDateTimePicker,
  920. destroyDateTimePicker,
  921. lazyInit = function (input) {
  922. input
  923. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart', function initOnActionCallback() {
  924. if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
  925. return;
  926. }
  927. clearTimeout(lazyInitTimer);
  928. lazyInitTimer = setTimeout(function () {
  929. if (!input.data('xdsoft_datetimepicker')) {
  930. createDateTimePicker(input);
  931. }
  932. input
  933. .off('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart', initOnActionCallback)
  934. .trigger('open.xdsoft');
  935. }, 100);
  936. });
  937. };
  938. createDateTimePicker = function (input) {
  939. var datetimepicker = $('<div class="xdsoft_datetimepicker xdsoft_noselect"></div>'),
  940. xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
  941. datepicker = $('<div class="xdsoft_datepicker active"></div>'),
  942. month_picker = $('<div class="xdsoft_monthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
  943. '<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
  944. '<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
  945. '<button type="button" class="xdsoft_next"></button></div>'),
  946. calendar = $('<div class="xdsoft_calendar"></div>'),
  947. timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'),
  948. timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
  949. timebox = $('<div class="xdsoft_time_variant"></div>'),
  950. applyButton = $('<button type="button" class="xdsoft_save_selected blue-gradient-button">Save Selected</button>'),
  951. monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
  952. yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
  953. triggerAfterOpen = false,
  954. XDSoft_datetime,
  955. xchangeTimer,
  956. timerclick,
  957. current_time_index,
  958. setPos,
  959. timer = 0,
  960. _xdsoft_datetime,
  961. forEachAncestorOf;
  962. if (options.id) {
  963. datetimepicker.attr('id', options.id);
  964. }
  965. if (options.style) {
  966. datetimepicker.attr('style', options.style);
  967. }
  968. if (options.weeks) {
  969. datetimepicker.addClass('xdsoft_showweeks');
  970. }
  971. if (options.rtl) {
  972. datetimepicker.addClass('xdsoft_rtl');
  973. }
  974. datetimepicker.addClass('xdsoft_' + options.theme);
  975. datetimepicker.addClass(options.className);
  976. month_picker
  977. .find('.xdsoft_month span')
  978. .after(monthselect);
  979. month_picker
  980. .find('.xdsoft_year span')
  981. .after(yearselect);
  982. month_picker
  983. .find('.xdsoft_month,.xdsoft_year')
  984. .on('touchstart mousedown.xdsoft', function (event) {
  985. var select = $(this).find('.xdsoft_select').eq(0),
  986. val = 0,
  987. top = 0,
  988. visible = select.is(':visible'),
  989. items,
  990. i;
  991. month_picker
  992. .find('.xdsoft_select')
  993. .hide();
  994. if (_xdsoft_datetime.currentTime) {
  995. val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
  996. }
  997. select[visible ? 'hide' : 'show']();
  998. for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
  999. if (items.eq(i).data('value') === val) {
  1000. break;
  1001. } else {
  1002. top += items[0].offsetHeight;
  1003. }
  1004. }
  1005. select.xdsoftScroller(options, top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
  1006. event.stopPropagation();
  1007. return false;
  1008. });
  1009. var handleTouchMoved = function (event) {
  1010. var evt = event.originalEvent;
  1011. var touchPosition = evt.touches ? evt.touches[0] : evt;
  1012. this.touchStartPosition = this.touchStartPosition || touchPosition;
  1013. var xMovement = Math.abs(this.touchStartPosition.clientX - touchPosition.clientX);
  1014. var yMovement = Math.abs(this.touchStartPosition.clientY - touchPosition.clientY);
  1015. var distance = Math.sqrt(xMovement * xMovement + yMovement * yMovement);
  1016. if(distance > options.touchMovedThreshold) {
  1017. this.touchMoved = true;
  1018. }
  1019. }
  1020. month_picker
  1021. .find('.xdsoft_select')
  1022. .xdsoftScroller(options)
  1023. .on('touchstart mousedown.xdsoft', function (event) {
  1024. var evt = event.originalEvent;
  1025. this.touchMoved = false;
  1026. this.touchStartPosition = evt.touches ? evt.touches[0] : evt;
  1027. event.stopPropagation();
  1028. event.preventDefault();
  1029. })
  1030. .on('touchmove', '.xdsoft_option', handleTouchMoved)
  1031. .on('touchend mousedown.xdsoft', '.xdsoft_option', function () {
  1032. if (!this.touchMoved) {
  1033. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  1034. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1035. }
  1036. var year = _xdsoft_datetime.currentTime.getFullYear();
  1037. if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
  1038. _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
  1039. }
  1040. $(this).parent().parent().hide();
  1041. datetimepicker.trigger('xchange.xdsoft');
  1042. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1043. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1044. }
  1045. if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  1046. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1047. }
  1048. }
  1049. });
  1050. datetimepicker.getValue = function () {
  1051. return _xdsoft_datetime.getCurrentTime();
  1052. };
  1053. datetimepicker.setOptions = function (_options) {
  1054. var highlightedDates = {};
  1055. options = $.extend(true, {}, options, _options);
  1056. if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
  1057. options.allowTimes = $.extend(true, [], _options.allowTimes);
  1058. }
  1059. if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
  1060. options.weekends = $.extend(true, [], _options.weekends);
  1061. }
  1062. if (_options.allowDates && $.isArray(_options.allowDates) && _options.allowDates.length) {
  1063. options.allowDates = $.extend(true, [], _options.allowDates);
  1064. }
  1065. if (_options.allowDateRe && Object.prototype.toString.call(_options.allowDateRe)==="[object String]") {
  1066. options.allowDateRe = new RegExp(_options.allowDateRe);
  1067. }
  1068. if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
  1069. $.each(_options.highlightedDates, function (index, value) {
  1070. var splitData = $.map(value.split(','), $.trim),
  1071. exDesc,
  1072. hDate = new HighlightedDate(dateHelper.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
  1073. keyDate = dateHelper.formatDate(hDate.date, options.formatDate);
  1074. if (highlightedDates[keyDate] !== undefined) {
  1075. exDesc = highlightedDates[keyDate].desc;
  1076. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  1077. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  1078. }
  1079. } else {
  1080. highlightedDates[keyDate] = hDate;
  1081. }
  1082. });
  1083. options.highlightedDates = $.extend(true, [], highlightedDates);
  1084. }
  1085. if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
  1086. highlightedDates = $.extend(true, [], options.highlightedDates);
  1087. $.each(_options.highlightedPeriods, function (index, value) {
  1088. var dateTest, // start date
  1089. dateEnd,
  1090. desc,
  1091. hDate,
  1092. keyDate,
  1093. exDesc,
  1094. style;
  1095. if ($.isArray(value)) {
  1096. dateTest = value[0];
  1097. dateEnd = value[1];
  1098. desc = value[2];
  1099. style = value[3];
  1100. }
  1101. else {
  1102. var splitData = $.map(value.split(','), $.trim);
  1103. dateTest = dateHelper.parseDate(splitData[0], options.formatDate);
  1104. dateEnd = dateHelper.parseDate(splitData[1], options.formatDate);
  1105. desc = splitData[2];
  1106. style = splitData[3];
  1107. }
  1108. while (dateTest <= dateEnd) {
  1109. hDate = new HighlightedDate(dateTest, desc, style);
  1110. keyDate = dateHelper.formatDate(dateTest, options.formatDate);
  1111. dateTest.setDate(dateTest.getDate() + 1);
  1112. if (highlightedDates[keyDate] !== undefined) {
  1113. exDesc = highlightedDates[keyDate].desc;
  1114. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  1115. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  1116. }
  1117. } else {
  1118. highlightedDates[keyDate] = hDate;
  1119. }
  1120. }
  1121. });
  1122. options.highlightedDates = $.extend(true, [], highlightedDates);
  1123. }
  1124. if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
  1125. options.disabledDates = $.extend(true, [], _options.disabledDates);
  1126. }
  1127. if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
  1128. options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
  1129. }
  1130. if ((options.open || options.opened) && (!options.inline)) {
  1131. input.trigger('open.xdsoft');
  1132. }
  1133. if (options.inline) {
  1134. triggerAfterOpen = true;
  1135. datetimepicker.addClass('xdsoft_inline');
  1136. input.after(datetimepicker).hide();
  1137. }
  1138. if (options.inverseButton) {
  1139. options.next = 'xdsoft_prev';
  1140. options.prev = 'xdsoft_next';
  1141. }
  1142. if (options.datepicker) {
  1143. datepicker.addClass('active');
  1144. } else {
  1145. datepicker.removeClass('active');
  1146. }
  1147. if (options.timepicker) {
  1148. timepicker.addClass('active');
  1149. } else {
  1150. timepicker.removeClass('active');
  1151. }
  1152. if (options.value) {
  1153. _xdsoft_datetime.setCurrentTime(options.value);
  1154. if (input && input.val) {
  1155. input.val(_xdsoft_datetime.str);
  1156. }
  1157. }
  1158. if (isNaN(options.dayOfWeekStart)) {
  1159. options.dayOfWeekStart = 0;
  1160. } else {
  1161. options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
  1162. }
  1163. if (!options.timepickerScrollbar) {
  1164. timeboxparent.xdsoftScroller(options, 'hide');
  1165. }
  1166. if (options.minDate && /^[\+\-](.*)$/.test(options.minDate)) {
  1167. options.minDate = dateHelper.formatDate(_xdsoft_datetime.strToDateTime(options.minDate), options.formatDate);
  1168. }
  1169. if (options.maxDate && /^[\+\-](.*)$/.test(options.maxDate)) {
  1170. options.maxDate = dateHelper.formatDate(_xdsoft_datetime.strToDateTime(options.maxDate), options.formatDate);
  1171. }
  1172. if (options.minDateTime && /^\+(.*)$/.test(options.minDateTime)) {
  1173. options.minDateTime = _xdsoft_datetime.strToDateTime(options.minDateTime).dateFormat(options.formatDate);
  1174. }
  1175. if (options.maxDateTime && /^\+(.*)$/.test(options.maxDateTime)) {
  1176. options.maxDateTime = _xdsoft_datetime.strToDateTime(options.maxDateTime).dateFormat(options.formatDate);
  1177. }
  1178. applyButton.toggle(options.showApplyButton);
  1179. month_picker
  1180. .find('.xdsoft_today_button')
  1181. .css('visibility', !options.todayButton ? 'hidden' : 'visible');
  1182. month_picker
  1183. .find('.' + options.prev)
  1184. .css('visibility', !options.prevButton ? 'hidden' : 'visible');
  1185. month_picker
  1186. .find('.' + options.next)
  1187. .css('visibility', !options.nextButton ? 'hidden' : 'visible');
  1188. setMask(options);
  1189. if (options.validateOnBlur) {
  1190. input
  1191. .off('blur.xdsoft')
  1192. .on('blur.xdsoft', function () {
  1193. if (options.allowBlank && (!$.trim($(this).val()).length ||
  1194. (typeof options.mask === "string" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) {
  1195. $(this).val(null);
  1196. datetimepicker.data('xdsoft_datetime').empty();
  1197. } else {
  1198. var d = dateHelper.parseDate($(this).val(), options.format);
  1199. if (d) { // parseDate() may skip some invalid parts like date or time, so make it clear for user: show parsed date/time
  1200. $(this).val(dateHelper.formatDate(d, options.format));
  1201. } else {
  1202. var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
  1203. splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
  1204. // parse the numbers as 0312 => 03:12
  1205. if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
  1206. $(this).val([splittedHours, splittedMinutes].map(function (item) {
  1207. return item > 9 ? item : '0' + item;
  1208. }).join(':'));
  1209. } else {
  1210. $(this).val(dateHelper.formatDate(_xdsoft_datetime.now(), options.format));
  1211. }
  1212. }
  1213. datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1214. }
  1215. datetimepicker.trigger('changedatetime.xdsoft');
  1216. datetimepicker.trigger('close.xdsoft');
  1217. });
  1218. }
  1219. options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
  1220. datetimepicker
  1221. .trigger('xchange.xdsoft')
  1222. .trigger('afterOpen.xdsoft');
  1223. };
  1224. datetimepicker
  1225. .data('options', options)
  1226. .on('touchstart mousedown.xdsoft', function (event) {
  1227. event.stopPropagation();
  1228. event.preventDefault();
  1229. yearselect.hide();
  1230. monthselect.hide();
  1231. return false;
  1232. });
  1233. //scroll_element = timepicker.find('.xdsoft_time_box');
  1234. timeboxparent.append(timebox);
  1235. timeboxparent.xdsoftScroller(options);
  1236. datetimepicker.on('afterOpen.xdsoft', function () {
  1237. timeboxparent.xdsoftScroller(options);
  1238. });
  1239. datetimepicker
  1240. .append(datepicker)
  1241. .append(timepicker);
  1242. if (options.withoutCopyright !== true) {
  1243. datetimepicker
  1244. .append(xdsoft_copyright);
  1245. }
  1246. datepicker
  1247. .append(month_picker)
  1248. .append(calendar)
  1249. .append(applyButton);
  1250. if (options.insideParent) {
  1251. $(input).parent().append(datetimepicker);
  1252. } else {
  1253. $(options.parentID).append(datetimepicker);
  1254. }
  1255. XDSoft_datetime = function () {
  1256. var _this = this;
  1257. _this.now = function (norecursion) {
  1258. var d = new Date(),
  1259. date,
  1260. time;
  1261. if (!norecursion && options.defaultDate) {
  1262. date = _this.strToDateTime(options.defaultDate);
  1263. d.setFullYear(date.getFullYear());
  1264. d.setMonth(date.getMonth());
  1265. d.setDate(date.getDate());
  1266. }
  1267. d.setFullYear(d.getFullYear());
  1268. if (!norecursion && options.defaultTime) {
  1269. time = _this.strtotime(options.defaultTime);
  1270. d.setHours(time.getHours());
  1271. d.setMinutes(time.getMinutes());
  1272. d.setSeconds(time.getSeconds());
  1273. d.setMilliseconds(time.getMilliseconds());
  1274. }
  1275. return d;
  1276. };
  1277. _this.isValidDate = function (d) {
  1278. if (Object.prototype.toString.call(d) !== "[object Date]") {
  1279. return false;
  1280. }
  1281. return !isNaN(d.getTime());
  1282. };
  1283. _this.setCurrentTime = function (dTime, requireValidDate) {
  1284. if (typeof dTime === 'string') {
  1285. _this.currentTime = _this.strToDateTime(dTime);
  1286. }
  1287. else if (_this.isValidDate(dTime)) {
  1288. _this.currentTime = dTime;
  1289. }
  1290. else if (!dTime && !requireValidDate && options.allowBlank && !options.inline) {
  1291. _this.currentTime = null;
  1292. }
  1293. else {
  1294. _this.currentTime = _this.now();
  1295. }
  1296. datetimepicker.trigger('xchange.xdsoft');
  1297. };
  1298. _this.empty = function () {
  1299. _this.currentTime = null;
  1300. };
  1301. _this.getCurrentTime = function () {
  1302. return _this.currentTime;
  1303. };
  1304. _this.nextMonth = function () {
  1305. if (_this.currentTime === undefined || _this.currentTime === null) {
  1306. _this.currentTime = _this.now();
  1307. }
  1308. var month = _this.currentTime.getMonth() + 1,
  1309. year;
  1310. if (month === 12) {
  1311. _this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
  1312. month = 0;
  1313. }
  1314. year = _this.currentTime.getFullYear();
  1315. _this.currentTime.setDate(
  1316. Math.min(
  1317. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1318. _this.currentTime.getDate()
  1319. )
  1320. );
  1321. _this.currentTime.setMonth(month);
  1322. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1323. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1324. }
  1325. if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  1326. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1327. }
  1328. datetimepicker.trigger('xchange.xdsoft');
  1329. return month;
  1330. };
  1331. _this.prevMonth = function () {
  1332. if (_this.currentTime === undefined || _this.currentTime === null) {
  1333. _this.currentTime = _this.now();
  1334. }
  1335. var month = _this.currentTime.getMonth() - 1;
  1336. if (month === -1) {
  1337. _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
  1338. month = 11;
  1339. }
  1340. _this.currentTime.setDate(
  1341. Math.min(
  1342. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1343. _this.currentTime.getDate()
  1344. )
  1345. );
  1346. _this.currentTime.setMonth(month);
  1347. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1348. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1349. }
  1350. datetimepicker.trigger('xchange.xdsoft');
  1351. return month;
  1352. };
  1353. _this.getWeekOfYear = function (datetime) {
  1354. if (options.onGetWeekOfYear && $.isFunction(options.onGetWeekOfYear)) {
  1355. var week = options.onGetWeekOfYear.call(datetimepicker, datetime);
  1356. if (typeof week !== 'undefined') {
  1357. return week;
  1358. }
  1359. }
  1360. var onejan = new Date(datetime.getFullYear(), 0, 1);
  1361. //First week of the year is th one with the first Thursday according to ISO8601
  1362. if (onejan.getDay() !== 4) {
  1363. onejan.setMonth(0, 1 + ((4 - onejan.getDay()+ 7) % 7));
  1364. }
  1365. return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
  1366. };
  1367. _this.strToDateTime = function (sDateTime) {
  1368. var tmpDate = [], timeOffset, currentTime;
  1369. if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
  1370. return sDateTime;
  1371. }
  1372. tmpDate = /^([+-]{1})(.*)$/.exec(sDateTime);
  1373. if (tmpDate) {
  1374. tmpDate[2] = dateHelper.parseDate(tmpDate[2], options.formatDate);
  1375. }
  1376. if (tmpDate && tmpDate[2]) {
  1377. timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
  1378. currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
  1379. } else {
  1380. currentTime = sDateTime ? dateHelper.parseDate(sDateTime, options.format) : _this.now();
  1381. }
  1382. if (!_this.isValidDate(currentTime)) {
  1383. currentTime = _this.now();
  1384. }
  1385. return currentTime;
  1386. };
  1387. _this.strToDate = function (sDate) {
  1388. if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
  1389. return sDate;
  1390. }
  1391. var currentTime = sDate ? dateHelper.parseDate(sDate, options.formatDate) : _this.now(true);
  1392. if (!_this.isValidDate(currentTime)) {
  1393. currentTime = _this.now(true);
  1394. }
  1395. return currentTime;
  1396. };
  1397. _this.strtotime = function (sTime) {
  1398. if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
  1399. return sTime;
  1400. }
  1401. var currentTime = sTime ? dateHelper.parseDate(sTime, options.formatTime) : _this.now(true);
  1402. if (!_this.isValidDate(currentTime)) {
  1403. currentTime = _this.now(true);
  1404. }
  1405. return currentTime;
  1406. };
  1407. _this.str = function () {
  1408. var format = options.format;
  1409. if (options.yearOffset) {
  1410. format = format.replace('Y', _this.currentTime.getFullYear() + options.yearOffset);
  1411. format = format.replace('y', String(_this.currentTime.getFullYear() + options.yearOffset).substring(2, 4));
  1412. }
  1413. return dateHelper.formatDate(_this.currentTime, format);
  1414. };
  1415. _this.currentTime = this.now();
  1416. };
  1417. _xdsoft_datetime = new XDSoft_datetime();
  1418. applyButton.on('touchend click', function (e) {//pathbrite
  1419. e.preventDefault();
  1420. datetimepicker.data('changed', true);
  1421. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1422. input.val(_xdsoft_datetime.str());
  1423. datetimepicker.trigger('close.xdsoft');
  1424. });
  1425. month_picker
  1426. .find('.xdsoft_today_button')
  1427. .on('touchend mousedown.xdsoft', function () {
  1428. datetimepicker.data('changed', true);
  1429. _xdsoft_datetime.setCurrentTime(0, true);
  1430. datetimepicker.trigger('afterOpen.xdsoft');
  1431. }).on('dblclick.xdsoft', function () {
  1432. var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
  1433. currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
  1434. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1435. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1436. if (currentDate < minDate) {
  1437. return;
  1438. }
  1439. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1440. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
  1441. if (currentDate > maxDate) {
  1442. return;
  1443. }
  1444. input.val(_xdsoft_datetime.str());
  1445. input.trigger('change');
  1446. datetimepicker.trigger('close.xdsoft');
  1447. });
  1448. month_picker
  1449. .find('.xdsoft_prev,.xdsoft_next')
  1450. .on('touchend mousedown.xdsoft', function () {
  1451. var $this = $(this),
  1452. timer = 0,
  1453. stop = false;
  1454. (function arguments_callee1(v) {
  1455. if ($this.hasClass(options.next)) {
  1456. _xdsoft_datetime.nextMonth();
  1457. } else if ($this.hasClass(options.prev)) {
  1458. _xdsoft_datetime.prevMonth();
  1459. }
  1460. if (options.monthChangeSpinner) {
  1461. if (!stop) {
  1462. timer = setTimeout(arguments_callee1, v || 100);
  1463. }
  1464. }
  1465. }(500));
  1466. $([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft', function arguments_callee2() {
  1467. clearTimeout(timer);
  1468. stop = true;
  1469. $([options.ownerDocument.body, options.contentWindow]).off('touchend mouseup.xdsoft', arguments_callee2);
  1470. });
  1471. });
  1472. timepicker
  1473. .find('.xdsoft_prev,.xdsoft_next')
  1474. .on('touchend mousedown.xdsoft', function () {
  1475. var $this = $(this),
  1476. timer = 0,
  1477. stop = false,
  1478. period = 110;
  1479. (function arguments_callee4(v) {
  1480. var pheight = timeboxparent[0].clientHeight,
  1481. height = timebox[0].offsetHeight,
  1482. top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  1483. if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
  1484. timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
  1485. } else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
  1486. timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
  1487. }
  1488. /**
  1489. * Fixed bug:
  1490. * When using css3 transition, it will cause a bug that you cannot scroll the timepicker list.
  1491. * The reason is that the transition-duration time, if you set it to 0, all things fine, otherwise, this
  1492. * would cause a bug when you use jquery.css method.
  1493. * Let's say: * { transition: all .5s ease; }
  1494. * jquery timebox.css('marginTop') will return the original value which is before you clicking the next/prev button,
  1495. * meanwhile the timebox[0].style.marginTop will return the right value which is after you clicking the
  1496. * next/prev button.
  1497. *
  1498. * What we should do:
  1499. * Replace timebox.css('marginTop') with timebox[0].style.marginTop.
  1500. */
  1501. timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox[0].style.marginTop, 10) / (height - pheight))]);
  1502. period = (period > 10) ? 10 : period - 10;
  1503. if (!stop) {
  1504. timer = setTimeout(arguments_callee4, v || period);
  1505. }
  1506. }(500));
  1507. $([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft', function arguments_callee5() {
  1508. clearTimeout(timer);
  1509. stop = true;
  1510. $([options.ownerDocument.body, options.contentWindow])
  1511. .off('touchend mouseup.xdsoft', arguments_callee5);
  1512. });
  1513. });
  1514. xchangeTimer = 0;
  1515. // base handler - generating a calendar and timepicker
  1516. datetimepicker
  1517. .on('xchange.xdsoft', function (event) {
  1518. clearTimeout(xchangeTimer);
  1519. xchangeTimer = setTimeout(function () {
  1520. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  1521. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1522. }
  1523. var table = '',
  1524. start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
  1525. i = 0,
  1526. j,
  1527. today = _xdsoft_datetime.now(),
  1528. maxDate = false,
  1529. minDate = false,
  1530. minDateTime = false,
  1531. maxDateTime = false,
  1532. hDate,
  1533. day,
  1534. d,
  1535. y,
  1536. m,
  1537. w,
  1538. classes = [],
  1539. customDateSettings,
  1540. newRow = true,
  1541. time = '',
  1542. h,
  1543. line_time,
  1544. description;
  1545. while (start.getDay() !== options.dayOfWeekStart) {
  1546. start.setDate(start.getDate() - 1);
  1547. }
  1548. table += '<table><thead><tr>';
  1549. if (options.weeks) {
  1550. table += '<th></th>';
  1551. }
  1552. for (j = 0; j < 7; j += 1) {
  1553. table += '<th>' + options.i18n[globalLocale].dayOfWeekShort[(j + options.dayOfWeekStart) % 7] + '</th>';
  1554. }
  1555. table += '</tr></thead>';
  1556. table += '<tbody>';
  1557. if (options.maxDate !== false) {
  1558. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1559. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
  1560. }
  1561. if (options.minDate !== false) {
  1562. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1563. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1564. }
  1565. if (options.minDateTime !== false) {
  1566. minDateTime = _xdsoft_datetime.strToDate(options.minDateTime);
  1567. minDateTime = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), minDateTime.getHours(), minDateTime.getMinutes(), minDateTime.getSeconds());
  1568. }
  1569. if (options.maxDateTime !== false) {
  1570. maxDateTime = _xdsoft_datetime.strToDate(options.maxDateTime);
  1571. maxDateTime = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), maxDateTime.getHours(), maxDateTime.getMinutes(), maxDateTime.getSeconds());
  1572. }
  1573. var maxDateTimeDay;
  1574. if (maxDateTime !== false) {
  1575. maxDateTimeDay = ((maxDateTime.getFullYear() * 12) + maxDateTime.getMonth()) * 31 + maxDateTime.getDate();
  1576. }
  1577. while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
  1578. classes = [];
  1579. i += 1;
  1580. day = start.getDay();
  1581. d = start.getDate();
  1582. y = start.getFullYear();
  1583. m = start.getMonth();
  1584. w = _xdsoft_datetime.getWeekOfYear(start);
  1585. description = '';
  1586. classes.push('xdsoft_date');
  1587. if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
  1588. customDateSettings = options.beforeShowDay.call(datetimepicker, start);
  1589. } else {
  1590. customDateSettings = null;
  1591. }
  1592. if(options.allowDateRe && Object.prototype.toString.call(options.allowDateRe) === "[object RegExp]"){
  1593. if(!options.allowDateRe.test(dateHelper.formatDate(start, options.formatDate))){
  1594. classes.push('xdsoft_disabled');
  1595. }
  1596. }
  1597. if(options.allowDates && options.allowDates.length>0){
  1598. if(options.allowDates.indexOf(dateHelper.formatDate(start, options.formatDate)) === -1){
  1599. classes.push('xdsoft_disabled');
  1600. }
  1601. }
  1602. var currentDay = ((start.getFullYear() * 12) + start.getMonth()) * 31 + start.getDate();
  1603. if ((maxDate !== false && start > maxDate) || (minDateTime !== false && start < minDateTime) || (minDate !== false && start < minDate) || (maxDateTime !== false && currentDay > maxDateTimeDay) || (customDateSettings && customDateSettings[0] === false)) {
  1604. classes.push('xdsoft_disabled');
  1605. }
  1606. if (options.disabledDates.indexOf(dateHelper.formatDate(start, options.formatDate)) !== -1) {
  1607. classes.push('xdsoft_disabled');
  1608. }
  1609. if (options.disabledWeekDays.indexOf(day) !== -1) {
  1610. classes.push('xdsoft_disabled');
  1611. }
  1612. if (input.is('[disabled]')) {
  1613. classes.push('xdsoft_disabled');
  1614. }
  1615. if (customDateSettings && customDateSettings[1] !== "") {
  1616. classes.push(customDateSettings[1]);
  1617. }
  1618. if (_xdsoft_datetime.currentTime.getMonth() !== m) {
  1619. classes.push('xdsoft_other_month');
  1620. }
  1621. if ((options.defaultSelect || datetimepicker.data('changed')) && dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(start, options.formatDate)) {
  1622. classes.push('xdsoft_current');
  1623. }
  1624. if (dateHelper.formatDate(today, options.formatDate) === dateHelper.formatDate(start, options.formatDate)) {
  1625. classes.push('xdsoft_today');
  1626. }
  1627. if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(dateHelper.formatDate(start, options.formatDate)) !== -1) {
  1628. classes.push('xdsoft_weekend');
  1629. }
  1630. if (options.highlightedDates[dateHelper.formatDate(start, options.formatDate)] !== undefined) {
  1631. hDate = options.highlightedDates[dateHelper.formatDate(start, options.formatDate)];
  1632. classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
  1633. description = hDate.desc === undefined ? '' : hDate.desc;
  1634. }
  1635. if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
  1636. classes.push(options.beforeShowDay(start));
  1637. }
  1638. if (newRow) {
  1639. table += '<tr>';
  1640. newRow = false;
  1641. if (options.weeks) {
  1642. table += '<th>' + w + '</th>';
  1643. }
  1644. }
  1645. table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '" title="' + description + '">' +
  1646. '<div>' + d + '</div>' +
  1647. '</td>';
  1648. if (start.getDay() === options.dayOfWeekStartPrev) {
  1649. table += '</tr>';
  1650. newRow = true;
  1651. }
  1652. start.setDate(d + 1);
  1653. }
  1654. table += '</tbody></table>';
  1655. calendar.html(table);
  1656. month_picker.find('.xdsoft_label span').eq(0).text(options.i18n[globalLocale].months[_xdsoft_datetime.currentTime.getMonth()]);
  1657. month_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear() + options.yearOffset);
  1658. // generate timebox
  1659. time = '';
  1660. h = '';
  1661. m = '';
  1662. var minTimeMinutesOfDay = 0;
  1663. if (options.minTime !== false) {
  1664. var t = _xdsoft_datetime.strtotime(options.minTime);
  1665. minTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
  1666. }
  1667. var maxTimeMinutesOfDay = 24 * 60;
  1668. if (options.maxTime !== false) {
  1669. var t = _xdsoft_datetime.strtotime(options.maxTime);
  1670. maxTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
  1671. }
  1672. if (options.minDateTime !== false) {
  1673. var t = _xdsoft_datetime.strToDateTime(options.minDateTime);
  1674. var currentDayIsMinDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
  1675. if (currentDayIsMinDateTimeDay) {
  1676. var m = 60 * t.getHours() + t.getMinutes();
  1677. if (m > minTimeMinutesOfDay) minTimeMinutesOfDay = m;
  1678. }
  1679. }
  1680. if (options.maxDateTime !== false) {
  1681. var t = _xdsoft_datetime.strToDateTime(options.maxDateTime);
  1682. var currentDayIsMaxDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
  1683. if (currentDayIsMaxDateTimeDay) {
  1684. var m = 60 * t.getHours() + t.getMinutes();
  1685. if (m < maxTimeMinutesOfDay) maxTimeMinutesOfDay = m;
  1686. }
  1687. }
  1688. line_time = function line_time(h, m) {
  1689. var now = _xdsoft_datetime.now(), current_time,
  1690. isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
  1691. now.setHours(h);
  1692. h = parseInt(now.getHours(), 10);
  1693. now.setMinutes(m);
  1694. m = parseInt(now.getMinutes(), 10);
  1695. classes = [];
  1696. var currentMinutesOfDay = 60 * h + m;
  1697. if (input.is('[disabled]') || (currentMinutesOfDay >= maxTimeMinutesOfDay) || (currentMinutesOfDay < minTimeMinutesOfDay)) {
  1698. classes.push('xdsoft_disabled');
  1699. }
  1700. current_time = new Date(_xdsoft_datetime.currentTime);
  1701. current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
  1702. if (!isALlowTimesInit) {
  1703. current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
  1704. }
  1705. if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && ((!isALlowTimesInit && options.step > 59) || current_time.getMinutes() === parseInt(m, 10))) {
  1706. if (options.defaultSelect || datetimepicker.data('changed')) {
  1707. classes.push('xdsoft_current');
  1708. } else if (options.initTime) {
  1709. classes.push('xdsoft_init_time');
  1710. }
  1711. }
  1712. if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
  1713. classes.push('xdsoft_today');
  1714. }
  1715. time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + dateHelper.formatDate(now, options.formatTime) + '</div>';
  1716. };
  1717. if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
  1718. for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
  1719. for (j = 0; j < 60; j += options.step) {
  1720. var currentMinutesOfDay = i * 60 + j;
  1721. if (currentMinutesOfDay < minTimeMinutesOfDay) continue;
  1722. if (currentMinutesOfDay >= maxTimeMinutesOfDay) continue;
  1723. h = (i < 10 ? '0' : '') + i;
  1724. m = (j < 10 ? '0' : '') + j;
  1725. line_time(h, m);
  1726. }
  1727. }
  1728. } else {
  1729. for (i = 0; i < options.allowTimes.length; i += 1) {
  1730. h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
  1731. m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
  1732. line_time(h, m);
  1733. }
  1734. }
  1735. timebox.html(time);
  1736. opt = '';
  1737. for (i = parseInt(options.yearStart, 10); i <= parseInt(options.yearEnd, 10); i += 1) {
  1738. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + (i + options.yearOffset) + '</div>';
  1739. }
  1740. yearselect.children().eq(0)
  1741. .html(opt);
  1742. for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
  1743. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[globalLocale].months[i] + '</div>';
  1744. }
  1745. monthselect.children().eq(0).html(opt);
  1746. $(datetimepicker)
  1747. .trigger('generate.xdsoft');
  1748. }, 10);
  1749. event.stopPropagation();
  1750. })
  1751. .on('afterOpen.xdsoft', function () {
  1752. if (options.timepicker) {
  1753. var classType, pheight, height, top;
  1754. if (timebox.find('.xdsoft_current').length) {
  1755. classType = '.xdsoft_current';
  1756. } else if (timebox.find('.xdsoft_init_time').length) {
  1757. classType = '.xdsoft_init_time';
  1758. }
  1759. if (classType) {
  1760. pheight = timeboxparent[0].clientHeight;
  1761. height = timebox[0].offsetHeight;
  1762. top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
  1763. if ((height - pheight) < top) {
  1764. top = height - pheight;
  1765. }
  1766. timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
  1767. } else {
  1768. timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
  1769. }
  1770. }
  1771. });
  1772. timerclick = 0;
  1773. calendar
  1774. .on('touchend click.xdsoft', 'td', function (xdevent) {
  1775. xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
  1776. timerclick += 1;
  1777. var $this = $(this),
  1778. currentTime = _xdsoft_datetime.currentTime;
  1779. if (currentTime === undefined || currentTime === null) {
  1780. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1781. currentTime = _xdsoft_datetime.currentTime;
  1782. }
  1783. if ($this.hasClass('xdsoft_disabled')) {
  1784. return false;
  1785. }
  1786. currentTime.setDate(1);
  1787. currentTime.setFullYear($this.data('year'));
  1788. currentTime.setMonth($this.data('month'));
  1789. currentTime.setDate($this.data('date'));
  1790. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1791. input.val(_xdsoft_datetime.str());
  1792. if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
  1793. options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1794. }
  1795. datetimepicker.data('changed', true);
  1796. datetimepicker.trigger('xchange.xdsoft');
  1797. datetimepicker.trigger('changedatetime.xdsoft');
  1798. if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === false && !options.timepicker))) && !options.inline) {
  1799. datetimepicker.trigger('close.xdsoft');
  1800. }
  1801. setTimeout(function () {
  1802. timerclick = 0;
  1803. }, 200);
  1804. });
  1805. timebox
  1806. .on('touchstart', 'div', function (xdevent) {
  1807. this.touchMoved = false;
  1808. })
  1809. .on('touchmove', 'div', handleTouchMoved)
  1810. .on('touchend click.xdsoft', 'div', function (xdevent) {
  1811. if (!this.touchMoved) {
  1812. xdevent.stopPropagation();
  1813. var $this = $(this),
  1814. currentTime = _xdsoft_datetime.currentTime;
  1815. if (currentTime === undefined || currentTime === null) {
  1816. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1817. currentTime = _xdsoft_datetime.currentTime;
  1818. }
  1819. if ($this.hasClass('xdsoft_disabled')) {
  1820. return false;
  1821. }
  1822. currentTime.setHours($this.data('hour'));
  1823. currentTime.setMinutes($this.data('minute'));
  1824. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1825. datetimepicker.data('input').val(_xdsoft_datetime.str());
  1826. if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
  1827. options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1828. }
  1829. datetimepicker.data('changed', true);
  1830. datetimepicker.trigger('xchange.xdsoft');
  1831. datetimepicker.trigger('changedatetime.xdsoft');
  1832. if (options.inline !== true && options.closeOnTimeSelect === true) {
  1833. datetimepicker.trigger('close.xdsoft');
  1834. }
  1835. }
  1836. });
  1837. datepicker
  1838. .on('mousewheel.xdsoft', function (event) {
  1839. if (!options.scrollMonth) {
  1840. return true;
  1841. }
  1842. if (event.deltaY < 0) {
  1843. _xdsoft_datetime.nextMonth();
  1844. } else {
  1845. _xdsoft_datetime.prevMonth();
  1846. }
  1847. return false;
  1848. });
  1849. input
  1850. .on('mousewheel.xdsoft', function (event) {
  1851. if (!options.scrollInput) {
  1852. return true;
  1853. }
  1854. if (!options.datepicker && options.timepicker) {
  1855. current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
  1856. if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
  1857. current_time_index += event.deltaY;
  1858. }
  1859. if (timebox.children().eq(current_time_index).length) {
  1860. timebox.children().eq(current_time_index).trigger('mousedown');
  1861. }
  1862. return false;
  1863. }
  1864. if (options.datepicker && !options.timepicker) {
  1865. datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
  1866. if (input.val) {
  1867. input.val(_xdsoft_datetime.str());
  1868. }
  1869. datetimepicker.trigger('changedatetime.xdsoft');
  1870. return false;
  1871. }
  1872. });
  1873. datetimepicker
  1874. .on('changedatetime.xdsoft', function (event) {
  1875. if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
  1876. var $input = datetimepicker.data('input');
  1877. options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
  1878. delete options.value;
  1879. $input.trigger('change');
  1880. }
  1881. })
  1882. .on('generate.xdsoft', function () {
  1883. if (options.onGenerate && $.isFunction(options.onGenerate)) {
  1884. options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1885. }
  1886. if (triggerAfterOpen) {
  1887. datetimepicker.trigger('afterOpen.xdsoft');
  1888. triggerAfterOpen = false;
  1889. }
  1890. })
  1891. .on('click.xdsoft', function (xdevent) {
  1892. xdevent.stopPropagation();
  1893. });
  1894. current_time_index = 0;
  1895. /**
  1896. * Runs the callback for each of the specified node's ancestors.
  1897. *
  1898. * Return FALSE from the callback to stop ascending.
  1899. *
  1900. * @param {DOMNode} node
  1901. * @param {Function} callback
  1902. * @returns {undefined}
  1903. */
  1904. forEachAncestorOf = function (node, callback) {
  1905. do {
  1906. node = node.parentNode;
  1907. if (!node || callback(node) === false) {
  1908. break;
  1909. }
  1910. } while (node.nodeName !== 'HTML');
  1911. };
  1912. /**
  1913. * Sets the position of the picker.
  1914. *
  1915. * @returns {undefined}
  1916. */
  1917. setPos = function () {
  1918. var dateInputOffset,
  1919. dateInputElem,
  1920. verticalPosition,
  1921. left,
  1922. position,
  1923. datetimepickerElem,
  1924. dateInputHasFixedAncestor,
  1925. $dateInput,
  1926. windowWidth,
  1927. verticalAnchorEdge,
  1928. datetimepickerCss,
  1929. windowHeight,
  1930. windowScrollTop;
  1931. $dateInput = datetimepicker.data('input');
  1932. dateInputOffset = $dateInput.offset();
  1933. dateInputElem = $dateInput[0];
  1934. verticalAnchorEdge = 'top';
  1935. verticalPosition = (dateInputOffset.top + dateInputElem.offsetHeight) - 1;
  1936. left = dateInputOffset.left;
  1937. position = "absolute";
  1938. windowWidth = $(options.contentWindow).width();
  1939. windowHeight = $(options.contentWindow).height();
  1940. windowScrollTop = $(options.contentWindow).scrollTop();
  1941. if ((options.ownerDocument.documentElement.clientWidth - dateInputOffset.left) < datepicker.parent().outerWidth(true)) {
  1942. var diff = datepicker.parent().outerWidth(true) - dateInputElem.offsetWidth;
  1943. left = left - diff;
  1944. }
  1945. if ($dateInput.parent().css('direction') === 'rtl') {
  1946. left -= (datetimepicker.outerWidth() - $dateInput.outerWidth());
  1947. }
  1948. if (options.fixed) {
  1949. verticalPosition -= windowScrollTop;
  1950. left -= $(options.contentWindow).scrollLeft();
  1951. position = "fixed";
  1952. } else {
  1953. dateInputHasFixedAncestor = false;
  1954. forEachAncestorOf(dateInputElem, function (ancestorNode) {
  1955. if (ancestorNode === null) {
  1956. return false;
  1957. }
  1958. if (options.contentWindow.getComputedStyle(ancestorNode).getPropertyValue('position') === 'fixed') {
  1959. dateInputHasFixedAncestor = true;
  1960. return false;
  1961. }
  1962. });
  1963. if (dateInputHasFixedAncestor && !options.insideParent) {
  1964. position = 'fixed';
  1965. //If the picker won't fit entirely within the viewport then display it above the date input.
  1966. if (verticalPosition + datetimepicker.outerHeight() > windowHeight + windowScrollTop) {
  1967. verticalAnchorEdge = 'bottom';
  1968. verticalPosition = (windowHeight + windowScrollTop) - dateInputOffset.top;
  1969. } else {
  1970. verticalPosition -= windowScrollTop;
  1971. }
  1972. } else {
  1973. if (verticalPosition + datetimepicker[0].offsetHeight > windowHeight + windowScrollTop) {
  1974. verticalPosition = dateInputOffset.top - datetimepicker[0].offsetHeight + 1;
  1975. }
  1976. }
  1977. if (verticalPosition < 0) {
  1978. verticalPosition = 0;
  1979. }
  1980. if (left + dateInputElem.offsetWidth > windowWidth) {
  1981. left = windowWidth - dateInputElem.offsetWidth;
  1982. }
  1983. }
  1984. datetimepickerElem = datetimepicker[0];
  1985. forEachAncestorOf(datetimepickerElem, function (ancestorNode) {
  1986. var ancestorNodePosition;
  1987. ancestorNodePosition = options.contentWindow.getComputedStyle(ancestorNode).getPropertyValue('position');
  1988. if (ancestorNodePosition === 'relative' && windowWidth >= ancestorNode.offsetWidth) {
  1989. left = left - ((windowWidth - ancestorNode.offsetWidth) / 2);
  1990. return false;
  1991. }
  1992. });
  1993. datetimepickerCss = {
  1994. position: position,
  1995. left: options.insideParent ? dateInputElem.offsetLeft : left,
  1996. top: '', //Initialize to prevent previous values interfering with new ones.
  1997. bottom: '' //Initialize to prevent previous values interfering with new ones.
  1998. };
  1999. if (options.insideParent) {
  2000. datetimepickerCss[verticalAnchorEdge] = dateInputElem.offsetTop + dateInputElem.offsetHeight;
  2001. } else {
  2002. datetimepickerCss[verticalAnchorEdge] = verticalPosition;
  2003. }
  2004. datetimepicker.css(datetimepickerCss);
  2005. };
  2006. datetimepicker
  2007. .on('open.xdsoft', function (event) {
  2008. var onShow = true;
  2009. if (options.onShow && $.isFunction(options.onShow)) {
  2010. onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  2011. }
  2012. if (onShow !== false) {
  2013. datetimepicker.show();
  2014. setPos();
  2015. $(options.contentWindow)
  2016. .off('resize.xdsoft', setPos)
  2017. .on('resize.xdsoft', setPos);
  2018. if (options.closeOnWithoutClick) {
  2019. $([options.ownerDocument.body, options.contentWindow]).on('touchstart mousedown.xdsoft', function arguments_callee6() {
  2020. datetimepicker.trigger('close.xdsoft');
  2021. $([options.ownerDocument.body, options.contentWindow]).off('touchstart mousedown.xdsoft', arguments_callee6);
  2022. });
  2023. }
  2024. }
  2025. })
  2026. .on('close.xdsoft', function (event) {
  2027. var onClose = true;
  2028. month_picker
  2029. .find('.xdsoft_month,.xdsoft_year')
  2030. .find('.xdsoft_select')
  2031. .hide();
  2032. if (options.onClose && $.isFunction(options.onClose)) {
  2033. onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  2034. }
  2035. if (onClose !== false && !options.opened && !options.inline) {
  2036. datetimepicker.hide();
  2037. }
  2038. event.stopPropagation();
  2039. })
  2040. .on('toggle.xdsoft', function () {
  2041. if (datetimepicker.is(':visible')) {
  2042. datetimepicker.trigger('close.xdsoft');
  2043. } else {
  2044. datetimepicker.trigger('open.xdsoft');
  2045. }
  2046. })
  2047. .data('input', input);
  2048. timer = 0;
  2049. datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
  2050. datetimepicker.setOptions(options);
  2051. function getCurrentValue() {
  2052. var ct = false, time;
  2053. if (options.startDate) {
  2054. ct = _xdsoft_datetime.strToDate(options.startDate);
  2055. } else {
  2056. ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
  2057. if (ct) {
  2058. ct = _xdsoft_datetime.strToDateTime(ct);
  2059. if (options.yearOffset) {
  2060. ct = new Date(ct.getFullYear() - options.yearOffset, ct.getMonth(), ct.getDate(), ct.getHours(), ct.getMinutes(), ct.getSeconds(), ct.getMilliseconds());
  2061. }
  2062. } else if (options.defaultDate) {
  2063. ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
  2064. if (options.defaultTime) {
  2065. time = _xdsoft_datetime.strtotime(options.defaultTime);
  2066. ct.setHours(time.getHours());
  2067. ct.setMinutes(time.getMinutes());
  2068. }
  2069. }
  2070. }
  2071. if (ct && _xdsoft_datetime.isValidDate(ct)) {
  2072. datetimepicker.data('changed', true);
  2073. } else {
  2074. ct = '';
  2075. }
  2076. return ct || 0;
  2077. }
  2078. function setMask(options) {
  2079. var isValidValue = function (mask, value) {
  2080. var reg = mask
  2081. .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
  2082. .replace(/_/g, '{digit+}')
  2083. .replace(/([0-9]{1})/g, '{digit$1}')
  2084. .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
  2085. .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
  2086. return (new RegExp(reg)).test(value);
  2087. },
  2088. getCaretPos = function (input) {
  2089. try {
  2090. if (options.ownerDocument.selection && options.ownerDocument.selection.createRange) {
  2091. var range = options.ownerDocument.selection.createRange();
  2092. return range.getBookmark().charCodeAt(2) - 2;
  2093. }
  2094. if (input.setSelectionRange) {
  2095. return input.selectionStart;
  2096. }
  2097. } catch (e) {
  2098. return 0;
  2099. }
  2100. },
  2101. setCaretPos = function (node, pos) {
  2102. node = (typeof node === "string" || node instanceof String) ? options.ownerDocument.getElementById(node) : node;
  2103. if (!node) {
  2104. return false;
  2105. }
  2106. if (node.createTextRange) {
  2107. var textRange = node.createTextRange();
  2108. textRange.collapse(true);
  2109. textRange.moveEnd('character', pos);
  2110. textRange.moveStart('character', pos);
  2111. textRange.select();
  2112. return true;
  2113. }
  2114. if (node.setSelectionRange) {
  2115. node.setSelectionRange(pos, pos);
  2116. return true;
  2117. }
  2118. return false;
  2119. };
  2120. if(options.mask) {
  2121. input.off('keydown.xdsoft');
  2122. }
  2123. if (options.mask === true) {
  2124. if (dateHelper.formatMask) {
  2125. options.mask = dateHelper.formatMask(options.format)
  2126. } else {
  2127. options.mask = options.format
  2128. .replace(/Y/g, '9999')
  2129. .replace(/F/g, '9999')
  2130. .replace(/m/g, '19')
  2131. .replace(/d/g, '39')
  2132. .replace(/H/g, '29')
  2133. .replace(/i/g, '59')
  2134. .replace(/s/g, '59');
  2135. }
  2136. }
  2137. if ($.type(options.mask) === 'string') {
  2138. if (!isValidValue(options.mask, input.val())) {
  2139. input.val(options.mask.replace(/[0-9]/g, '_'));
  2140. setCaretPos(input[0], 0);
  2141. }
  2142. input.on('paste.xdsoft', function (event) {
  2143. // couple options here
  2144. // 1. return false - tell them they can't paste
  2145. // 2. insert over current characters - minimal validation
  2146. // 3. full fledged parsing and validation
  2147. // let's go option 2 for now
  2148. // fires multiple times for some reason
  2149. // https://stackoverflow.com/a/30496488/1366033
  2150. var clipboardData = event.clipboardData || event.originalEvent.clipboardData || window.clipboardData,
  2151. pastedData = clipboardData.getData('text'),
  2152. val = this.value,
  2153. pos = this.selectionStart
  2154. var valueBeforeCursor = val.substr(0, pos);
  2155. var valueAfterPaste = val.substr(pos + pastedData.length);
  2156. val = valueBeforeCursor + pastedData + valueAfterPaste;
  2157. pos += pastedData.length;
  2158. if (isValidValue(options.mask, val)) {
  2159. this.value = val;
  2160. setCaretPos(this, pos);
  2161. } else if ($.trim(val) === '') {
  2162. this.value = options.mask.replace(/[0-9]/g, '_');
  2163. } else {
  2164. input.trigger('error_input.xdsoft');
  2165. }
  2166. event.preventDefault();
  2167. return false;
  2168. });
  2169. input.on('keydown.xdsoft', function (event) {
  2170. var val = this.value,
  2171. key = event.which,
  2172. pos = this.selectionStart,
  2173. selEnd = this.selectionEnd,
  2174. hasSel = pos !== selEnd,
  2175. digit;
  2176. // only alow these characters
  2177. if (((key >= KEY0 && key <= KEY9) ||
  2178. (key >= _KEY0 && key <= _KEY9)) ||
  2179. (key === BACKSPACE || key === DEL)) {
  2180. // get char to insert which is new character or placeholder ('_')
  2181. digit = (key === BACKSPACE || key === DEL) ? '_' :
  2182. String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key);
  2183. // we're deleting something, we're not at the start, and have normal cursor, move back one
  2184. // if we have a selection length, cursor actually sits behind deletable char, not in front
  2185. if (key === BACKSPACE && pos && !hasSel) {
  2186. pos -= 1;
  2187. }
  2188. // don't stop on a separator, continue whatever direction you were going
  2189. // value char - keep incrementing position while on separator char and we still have room
  2190. // del char - keep decrementing position while on separator char and we still have room
  2191. while (true) {
  2192. var maskValueAtCurPos = options.mask.substr(pos, 1);
  2193. var posShorterThanMaskLength = pos < options.mask.length;
  2194. var posGreaterThanZero = pos > 0;
  2195. var notNumberOrPlaceholder = /[^0-9_]/;
  2196. var curPosOnSep = notNumberOrPlaceholder.test(maskValueAtCurPos);
  2197. var continueMovingPosition = curPosOnSep && posShorterThanMaskLength && posGreaterThanZero
  2198. // if we hit a real char, stay where we are
  2199. if (!continueMovingPosition) break;
  2200. // hitting backspace in a selection, you can possibly go back any further - go forward
  2201. pos += (key === BACKSPACE && !hasSel) ? -1 : 1;
  2202. }
  2203. if (event.metaKey) { // cmd has been pressed
  2204. pos = 0;
  2205. hasSel = true;
  2206. }
  2207. if (hasSel) {
  2208. // pos might have moved so re-calc length
  2209. var selLength = selEnd - pos
  2210. // if we have a selection length we will wipe out entire selection and replace with default template for that range
  2211. var defaultBlank = options.mask.replace(/[0-9]/g, '_');
  2212. var defaultBlankSelectionReplacement = defaultBlank.substr(pos, selLength);
  2213. var selReplacementRemainder = defaultBlankSelectionReplacement.substr(1) // might be empty
  2214. var valueBeforeSel = val.substr(0, pos);
  2215. var insertChars = digit + selReplacementRemainder;
  2216. var charsAfterSelection = val.substr(pos + selLength);
  2217. val = valueBeforeSel + insertChars + charsAfterSelection
  2218. } else {
  2219. var valueBeforeCursor = val.substr(0, pos);
  2220. var insertChar = digit;
  2221. var valueAfterNextChar = val.substr(pos + 1);
  2222. val = valueBeforeCursor + insertChar + valueAfterNextChar
  2223. }
  2224. if ($.trim(val) === '') {
  2225. // if empty, set to default
  2226. val = defaultBlank
  2227. } else {
  2228. // if at the last character don't need to do anything
  2229. if (pos === options.mask.length) {
  2230. event.preventDefault();
  2231. return false;
  2232. }
  2233. }
  2234. // resume cursor location
  2235. pos += (key === BACKSPACE) ? 0 : 1;
  2236. // don't stop on a separator, continue whatever direction you were going
  2237. while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  2238. pos += (key === BACKSPACE) ? 0 : 1;
  2239. }
  2240. if (isValidValue(options.mask, val)) {
  2241. this.value = val;
  2242. setCaretPos(this, pos);
  2243. } else if ($.trim(val) === '') {
  2244. this.value = options.mask.replace(/[0-9]/g, '_');
  2245. } else {
  2246. input.trigger('error_input.xdsoft');
  2247. }
  2248. } else {
  2249. if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
  2250. return true;
  2251. }
  2252. }
  2253. event.preventDefault();
  2254. return false;
  2255. });
  2256. }
  2257. }
  2258. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  2259. input
  2260. .data('xdsoft_datetimepicker', datetimepicker)
  2261. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart', function () {
  2262. if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
  2263. return;
  2264. }
  2265. if (!options.openOnFocus) {
  2266. return;
  2267. }
  2268. clearTimeout(timer);
  2269. timer = setTimeout(function () {
  2270. if (input.is(':disabled')) {
  2271. return;
  2272. }
  2273. triggerAfterOpen = true;
  2274. _xdsoft_datetime.setCurrentTime(getCurrentValue(), true);
  2275. if(options.mask) {
  2276. setMask(options);
  2277. }
  2278. datetimepicker.trigger('open.xdsoft');
  2279. }, 100);
  2280. })
  2281. .on('keydown.xdsoft', function (event) {
  2282. var elementSelector,
  2283. key = event.which;
  2284. if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
  2285. elementSelector = $("input:visible,textarea:visible,button:visible,a:visible");
  2286. datetimepicker.trigger('close.xdsoft');
  2287. elementSelector.eq(elementSelector.index(this) + 1).focus();
  2288. return false;
  2289. }
  2290. if ([TAB].indexOf(key) !== -1) {
  2291. datetimepicker.trigger('close.xdsoft');
  2292. return true;
  2293. }
  2294. })
  2295. .on('blur.xdsoft', function () {
  2296. datetimepicker.trigger('close.xdsoft');
  2297. });
  2298. };
  2299. destroyDateTimePicker = function (input) {
  2300. var datetimepicker = input.data('xdsoft_datetimepicker');
  2301. if (datetimepicker) {
  2302. datetimepicker.data('xdsoft_datetime', null);
  2303. datetimepicker.remove();
  2304. input
  2305. .data('xdsoft_datetimepicker', null)
  2306. .off('.xdsoft');
  2307. $(options.contentWindow).off('resize.xdsoft');
  2308. $([options.contentWindow, options.ownerDocument.body]).off('mousedown.xdsoft touchstart');
  2309. if (input.unmousewheel) {
  2310. input.unmousewheel();
  2311. }
  2312. }
  2313. };
  2314. $(options.ownerDocument)
  2315. .off('keydown.xdsoftctrl keyup.xdsoftctrl')
  2316. .off('keydown.xdsoftcmd keyup.xdsoftcmd')
  2317. .on('keydown.xdsoftctrl', function (e) {
  2318. if (e.keyCode === CTRLKEY) {
  2319. ctrlDown = true;
  2320. }
  2321. })
  2322. .on('keyup.xdsoftctrl', function (e) {
  2323. if (e.keyCode === CTRLKEY) {
  2324. ctrlDown = false;
  2325. }
  2326. })
  2327. .on('keydown.xdsoftcmd', function (e) {
  2328. if (e.keyCode === CMDKEY) {
  2329. cmdDown = true;
  2330. }
  2331. })
  2332. .on('keyup.xdsoftcmd', function (e) {
  2333. if (e.keyCode === CMDKEY) {
  2334. cmdDown = false;
  2335. }
  2336. });
  2337. this.each(function () {
  2338. var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
  2339. if (datetimepicker) {
  2340. if ($.type(opt) === 'string') {
  2341. switch (opt) {
  2342. case 'show':
  2343. $(this).select().focus();
  2344. datetimepicker.trigger('open.xdsoft');
  2345. break;
  2346. case 'hide':
  2347. datetimepicker.trigger('close.xdsoft');
  2348. break;
  2349. case 'toggle':
  2350. datetimepicker.trigger('toggle.xdsoft');
  2351. break;
  2352. case 'destroy':
  2353. destroyDateTimePicker($(this));
  2354. break;
  2355. case 'reset':
  2356. this.value = this.defaultValue;
  2357. if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(dateHelper.parseDate(this.value, options.format))) {
  2358. datetimepicker.data('changed', false);
  2359. }
  2360. datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
  2361. break;
  2362. case 'validate':
  2363. $input = datetimepicker.data('input');
  2364. $input.trigger('blur.xdsoft');
  2365. break;
  2366. default:
  2367. if (datetimepicker[opt] && $.isFunction(datetimepicker[opt])) {
  2368. result = datetimepicker[opt](opt2);
  2369. }
  2370. }
  2371. } else {
  2372. datetimepicker
  2373. .setOptions(opt);
  2374. }
  2375. return 0;
  2376. }
  2377. if ($.type(opt) !== 'string') {
  2378. if (!options.lazyInit || options.open || options.inline) {
  2379. createDateTimePicker($(this));
  2380. } else {
  2381. lazyInit($(this));
  2382. }
  2383. }
  2384. });
  2385. return result;
  2386. };
  2387. $.fn.datetimepicker.defaults = default_options;
  2388. function HighlightedDate(date, desc, style) {
  2389. "use strict";
  2390. this.date = date;
  2391. this.desc = desc;
  2392. this.style = style;
  2393. }
  2394. };
  2395. ;(function (factory) {
  2396. if ( typeof define === 'function' && define.amd ) {
  2397. // AMD. Register as an anonymous module.
  2398. define(['jquery', 'jquery-mousewheel'], factory);
  2399. } else if (typeof exports === 'object') {
  2400. // Node/CommonJS style for Browserify
  2401. module.exports = factory(require('jquery'));;
  2402. } else {
  2403. // Browser globals
  2404. factory(jQuery);
  2405. }
  2406. }(datetimepickerFactory));
  2407. /*!
  2408. * jQuery Mousewheel 3.1.13
  2409. *
  2410. * Copyright jQuery Foundation and other contributors
  2411. * Released under the MIT license
  2412. * http://jquery.org/license
  2413. */
  2414. (function (factory) {
  2415. if ( typeof define === 'function' && define.amd ) {
  2416. // AMD. Register as an anonymous module.
  2417. define(['jquery'], factory);
  2418. } else if (typeof exports === 'object') {
  2419. // Node/CommonJS style for Browserify
  2420. module.exports = factory;
  2421. } else {
  2422. // Browser globals
  2423. factory(jQuery);
  2424. }
  2425. }(function ($) {
  2426. var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
  2427. toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
  2428. ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
  2429. slice = Array.prototype.slice,
  2430. nullLowestDeltaTimeout, lowestDelta;
  2431. if ( $.event.fixHooks ) {
  2432. for ( var i = toFix.length; i; ) {
  2433. $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
  2434. }
  2435. }
  2436. var special = $.event.special.mousewheel = {
  2437. version: '3.1.12',
  2438. setup: function() {
  2439. if ( this.addEventListener ) {
  2440. for ( var i = toBind.length; i; ) {
  2441. this.addEventListener( toBind[--i], handler, false );
  2442. }
  2443. } else {
  2444. this.onmousewheel = handler;
  2445. }
  2446. // Store the line height and page height for this particular element
  2447. $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
  2448. $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
  2449. },
  2450. teardown: function() {
  2451. if ( this.removeEventListener ) {
  2452. for ( var i = toBind.length; i; ) {
  2453. this.removeEventListener( toBind[--i], handler, false );
  2454. }
  2455. } else {
  2456. this.onmousewheel = null;
  2457. }
  2458. // Clean up the data we added to the element
  2459. $.removeData(this, 'mousewheel-line-height');
  2460. $.removeData(this, 'mousewheel-page-height');
  2461. },
  2462. getLineHeight: function(elem) {
  2463. var $elem = $(elem),
  2464. $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
  2465. if (!$parent.length) {
  2466. $parent = $('body');
  2467. }
  2468. return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
  2469. },
  2470. getPageHeight: function(elem) {
  2471. return $(elem).height();
  2472. },
  2473. settings: {
  2474. adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
  2475. normalizeOffset: true // calls getBoundingClientRect for each event
  2476. }
  2477. };
  2478. $.fn.extend({
  2479. mousewheel: function(fn) {
  2480. return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
  2481. },
  2482. unmousewheel: function(fn) {
  2483. return this.unbind('mousewheel', fn);
  2484. }
  2485. });
  2486. function handler(event) {
  2487. var orgEvent = event || window.event,
  2488. args = slice.call(arguments, 1),
  2489. delta = 0,
  2490. deltaX = 0,
  2491. deltaY = 0,
  2492. absDelta = 0,
  2493. offsetX = 0,
  2494. offsetY = 0;
  2495. event = $.event.fix(orgEvent);
  2496. event.type = 'mousewheel';
  2497. // Old school scrollwheel delta
  2498. if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
  2499. if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
  2500. if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
  2501. if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
  2502. // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
  2503. if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
  2504. deltaX = deltaY * -1;
  2505. deltaY = 0;
  2506. }
  2507. // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
  2508. delta = deltaY === 0 ? deltaX : deltaY;
  2509. // New school wheel delta (wheel event)
  2510. if ( 'deltaY' in orgEvent ) {
  2511. deltaY = orgEvent.deltaY * -1;
  2512. delta = deltaY;
  2513. }
  2514. if ( 'deltaX' in orgEvent ) {
  2515. deltaX = orgEvent.deltaX;
  2516. if ( deltaY === 0 ) { delta = deltaX * -1; }
  2517. }
  2518. // No change actually happened, no reason to go any further
  2519. if ( deltaY === 0 && deltaX === 0 ) { return; }
  2520. // Need to convert lines and pages to pixels if we aren't already in pixels
  2521. // There are three delta modes:
  2522. // * deltaMode 0 is by pixels, nothing to do
  2523. // * deltaMode 1 is by lines
  2524. // * deltaMode 2 is by pages
  2525. if ( orgEvent.deltaMode === 1 ) {
  2526. var lineHeight = $.data(this, 'mousewheel-line-height');
  2527. delta *= lineHeight;
  2528. deltaY *= lineHeight;
  2529. deltaX *= lineHeight;
  2530. } else if ( orgEvent.deltaMode === 2 ) {
  2531. var pageHeight = $.data(this, 'mousewheel-page-height');
  2532. delta *= pageHeight;
  2533. deltaY *= pageHeight;
  2534. deltaX *= pageHeight;
  2535. }
  2536. // Store lowest absolute delta to normalize the delta values
  2537. absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
  2538. if ( !lowestDelta || absDelta < lowestDelta ) {
  2539. lowestDelta = absDelta;
  2540. // Adjust older deltas if necessary
  2541. if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  2542. lowestDelta /= 40;
  2543. }
  2544. }
  2545. // Adjust older deltas if necessary
  2546. if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  2547. // Divide all the things by 40!
  2548. delta /= 40;
  2549. deltaX /= 40;
  2550. deltaY /= 40;
  2551. }
  2552. // Get a whole, normalized value for the deltas
  2553. delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
  2554. deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
  2555. deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
  2556. // Normalise offsetX and offsetY properties
  2557. if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
  2558. var boundingRect = this.getBoundingClientRect();
  2559. offsetX = event.clientX - boundingRect.left;
  2560. offsetY = event.clientY - boundingRect.top;
  2561. }
  2562. // Add information to the event object
  2563. event.deltaX = deltaX;
  2564. event.deltaY = deltaY;
  2565. event.deltaFactor = lowestDelta;
  2566. event.offsetX = offsetX;
  2567. event.offsetY = offsetY;
  2568. // Go ahead and set deltaMode to 0 since we converted to pixels
  2569. // Although this is a little odd since we overwrite the deltaX/Y
  2570. // properties with normalized deltas.
  2571. event.deltaMode = 0;
  2572. // Add event and delta to the front of the arguments
  2573. args.unshift(event, delta, deltaX, deltaY);
  2574. // Clearout lowestDelta after sometime to better
  2575. // handle multiple device types that give different
  2576. // a different lowestDelta
  2577. // Ex: trackpad = 3 and mouse wheel = 120
  2578. if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
  2579. nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
  2580. return ($.event.dispatch || $.event.handle).apply(this, args);
  2581. }
  2582. function nullLowestDelta() {
  2583. lowestDelta = null;
  2584. }
  2585. function shouldAdjustOldDeltas(orgEvent, absDelta) {
  2586. // If this is an older event and the delta is divisable by 120,
  2587. // then we are assuming that the browser is treating this as an
  2588. // older mouse wheel event and that we should divide the deltas
  2589. // by 40 to try and get a more usable deltaFactor.
  2590. // Side note, this actually impacts the reported scroll distance
  2591. // in older browsers and can cause scrolling to be slower than native.
  2592. // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
  2593. return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
  2594. }
  2595. }));