bootstrap-datetimepicker.js 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763
  1. /* =========================================================
  2. * bootstrap-datetimepicker.js
  3. * =========================================================
  4. * Copyright 2012 Stefan Petre
  5. * Improvements by Andrew Rowls
  6. * Improvements by Sébastien Malot
  7. * Improvements by Yun Lai
  8. * Project URL : http://www.malot.fr/bootstrap-datetimepicker
  9. *
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. * ========================================================= */
  22. /*
  23. * Improvement by CuGBabyBeaR @ 2013-09-12
  24. *
  25. * Make it work in bootstrap v3
  26. */
  27. !function ($) {
  28. function UTCDate() {
  29. return new Date(Date.UTC.apply(Date, arguments));
  30. }
  31. function UTCToday() {
  32. var today = new Date();
  33. return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate(), today.getUTCHours(), today.getUTCMinutes(), today.getUTCSeconds(), 0);
  34. }
  35. // Picker object
  36. var Datetimepicker = function (element, options) {
  37. var that = this;
  38. this.element = $(element);
  39. // add container for single page application
  40. // when page switch the datetimepicker div will be removed also.
  41. this.container = options.container || 'body';
  42. this.language = options.language || this.element.data('date-language') || "en";
  43. this.language = this.language in dates ? this.language : "en";
  44. this.isRTL = dates[this.language].rtl || false;
  45. this.formatType = options.formatType || this.element.data('format-type') || 'standard';
  46. this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || dates[this.language].format || DPGlobal.getDefaultFormat(this.formatType, 'input'), this.formatType);
  47. this.isInline = false;
  48. this.isVisible = false;
  49. this.isInput = this.element.is('input');
  50. this.bootcssVer = this.isInput ? (this.element.is('.form-control') ? 3 : 2) : ( this.bootcssVer = this.element.is('.input-group') ? 3 : 2 );
  51. 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-calendar').parent() : this.element.find('.add-on .icon-th, .add-on .icon-time, .add-on .icon-calendar').parent()) : false;
  52. this.componentReset = this.element.is('.date') ? ( this.bootcssVer == 3 ? this.element.find('.input-group-addon .glyphicon-remove').parent() : this.element.find('.add-on .icon-remove').parent()) : false;
  53. this.hasInput = this.component && this.element.find('input').length;
  54. if (this.component && this.component.length === 0) {
  55. this.component = false;
  56. }
  57. this.linkField = options.linkField || this.element.data('link-field') || false;
  58. this.linkFormat = DPGlobal.parseFormat(options.linkFormat || this.element.data('link-format') || DPGlobal.getDefaultFormat(this.formatType, 'link'), this.formatType);
  59. this.minuteStep = options.minuteStep || this.element.data('minute-step') || 5;
  60. this.pickerPosition = options.pickerPosition || this.element.data('picker-position') || 'bottom-right';
  61. this.showMeridian = options.showMeridian || this.element.data('show-meridian') || false;
  62. this.initialDate = options.initialDate || new Date();
  63. this._attachEvents();
  64. this.formatViewType = "datetime";
  65. if ('formatViewType' in options) {
  66. this.formatViewType = options.formatViewType;
  67. } else if ('formatViewType' in this.element.data()) {
  68. this.formatViewType = this.element.data('formatViewType');
  69. }
  70. this.minView = 0;
  71. if ('minView' in options) {
  72. this.minView = options.minView;
  73. } else if ('minView' in this.element.data()) {
  74. this.minView = this.element.data('min-view');
  75. }
  76. this.minView = DPGlobal.convertViewMode(this.minView);
  77. this.maxView = DPGlobal.modes.length - 1;
  78. if ('maxView' in options) {
  79. this.maxView = options.maxView;
  80. } else if ('maxView' in this.element.data()) {
  81. this.maxView = this.element.data('max-view');
  82. }
  83. this.maxView = DPGlobal.convertViewMode(this.maxView);
  84. this.wheelViewModeNavigation = false;
  85. if ('wheelViewModeNavigation' in options) {
  86. this.wheelViewModeNavigation = options.wheelViewModeNavigation;
  87. } else if ('wheelViewModeNavigation' in this.element.data()) {
  88. this.wheelViewModeNavigation = this.element.data('view-mode-wheel-navigation');
  89. }
  90. this.wheelViewModeNavigationInverseDirection = false;
  91. if ('wheelViewModeNavigationInverseDirection' in options) {
  92. this.wheelViewModeNavigationInverseDirection = options.wheelViewModeNavigationInverseDirection;
  93. } else if ('wheelViewModeNavigationInverseDirection' in this.element.data()) {
  94. this.wheelViewModeNavigationInverseDirection = this.element.data('view-mode-wheel-navigation-inverse-dir');
  95. }
  96. this.wheelViewModeNavigationDelay = 100;
  97. if ('wheelViewModeNavigationDelay' in options) {
  98. this.wheelViewModeNavigationDelay = options.wheelViewModeNavigationDelay;
  99. } else if ('wheelViewModeNavigationDelay' in this.element.data()) {
  100. this.wheelViewModeNavigationDelay = this.element.data('view-mode-wheel-navigation-delay');
  101. }
  102. this.startViewMode = 2;
  103. if ('startView' in options) {
  104. this.startViewMode = options.startView;
  105. } else if ('startView' in this.element.data()) {
  106. this.startViewMode = this.element.data('start-view');
  107. }
  108. this.startViewMode = DPGlobal.convertViewMode(this.startViewMode);
  109. this.viewMode = this.startViewMode;
  110. this.viewSelect = this.minView;
  111. if ('viewSelect' in options) {
  112. this.viewSelect = options.viewSelect;
  113. } else if ('viewSelect' in this.element.data()) {
  114. this.viewSelect = this.element.data('view-select');
  115. }
  116. this.viewSelect = DPGlobal.convertViewMode(this.viewSelect);
  117. this.forceParse = true;
  118. if ('forceParse' in options) {
  119. this.forceParse = options.forceParse;
  120. } else if ('dateForceParse' in this.element.data()) {
  121. this.forceParse = this.element.data('date-force-parse');
  122. }
  123. this.picker = $((this.bootcssVer == 3) ? DPGlobal.templateV3 : DPGlobal.template)
  124. .appendTo(this.isInline ? this.element : this.container) // 'body')
  125. .on({
  126. click: $.proxy(this.click, this),
  127. mousedown: $.proxy(this.mousedown, this)
  128. });
  129. if (this.wheelViewModeNavigation) {
  130. if ($.fn.mousewheel) {
  131. this.picker.on({mousewheel: $.proxy(this.mousewheel, this)});
  132. } else {
  133. console.log("Mouse Wheel event is not supported. Please include the jQuery Mouse Wheel plugin before enabling this option");
  134. }
  135. }
  136. if (this.isInline) {
  137. this.picker.addClass('datetimepicker-inline');
  138. } else {
  139. this.picker.addClass('datetimepicker-dropdown-' + this.pickerPosition + ' dropdown-menu');
  140. }
  141. if (this.isRTL) {
  142. this.picker.addClass('datetimepicker-rtl');
  143. if (this.bootcssVer == 3) {
  144. this.picker.find('.prev span, .next span')
  145. .toggleClass('glyphicon-arrow-left glyphicon-arrow-right');
  146. } else {
  147. this.picker.find('.prev i, .next i')
  148. .toggleClass('icon-arrow-left icon-arrow-right');
  149. }
  150. ;
  151. }
  152. $(document).on('mousedown', function (e) {
  153. // Clicked outside the datetimepicker, hide it
  154. if ($(e.target).closest('.datetimepicker').length === 0) {
  155. that.hide();
  156. }
  157. });
  158. this.autoclose = false;
  159. if ('autoclose' in options) {
  160. this.autoclose = options.autoclose;
  161. } else if ('dateAutoclose' in this.element.data()) {
  162. this.autoclose = this.element.data('date-autoclose');
  163. }
  164. this.keyboardNavigation = true;
  165. if ('keyboardNavigation' in options) {
  166. this.keyboardNavigation = options.keyboardNavigation;
  167. } else if ('dateKeyboardNavigation' in this.element.data()) {
  168. this.keyboardNavigation = this.element.data('date-keyboard-navigation');
  169. }
  170. this.todayBtn = (options.todayBtn || this.element.data('date-today-btn') || false);
  171. this.todayHighlight = (options.todayHighlight || this.element.data('date-today-highlight') || false);
  172. this.weekStart = ((options.weekStart || this.element.data('date-weekstart') || dates[this.language].weekStart || 0) % 7);
  173. this.weekEnd = ((this.weekStart + 6) % 7);
  174. this.startDate = -Infinity;
  175. this.endDate = Infinity;
  176. this.daysOfWeekDisabled = [];
  177. this.setStartDate(options.startDate || this.element.data('date-startdate'));
  178. this.setEndDate(options.endDate || this.element.data('date-enddate'));
  179. this.setDaysOfWeekDisabled(options.daysOfWeekDisabled || this.element.data('date-days-of-week-disabled'));
  180. this.fillDow();
  181. this.fillMonths();
  182. this.update();
  183. this.showMode();
  184. if (this.isInline) {
  185. this.show();
  186. }
  187. };
  188. Datetimepicker.prototype = {
  189. constructor: Datetimepicker,
  190. _events: [],
  191. _attachEvents: function () {
  192. this._detachEvents();
  193. if (this.isInput) { // single input
  194. this._events = [
  195. [this.element, {
  196. focus: $.proxy(this.show, this),
  197. keyup: $.proxy(this.update, this),
  198. keydown: $.proxy(this.keydown, this)
  199. }]
  200. ];
  201. }
  202. else if (this.component && this.hasInput) { // component: input + button
  203. this._events = [
  204. // For components that are not readonly, allow keyboard nav
  205. [this.element.find('input'), {
  206. focus: $.proxy(this.show, this),
  207. keyup: $.proxy(this.update, this),
  208. keydown: $.proxy(this.keydown, this)
  209. }],
  210. [this.component, {
  211. click: $.proxy(this.show, this)
  212. }]
  213. ];
  214. if (this.componentReset) {
  215. this._events.push([
  216. this.componentReset,
  217. {click: $.proxy(this.reset, this)}
  218. ]);
  219. }
  220. }
  221. else if (this.element.is('div')) { // inline datetimepicker
  222. this.isInline = true;
  223. }
  224. else {
  225. this._events = [
  226. [this.element, {
  227. click: $.proxy(this.show, this)
  228. }]
  229. ];
  230. }
  231. for (var i = 0, el, ev; i < this._events.length; i++) {
  232. el = this._events[i][0];
  233. ev = this._events[i][1];
  234. el.on(ev);
  235. }
  236. },
  237. _detachEvents: function () {
  238. for (var i = 0, el, ev; i < this._events.length; i++) {
  239. el = this._events[i][0];
  240. ev = this._events[i][1];
  241. el.off(ev);
  242. }
  243. this._events = [];
  244. },
  245. show: function (e) {
  246. this.picker.show();
  247. this.height = this.component ? this.component.outerHeight() : this.element.outerHeight();
  248. if (this.forceParse) {
  249. this.update();
  250. }
  251. this.place();
  252. $(window).on('resize', $.proxy(this.place, this));
  253. if (e) {
  254. e.stopPropagation();
  255. e.preventDefault();
  256. }
  257. this.isVisible = true;
  258. this.element.trigger({
  259. type: 'show',
  260. date: this.date
  261. });
  262. },
  263. hide: function (e) {
  264. if (!this.isVisible) return;
  265. if (this.isInline) return;
  266. this.picker.hide();
  267. $(window).off('resize', this.place);
  268. this.viewMode = this.startViewMode;
  269. this.showMode();
  270. if (!this.isInput) {
  271. $(document).off('mousedown', this.hide);
  272. }
  273. if (
  274. this.forceParse &&
  275. (
  276. this.isInput && this.element.val() ||
  277. this.hasInput && this.element.find('input').val()
  278. )
  279. )
  280. this.setValue();
  281. this.isVisible = false;
  282. this.element.trigger({
  283. type: 'hide',
  284. date: this.date
  285. });
  286. },
  287. remove: function () {
  288. this._detachEvents();
  289. this.picker.remove();
  290. delete this.picker;
  291. delete this.element.data().datetimepicker;
  292. },
  293. getDate: function () {
  294. var d = this.getUTCDate();
  295. return new Date(d.getTime() + (d.getTimezoneOffset() * 60000));
  296. },
  297. getUTCDate: function () {
  298. return this.date;
  299. },
  300. setDate: function (d) {
  301. this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset() * 60000)));
  302. },
  303. setUTCDate: function (d) {
  304. if (d >= this.startDate && d <= this.endDate) {
  305. this.date = d;
  306. this.setValue();
  307. this.viewDate = this.date;
  308. this.fill();
  309. } else {
  310. this.element.trigger({
  311. type: 'outOfRange',
  312. date: d,
  313. startDate: this.startDate,
  314. endDate: this.endDate
  315. });
  316. }
  317. },
  318. setFormat: function (format) {
  319. this.format = DPGlobal.parseFormat(format, this.formatType);
  320. var element;
  321. if (this.isInput) {
  322. element = this.element;
  323. } else if (this.component) {
  324. element = this.element.find('input');
  325. }
  326. if (element && element.val()) {
  327. this.setValue();
  328. }
  329. },
  330. setValue: function () {
  331. var formatted = this.getFormattedDate();
  332. if (!this.isInput) {
  333. if (this.component) {
  334. this.element.find('input').val(formatted);
  335. }
  336. this.element.data('date', formatted);
  337. } else {
  338. this.element.val(formatted);
  339. }
  340. if (this.linkField) {
  341. $('#' + this.linkField).val(this.getFormattedDate(this.linkFormat));
  342. }
  343. },
  344. getFormattedDate: function (format) {
  345. if (format == undefined) format = this.format;
  346. return DPGlobal.formatDate(this.date, format, this.language, this.formatType);
  347. },
  348. setStartDate: function (startDate) {
  349. this.startDate = startDate || -Infinity;
  350. if (this.startDate !== -Infinity) {
  351. this.startDate = DPGlobal.parseDate(this.startDate, this.format, this.language, this.formatType);
  352. }
  353. this.update();
  354. this.updateNavArrows();
  355. },
  356. setEndDate: function (endDate) {
  357. this.endDate = endDate || Infinity;
  358. if (this.endDate !== Infinity) {
  359. this.endDate = DPGlobal.parseDate(this.endDate, this.format, this.language, this.formatType);
  360. }
  361. this.update();
  362. this.updateNavArrows();
  363. },
  364. setDaysOfWeekDisabled: function (daysOfWeekDisabled) {
  365. this.daysOfWeekDisabled = daysOfWeekDisabled || [];
  366. if (!$.isArray(this.daysOfWeekDisabled)) {
  367. this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
  368. }
  369. this.daysOfWeekDisabled = $.map(this.daysOfWeekDisabled, function (d) {
  370. return parseInt(d, 10);
  371. });
  372. this.update();
  373. this.updateNavArrows();
  374. },
  375. place: function () {
  376. if (this.isInline) return;
  377. var index_highest = 0;
  378. $('div').each(function () {
  379. var index_current = parseInt($(this).css("zIndex"), 10);
  380. if (index_current > index_highest) {
  381. index_highest = index_current;
  382. }
  383. });
  384. var zIndex = index_highest + 10;
  385. var offset, top, left, containerOffset;
  386. if (this.container instanceof $) {
  387. containerOffset = this.container.offset();
  388. } else {
  389. containerOffset = $(this.container).offset();
  390. }
  391. if (this.component) {
  392. offset = this.component.offset();
  393. left = offset.left;
  394. if (this.pickerPosition == 'bottom-left' || this.pickerPosition == 'top-left') {
  395. left += this.component.outerWidth() - this.picker.outerWidth();
  396. }
  397. } else {
  398. offset = this.element.offset();
  399. left = offset.left;
  400. }
  401. if(left+220 > document.body.clientWidth){
  402. left = document.body.clientWidth-220;
  403. }
  404. if (this.pickerPosition == 'top-left' || this.pickerPosition == 'top-right') {
  405. top = offset.top - this.picker.outerHeight();
  406. } else {
  407. top = offset.top + this.height;
  408. }
  409. top = top - containerOffset.top;
  410. left = left - containerOffset.left;
  411. this.picker.css({
  412. top: top,
  413. left: left,
  414. zIndex: zIndex
  415. });
  416. },
  417. update: function () {
  418. var date, fromArgs = false;
  419. if (arguments && arguments.length && (typeof arguments[0] === 'string' || arguments[0] instanceof Date)) {
  420. date = arguments[0];
  421. fromArgs = true;
  422. } else {
  423. date = (this.isInput ? this.element.val() : this.element.find('input').val()) || this.element.data('date') || this.initialDate;
  424. if (typeof date == 'string' || date instanceof String) {
  425. date = date.replace(/^\s+|\s+$/g,'');
  426. }
  427. }
  428. if (!date) {
  429. date = new Date();
  430. fromArgs = false;
  431. }
  432. this.date = DPGlobal.parseDate(date, this.format, this.language, this.formatType);
  433. if (fromArgs) this.setValue();
  434. if (this.date < this.startDate) {
  435. this.viewDate = new Date(this.startDate);
  436. } else if (this.date > this.endDate) {
  437. this.viewDate = new Date(this.endDate);
  438. } else {
  439. this.viewDate = new Date(this.date);
  440. }
  441. this.fill();
  442. },
  443. fillDow: function () {
  444. var dowCnt = this.weekStart,
  445. html = '<tr>';
  446. while (dowCnt < this.weekStart + 7) {
  447. html += '<th class="dow">' + dates[this.language].daysMin[(dowCnt++) % 7] + '</th>';
  448. }
  449. html += '</tr>';
  450. this.picker.find('.datetimepicker-days thead').append(html);
  451. },
  452. fillMonths: function () {
  453. var html = '',
  454. i = 0;
  455. while (i < 12) {
  456. html += '<span class="month">' + dates[this.language].monthsShort[i++] + '</span>';
  457. }
  458. this.picker.find('.datetimepicker-months td').html(html);
  459. },
  460. fill: function () {
  461. if (this.date == null || this.viewDate == null) {
  462. return;
  463. }
  464. var d = new Date(this.viewDate),
  465. year = d.getUTCFullYear(),
  466. month = d.getUTCMonth(),
  467. dayMonth = d.getUTCDate(),
  468. hours = d.getUTCHours(),
  469. minutes = d.getUTCMinutes(),
  470. startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
  471. startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
  472. endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
  473. endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
  474. currentDate = (new UTCDate(this.date.getUTCFullYear(), this.date.getUTCMonth(), this.date.getUTCDate())).valueOf(),
  475. today = new Date();
  476. this.picker.find('.datetimepicker-days thead th:eq(1)')
  477. .text(dates[this.language].months[month] + ' ' + year);
  478. if (this.formatViewType == "time") {
  479. var hourConverted = hours % 12 ? hours % 12 : 12;
  480. var hoursDisplay = (hourConverted < 10 ? '0' : '') + hourConverted;
  481. var minutesDisplay = (minutes < 10 ? '0' : '') + minutes;
  482. var meridianDisplay = dates[this.language].meridiem[hours < 12 ? 0 : 1];
  483. this.picker.find('.datetimepicker-hours thead th:eq(1)')
  484. .text(hoursDisplay + ':' + minutesDisplay + ' ' + (meridianDisplay ? meridianDisplay.toUpperCase() : ''));
  485. this.picker.find('.datetimepicker-minutes thead th:eq(1)')
  486. .text(hoursDisplay + ':' + minutesDisplay + ' ' + (meridianDisplay ? meridianDisplay.toUpperCase() : ''));
  487. } else {
  488. this.picker.find('.datetimepicker-hours thead th:eq(1)')
  489. .text(dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
  490. this.picker.find('.datetimepicker-minutes thead th:eq(1)')
  491. .text(dayMonth + ' ' + dates[this.language].months[month] + ' ' + year);
  492. }
  493. this.picker.find('tfoot th.today')
  494. .text(dates[this.language].today)
  495. .toggle(this.todayBtn !== false);
  496. this.updateNavArrows();
  497. this.fillMonths();
  498. /*var prevMonth = UTCDate(year, month, 0,0,0,0,0);
  499. prevMonth.setUTCDate(prevMonth.getDate() - (prevMonth.getUTCDay() - this.weekStart + 7)%7);*/
  500. var prevMonth = UTCDate(year, month - 1, 28, 0, 0, 0, 0),
  501. day = DPGlobal.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
  502. prevMonth.setUTCDate(day);
  503. prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7) % 7);
  504. var nextMonth = new Date(prevMonth);
  505. nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
  506. nextMonth = nextMonth.valueOf();
  507. var html = [];
  508. var clsName;
  509. while (prevMonth.valueOf() < nextMonth) {
  510. if (prevMonth.getUTCDay() == this.weekStart) {
  511. html.push('<tr>');
  512. }
  513. clsName = '';
  514. if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
  515. clsName += ' old';
  516. } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
  517. clsName += ' new';
  518. }
  519. // Compare internal UTC date with local today, not UTC today
  520. if (this.todayHighlight &&
  521. prevMonth.getUTCFullYear() == today.getFullYear() &&
  522. prevMonth.getUTCMonth() == today.getMonth() &&
  523. prevMonth.getUTCDate() == today.getDate()) {
  524. clsName += ' today';
  525. }
  526. if (prevMonth.valueOf() == currentDate) {
  527. clsName += ' active';
  528. }
  529. if ((prevMonth.valueOf() + 86400000) <= this.startDate || prevMonth.valueOf() > this.endDate ||
  530. $.inArray(prevMonth.getUTCDay(), this.daysOfWeekDisabled) !== -1) {
  531. clsName += ' disabled';
  532. }
  533. html.push('<td class="day' + clsName + '">' + prevMonth.getUTCDate() + '</td>');
  534. if (prevMonth.getUTCDay() == this.weekEnd) {
  535. html.push('</tr>');
  536. }
  537. prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
  538. }
  539. this.picker.find('.datetimepicker-days tbody').empty().append(html.join(''));
  540. html = [];
  541. var txt = '', meridian = '', meridianOld = '';
  542. for (var i = 0; i < 24; i++) {
  543. var actual = UTCDate(year, month, dayMonth, i);
  544. clsName = '';
  545. // We want the previous hour for the startDate
  546. if ((actual.valueOf() + 3600000) <= this.startDate || actual.valueOf() > this.endDate) {
  547. clsName += ' disabled';
  548. } else if (hours == i) {
  549. clsName += ' active';
  550. }
  551. if (this.showMeridian && dates[this.language].meridiem.length == 2) {
  552. meridian = (i < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
  553. if (meridian != meridianOld) {
  554. if (meridianOld != '') {
  555. html.push('</fieldset>');
  556. }
  557. html.push('<fieldset class="hour"><legend>' + meridian.toUpperCase() + '</legend>');
  558. }
  559. meridianOld = meridian;
  560. txt = (i % 12 ? i % 12 : 12);
  561. html.push('<span class="hour' + clsName + ' hour_' + (i < 12 ? 'am' : 'pm') + '">' + txt + '</span>');
  562. if (i == 23) {
  563. html.push('</fieldset>');
  564. }
  565. } else {
  566. txt = i + ':00';
  567. html.push('<span class="hour' + clsName + '">' + txt + '</span>');
  568. }
  569. }
  570. this.picker.find('.datetimepicker-hours td').html(html.join(''));
  571. html = [];
  572. txt = '', meridian = '', meridianOld = '';
  573. for (var i = 0; i < 60; i += this.minuteStep) {
  574. var actual = UTCDate(year, month, dayMonth, hours, i, 0);
  575. clsName = '';
  576. if (actual.valueOf() < this.startDate || actual.valueOf() > this.endDate) {
  577. clsName += ' disabled';
  578. } else if (Math.floor(minutes / this.minuteStep) == Math.floor(i / this.minuteStep)) {
  579. clsName += ' active';
  580. }
  581. if (this.showMeridian && dates[this.language].meridiem.length == 2) {
  582. meridian = (hours < 12 ? dates[this.language].meridiem[0] : dates[this.language].meridiem[1]);
  583. if (meridian != meridianOld) {
  584. if (meridianOld != '') {
  585. html.push('</fieldset>');
  586. }
  587. html.push('<fieldset class="minute"><legend>' + meridian.toUpperCase() + '</legend>');
  588. }
  589. meridianOld = meridian;
  590. txt = (hours % 12 ? hours % 12 : 12);
  591. //html.push('<span class="minute'+clsName+' minute_'+(hours<12?'am':'pm')+'">'+txt+'</span>');
  592. html.push('<span class="minute' + clsName + '">' + txt + ':' + (i < 10 ? '0' + i : i) + '</span>');
  593. if (i == 59) {
  594. html.push('</fieldset>');
  595. }
  596. } else {
  597. txt = i + ':00';
  598. //html.push('<span class="hour'+clsName+'">'+txt+'</span>');
  599. html.push('<span class="minute' + clsName + '">' + hours + ':' + (i < 10 ? '0' + i : i) + '</span>');
  600. }
  601. }
  602. this.picker.find('.datetimepicker-minutes td').html(html.join(''));
  603. var currentYear = this.date.getUTCFullYear();
  604. var months = this.picker.find('.datetimepicker-months')
  605. .find('th:eq(1)')
  606. .text(year)
  607. .end()
  608. .find('span').removeClass('active');
  609. if (currentYear == year) {
  610. months.eq(this.date.getUTCMonth()).addClass('active');
  611. }
  612. if (year < startYear || year > endYear) {
  613. months.addClass('disabled');
  614. }
  615. if (year == startYear) {
  616. months.slice(0, startMonth).addClass('disabled');
  617. }
  618. if (year == endYear) {
  619. months.slice(endMonth + 1).addClass('disabled');
  620. }
  621. html = '';
  622. year = parseInt(year / 10, 10) * 10;
  623. var yearCont = this.picker.find('.datetimepicker-years')
  624. .find('th:eq(1)')
  625. .text(year + '-' + (year + 9))
  626. .end()
  627. .find('td');
  628. year -= 1;
  629. for (var i = -1; i < 11; i++) {
  630. html += '<span class="year' + (i == -1 || i == 10 ? ' old' : '') + (currentYear == year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : '') + '">' + year + '</span>';
  631. year += 1;
  632. }
  633. yearCont.html(html);
  634. this.place();
  635. },
  636. updateNavArrows: function () {
  637. var d = new Date(this.viewDate),
  638. year = d.getUTCFullYear(),
  639. month = d.getUTCMonth(),
  640. day = d.getUTCDate(),
  641. hour = d.getUTCHours();
  642. switch (this.viewMode) {
  643. case 0:
  644. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
  645. && month <= this.startDate.getUTCMonth()
  646. && day <= this.startDate.getUTCDate()
  647. && hour <= this.startDate.getUTCHours()) {
  648. this.picker.find('.prev').css({visibility: 'hidden'});
  649. } else {
  650. this.picker.find('.prev').css({visibility: 'visible'});
  651. }
  652. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
  653. && month >= this.endDate.getUTCMonth()
  654. && day >= this.endDate.getUTCDate()
  655. && hour >= this.endDate.getUTCHours()) {
  656. this.picker.find('.next').css({visibility: 'hidden'});
  657. } else {
  658. this.picker.find('.next').css({visibility: 'visible'});
  659. }
  660. break;
  661. case 1:
  662. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
  663. && month <= this.startDate.getUTCMonth()
  664. && day <= this.startDate.getUTCDate()) {
  665. this.picker.find('.prev').css({visibility: 'hidden'});
  666. } else {
  667. this.picker.find('.prev').css({visibility: 'visible'});
  668. }
  669. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
  670. && month >= this.endDate.getUTCMonth()
  671. && day >= this.endDate.getUTCDate()) {
  672. this.picker.find('.next').css({visibility: 'hidden'});
  673. } else {
  674. this.picker.find('.next').css({visibility: 'visible'});
  675. }
  676. break;
  677. case 2:
  678. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()
  679. && month <= this.startDate.getUTCMonth()) {
  680. this.picker.find('.prev').css({visibility: 'hidden'});
  681. } else {
  682. this.picker.find('.prev').css({visibility: 'visible'});
  683. }
  684. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()
  685. && month >= this.endDate.getUTCMonth()) {
  686. this.picker.find('.next').css({visibility: 'hidden'});
  687. } else {
  688. this.picker.find('.next').css({visibility: 'visible'});
  689. }
  690. break;
  691. case 3:
  692. case 4:
  693. if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
  694. this.picker.find('.prev').css({visibility: 'hidden'});
  695. } else {
  696. this.picker.find('.prev').css({visibility: 'visible'});
  697. }
  698. if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
  699. this.picker.find('.next').css({visibility: 'hidden'});
  700. } else {
  701. this.picker.find('.next').css({visibility: 'visible'});
  702. }
  703. break;
  704. }
  705. },
  706. mousewheel: function (e) {
  707. e.preventDefault();
  708. e.stopPropagation();
  709. if (this.wheelPause) {
  710. return;
  711. }
  712. this.wheelPause = true;
  713. var originalEvent = e.originalEvent;
  714. var delta = originalEvent.wheelDelta;
  715. var mode = delta > 0 ? 1 : (delta === 0) ? 0 : -1;
  716. if (this.wheelViewModeNavigationInverseDirection) {
  717. mode = -mode;
  718. }
  719. this.showMode(mode);
  720. setTimeout($.proxy(function () {
  721. this.wheelPause = false
  722. }, this), this.wheelViewModeNavigationDelay);
  723. },
  724. click: function (e) {
  725. e.stopPropagation();
  726. e.preventDefault();
  727. var target = $(e.target).closest('span, td, th, legend');
  728. if (target.is('.glyphicon')) {
  729. target = $(target).parent().closest('span, td, th, legend');
  730. }
  731. if (target.length == 1) {
  732. if (target.is('.disabled')) {
  733. this.element.trigger({
  734. type: 'outOfRange',
  735. date: this.viewDate,
  736. startDate: this.startDate,
  737. endDate: this.endDate
  738. });
  739. return;
  740. }
  741. switch (target[0].nodeName.toLowerCase()) {
  742. case 'th':
  743. switch (target[0].className) {
  744. case 'switch':
  745. this.showMode(1);
  746. break;
  747. case 'prev':
  748. case 'next':
  749. var dir = DPGlobal.modes[this.viewMode].navStep * (target[0].className == 'prev' ? -1 : 1);
  750. switch (this.viewMode) {
  751. case 0:
  752. this.viewDate = this.moveHour(this.viewDate, dir);
  753. break;
  754. case 1:
  755. this.viewDate = this.moveDate(this.viewDate, dir);
  756. break;
  757. case 2:
  758. this.viewDate = this.moveMonth(this.viewDate, dir);
  759. break;
  760. case 3:
  761. case 4:
  762. this.viewDate = this.moveYear(this.viewDate, dir);
  763. break;
  764. }
  765. this.fill();
  766. this.element.trigger({
  767. type: target[0].className + ':' + this.convertViewModeText(this.viewMode),
  768. date: this.viewDate,
  769. startDate: this.startDate,
  770. endDate: this.endDate
  771. });
  772. break;
  773. case 'today':
  774. var date = new Date();
  775. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
  776. // Respect startDate and endDate.
  777. if (date < this.startDate) date = this.startDate;
  778. else if (date > this.endDate) date = this.endDate;
  779. this.viewMode = this.startViewMode;
  780. this.showMode(0);
  781. this._setDate(date);
  782. this.fill();
  783. if (this.autoclose) {
  784. this.hide();
  785. }
  786. break;
  787. }
  788. break;
  789. case 'span':
  790. if (!target.is('.disabled')) {
  791. var year = this.viewDate.getUTCFullYear(),
  792. month = this.viewDate.getUTCMonth(),
  793. day = this.viewDate.getUTCDate(),
  794. hours = this.viewDate.getUTCHours(),
  795. minutes = this.viewDate.getUTCMinutes(),
  796. seconds = this.viewDate.getUTCSeconds();
  797. if (target.is('.month')) {
  798. this.viewDate.setUTCDate(1);
  799. month = target.parent().find('span').index(target);
  800. day = this.viewDate.getUTCDate();
  801. this.viewDate.setUTCMonth(month);
  802. this.element.trigger({
  803. type: 'changeMonth',
  804. date: this.viewDate
  805. });
  806. if (this.viewSelect >= 3) {
  807. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  808. }
  809. } else if (target.is('.year')) {
  810. this.viewDate.setUTCDate(1);
  811. year = parseInt(target.text(), 10) || 0;
  812. this.viewDate.setUTCFullYear(year);
  813. this.element.trigger({
  814. type: 'changeYear',
  815. date: this.viewDate
  816. });
  817. if (this.viewSelect >= 4) {
  818. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  819. }
  820. } else if (target.is('.hour')) {
  821. hours = parseInt(target.text(), 10) || 0;
  822. if (target.hasClass('hour_am') || target.hasClass('hour_pm')) {
  823. if (hours == 12 && target.hasClass('hour_am')) {
  824. hours = 0;
  825. } else if (hours != 12 && target.hasClass('hour_pm')) {
  826. hours += 12;
  827. }
  828. }
  829. this.viewDate.setUTCHours(hours);
  830. this.element.trigger({
  831. type: 'changeHour',
  832. date: this.viewDate
  833. });
  834. if (this.viewSelect >= 1) {
  835. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  836. }
  837. } else if (target.is('.minute')) {
  838. minutes = parseInt(target.text().substr(target.text().indexOf(':') + 1), 10) || 0;
  839. this.viewDate.setUTCMinutes(minutes);
  840. this.element.trigger({
  841. type: 'changeMinute',
  842. date: this.viewDate
  843. });
  844. if (this.viewSelect >= 0) {
  845. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  846. }
  847. }
  848. if (this.viewMode != 0) {
  849. var oldViewMode = this.viewMode;
  850. this.showMode(-1);
  851. this.fill();
  852. if (oldViewMode == this.viewMode && this.autoclose) {
  853. this.hide();
  854. }
  855. } else {
  856. this.fill();
  857. if (this.autoclose) {
  858. this.hide();
  859. }
  860. }
  861. }
  862. break;
  863. case 'td':
  864. if (target.is('.day') && !target.is('.disabled')) {
  865. var day = parseInt(target.text(), 10) || 1;
  866. var year = this.viewDate.getUTCFullYear(),
  867. month = this.viewDate.getUTCMonth(),
  868. hours = this.viewDate.getUTCHours(),
  869. minutes = this.viewDate.getUTCMinutes(),
  870. seconds = this.viewDate.getUTCSeconds();
  871. if (target.is('.old')) {
  872. if (month === 0) {
  873. month = 11;
  874. year -= 1;
  875. } else {
  876. month -= 1;
  877. }
  878. } else if (target.is('.new')) {
  879. if (month == 11) {
  880. month = 0;
  881. year += 1;
  882. } else {
  883. month += 1;
  884. }
  885. }
  886. this.viewDate.setUTCFullYear(year);
  887. this.viewDate.setUTCMonth(month, day);
  888. this.element.trigger({
  889. type: 'changeDay',
  890. date: this.viewDate
  891. });
  892. if (this.viewSelect >= 2) {
  893. this._setDate(UTCDate(year, month, day, hours, minutes, seconds, 0));
  894. }
  895. }
  896. var oldViewMode = this.viewMode;
  897. this.showMode(-1);
  898. this.fill();
  899. if (oldViewMode == this.viewMode && this.autoclose) {
  900. this.hide();
  901. }
  902. break;
  903. }
  904. }
  905. },
  906. _setDate: function (date, which) {
  907. if (!which || which == 'date')
  908. this.date = date;
  909. if (!which || which == 'view')
  910. this.viewDate = date;
  911. this.fill();
  912. this.setValue();
  913. var element;
  914. if (this.isInput) {
  915. element = this.element;
  916. } else if (this.component) {
  917. element = this.element.find('input');
  918. }
  919. if (element) {
  920. element.change();
  921. if (this.autoclose && (!which || which == 'date')) {
  922. //this.hide();
  923. }
  924. }
  925. this.element.trigger({
  926. type: 'changeDate',
  927. date: this.date
  928. });
  929. },
  930. moveMinute: function (date, dir) {
  931. if (!dir) return date;
  932. var new_date = new Date(date.valueOf());
  933. //dir = dir > 0 ? 1 : -1;
  934. new_date.setUTCMinutes(new_date.getUTCMinutes() + (dir * this.minuteStep));
  935. return new_date;
  936. },
  937. moveHour: function (date, dir) {
  938. if (!dir) return date;
  939. var new_date = new Date(date.valueOf());
  940. //dir = dir > 0 ? 1 : -1;
  941. new_date.setUTCHours(new_date.getUTCHours() + dir);
  942. return new_date;
  943. },
  944. moveDate: function (date, dir) {
  945. if (!dir) return date;
  946. var new_date = new Date(date.valueOf());
  947. //dir = dir > 0 ? 1 : -1;
  948. new_date.setUTCDate(new_date.getUTCDate() + dir);
  949. return new_date;
  950. },
  951. moveMonth: function (date, dir) {
  952. if (!dir) return date;
  953. var new_date = new Date(date.valueOf()),
  954. day = new_date.getUTCDate(),
  955. month = new_date.getUTCMonth(),
  956. mag = Math.abs(dir),
  957. new_month, test;
  958. dir = dir > 0 ? 1 : -1;
  959. if (mag == 1) {
  960. test = dir == -1
  961. // If going back one month, make sure month is not current month
  962. // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
  963. ? function () {
  964. return new_date.getUTCMonth() == month;
  965. }
  966. // If going forward one month, make sure month is as expected
  967. // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
  968. : function () {
  969. return new_date.getUTCMonth() != new_month;
  970. };
  971. new_month = month + dir;
  972. new_date.setUTCMonth(new_month);
  973. // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
  974. if (new_month < 0 || new_month > 11)
  975. new_month = (new_month + 12) % 12;
  976. } else {
  977. // For magnitudes >1, move one month at a time...
  978. for (var i = 0; i < mag; i++)
  979. // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
  980. new_date = this.moveMonth(new_date, dir);
  981. // ...then reset the day, keeping it in the new month
  982. new_month = new_date.getUTCMonth();
  983. new_date.setUTCDate(day);
  984. test = function () {
  985. return new_month != new_date.getUTCMonth();
  986. };
  987. }
  988. // Common date-resetting loop -- if date is beyond end of month, make it
  989. // end of month
  990. while (test()) {
  991. new_date.setUTCDate(--day);
  992. new_date.setUTCMonth(new_month);
  993. }
  994. return new_date;
  995. },
  996. moveYear: function (date, dir) {
  997. return this.moveMonth(date, dir * 12);
  998. },
  999. dateWithinRange: function (date) {
  1000. return date >= this.startDate && date <= this.endDate;
  1001. },
  1002. keydown: function (e) {
  1003. if (this.picker.is(':not(:visible)')) {
  1004. if (e.keyCode == 27) // allow escape to hide and re-show picker
  1005. this.show();
  1006. return;
  1007. }
  1008. var dateChanged = false,
  1009. dir, day, month,
  1010. newDate, newViewDate;
  1011. switch (e.keyCode) {
  1012. case 27: // escape
  1013. this.hide();
  1014. e.preventDefault();
  1015. break;
  1016. case 37: // left
  1017. case 39: // right
  1018. if (!this.keyboardNavigation) break;
  1019. dir = e.keyCode == 37 ? -1 : 1;
  1020. viewMode = this.viewMode;
  1021. if (e.ctrlKey) {
  1022. viewMode += 2;
  1023. } else if (e.shiftKey) {
  1024. viewMode += 1;
  1025. }
  1026. if (viewMode == 4) {
  1027. newDate = this.moveYear(this.date, dir);
  1028. newViewDate = this.moveYear(this.viewDate, dir);
  1029. } else if (viewMode == 3) {
  1030. newDate = this.moveMonth(this.date, dir);
  1031. newViewDate = this.moveMonth(this.viewDate, dir);
  1032. } else if (viewMode == 2) {
  1033. newDate = this.moveDate(this.date, dir);
  1034. newViewDate = this.moveDate(this.viewDate, dir);
  1035. } else if (viewMode == 1) {
  1036. newDate = this.moveHour(this.date, dir);
  1037. newViewDate = this.moveHour(this.viewDate, dir);
  1038. } else if (viewMode == 0) {
  1039. newDate = this.moveMinute(this.date, dir);
  1040. newViewDate = this.moveMinute(this.viewDate, dir);
  1041. }
  1042. if (this.dateWithinRange(newDate)) {
  1043. this.date = newDate;
  1044. this.viewDate = newViewDate;
  1045. this.setValue();
  1046. this.update();
  1047. e.preventDefault();
  1048. dateChanged = true;
  1049. }
  1050. break;
  1051. case 38: // up
  1052. case 40: // down
  1053. if (!this.keyboardNavigation) break;
  1054. dir = e.keyCode == 38 ? -1 : 1;
  1055. viewMode = this.viewMode;
  1056. if (e.ctrlKey) {
  1057. viewMode += 2;
  1058. } else if (e.shiftKey) {
  1059. viewMode += 1;
  1060. }
  1061. if (viewMode == 4) {
  1062. newDate = this.moveYear(this.date, dir);
  1063. newViewDate = this.moveYear(this.viewDate, dir);
  1064. } else if (viewMode == 3) {
  1065. newDate = this.moveMonth(this.date, dir);
  1066. newViewDate = this.moveMonth(this.viewDate, dir);
  1067. } else if (viewMode == 2) {
  1068. newDate = this.moveDate(this.date, dir * 7);
  1069. newViewDate = this.moveDate(this.viewDate, dir * 7);
  1070. } else if (viewMode == 1) {
  1071. if (this.showMeridian) {
  1072. newDate = this.moveHour(this.date, dir * 6);
  1073. newViewDate = this.moveHour(this.viewDate, dir * 6);
  1074. } else {
  1075. newDate = this.moveHour(this.date, dir * 4);
  1076. newViewDate = this.moveHour(this.viewDate, dir * 4);
  1077. }
  1078. } else if (viewMode == 0) {
  1079. newDate = this.moveMinute(this.date, dir * 4);
  1080. newViewDate = this.moveMinute(this.viewDate, dir * 4);
  1081. }
  1082. if (this.dateWithinRange(newDate)) {
  1083. this.date = newDate;
  1084. this.viewDate = newViewDate;
  1085. this.setValue();
  1086. this.update();
  1087. e.preventDefault();
  1088. dateChanged = true;
  1089. }
  1090. break;
  1091. case 13: // enter
  1092. if (this.viewMode != 0) {
  1093. var oldViewMode = this.viewMode;
  1094. this.showMode(-1);
  1095. this.fill();
  1096. if (oldViewMode == this.viewMode && this.autoclose) {
  1097. this.hide();
  1098. }
  1099. } else {
  1100. this.fill();
  1101. if (this.autoclose) {
  1102. this.hide();
  1103. }
  1104. }
  1105. e.preventDefault();
  1106. break;
  1107. case 9: // tab
  1108. this.hide();
  1109. break;
  1110. }
  1111. if (dateChanged) {
  1112. var element;
  1113. if (this.isInput) {
  1114. element = this.element;
  1115. } else if (this.component) {
  1116. element = this.element.find('input');
  1117. }
  1118. if (element) {
  1119. element.change();
  1120. }
  1121. this.element.trigger({
  1122. type: 'changeDate',
  1123. date: this.date
  1124. });
  1125. }
  1126. },
  1127. showMode: function (dir) {
  1128. if (dir) {
  1129. var newViewMode = Math.max(0, Math.min(DPGlobal.modes.length - 1, this.viewMode + dir));
  1130. if (newViewMode >= this.minView && newViewMode <= this.maxView) {
  1131. this.element.trigger({
  1132. type: 'changeMode',
  1133. date: this.viewDate,
  1134. oldViewMode: this.viewMode,
  1135. newViewMode: newViewMode
  1136. });
  1137. this.viewMode = newViewMode;
  1138. }
  1139. }
  1140. /*
  1141. vitalets: fixing bug of very special conditions:
  1142. jquery 1.7.1 + webkit + show inline datetimepicker in bootstrap popover.
  1143. Method show() does not set display css correctly and datetimepicker is not shown.
  1144. Changed to .css('display', 'block') solve the problem.
  1145. See https://github.com/vitalets/x-editable/issues/37
  1146. In jquery 1.7.2+ everything works fine.
  1147. */
  1148. //this.picker.find('>div').hide().filter('.datetimepicker-'+DPGlobal.modes[this.viewMode].clsName).show();
  1149. this.picker.find('>div').hide().filter('.datetimepicker-' + DPGlobal.modes[this.viewMode].clsName).css('display', 'block');
  1150. this.updateNavArrows();
  1151. },
  1152. reset: function (e) {
  1153. this._setDate(null, 'date');
  1154. },
  1155. convertViewModeText: function (viewMode) {
  1156. switch (viewMode) {
  1157. case 4:
  1158. return 'decade';
  1159. case 3:
  1160. return 'year';
  1161. case 2:
  1162. return 'month';
  1163. case 1:
  1164. return 'day';
  1165. case 0:
  1166. return 'hour';
  1167. }
  1168. }
  1169. };
  1170. $.fn.datetimepicker = function (option) {
  1171. var args = Array.apply(null, arguments);
  1172. args.shift();
  1173. var internal_return;
  1174. this.each(function () {
  1175. var $this = $(this),
  1176. data = $this.data('datetimepicker'),
  1177. options = typeof option == 'object' && option;
  1178. if (!data) {
  1179. $this.data('datetimepicker', (data = new Datetimepicker(this, $.extend({}, $.fn.datetimepicker.defaults, options))));
  1180. }
  1181. if (typeof option == 'string' && typeof data[option] == 'function') {
  1182. internal_return = data[option].apply(data, args);
  1183. if (internal_return !== undefined) {
  1184. return false;
  1185. }
  1186. }
  1187. });
  1188. if (internal_return !== undefined)
  1189. return internal_return;
  1190. else
  1191. return this;
  1192. };
  1193. $.fn.datetimepicker.defaults = {
  1194. };
  1195. $.fn.datetimepicker.Constructor = Datetimepicker;
  1196. var dates = $.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. },
  1207. zh_cn:{
  1208. days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
  1209. daysShort: ["日", "一", "二", "三", "四", "五", "六", "日"],
  1210. daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
  1211. months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
  1212. monthsShort: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
  1213. meridiem: ["上午", "下午"],
  1214. suffix: ["st", "nd", "rd", "th"],
  1215. today: "今天"
  1216. }
  1217. };
  1218. var DPGlobal = {
  1219. modes: [
  1220. {
  1221. clsName: 'minutes',
  1222. navFnc: 'Hours',
  1223. navStep: 1
  1224. },
  1225. {
  1226. clsName: 'hours',
  1227. navFnc: 'Date',
  1228. navStep: 1
  1229. },
  1230. {
  1231. clsName: 'days',
  1232. navFnc: 'Month',
  1233. navStep: 1
  1234. },
  1235. {
  1236. clsName: 'months',
  1237. navFnc: 'FullYear',
  1238. navStep: 1
  1239. },
  1240. {
  1241. clsName: 'years',
  1242. navFnc: 'FullYear',
  1243. navStep: 10
  1244. }
  1245. ],
  1246. isLeapYear: function (year) {
  1247. return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0))
  1248. },
  1249. getDaysInMonth: function (year, month) {
  1250. return [31, (DPGlobal.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]
  1251. },
  1252. getDefaultFormat: function (type, field) {
  1253. if (type == "standard") {
  1254. if (field == 'input')
  1255. return 'yyyy-mm-dd hh:ii';
  1256. else
  1257. return 'yyyy-mm-dd hh:ii:ss';
  1258. } else if (type == "php") {
  1259. if (field == 'input')
  1260. return 'Y-m-d H:i';
  1261. else
  1262. return 'Y-m-d H:i:s';
  1263. } else {
  1264. throw new Error("Invalid format type.");
  1265. }
  1266. },
  1267. validParts: function (type) {
  1268. if (type == "standard") {
  1269. return /hh?|HH?|p|P|ii?|ss?|dd?|DD?|mm?|MM?|yy(?:yy)?/g;
  1270. } else if (type == "php") {
  1271. return /[dDjlNwzFmMnStyYaABgGhHis]/g;
  1272. } else {
  1273. throw new Error("Invalid format type.");
  1274. }
  1275. },
  1276. nonpunctuation: /[^ -\/:-@\[-`{-~\t\n\rTZ]+/g,
  1277. parseFormat: function (format, type) {
  1278. // IE treats \0 as a string end in inputs (truncating the value),
  1279. // so it's a bad format delimiter, anyway
  1280. var separators = format.replace(this.validParts(type), '\0').split('\0'),
  1281. parts = format.match(this.validParts(type));
  1282. if (!separators || !separators.length || !parts || parts.length == 0) {
  1283. throw new Error("Invalid date format.");
  1284. }
  1285. return {separators: separators, parts: parts};
  1286. },
  1287. parseDate: function (date, format, language, type) {
  1288. if (date instanceof Date) {
  1289. var dateUTC = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
  1290. dateUTC.setMilliseconds(0);
  1291. return dateUTC;
  1292. }
  1293. if (/^\d{4}\-\d{1,2}\-\d{1,2}$/.test(date)) {
  1294. format = this.parseFormat('yyyy-mm-dd', type);
  1295. }
  1296. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}$/.test(date)) {
  1297. format = this.parseFormat('yyyy-mm-dd hh:ii', type);
  1298. }
  1299. if (/^\d{4}\-\d{1,2}\-\d{1,2}[T ]\d{1,2}\:\d{1,2}\:\d{1,2}[Z]{0,1}$/.test(date)) {
  1300. format = this.parseFormat('yyyy-mm-dd hh:ii:ss', type);
  1301. }
  1302. if (/^[-+]\d+[dmwy]([\s,]+[-+]\d+[dmwy])*$/.test(date)) {
  1303. var part_re = /([-+]\d+)([dmwy])/,
  1304. parts = date.match(/([-+]\d+)([dmwy])/g),
  1305. part, dir;
  1306. date = new Date();
  1307. for (var i = 0; i < parts.length; i++) {
  1308. part = part_re.exec(parts[i]);
  1309. dir = parseInt(part[1]);
  1310. switch (part[2]) {
  1311. case 'd':
  1312. date.setUTCDate(date.getUTCDate() + dir);
  1313. break;
  1314. case 'm':
  1315. date = Datetimepicker.prototype.moveMonth.call(Datetimepicker.prototype, date, dir);
  1316. break;
  1317. case 'w':
  1318. date.setUTCDate(date.getUTCDate() + dir * 7);
  1319. break;
  1320. case 'y':
  1321. date = Datetimepicker.prototype.moveYear.call(Datetimepicker.prototype, date, dir);
  1322. break;
  1323. }
  1324. }
  1325. return UTCDate(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), 0);
  1326. }
  1327. var parts = date && date.match(this.nonpunctuation) || [],
  1328. date = new Date(0, 0, 0, 0, 0, 0, 0),
  1329. parsed = {},
  1330. setters_order = ['hh', 'h', 'ii', 'i', 'ss', 's', 'yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'D', 'DD', 'd', 'dd', 'H', 'HH', 'p', 'P'],
  1331. setters_map = {
  1332. hh: function (d, v) {
  1333. return d.setUTCHours(v);
  1334. },
  1335. h: function (d, v) {
  1336. return d.setUTCHours(v);
  1337. },
  1338. HH: function (d, v) {
  1339. return d.setUTCHours(v == 12 ? 0 : v);
  1340. },
  1341. H: function (d, v) {
  1342. return d.setUTCHours(v == 12 ? 0 : v);
  1343. },
  1344. ii: function (d, v) {
  1345. return d.setUTCMinutes(v);
  1346. },
  1347. i: function (d, v) {
  1348. return d.setUTCMinutes(v);
  1349. },
  1350. ss: function (d, v) {
  1351. return d.setUTCSeconds(v);
  1352. },
  1353. s: function (d, v) {
  1354. return d.setUTCSeconds(v);
  1355. },
  1356. yyyy: function (d, v) {
  1357. return d.setUTCFullYear(v);
  1358. },
  1359. yy: function (d, v) {
  1360. return d.setUTCFullYear(2000 + v);
  1361. },
  1362. m: function (d, v) {
  1363. v -= 1;
  1364. while (v < 0) v += 12;
  1365. v %= 12;
  1366. d.setUTCMonth(v);
  1367. while (d.getUTCMonth() != v)
  1368. if (isNaN(d.getUTCMonth()))
  1369. return d;
  1370. else
  1371. d.setUTCDate(d.getUTCDate() - 1);
  1372. return d;
  1373. },
  1374. d: function (d, v) {
  1375. return d.setUTCDate(v);
  1376. },
  1377. p: function (d, v) {
  1378. return d.setUTCHours(v == 1 ? d.getUTCHours() + 12 : d.getUTCHours());
  1379. }
  1380. },
  1381. val, filtered, part;
  1382. setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
  1383. setters_map['dd'] = setters_map['d'];
  1384. setters_map['P'] = setters_map['p'];
  1385. date = UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
  1386. if (parts.length == format.parts.length) {
  1387. for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
  1388. val = parseInt(parts[i], 10);
  1389. part = format.parts[i];
  1390. if (isNaN(val)) {
  1391. switch (part) {
  1392. case 'MM':
  1393. filtered = $(dates[language].months).filter(function () {
  1394. var m = this.slice(0, parts[i].length),
  1395. p = parts[i].slice(0, m.length);
  1396. return m == p;
  1397. });
  1398. val = $.inArray(filtered[0], dates[language].months) + 1;
  1399. break;
  1400. case 'M':
  1401. filtered = $(dates[language].monthsShort).filter(function () {
  1402. var m = this.slice(0, parts[i].length),
  1403. p = parts[i].slice(0, m.length);
  1404. return m.toLowerCase() == p.toLowerCase();
  1405. });
  1406. val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
  1407. break;
  1408. case 'p':
  1409. case 'P':
  1410. val = $.inArray(parts[i].toLowerCase(), dates[language].meridiem);
  1411. break;
  1412. }
  1413. }
  1414. parsed[part] = val;
  1415. }
  1416. for (var i = 0, s; i < setters_order.length; i++) {
  1417. s = setters_order[i];
  1418. if (s in parsed && !isNaN(parsed[s]))
  1419. setters_map[s](date, parsed[s])
  1420. }
  1421. }
  1422. return date;
  1423. },
  1424. formatDate: function (date, format, language, type) {
  1425. if (date == null) {
  1426. return '';
  1427. }
  1428. var val;
  1429. if (type == 'standard') {
  1430. val = {
  1431. // year
  1432. yy: date.getUTCFullYear().toString().substring(2),
  1433. yyyy: date.getUTCFullYear(),
  1434. // month
  1435. m: date.getUTCMonth() + 1,
  1436. M: dates[language].monthsShort[date.getUTCMonth()],
  1437. MM: dates[language].months[date.getUTCMonth()],
  1438. // day
  1439. d: date.getUTCDate(),
  1440. D: dates[language].daysShort[date.getUTCDay()],
  1441. DD: dates[language].days[date.getUTCDay()],
  1442. p: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
  1443. // hour
  1444. h: date.getUTCHours(),
  1445. // minute
  1446. i: date.getUTCMinutes(),
  1447. // second
  1448. s: date.getUTCSeconds()
  1449. };
  1450. if (dates[language].meridiem.length == 2) {
  1451. val.H = (val.h % 12 == 0 ? 12 : val.h % 12);
  1452. }
  1453. else {
  1454. val.H = val.h;
  1455. }
  1456. val.HH = (val.H < 10 ? '0' : '') + val.H;
  1457. val.P = val.p.toUpperCase();
  1458. val.hh = (val.h < 10 ? '0' : '') + val.h;
  1459. val.ii = (val.i < 10 ? '0' : '') + val.i;
  1460. val.ss = (val.s < 10 ? '0' : '') + val.s;
  1461. val.dd = (val.d < 10 ? '0' : '') + val.d;
  1462. val.mm = (val.m < 10 ? '0' : '') + val.m;
  1463. } else if (type == 'php') {
  1464. // php format
  1465. val = {
  1466. // year
  1467. y: date.getUTCFullYear().toString().substring(2),
  1468. Y: date.getUTCFullYear(),
  1469. // month
  1470. F: dates[language].months[date.getUTCMonth()],
  1471. M: dates[language].monthsShort[date.getUTCMonth()],
  1472. n: date.getUTCMonth() + 1,
  1473. t: DPGlobal.getDaysInMonth(date.getUTCFullYear(), date.getUTCMonth()),
  1474. // day
  1475. j: date.getUTCDate(),
  1476. l: dates[language].days[date.getUTCDay()],
  1477. D: dates[language].daysShort[date.getUTCDay()],
  1478. w: date.getUTCDay(), // 0 -> 6
  1479. N: (date.getUTCDay() == 0 ? 7 : date.getUTCDay()), // 1 -> 7
  1480. S: (date.getUTCDate() % 10 <= dates[language].suffix.length ? dates[language].suffix[date.getUTCDate() % 10 - 1] : ''),
  1481. // hour
  1482. a: (dates[language].meridiem.length == 2 ? dates[language].meridiem[date.getUTCHours() < 12 ? 0 : 1] : ''),
  1483. g: (date.getUTCHours() % 12 == 0 ? 12 : date.getUTCHours() % 12),
  1484. G: date.getUTCHours(),
  1485. // minute
  1486. i: date.getUTCMinutes(),
  1487. // second
  1488. s: date.getUTCSeconds()
  1489. };
  1490. val.m = (val.n < 10 ? '0' : '') + val.n;
  1491. val.d = (val.j < 10 ? '0' : '') + val.j;
  1492. val.A = val.a.toString().toUpperCase();
  1493. val.h = (val.g < 10 ? '0' : '') + val.g;
  1494. val.H = (val.G < 10 ? '0' : '') + val.G;
  1495. val.i = (val.i < 10 ? '0' : '') + val.i;
  1496. val.s = (val.s < 10 ? '0' : '') + val.s;
  1497. } else {
  1498. throw new Error("Invalid format type.");
  1499. }
  1500. var date = [],
  1501. seps = $.extend([], format.separators);
  1502. for (var i = 0, cnt = format.parts.length; i < cnt; i++) {
  1503. if (seps.length) {
  1504. date.push(seps.shift());
  1505. }
  1506. date.push(val[format.parts[i]]);
  1507. }
  1508. if (seps.length) {
  1509. date.push(seps.shift());
  1510. }
  1511. return date.join('');
  1512. },
  1513. convertViewMode: function (viewMode) {
  1514. switch (viewMode) {
  1515. case 4:
  1516. case 'decade':
  1517. viewMode = 4;
  1518. break;
  1519. case 3:
  1520. case 'year':
  1521. viewMode = 3;
  1522. break;
  1523. case 2:
  1524. case 'month':
  1525. viewMode = 2;
  1526. break;
  1527. case 1:
  1528. case 'day':
  1529. viewMode = 1;
  1530. break;
  1531. case 0:
  1532. case 'hour':
  1533. viewMode = 0;
  1534. break;
  1535. }
  1536. return viewMode;
  1537. },
  1538. headTemplate: '<thead>' +
  1539. '<tr>' +
  1540. '<th class="prev"><i class="icon-arrow-left"/></th>' +
  1541. '<th colspan="5" class="switch"></th>' +
  1542. '<th class="next"><i class="icon-arrow-right"/></th>' +
  1543. '</tr>' +
  1544. '</thead>',
  1545. headTemplateV3: '<thead>' +
  1546. '<tr>' +
  1547. '<th class="prev"><span class="glyphicon glyphicon-arrow-left"></span> </th>' +
  1548. '<th colspan="5" class="switch"></th>' +
  1549. '<th class="next"><span class="glyphicon glyphicon-arrow-right"></span> </th>' +
  1550. '</tr>' +
  1551. '</thead>',
  1552. contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
  1553. footTemplate: '<tfoot><tr><th colspan="7" class="today"></th></tr></tfoot>'
  1554. };
  1555. DPGlobal.template = '<div class="datetimepicker">' +
  1556. '<div class="datetimepicker-minutes">' +
  1557. '<table class=" table-condensed">' +
  1558. DPGlobal.headTemplate +
  1559. DPGlobal.contTemplate +
  1560. DPGlobal.footTemplate +
  1561. '</table>' +
  1562. '</div>' +
  1563. '<div class="datetimepicker-hours">' +
  1564. '<table class=" table-condensed">' +
  1565. DPGlobal.headTemplate +
  1566. DPGlobal.contTemplate +
  1567. DPGlobal.footTemplate +
  1568. '</table>' +
  1569. '</div>' +
  1570. '<div class="datetimepicker-days">' +
  1571. '<table class=" table-condensed">' +
  1572. DPGlobal.headTemplate +
  1573. '<tbody></tbody>' +
  1574. DPGlobal.footTemplate +
  1575. '</table>' +
  1576. '</div>' +
  1577. '<div class="datetimepicker-months">' +
  1578. '<table class="table-condensed">' +
  1579. DPGlobal.headTemplate +
  1580. DPGlobal.contTemplate +
  1581. DPGlobal.footTemplate +
  1582. '</table>' +
  1583. '</div>' +
  1584. '<div class="datetimepicker-years">' +
  1585. '<table class="table-condensed">' +
  1586. DPGlobal.headTemplate +
  1587. DPGlobal.contTemplate +
  1588. DPGlobal.footTemplate +
  1589. '</table>' +
  1590. '</div>' +
  1591. '</div>';
  1592. DPGlobal.templateV3 = '<div class="datetimepicker">' +
  1593. '<div class="datetimepicker-minutes">' +
  1594. '<table class=" table-condensed">' +
  1595. DPGlobal.headTemplateV3 +
  1596. DPGlobal.contTemplate +
  1597. DPGlobal.footTemplate +
  1598. '</table>' +
  1599. '</div>' +
  1600. '<div class="datetimepicker-hours">' +
  1601. '<table class=" table-condensed">' +
  1602. DPGlobal.headTemplateV3 +
  1603. DPGlobal.contTemplate +
  1604. DPGlobal.footTemplate +
  1605. '</table>' +
  1606. '</div>' +
  1607. '<div class="datetimepicker-days">' +
  1608. '<table class=" table-condensed">' +
  1609. DPGlobal.headTemplateV3 +
  1610. '<tbody></tbody>' +
  1611. DPGlobal.footTemplate +
  1612. '</table>' +
  1613. '</div>' +
  1614. '<div class="datetimepicker-months">' +
  1615. '<table class="table-condensed">' +
  1616. DPGlobal.headTemplateV3 +
  1617. DPGlobal.contTemplate +
  1618. DPGlobal.footTemplate +
  1619. '</table>' +
  1620. '</div>' +
  1621. '<div class="datetimepicker-years">' +
  1622. '<table class="table-condensed">' +
  1623. DPGlobal.headTemplateV3 +
  1624. DPGlobal.contTemplate +
  1625. DPGlobal.footTemplate +
  1626. '</table>' +
  1627. '</div>' +
  1628. '</div>';
  1629. $.fn.datetimepicker.DPGlobal = DPGlobal;
  1630. /* DATETIMEPICKER NO CONFLICT
  1631. * =================== */
  1632. $.fn.datetimepicker.noConflict = function () {
  1633. $.fn.datetimepicker = old;
  1634. return this;
  1635. };
  1636. /* DATETIMEPICKER DATA-API
  1637. * ================== */
  1638. $(document).on(
  1639. 'focus.datetimepicker.data-api click.datetimepicker.data-api',
  1640. '[data-provide="datetimepicker"]',
  1641. function (e) {
  1642. var $this = $(this);
  1643. if ($this.data('datetimepicker')) return;
  1644. e.preventDefault();
  1645. // component click requires us to explicitly show it
  1646. $this.datetimepicker('show');
  1647. }
  1648. );
  1649. $(function () {
  1650. $('[data-provide="datetimepicker-inline"]').datetimepicker();
  1651. });
  1652. }(window.jQuery);