bootstrap-datetimepicker.min.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521
  1. (function (a) {
  2. if (typeof define === "function" && define.amd) {
  3. define(["jquery"], a)
  4. } else {
  5. if (typeof exports === "object") {
  6. a(require("jquery"))
  7. } else {
  8. a(jQuery)
  9. }
  10. }
  11. }(function (f, c) {
  12. if (!("indexOf" in Array.prototype)) {
  13. Array.prototype.indexOf = function (k, j) {
  14. if (j === c) {
  15. j = 0
  16. }
  17. if (j < 0) {
  18. j += this.length
  19. }
  20. if (j < 0) {
  21. j = 0
  22. }
  23. for (var l = this.length; j < l; j++) {
  24. if (j in this && this[j] === k) {
  25. return j
  26. }
  27. }
  28. return -1
  29. }
  30. }
  31. function e(l) {
  32. var k = f(l);
  33. var j = k.add(k.parents());
  34. var m = false;
  35. j.each(function () {
  36. if (f(this).css("position") === "fixed") {
  37. m = true;
  38. return false
  39. }
  40. });
  41. return m
  42. }
  43. function h() {
  44. return new Date(Date.UTC.apply(Date, arguments))
  45. }
  46. function d() {
  47. var j = new Date();
  48. return h(j.getUTCFullYear(), j.getUTCMonth(), j.getUTCDate(), j.getUTCHours(), j.getUTCMinutes(), j.getUTCSeconds(), 0)
  49. }
  50. var i = function (l, k) {
  51. var n = this;
  52. this.element = f(l);
  53. this.container = k.container || "body";
  54. this.language = k.language || this.element.data("date-language") || "en";
  55. this.language = this.language in a ? this.language : this.language.split("-")[0];
  56. this.language = this.language in a ? this.language : "en";
  57. this.isRTL = a[this.language].rtl || false;
  58. this.formatType = k.formatType || this.element.data("format-type") || "standard";
  59. this.format = g.parseFormat(k.format || this.element.data("date-format") || a[this.language].format || g.getDefaultFormat(this.formatType, "input"), this.formatType);
  60. this.isInline = false;
  61. this.isVisible = false;
  62. this.isInput = this.element.is("input");
  63. this.fontAwesome = k.fontAwesome || this.element.data("font-awesome") || false;
  64. this.bootcssVer = k.bootcssVer || (this.isInput ? (this.element.is(".form-control") ? 3 : 2) : (this.bootcssVer = this.element.is(".input-group") ? 3 : 2));
  65. this.component = this.element.is(".date") ? (this.bootcssVer == 3 ? this.element.find(".input-group-addon .glyphicon-th, .input-group-addon .glyphicon-time, .input-group-addon .glyphicon-remove, .input-group-addon .glyphicon-calendar, .input-group-addon .fa-calendar, .input-group-addon .fa-clock-o").parent() : this.element.find(".add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar, .add-on .fa-calendar, .add-on .fa-clock-o").parent()) : false;
  66. this.componentReset = this.element.is(".date") ? (this.bootcssVer == 3 ? this.element.find(".input-group-addon .glyphicon-remove, .input-group-addon .fa-times").parent() : this.element.find(".add-on .icon-remove, .add-on .fa-times").parent()) : false;
  67. this.hasInput = this.component && this.element.find("input").length;
  68. if (this.component && this.component.length === 0) {
  69. this.component = false
  70. }
  71. this.linkField = k.linkField || this.element.data("link-field") || false;
  72. this.linkFormat = g.parseFormat(k.linkFormat || this.element.data("link-format") || g.getDefaultFormat(this.formatType, "link"), this.formatType);
  73. this.minuteStep = k.minuteStep || this.element.data("minute-step") || 5;
  74. this.pickerPosition = k.pickerPosition || this.element.data("picker-position") || "bottom-right";
  75. this.showMeridian = k.showMeridian || this.element.data("show-meridian") || false;
  76. this.initialDate = k.initialDate || new Date();
  77. this.zIndex = k.zIndex || this.element.data("z-index") || c;
  78. this.title = typeof k.title === "undefined" ? false : k.title;
  79. this.defaultTimeZone = (new Date).toString().split("(")[1].slice(0, -1);
  80. this.timezone = k.timezone || this.defaultTimeZone;
  81. this.icons = {
  82. leftArrow: this.fontAwesome ? "fa-arrow-left" : (this.bootcssVer === 3 ? "glyphicon-arrow-left" : "icon-arrow-left"),
  83. rightArrow: this.fontAwesome ? "fa-arrow-right" : (this.bootcssVer === 3 ? "glyphicon-arrow-right" : "icon-arrow-right")
  84. };
  85. this.icontype = this.fontAwesome ? "fa" : "glyphicon";
  86. this._attachEvents();
  87. this.clickedOutside = function (o) {
  88. if (f(o.target).closest(".datetimepicker").length === 0) {
  89. n.hide()
  90. }
  91. };
  92. this.formatViewType = "datetime";
  93. if ("formatViewType" in k) {
  94. this.formatViewType = k.formatViewType
  95. } else {
  96. if ("formatViewType" in this.element.data()) {
  97. this.formatViewType = this.element.data("formatViewType")
  98. }
  99. }
  100. this.minView = 0;
  101. if ("minView" in k) {
  102. this.minView = k.minView
  103. } else {
  104. if ("minView" in this.element.data()) {
  105. this.minView = this.element.data("min-view")
  106. }
  107. }
  108. this.minView = g.convertViewMode(this.minView);
  109. this.maxView = g.modes.length - 1;
  110. if ("maxView" in k) {
  111. this.maxView = k.maxView
  112. } else {
  113. if ("maxView" in this.element.data()) {
  114. this.maxView = this.element.data("max-view")
  115. }
  116. }
  117. this.maxView = g.convertViewMode(this.maxView);
  118. this.wheelViewModeNavigation = false;
  119. if ("wheelViewModeNavigation" in k) {
  120. this.wheelViewModeNavigation = k.wheelViewModeNavigation
  121. } else {
  122. if ("wheelViewModeNavigation" in this.element.data()) {
  123. this.wheelViewModeNavigation = this.element.data("view-mode-wheel-navigation")
  124. }
  125. }
  126. this.wheelViewModeNavigationInverseDirection = false;
  127. if ("wheelViewModeNavigationInverseDirection" in k) {
  128. this.wheelViewModeNavigationInverseDirection = k.wheelViewModeNavigationInverseDirection
  129. } else {
  130. if ("wheelViewModeNavigationInverseDirection" in this.element.data()) {
  131. this.wheelViewModeNavigationInverseDirection = this.element.data("view-mode-wheel-navigation-inverse-dir")
  132. }
  133. }
  134. this.wheelViewModeNavigationDelay = 100;
  135. if ("wheelViewModeNavigationDelay" in k) {
  136. this.wheelViewModeNavigationDelay = k.wheelViewModeNavigationDelay
  137. } else {
  138. if ("wheelViewModeNavigationDelay" in this.element.data()) {
  139. this.wheelViewModeNavigationDelay = this.element.data("view-mode-wheel-navigation-delay")
  140. }
  141. }
  142. this.startViewMode = 2;
  143. if ("startView" in k) {
  144. this.startViewMode = k.startView
  145. } else {
  146. if ("startView" in this.element.data()) {
  147. this.startViewMode = this.element.data("start-view")
  148. }
  149. }
  150. this.startViewMode = g.convertViewMode(this.startViewMode);
  151. this.viewMode = this.startViewMode;
  152. this.viewSelect = this.minView;
  153. if ("viewSelect" in k) {
  154. this.viewSelect = k.viewSelect
  155. } else {
  156. if ("viewSelect" in this.element.data()) {
  157. this.viewSelect = this.element.data("view-select")
  158. }
  159. }
  160. this.viewSelect = g.convertViewMode(this.viewSelect);
  161. this.forceParse = true;
  162. if ("forceParse" in k) {
  163. this.forceParse = k.forceParse
  164. } else {
  165. if ("dateForceParse" in this.element.data()) {
  166. this.forceParse = this.element.data("date-force-parse")
  167. }
  168. }
  169. var m = this.bootcssVer === 3 ? g.templateV3 : g.template;
  170. while (m.indexOf("{iconType}") !== -1) {
  171. m = m.replace("{iconType}", this.icontype)
  172. }
  173. while (m.indexOf("{leftArrow}") !== -1) {
  174. m = m.replace("{leftArrow}", this.icons.leftArrow)
  175. }
  176. while (m.indexOf("{rightArrow}") !== -1) {
  177. m = m.replace("{rightArrow}", this.icons.rightArrow)
  178. }
  179. this.picker = f(m).appendTo(this.isInline ? this.element : this.container).on({
  180. click: f.proxy(this.click, this),
  181. mousedown: f.proxy(this.mousedown, this)
  182. });
  183. if (this.wheelViewModeNavigation) {
  184. if (f.fn.mousewheel) {
  185. this.picker.on({mousewheel: f.proxy(this.mousewheel, this)})
  186. } else {
  187. console.log("Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option")
  188. }
  189. }
  190. if (this.isInline) {
  191. this.picker.addClass("datetimepicker-inline")
  192. } else {
  193. this.picker.addClass("datetimepicker-dropdown-" + this.pickerPosition + " dropdown-menu")
  194. }
  195. if (this.isRTL) {
  196. this.picker.addClass("datetimepicker-rtl");
  197. var j = this.bootcssVer === 3 ? ".prev span, .next span" : ".prev i, .next i";
  198. this.picker.find(j).toggleClass(this.icons.leftArrow + " " + this.icons.rightArrow)
  199. }
  200. f(document).on("mousedown", this.clickedOutside);
  201. this.autoclose = false;
  202. if ("autoclose" in k) {
  203. this.autoclose = k.autoclose
  204. } else {
  205. if ("dateAutoclose" in this.element.data()) {
  206. this.autoclose = this.element.data("date-autoclose")
  207. }
  208. }
  209. this.keyboardNavigation = true;
  210. if ("keyboardNavigation" in k) {
  211. this.keyboardNavigation = k.keyboardNavigation
  212. } else {
  213. if ("dateKeyboardNavigation" in this.element.data()) {
  214. this.keyboardNavigation = this.element.data("date-keyboard-navigation")
  215. }
  216. }
  217. this.todayBtn = (k.todayBtn || this.element.data("date-today-btn") || false);
  218. this.clearBtn = (k.clearBtn || this.element.data("date-clear-btn") || false);
  219. this.todayHighlight = (k.todayHighlight || this.element.data("date-today-highlight") || false);
  220. this.weekStart = ((k.weekStart || this.element.data("date-weekstart") || a[this.language].weekStart || 0) % 7);
  221. this.weekEnd = ((this.weekStart + 6) % 7);
  222. this.startDate = -Infinity;
  223. this.endDate = Infinity;
  224. this.datesDisabled = [];
  225. this.daysOfWeekDisabled = [];
  226. this.setStartDate(k.startDate || this.element.data("date-startdate"));
  227. this.setEndDate(k.endDate || this.element.data("date-enddate"));
  228. this.setDatesDisabled(k.datesDisabled || this.element.data("date-dates-disabled"));
  229. this.setDaysOfWeekDisabled(k.daysOfWeekDisabled || this.element.data("date-days-of-week-disabled"));
  230. this.setMinutesDisabled(k.minutesDisabled || this.element.data("date-minute-disabled"));
  231. this.setHoursDisabled(k.hoursDisabled || this.element.data("date-hour-disabled"));
  232. this.fillDow();
  233. this.fillMonths();
  234. this.update();
  235. this.showMode();
  236. if (this.isInline) {
  237. this.show()
  238. }
  239. };
  240. i.prototype = {
  241. constructor: i, _events: [], _attachEvents: function () {
  242. this._detachEvents();
  243. if (this.isInput) {
  244. this._events = [[this.element, {
  245. focus: f.proxy(this.show, this),
  246. keyup: f.proxy(this.update, this),
  247. keydown: f.proxy(this.keydown, this)
  248. }]]
  249. } else {
  250. if (this.component && this.hasInput) {
  251. this._events = [[this.element.find("input"), {
  252. focus: f.proxy(this.show, this),
  253. keyup: f.proxy(this.update, this),
  254. keydown: f.proxy(this.keydown, this)
  255. }], [this.component, {click: f.proxy(this.show, this)}]];
  256. if (this.componentReset) {
  257. this._events.push([this.componentReset, {click: f.proxy(this.reset, this)}])
  258. }
  259. } else {
  260. if (this.element.is("div")) {
  261. this.isInline = true
  262. } else {
  263. this._events = [[this.element, {click: f.proxy(this.show, this)}]]
  264. }
  265. }
  266. }
  267. for (var j = 0, k, l; j < this._events.length; j++) {
  268. k = this._events[j][0];
  269. l = this._events[j][1];
  270. k.on(l)
  271. }
  272. }, _detachEvents: function () {
  273. for (var j = 0, k, l; j < this._events.length; j++) {
  274. k = this._events[j][0];
  275. l = this._events[j][1];
  276. k.off(l)
  277. }
  278. this._events = []
  279. }, show: function (j) {
  280. this.picker.show();
  281. this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
  282. if (this.forceParse) {
  283. this.update()
  284. }
  285. this.place();
  286. f(window).on("resize", f.proxy(this.place, this));
  287. if (j) {
  288. j.stopPropagation();
  289. j.preventDefault()
  290. }
  291. this.isVisible = true;
  292. this.element.trigger({type: "show", date: this.date})
  293. }, hide: function (j) {
  294. if (!this.isVisible) {
  295. return
  296. }
  297. if (this.isInline) {
  298. return
  299. }
  300. this.picker.hide();
  301. f(window).off("resize", this.place);
  302. this.viewMode = this.startViewMode;
  303. this.showMode();
  304. if (!this.isInput) {
  305. f(document).off("mousedown", this.hide)
  306. }
  307. if (this.forceParse && (this.isInput && this.element.val() || this.hasInput && this.element.find("input").val())) {
  308. this.setValue()
  309. }
  310. this.isVisible = false;
  311. this.element.trigger({type: "hide", date: this.date})
  312. }, remove: function () {
  313. this._detachEvents();
  314. f(document).off("mousedown", this.clickedOutside);
  315. this.picker.remove();
  316. delete this.picker;
  317. delete this.element.data().datetimepicker
  318. }, getDate: function () {
  319. var j = this.getUTCDate();
  320. return new Date(j.getTime() + (j.getTimezoneOffset() * 60000))
  321. }, getUTCDate: function () {
  322. return this.date
  323. }, getInitialDate: function () {
  324. return this.initialDate
  325. }, setInitialDate: function (j) {
  326. this.initialDate = j
  327. }, setDate: function (j) {
  328. this.setUTCDate(new Date(j.getTime() - (j.getTimezoneOffset() * 60000)))
  329. }, setUTCDate: function (j) {
  330. if (j >= this.startDate && j <= this.endDate) {
  331. this.date = j;
  332. this.setValue();
  333. this.viewDate = this.date;
  334. this.fill()
  335. } else {
  336. this.element.trigger({type: "outOfRange", date: j, startDate: this.startDate, endDate: this.endDate})
  337. }
  338. }, setFormat: function (k) {
  339. this.format = g.parseFormat(k, this.formatType);
  340. var j;
  341. if (this.isInput) {
  342. j = this.element
  343. } else {
  344. if (this.component) {
  345. j = this.element.find("input")
  346. }
  347. }
  348. if (j && j.val()) {
  349. this.setValue()
  350. }
  351. }, setValue: function () {
  352. var j = this.getFormattedDate();
  353. if (!this.isInput) {
  354. if (this.component) {
  355. this.element.find("input").val(j)
  356. }
  357. this.element.data("date", j)
  358. } else {
  359. this.element.val(j)
  360. }
  361. if (this.linkField) {
  362. f("#" + this.linkField).val(this.getFormattedDate(this.linkFormat))
  363. }
  364. }, getFormattedDate: function (j) {
  365. if (j == c) {
  366. j = this.format
  367. }
  368. return g.formatDate(this.date, j, this.language, this.formatType, this.timezone)
  369. }, setStartDate: function (j) {
  370. this.startDate = j || -Infinity;
  371. if (this.startDate !== -Infinity) {
  372. this.startDate = g.parseDate(this.startDate, this.format, this.language, this.formatType, this.timezone)
  373. }
  374. this.update();
  375. this.updateNavArrows()
  376. }, setEndDate: function (j) {
  377. this.endDate = j || Infinity;
  378. if (this.endDate !== Infinity) {
  379. this.endDate = g.parseDate(this.endDate, this.format, this.language, this.formatType, this.timezone)
  380. }
  381. this.update();
  382. this.updateNavArrows()
  383. }, setDatesDisabled: function (j) {
  384. this.datesDisabled = j || [];
  385. if (!f.isArray(this.datesDisabled)) {
  386. this.datesDisabled = this.datesDisabled.split(/,\s*/)
  387. }
  388. this.datesDisabled = f.map(this.datesDisabled, function (k) {
  389. return g.parseDate(k, this.format, this.language, this.formatType, this.timezone).toDateString()
  390. });
  391. this.update();
  392. this.updateNavArrows()
  393. }, setTitle: function (j, k) {
  394. return this.picker.find(j).find("th:eq(1)").text(this.title === false ? k : this.title)
  395. }, setDaysOfWeekDisabled: function (j) {
  396. this.daysOfWeekDisabled = j || [];
  397. if (!f.isArray(this.daysOfWeekDisabled)) {
  398. this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/)
  399. }
  400. this.daysOfWeekDisabled = f.map(this.daysOfWeekDisabled, function (k) {
  401. return parseInt(k, 10)
  402. });
  403. this.update();
  404. this.updateNavArrows()
  405. }, setMinutesDisabled: function (j) {
  406. this.minutesDisabled = j || [];
  407. if (!f.isArray(this.minutesDisabled)) {
  408. this.minutesDisabled = this.minutesDisabled.split(/,\s*/)
  409. }
  410. this.minutesDisabled = f.map(this.minutesDisabled, function (k) {
  411. return parseInt(k, 10)
  412. });
  413. this.update();
  414. this.updateNavArrows()
  415. }, setHoursDisabled: function (j) {
  416. this.hoursDisabled = j || [];
  417. if (!f.isArray(this.hoursDisabled)) {
  418. this.hoursDisabled = this.hoursDisabled.split(/,\s*/)
  419. }
  420. this.hoursDisabled = f.map(this.hoursDisabled, function (k) {
  421. return parseInt(k, 10)
  422. });
  423. this.update();
  424. this.updateNavArrows()
  425. }, place: function () {
  426. if (this.isInline) {
  427. return
  428. }
  429. if (!this.zIndex) {
  430. var k = 0;
  431. f("div").each(function () {
  432. var p = parseInt(f(this).css("zIndex"), 10);
  433. if (p > k) {
  434. k = p
  435. }
  436. });
  437. this.zIndex = k + 10
  438. }
  439. var o, n, m, l;
  440. if (this.container instanceof f) {
  441. l = this.container.offset()
  442. } else {
  443. l = f(this.container).offset()
  444. }
  445. if (this.component) {
  446. o = this.component.offset();
  447. m = o.left;
  448. if (this.pickerPosition == "bottom-left" || this.pickerPosition == "top-left") {
  449. m += this.component.outerWidth() - this.picker.outerWidth()
  450. }
  451. } else {
  452. o = this.element.offset();
  453. m = o.left;
  454. if (this.pickerPosition == "bottom-left" || this.pickerPosition == "top-left") {
  455. m += this.element.outerWidth() - this.picker.outerWidth()
  456. }
  457. }
  458. var j = document.body.clientWidth || window.innerWidth;
  459. if (m + 220 > j) {
  460. m = j - 220
  461. }
  462. if (this.pickerPosition == "top-left" || this.pickerPosition == "top-right") {
  463. n = o.top - this.picker.outerHeight()
  464. } else {
  465. n = o.top + this.height
  466. }
  467. n = n - l.top;
  468. m = m - l.left;
  469. this.picker.css({top: n, left: m, zIndex: this.zIndex})
  470. }, update: function () {
  471. var j, k = false;
  472. if (arguments && arguments.length && (typeof arguments[0] === "string" || arguments[0] instanceof Date)) {
  473. j = arguments[0];
  474. k = true
  475. } else {
  476. j = (this.isInput ? this.element.val() : this.element.find("input").val()) || this.element.data("date") || this.initialDate;
  477. if (typeof j == "string" || j instanceof String) {
  478. j = j.replace(/^\s+|\s+$/g, "")
  479. }
  480. }
  481. if (!j) {
  482. j = new Date();
  483. k = false
  484. }
  485. this.date = g.parseDate(j, this.format, this.language, this.formatType, this.timezone);
  486. if (k) {
  487. this.setValue()
  488. }
  489. if (this.date < this.startDate) {
  490. this.viewDate = new Date(this.startDate)
  491. } else {
  492. if (this.date > this.endDate) {
  493. this.viewDate = new Date(this.endDate)
  494. } else {
  495. this.viewDate = new Date(this.date)
  496. }
  497. }
  498. this.fill()
  499. }, fillDow: function () {
  500. var j = this.weekStart, k = "<tr>";
  501. while (j < this.weekStart + 7) {
  502. k += '<th class="dow">' + a[this.language].daysMin[(j++) % 7] + "</th>"
  503. }
  504. k += "</tr>";
  505. this.picker.find(".datetimepicker-days thead").append(k)
  506. }, fillMonths: function () {
  507. var k = "", j = 0;
  508. while (j < 12) {
  509. k += '<span class="month">' + a[this.language].monthsShort[j++] + "</span>"
  510. }
  511. this.picker.find(".datetimepicker-months td").html(k)
  512. }, fill: function () {
  513. if (this.date == null || this.viewDate == null) {
  514. return
  515. }
  516. var H = new Date(this.viewDate), u = H.getUTCFullYear(), I = H.getUTCMonth(), n = H.getUTCDate(), D = H.getUTCHours(), y = H.getUTCMinutes(), z = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity, E = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity, q = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity, A = this.endDate !== Infinity ? this.endDate.getUTCMonth() + 1 : Infinity, r = (new h(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(), G = new Date();
  517. this.setTitle(".datetimepicker-days", a[this.language].months[I] + " " + u);
  518. if (this.formatViewType == "time") {
  519. var k = this.getFormattedDate();
  520. this.setTitle(".datetimepicker-hours", k);
  521. this.setTitle(".datetimepicker-minutes", k)
  522. } else {
  523. this.setTitle(".datetimepicker-hours", n + " " + a[this.language].months[I] + " " + u);
  524. this.setTitle(".datetimepicker-minutes", n + " " + a[this.language].months[I] + " " + u)
  525. }
  526. this.picker.find("tfoot th.today").text(a[this.language].today || a.en.today).toggle(this.todayBtn !== false);
  527. this.picker.find("tfoot th.clear").text(a[this.language].clear || a.en.clear).toggle(this.clearBtn !== false);
  528. this.updateNavArrows();
  529. this.fillMonths();
  530. var K = h(u, I - 1, 28, 0, 0, 0, 0), C = g.getDaysInMonth(K.getUTCFullYear(), K.getUTCMonth());
  531. K.setUTCDate(C);
  532. K.setUTCDate(C - (K.getUTCDay() - this.weekStart + 7) % 7);
  533. var j = new Date(K);
  534. j.setUTCDate(j.getUTCDate() + 42);
  535. j = j.valueOf();
  536. var s = [];
  537. var v;
  538. while (K.valueOf() < j) {
  539. if (K.getUTCDay() == this.weekStart) {
  540. s.push("<tr>")
  541. }
  542. v = "";
  543. if (K.getUTCFullYear() < u || (K.getUTCFullYear() == u && K.getUTCMonth() < I)) {
  544. v += " old"
  545. } else {
  546. if (K.getUTCFullYear() > u || (K.getUTCFullYear() == u && K.getUTCMonth() > I)) {
  547. v += " new"
  548. }
  549. }
  550. if (this.todayHighlight && K.getUTCFullYear() == G.getFullYear() && K.getUTCMonth() == G.getMonth() && K.getUTCDate() == G.getDate()) {
  551. v += " today"
  552. }
  553. if (K.valueOf() == r) {
  554. v += " active"
  555. }
  556. if ((K.valueOf() + 86400000) <= this.startDate || K.valueOf() > this.endDate || f.inArray(K.getUTCDay(), this.daysOfWeekDisabled) !== -1 || f.inArray(K.toDateString(), this.datesDisabled) !== -1) {
  557. v += " disabled"
  558. }
  559. s.push('<td class="day' + v + '">' + K.getUTCDate() + "</td>");
  560. if (K.getUTCDay() == this.weekEnd) {
  561. s.push("</tr>")
  562. }
  563. K.setUTCDate(K.getUTCDate() + 1)
  564. }
  565. this.picker.find(".datetimepicker-days tbody").empty().append(s.join(""));
  566. s = [];
  567. var w = "", F = "", t = "";
  568. var l = this.hoursDisabled || [];
  569. for (var B = 0; B < 24; B++) {
  570. if (l.indexOf(B) !== -1) {
  571. continue
  572. }
  573. var x = h(u, I, n, B);
  574. v = "";
  575. if ((x.valueOf() + 3600000) <= this.startDate || x.valueOf() > this.endDate) {
  576. v += " disabled"
  577. } else {
  578. if (D == B) {
  579. v += " active"
  580. }
  581. }
  582. if (this.showMeridian && a[this.language].meridiem.length == 2) {
  583. F = (B < 12 ? a[this.language].meridiem[0] : a[this.language].meridiem[1]);
  584. if (F != t) {
  585. if (t != "") {
  586. s.push("</fieldset>")
  587. }
  588. s.push('<fieldset class="hour"><legend>' + F.toUpperCase() + "</legend>")
  589. }
  590. t = F;
  591. w = (B % 12 ? B % 12 : 12);
  592. s.push('<span class="hour' + v + " hour_" + (B < 12 ? "am" : "pm") + '">' + w + "</span>");
  593. if (B == 23) {
  594. s.push("</fieldset>")
  595. }
  596. } else {
  597. w = B + ":00";
  598. s.push('<span class="hour' + v + '">' + w + "</span>")
  599. }
  600. }
  601. this.picker.find(".datetimepicker-hours td").html(s.join(""));
  602. s = [];
  603. w = "", F = "", t = "";
  604. var m = this.minutesDisabled || [];
  605. for (var B = 0; B < 60; B += this.minuteStep) {
  606. if (m.indexOf(B) !== -1) {
  607. continue
  608. }
  609. var x = h(u, I, n, D, B, 0);
  610. v = "";
  611. if (x.valueOf() < this.startDate || x.valueOf() > this.endDate) {
  612. v += " disabled"
  613. } else {
  614. if (Math.floor(y / this.minuteStep) == Math.floor(B / this.minuteStep)) {
  615. v += " active"
  616. }
  617. }
  618. if (this.showMeridian && a[this.language].meridiem.length == 2) {
  619. F = (D < 12 ? a[this.language].meridiem[0] : a[this.language].meridiem[1]);
  620. if (F != t) {
  621. if (t != "") {
  622. s.push("</fieldset>")
  623. }
  624. s.push('<fieldset class="minute"><legend>' + F.toUpperCase() + "</legend>")
  625. }
  626. t = F;
  627. w = (D % 12 ? D % 12 : 12);
  628. s.push('<span class="minute' + v + '">' + w + ":" + (B < 10 ? "0" + B : B) + "</span>");
  629. if (B == 59) {
  630. s.push("</fieldset>")
  631. }
  632. } else {
  633. w = B + ":00";
  634. s.push('<span class="minute' + v + '">' + D + ":" + (B < 10 ? "0" + B : B) + "</span>")
  635. }
  636. }
  637. this.picker.find(".datetimepicker-minutes td").html(s.join(""));
  638. var L = this.date.getUTCFullYear();
  639. var p = this.setTitle(".datetimepicker-months", u).end().find("span").removeClass("active");
  640. if (L == u) {
  641. var o = p.length - 12;
  642. p.eq(this.date.getUTCMonth() + o).addClass("active")
  643. }
  644. if (u < z || u > q) {
  645. p.addClass("disabled")
  646. }
  647. if (u == z) {
  648. p.slice(0, E).addClass("disabled")
  649. }
  650. if (u == q) {
  651. p.slice(A).addClass("disabled")
  652. }
  653. s = "";
  654. u = parseInt(u / 10, 10) * 10;
  655. var J = this.setTitle(".datetimepicker-years", u + "-" + (u + 9)).end().find("td");
  656. u -= 1;
  657. for (var B = -1; B < 11; B++) {
  658. s += '<span class="year' + (B == -1 || B == 10 ? " old" : "") + (L == u ? " active" : "") + (u < z || u > q ? " disabled" : "") + '">' + u + "</span>";
  659. u += 1
  660. }
  661. J.html(s);
  662. this.place()
  663. }, updateNavArrows: function () {
  664. var n = new Date(this.viewDate), l = n.getUTCFullYear(), m = n.getUTCMonth(), k = n.getUTCDate(), j = n.getUTCHours();
  665. switch (this.viewMode) {
  666. case 0:
  667. if (this.startDate !== -Infinity && l <= this.startDate.getUTCFullYear() && m <= this.startDate.getUTCMonth() && k <= this.startDate.getUTCDate() && j <= this.startDate.getUTCHours()) {
  668. this.picker.find(".prev").css({visibility: "hidden"})
  669. } else {
  670. this.picker.find(".prev").css({visibility: "visible"})
  671. }
  672. if (this.endDate !== Infinity && l >= this.endDate.getUTCFullYear() && m >= this.endDate.getUTCMonth() && k >= this.endDate.getUTCDate() && j >= this.endDate.getUTCHours()) {
  673. this.picker.find(".next").css({visibility: "hidden"})
  674. } else {
  675. this.picker.find(".next").css({visibility: "visible"})
  676. }
  677. break;
  678. case 1:
  679. if (this.startDate !== -Infinity && l <= this.startDate.getUTCFullYear() && m <= this.startDate.getUTCMonth() && k <= this.startDate.getUTCDate()) {
  680. this.picker.find(".prev").css({visibility: "hidden"})
  681. } else {
  682. this.picker.find(".prev").css({visibility: "visible"})
  683. }
  684. if (this.endDate !== Infinity && l >= this.endDate.getUTCFullYear() && m >= this.endDate.getUTCMonth() && k >= this.endDate.getUTCDate()) {
  685. this.picker.find(".next").css({visibility: "hidden"})
  686. } else {
  687. this.picker.find(".next").css({visibility: "visible"})
  688. }
  689. break;
  690. case 2:
  691. if (this.startDate !== -Infinity && l <= this.startDate.getUTCFullYear() && m <= this.startDate.getUTCMonth()) {
  692. this.picker.find(".prev").css({visibility: "hidden"})
  693. } else {
  694. this.picker.find(".prev").css({visibility: "visible"})
  695. }
  696. if (this.endDate !== Infinity && l >= this.endDate.getUTCFullYear() && m >= this.endDate.getUTCMonth()) {
  697. this.picker.find(".next").css({visibility: "hidden"})
  698. } else {
  699. this.picker.find(".next").css({visibility: "visible"})
  700. }
  701. break;
  702. case 3:
  703. case 4:
  704. if (this.startDate !== -Infinity && l <= this.startDate.getUTCFullYear()) {
  705. this.picker.find(".prev").css({visibility: "hidden"})
  706. } else {
  707. this.picker.find(".prev").css({visibility: "visible"})
  708. }
  709. if (this.endDate !== Infinity && l >= this.endDate.getUTCFullYear()) {
  710. this.picker.find(".next").css({visibility: "hidden"})
  711. } else {
  712. this.picker.find(".next").css({visibility: "visible"})
  713. }
  714. break
  715. }
  716. }, mousewheel: function (k) {
  717. k.preventDefault();
  718. k.stopPropagation();
  719. if (this.wheelPause) {
  720. return
  721. }
  722. this.wheelPause = true;
  723. var j = k.originalEvent;
  724. var m = j.wheelDelta;
  725. var l = m > 0 ? 1 : (m === 0) ? 0 : -1;
  726. if (this.wheelViewModeNavigationInverseDirection) {
  727. l = -l
  728. }
  729. this.showMode(l);
  730. setTimeout(f.proxy(function () {
  731. this.wheelPause = false
  732. }, this), this.wheelViewModeNavigationDelay)
  733. }, click: function (n) {
  734. n.stopPropagation();
  735. n.preventDefault();
  736. var o = f(n.target).closest("span, td, th, legend");
  737. if (o.is("." + this.icontype)) {
  738. o = f(o).parent().closest("span, td, th, legend")
  739. }
  740. if (o.length == 1) {
  741. if (o.is(".disabled")) {
  742. this.element.trigger({
  743. type: "outOfRange",
  744. date: this.viewDate,
  745. startDate: this.startDate,
  746. endDate: this.endDate
  747. });
  748. return
  749. }
  750. switch (o[0].nodeName.toLowerCase()) {
  751. case"th":
  752. switch (o[0].className) {
  753. case"switch":
  754. this.showMode(1);
  755. break;
  756. case"prev":
  757. case"next":
  758. var j = g.modes[this.viewMode].navStep * (o[0].className == "prev" ? -1 : 1);
  759. switch (this.viewMode) {
  760. case 0:
  761. this.viewDate = this.moveHour(this.viewDate, j);
  762. break;
  763. case 1:
  764. this.viewDate = this.moveDate(this.viewDate, j);
  765. break;
  766. case 2:
  767. this.viewDate = this.moveMonth(this.viewDate, j);
  768. break;
  769. case 3:
  770. case 4:
  771. this.viewDate = this.moveYear(this.viewDate, j);
  772. break
  773. }
  774. this.fill();
  775. this.element.trigger({
  776. type: o[0].className + ":" + this.convertViewModeText(this.viewMode),
  777. date: this.viewDate,
  778. startDate: this.startDate,
  779. endDate: this.endDate
  780. });
  781. break;
  782. case"clear":
  783. this.reset();
  784. if (this.autoclose) {
  785. this.hide()
  786. }
  787. break;
  788. case"today":
  789. var k = new Date();
  790. k = h(k.getFullYear(), k.getMonth(), k.getDate(), k.getHours(), k.getMinutes(), k.getSeconds(), 0);
  791. if (k < this.startDate) {
  792. k = this.startDate
  793. } else {
  794. if (k > this.endDate) {
  795. k = this.endDate
  796. }
  797. }
  798. this.viewMode = this.startViewMode;
  799. this.showMode(0);
  800. this._setDate(k);
  801. this.fill();
  802. if (this.autoclose) {
  803. this.hide()
  804. }
  805. break
  806. }
  807. break;
  808. case"span":
  809. if (!o.is(".disabled")) {
  810. var q = this.viewDate.getUTCFullYear(), p = this.viewDate.getUTCMonth(), r = this.viewDate.getUTCDate(), s = this.viewDate.getUTCHours(), l = this.viewDate.getUTCMinutes(), t = this.viewDate.getUTCSeconds();
  811. if (o.is(".month")) {
  812. this.viewDate.setUTCDate(1);
  813. p = o.parent().find("span").index(o);
  814. r = this.viewDate.getUTCDate();
  815. this.viewDate.setUTCMonth(p);
  816. this.element.trigger({type: "changeMonth", date: this.viewDate});
  817. if (this.viewSelect >= 3) {
  818. this._setDate(h(q, p, r, s, l, t, 0))
  819. }
  820. } else {
  821. if (o.is(".year")) {
  822. this.viewDate.setUTCDate(1);
  823. q = parseInt(o.text(), 10) || 0;
  824. this.viewDate.setUTCFullYear(q);
  825. this.element.trigger({type: "changeYear", date: this.viewDate});
  826. if (this.viewSelect >= 4) {
  827. this._setDate(h(q, p, r, s, l, t, 0))
  828. }
  829. } else {
  830. if (o.is(".hour")) {
  831. s = parseInt(o.text(), 10) || 0;
  832. if (o.hasClass("hour_am") || o.hasClass("hour_pm")) {
  833. if (s == 12 && o.hasClass("hour_am")) {
  834. s = 0
  835. } else {
  836. if (s != 12 && o.hasClass("hour_pm")) {
  837. s += 12
  838. }
  839. }
  840. }
  841. this.viewDate.setUTCHours(s);
  842. this.element.trigger({type: "changeHour", date: this.viewDate});
  843. if (this.viewSelect >= 1) {
  844. this._setDate(h(q, p, r, s, l, t, 0))
  845. }
  846. } else {
  847. if (o.is(".minute")) {
  848. l = parseInt(o.text().substr(o.text().indexOf(":") + 1), 10) || 0;
  849. this.viewDate.setUTCMinutes(l);
  850. this.element.trigger({type: "changeMinute", date: this.viewDate});
  851. if (this.viewSelect >= 0) {
  852. this._setDate(h(q, p, r, s, l, t, 0))
  853. }
  854. }
  855. }
  856. }
  857. }
  858. if (this.viewMode != 0) {
  859. var m = this.viewMode;
  860. this.showMode(-1);
  861. this.fill();
  862. if (m == this.viewMode && this.autoclose) {
  863. this.hide()
  864. }
  865. } else {
  866. this.fill();
  867. if (this.autoclose) {
  868. this.hide()
  869. }
  870. }
  871. }
  872. break;
  873. case"td":
  874. if (o.is(".day") && !o.is(".disabled")) {
  875. var r = parseInt(o.text(), 10) || 1;
  876. var q = this.viewDate.getUTCFullYear(), p = this.viewDate.getUTCMonth(), s = this.viewDate.getUTCHours(), l = this.viewDate.getUTCMinutes(), t = this.viewDate.getUTCSeconds();
  877. if (o.is(".old")) {
  878. if (p === 0) {
  879. p = 11;
  880. q -= 1
  881. } else {
  882. p -= 1
  883. }
  884. } else {
  885. if (o.is(".new")) {
  886. if (p == 11) {
  887. p = 0;
  888. q += 1
  889. } else {
  890. p += 1
  891. }
  892. }
  893. }
  894. this.viewDate.setUTCFullYear(q);
  895. this.viewDate.setUTCMonth(p, r);
  896. this.element.trigger({type: "changeDay", date: this.viewDate});
  897. if (this.viewSelect >= 2) {
  898. this._setDate(h(q, p, r, s, l, t, 0))
  899. }
  900. }
  901. var m = this.viewMode;
  902. this.showMode(-1);
  903. this.fill();
  904. if (m == this.viewMode && this.autoclose) {
  905. this.hide()
  906. }
  907. break
  908. }
  909. }
  910. }, _setDate: function (j, l) {
  911. if (!l || l == "date") {
  912. this.date = j
  913. }
  914. if (!l || l == "view") {
  915. this.viewDate = j
  916. }
  917. this.fill();
  918. this.setValue();
  919. var k;
  920. if (this.isInput) {
  921. k = this.element
  922. } else {
  923. if (this.component) {
  924. k = this.element.find("input")
  925. }
  926. }
  927. if (k) {
  928. k.change();
  929. if (this.autoclose && (!l || l == "date")) {
  930. }
  931. }
  932. this.element.trigger({type: "changeDate", date: this.getDate()});
  933. if (j == null) {
  934. this.date = this.viewDate
  935. }
  936. }, moveMinute: function (k, j) {
  937. if (!j) {
  938. return k
  939. }
  940. var l = new Date(k.valueOf());
  941. l.setUTCMinutes(l.getUTCMinutes() + (j * this.minuteStep));
  942. return l
  943. }, moveHour: function (k, j) {
  944. if (!j) {
  945. return k
  946. }
  947. var l = new Date(k.valueOf());
  948. l.setUTCHours(l.getUTCHours() + j);
  949. return l
  950. }, moveDate: function (k, j) {
  951. if (!j) {
  952. return k
  953. }
  954. var l = new Date(k.valueOf());
  955. l.setUTCDate(l.getUTCDate() + j);
  956. return l
  957. }, moveMonth: function (j, k) {
  958. if (!k) {
  959. return j
  960. }
  961. var n = new Date(j.valueOf()), r = n.getUTCDate(), o = n.getUTCMonth(), m = Math.abs(k), q, p;
  962. k = k > 0 ? 1 : -1;
  963. if (m == 1) {
  964. p = k == -1 ? function () {
  965. return n.getUTCMonth() == o
  966. } : function () {
  967. return n.getUTCMonth() != q
  968. };
  969. q = o + k;
  970. n.setUTCMonth(q);
  971. if (q < 0 || q > 11) {
  972. q = (q + 12) % 12
  973. }
  974. } else {
  975. for (var l = 0; l < m; l++) {
  976. n = this.moveMonth(n, k)
  977. }
  978. q = n.getUTCMonth();
  979. n.setUTCDate(r);
  980. p = function () {
  981. return q != n.getUTCMonth()
  982. }
  983. }
  984. while (p()) {
  985. n.setUTCDate(--r);
  986. n.setUTCMonth(q)
  987. }
  988. return n
  989. }, moveYear: function (k, j) {
  990. return this.moveMonth(k, j * 12)
  991. }, dateWithinRange: function (j) {
  992. return j >= this.startDate && j <= this.endDate
  993. }, keydown: function (n) {
  994. if (this.picker.is(":not(:visible)")) {
  995. if (n.keyCode == 27) {
  996. this.show()
  997. }
  998. return
  999. }
  1000. var p = false, k, q, o, r, j;
  1001. switch (n.keyCode) {
  1002. case 27:
  1003. this.hide();
  1004. n.preventDefault();
  1005. break;
  1006. case 37:
  1007. case 39:
  1008. if (!this.keyboardNavigation) {
  1009. break
  1010. }
  1011. k = n.keyCode == 37 ? -1 : 1;
  1012. viewMode = this.viewMode;
  1013. if (n.ctrlKey) {
  1014. viewMode += 2
  1015. } else {
  1016. if (n.shiftKey) {
  1017. viewMode += 1
  1018. }
  1019. }
  1020. if (viewMode == 4) {
  1021. r = this.moveYear(this.date, k);
  1022. j = this.moveYear(this.viewDate, k)
  1023. } else {
  1024. if (viewMode == 3) {
  1025. r = this.moveMonth(this.date, k);
  1026. j = this.moveMonth(this.viewDate, k)
  1027. } else {
  1028. if (viewMode == 2) {
  1029. r = this.moveDate(this.date, k);
  1030. j = this.moveDate(this.viewDate, k)
  1031. } else {
  1032. if (viewMode == 1) {
  1033. r = this.moveHour(this.date, k);
  1034. j = this.moveHour(this.viewDate, k)
  1035. } else {
  1036. if (viewMode == 0) {
  1037. r = this.moveMinute(this.date, k);
  1038. j = this.moveMinute(this.viewDate, k)
  1039. }
  1040. }
  1041. }
  1042. }
  1043. }
  1044. if (this.dateWithinRange(r)) {
  1045. this.date = r;
  1046. this.viewDate = j;
  1047. this.setValue();
  1048. this.update();
  1049. n.preventDefault();
  1050. p = true
  1051. }
  1052. break;
  1053. case 38:
  1054. case 40:
  1055. if (!this.keyboardNavigation) {
  1056. break
  1057. }
  1058. k = n.keyCode == 38 ? -1 : 1;
  1059. viewMode = this.viewMode;
  1060. if (n.ctrlKey) {
  1061. viewMode += 2
  1062. } else {
  1063. if (n.shiftKey) {
  1064. viewMode += 1
  1065. }
  1066. }
  1067. if (viewMode == 4) {
  1068. r = this.moveYear(this.date, k);
  1069. j = this.moveYear(this.viewDate, k)
  1070. } else {
  1071. if (viewMode == 3) {
  1072. r = this.moveMonth(this.date, k);
  1073. j = this.moveMonth(this.viewDate, k)
  1074. } else {
  1075. if (viewMode == 2) {
  1076. r = this.moveDate(this.date, k * 7);
  1077. j = this.moveDate(this.viewDate, k * 7)
  1078. } else {
  1079. if (viewMode == 1) {
  1080. if (this.showMeridian) {
  1081. r = this.moveHour(this.date, k * 6);
  1082. j = this.moveHour(this.viewDate, k * 6)
  1083. } else {
  1084. r = this.moveHour(this.date, k * 4);
  1085. j = this.moveHour(this.viewDate, k * 4)
  1086. }
  1087. } else {
  1088. if (viewMode == 0) {
  1089. r = this.moveMinute(this.date, k * 4);
  1090. j = this.moveMinute(this.viewDate, k * 4)
  1091. }
  1092. }
  1093. }
  1094. }
  1095. }
  1096. if (this.dateWithinRange(r)) {
  1097. this.date = r;
  1098. this.viewDate = j;
  1099. this.setValue();
  1100. this.update();
  1101. n.preventDefault();
  1102. p = true
  1103. }
  1104. break;
  1105. case 13:
  1106. if (this.viewMode != 0) {
  1107. var m = this.viewMode;
  1108. this.showMode(-1);
  1109. this.fill();
  1110. if (m == this.viewMode && this.autoclose) {
  1111. this.hide()
  1112. }
  1113. } else {
  1114. this.fill();
  1115. if (this.autoclose) {
  1116. this.hide()
  1117. }
  1118. }
  1119. n.preventDefault();
  1120. break;
  1121. case 9:
  1122. this.hide();
  1123. break
  1124. }
  1125. if (p) {
  1126. var l;
  1127. if (this.isInput) {
  1128. l = this.element
  1129. } else {
  1130. if (this.component) {
  1131. l = this.element.find("input")
  1132. }
  1133. }
  1134. if (l) {
  1135. l.change()
  1136. }
  1137. this.element.trigger({type: "changeDate", date: this.getDate()})
  1138. }
  1139. }, showMode: function (j) {
  1140. if (j) {
  1141. var k = Math.max(0, Math.min(g.modes.length - 1, this.viewMode + j));
  1142. if (k >= this.minView && k <= this.maxView) {
  1143. this.element.trigger({
  1144. type: "changeMode",
  1145. date: this.viewDate,
  1146. oldViewMode: this.viewMode,
  1147. newViewMode: k
  1148. });
  1149. this.viewMode = k
  1150. }
  1151. }
  1152. this.picker.find(">div").hide().filter(".datetimepicker-" + g.modes[this.viewMode].clsName).css("display", "block");
  1153. this.updateNavArrows()
  1154. }, reset: function (j) {
  1155. this._setDate(null, "date")
  1156. }, convertViewModeText: function (j) {
  1157. switch (j) {
  1158. case 4:
  1159. return "decade";
  1160. case 3:
  1161. return "year";
  1162. case 2:
  1163. return "month";
  1164. case 1:
  1165. return "day";
  1166. case 0:
  1167. return "hour"
  1168. }
  1169. }
  1170. };
  1171. var b = f.fn.datetimepicker;
  1172. f.fn.datetimepicker = function (l) {
  1173. var j = Array.apply(null, arguments);
  1174. j.shift();
  1175. var k;
  1176. this.each(function () {
  1177. var o = f(this), n = o.data("datetimepicker"), m = typeof l == "object" && l;
  1178. if (!n) {
  1179. o.data("datetimepicker", (n = new i(this, f.extend({}, f.fn.datetimepicker.defaults, m))))
  1180. }
  1181. if (typeof l == "string" && typeof n[l] == "function") {
  1182. k = n[l].apply(n, j);
  1183. if (k !== c) {
  1184. return false
  1185. }
  1186. }
  1187. });
  1188. if (k !== c) {
  1189. return k
  1190. } else {
  1191. return this
  1192. }
  1193. };
  1194. f.fn.datetimepicker.defaults = {};
  1195. f.fn.datetimepicker.Constructor = i;
  1196. var a = f.fn.datetimepicker.dates = {
  1197. en: {
  1198. days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
  1199. daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
  1200. daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
  1201. months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
  1202. monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
  1203. meridiem: ["am", "pm"],
  1204. suffix: ["st", "nd", "rd", "th"],
  1205. today: "Today",
  1206. clear: "Clear"
  1207. }
  1208. };
  1209. var g = {
  1210. modes: [{clsName: "minutes", navFnc: "Hours", navStep: 1}, {
  1211. clsName: "hours",
  1212. navFnc: "Date",
  1213. navStep: 1
  1214. }, {clsName: "days", navFnc: "Month", navStep: 1}, {
  1215. clsName: "months",
  1216. navFnc: "FullYear",
  1217. navStep: 1
  1218. }, {clsName: "years", navFnc: "FullYear", navStep: 10}],
  1219. isLeapYear: function (j) {
  1220. return (((j % 4 === 0) && (j % 100 !== 0)) || (j % 400 === 0))
  1221. },
  1222. getDaysInMonth: function (j, k) {
  1223. return [31, (g.isLeapYear(j) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][k]
  1224. },
  1225. getDefaultFormat: function (j, k) {
  1226. if (j == "standard") {
  1227. if (k == "input") {
  1228. return "yyyy-mm-dd hh:ii"
  1229. } else {
  1230. return "yyyy-mm-dd hh:ii:ss"
  1231. }
  1232. } else {
  1233. if (j == "php") {
  1234. if (k == "input") {
  1235. return "Y-m-d H:i"
  1236. } else {
  1237. return "Y-m-d H:i:s"
  1238. }
  1239. } else {
  1240. throw new Error("Invalid format type.")
  1241. }
  1242. }
  1243. },
  1244. validParts: function (j) {
  1245. if (j == "standard") {
  1246. return /t|hh?|HH?|p|P|z|Z|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g
  1247. } else {
  1248. if (j == "php") {
  1249. return /[dDjlNwzFmMnStyYaABgGhHis]/g
  1250. } else {
  1251. throw new Error("Invalid format type.")
  1252. }
  1253. }
  1254. },
  1255. nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
  1256. parseFormat: function (m, k) {
  1257. var j = m.replace(this.validParts(k), "\0").split("\0"), l = m.match(this.validParts(k));
  1258. if (!j || !j.length || !l || l.length == 0) {
  1259. throw new Error("Invalid date format.")
  1260. }
  1261. return {separators: j, parts: l}
  1262. },
  1263. parseDate: function (A, y, v, j, r) {
  1264. if (A instanceof Date) {
  1265. var u = new Date(A.valueOf() - A.getTimezoneOffset() * 60000);
  1266. u.setMilliseconds(0);
  1267. return u
  1268. }
  1269. if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(A)) {
  1270. y = this.parseFormat("yyyy-mm-dd", j)
  1271. }
  1272. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(A)) {
  1273. y = this.parseFormat("yyyy-mm-dd hh:ii", j)
  1274. }
  1275. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(A)) {
  1276. y = this.parseFormat("yyyy-mm-dd hh:ii:ss", j)
  1277. }
  1278. if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(A)) {
  1279. var l = /([-+]\d+)([dmwy])/, q = A.match(/([-+]\d+)([dmwy])/g), t, p;
  1280. A = new Date();
  1281. for (var x = 0; x < q.length; x++) {
  1282. t = l.exec(q[x]);
  1283. p = parseInt(t[1]);
  1284. switch (t[2]) {
  1285. case"d":
  1286. A.setUTCDate(A.getUTCDate() + p);
  1287. break;
  1288. case"m":
  1289. A = i.prototype.moveMonth.call(i.prototype, A, p);
  1290. break;
  1291. case"w":
  1292. A.setUTCDate(A.getUTCDate() + p * 7);
  1293. break;
  1294. case"y":
  1295. A = i.prototype.moveYear.call(i.prototype, A, p);
  1296. break
  1297. }
  1298. }
  1299. return h(A.getUTCFullYear(), A.getUTCMonth(), A.getUTCDate(), A.getUTCHours(), A.getUTCMinutes(), A.getUTCSeconds(), 0)
  1300. }
  1301. var q = A && A.toString().match(this.nonpunctuation) || [], A = new Date(0, 0, 0, 0, 0, 0, 0), m = {}, z = ["hh", "h", "ii", "i", "ss", "s", "yyyy", "yy", "M", "MM", "m", "mm", "D", "DD", "d", "dd", "H", "HH", "p", "P", "z", "Z"], o = {
  1302. hh: function (C, s) {
  1303. return C.setUTCHours(s)
  1304. }, h: function (C, s) {
  1305. return C.setUTCHours(s)
  1306. }, HH: function (C, s) {
  1307. return C.setUTCHours(s == 12 ? 0 : s)
  1308. }, H: function (C, s) {
  1309. return C.setUTCHours(s == 12 ? 0 : s)
  1310. }, ii: function (C, s) {
  1311. return C.setUTCMinutes(s)
  1312. }, i: function (C, s) {
  1313. return C.setUTCMinutes(s)
  1314. }, ss: function (C, s) {
  1315. return C.setUTCSeconds(s)
  1316. }, s: function (C, s) {
  1317. return C.setUTCSeconds(s)
  1318. }, yyyy: function (C, s) {
  1319. return C.setUTCFullYear(s)
  1320. }, yy: function (C, s) {
  1321. return C.setUTCFullYear(2000 + s)
  1322. }, m: function (C, s) {
  1323. s -= 1;
  1324. while (s < 0) {
  1325. s += 12
  1326. }
  1327. s %= 12;
  1328. C.setUTCMonth(s);
  1329. while (C.getUTCMonth() != s) {
  1330. if (isNaN(C.getUTCMonth())) {
  1331. return C
  1332. } else {
  1333. C.setUTCDate(C.getUTCDate() - 1)
  1334. }
  1335. }
  1336. return C
  1337. }, d: function (C, s) {
  1338. return C.setUTCDate(s)
  1339. }, p: function (C, s) {
  1340. return C.setUTCHours(s == 1 ? C.getUTCHours() + 12 : C.getUTCHours())
  1341. }, z: function () {
  1342. return r
  1343. }
  1344. }, B, k, t;
  1345. o.M = o.MM = o.mm = o.m;
  1346. o.dd = o.d;
  1347. o.P = o.p;
  1348. o.Z = o.z;
  1349. A = h(A.getFullYear(), A.getMonth(), A.getDate(), A.getHours(), A.getMinutes(), A.getSeconds());
  1350. if (q.length == y.parts.length) {
  1351. for (var x = 0, w = y.parts.length; x < w; x++) {
  1352. B = parseInt(q[x], 10);
  1353. t = y.parts[x];
  1354. if (isNaN(B)) {
  1355. switch (t) {
  1356. case"MM":
  1357. k = f(a[v].months).filter(function () {
  1358. var s = this.slice(0, q[x].length), C = q[x].slice(0, s.length);
  1359. return s == C
  1360. });
  1361. B = f.inArray(k[0], a[v].months) + 1;
  1362. break;
  1363. case"M":
  1364. k = f(a[v].monthsShort).filter(function () {
  1365. var s = this.slice(0, q[x].length), C = q[x].slice(0, s.length);
  1366. return s.toLowerCase() == C.toLowerCase()
  1367. });
  1368. B = f.inArray(k[0], a[v].monthsShort) + 1;
  1369. break;
  1370. case"p":
  1371. case"P":
  1372. B = f.inArray(q[x].toLowerCase(), a[v].meridiem);
  1373. break;
  1374. case"z":
  1375. case"Z":
  1376. r;
  1377. break
  1378. }
  1379. }
  1380. m[t] = B
  1381. }
  1382. for (var x = 0, n; x < z.length; x++) {
  1383. n = z[x];
  1384. if (n in m && !isNaN(m[n])) {
  1385. o[n](A, m[n])
  1386. }
  1387. }
  1388. }
  1389. return A
  1390. },
  1391. formatDate: function (l, q, m, p, o) {
  1392. if (l == null) {
  1393. return ""
  1394. }
  1395. var k;
  1396. if (p == "standard") {
  1397. k = {
  1398. t: l.getTime(),
  1399. yy: l.getUTCFullYear().toString().substring(2),
  1400. yyyy: l.getUTCFullYear(),
  1401. m: l.getUTCMonth() + 1,
  1402. M: a[m].monthsShort[l.getUTCMonth()],
  1403. MM: a[m].months[l.getUTCMonth()],
  1404. d: l.getUTCDate(),
  1405. D: a[m].daysShort[l.getUTCDay()],
  1406. DD: a[m].days[l.getUTCDay()],
  1407. p: (a[m].meridiem.length == 2 ? a[m].meridiem[l.getUTCHours() < 12 ? 0 : 1] : ""),
  1408. h: l.getUTCHours(),
  1409. i: l.getUTCMinutes(),
  1410. s: l.getUTCSeconds(),
  1411. z: o
  1412. };
  1413. if (a[m].meridiem.length == 2) {
  1414. k.H = (k.h % 12 == 0 ? 12 : k.h % 12)
  1415. } else {
  1416. k.H = k.h
  1417. }
  1418. k.HH = (k.H < 10 ? "0" : "") + k.H;
  1419. k.P = k.p.toUpperCase();
  1420. k.Z = k.z;
  1421. k.hh = (k.h < 10 ? "0" : "") + k.h;
  1422. k.ii = (k.i < 10 ? "0" : "") + k.i;
  1423. k.ss = (k.s < 10 ? "0" : "") + k.s;
  1424. k.dd = (k.d < 10 ? "0" : "") + k.d;
  1425. k.mm = (k.m < 10 ? "0" : "") + k.m
  1426. } else {
  1427. if (p == "php") {
  1428. k = {
  1429. y: l.getUTCFullYear().toString().substring(2),
  1430. Y: l.getUTCFullYear(),
  1431. F: a[m].months[l.getUTCMonth()],
  1432. M: a[m].monthsShort[l.getUTCMonth()],
  1433. n: l.getUTCMonth() + 1,
  1434. t: g.getDaysInMonth(l.getUTCFullYear(), l.getUTCMonth()),
  1435. j: l.getUTCDate(),
  1436. l: a[m].days[l.getUTCDay()],
  1437. D: a[m].daysShort[l.getUTCDay()],
  1438. w: l.getUTCDay(),
  1439. N: (l.getUTCDay() == 0 ? 7 : l.getUTCDay()),
  1440. S: (l.getUTCDate() % 10 <= a[m].suffix.length ? a[m].suffix[l.getUTCDate() % 10 - 1] : ""),
  1441. a: (a[m].meridiem.length == 2 ? a[m].meridiem[l.getUTCHours() < 12 ? 0 : 1] : ""),
  1442. g: (l.getUTCHours() % 12 == 0 ? 12 : l.getUTCHours() % 12),
  1443. G: l.getUTCHours(),
  1444. i: l.getUTCMinutes(),
  1445. s: l.getUTCSeconds()
  1446. };
  1447. k.m = (k.n < 10 ? "0" : "") + k.n;
  1448. k.d = (k.j < 10 ? "0" : "") + k.j;
  1449. k.A = k.a.toString().toUpperCase();
  1450. k.h = (k.g < 10 ? "0" : "") + k.g;
  1451. k.H = (k.G < 10 ? "0" : "") + k.G;
  1452. k.i = (k.i < 10 ? "0" : "") + k.i;
  1453. k.s = (k.s < 10 ? "0" : "") + k.s
  1454. } else {
  1455. throw new Error("Invalid format type.")
  1456. }
  1457. }
  1458. var l = [], r = f.extend([], q.separators);
  1459. for (var n = 0, j = q.parts.length; n < j; n++) {
  1460. if (r.length) {
  1461. l.push(r.shift())
  1462. }
  1463. l.push(k[q.parts[n]])
  1464. }
  1465. if (r.length) {
  1466. l.push(r.shift())
  1467. }
  1468. return l.join("")
  1469. },
  1470. convertViewMode: function (j) {
  1471. switch (j) {
  1472. case 4:
  1473. case"decade":
  1474. j = 4;
  1475. break;
  1476. case 3:
  1477. case"year":
  1478. j = 3;
  1479. break;
  1480. case 2:
  1481. case"month":
  1482. j = 2;
  1483. break;
  1484. case 1:
  1485. case"day":
  1486. j = 1;
  1487. break;
  1488. case 0:
  1489. case"hour":
  1490. j = 0;
  1491. break
  1492. }
  1493. return j
  1494. },
  1495. headTemplate: '<thead><tr><th class="prev"><i class="{iconType} {leftArrow}"/></th><th colspan="5" class="switch"></th><th class="next"><i class="{iconType} {rightArrow}"/></th></tr></thead>',
  1496. headTemplateV3: '<thead><tr><th class="prev"><span class="{iconType} {leftArrow}"></span> </th><th colspan="5" class="switch"></th><th class="next"><span class="{iconType} {rightArrow}"></span> </th></tr></thead>',
  1497. contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
  1498. footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr><tr><th colspan="7" class="clear"></th></tr></tfoot>'
  1499. };
  1500. g.template = '<div class="datetimepicker"><div class="datetimepicker-minutes"><table class=" table-condensed">' + g.headTemplate + g.contTemplate + g.footTemplate + '</table></div><div class="datetimepicker-hours"><table class=" table-condensed">' + g.headTemplate + g.contTemplate + g.footTemplate + '</table></div><div class="datetimepicker-days"><table class=" table-condensed">' + g.headTemplate + "<tbody></tbody>" + g.footTemplate + '</table></div><div class="datetimepicker-months"><table class="table-condensed">' + g.headTemplate + g.contTemplate + g.footTemplate + '</table></div><div class="datetimepicker-years"><table class="table-condensed">' + g.headTemplate + g.contTemplate + g.footTemplate + "</table></div></div>";
  1501. g.templateV3 = '<div class="datetimepicker"><div class="datetimepicker-minutes"><table class=" table-condensed">' + g.headTemplateV3 + g.contTemplate + g.footTemplate + '</table></div><div class="datetimepicker-hours"><table class=" table-condensed">' + g.headTemplateV3 + g.contTemplate + g.footTemplate + '</table></div><div class="datetimepicker-days"><table class=" table-condensed">' + g.headTemplateV3 + "<tbody></tbody>" + g.footTemplate + '</table></div><div class="datetimepicker-months"><table class="table-condensed">' + g.headTemplateV3 + g.contTemplate + g.footTemplate + '</table></div><div class="datetimepicker-years"><table class="table-condensed">' + g.headTemplateV3 + g.contTemplate + g.footTemplate + "</table></div></div>";
  1502. f.fn.datetimepicker.DPGlobal = g;
  1503. f.fn.datetimepicker.noConflict = function () {
  1504. f.fn.datetimepicker = b;
  1505. return this
  1506. };
  1507. f(document).on("focus.datetimepicker.data-api click.datetimepicker.data-api", '[data-provide="datetimepicker"]', function (k) {
  1508. var j = f(this);
  1509. if (j.data("datetimepicker")) {
  1510. return
  1511. }
  1512. k.preventDefault();
  1513. j.datetimepicker("show")
  1514. });
  1515. f(function () {
  1516. f('[data-provide="datetimepicker-inline"]').datetimepicker()
  1517. })
  1518. }));