jquery.datetimepicker.full.js 112 KB

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