jquery.datetimepicker.full.js 113 KB

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