You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tempusdominus-bootstrap-4.js 107KB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505
  1. /*!@preserve
  2. * Tempus Dominus Bootstrap4 v5.39.0 (https://tempusdominus.github.io/bootstrap-4/)
  3. * Copyright 2016-2020 Jonathan Peterson and contributors
  4. * Licensed under MIT (https://github.com/tempusdominus/bootstrap-3/blob/master/LICENSE)
  5. */
  6. if (typeof jQuery === 'undefined') {
  7. throw new Error('Tempus Dominus Bootstrap4\'s requires jQuery. jQuery must be included before Tempus Dominus Bootstrap4\'s JavaScript.');
  8. }
  9. +function ($) {
  10. var version = $.fn.jquery.split(' ')[0].split('.');
  11. if ((version[0] < 2 && version[1] < 9) || (version[0] === 1 && version[1] === 9 && version[2] < 1) || (version[0] >= 4)) {
  12. throw new Error('Tempus Dominus Bootstrap4\'s requires at least jQuery v3.0.0 but less than v4.0.0');
  13. }
  14. }(jQuery);
  15. if (typeof moment === 'undefined') {
  16. throw new Error('Tempus Dominus Bootstrap4\'s requires moment.js. Moment.js must be included before Tempus Dominus Bootstrap4\'s JavaScript.');
  17. }
  18. var version = moment.version.split('.')
  19. if ((version[0] <= 2 && version[1] < 17) || (version[0] >= 3)) {
  20. throw new Error('Tempus Dominus Bootstrap4\'s requires at least moment.js v2.17.0 but less than v3.0.0');
  21. }
  22. +function () {
  23. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  24. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  25. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  26. // ReSharper disable once InconsistentNaming
  27. var DateTimePicker = function ($, moment) {
  28. function escapeRegExp(text) {
  29. return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
  30. }
  31. function isValidDate(date) {
  32. return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());
  33. }
  34. function isValidDateTimeStr(str) {
  35. return isValidDate(new Date(str));
  36. } // ReSharper disable InconsistentNaming
  37. var trim = function trim(str) {
  38. return str.replace(/(^\s+)|(\s+$)/g, '');
  39. },
  40. NAME = 'datetimepicker',
  41. DATA_KEY = "" + NAME,
  42. EVENT_KEY = "." + DATA_KEY,
  43. DATA_API_KEY = '.data-api',
  44. Selector = {
  45. DATA_TOGGLE: "[data-toggle=\"" + DATA_KEY + "\"]"
  46. },
  47. ClassName = {
  48. INPUT: NAME + "-input"
  49. },
  50. Event = {
  51. CHANGE: "change" + EVENT_KEY,
  52. BLUR: "blur" + EVENT_KEY,
  53. KEYUP: "keyup" + EVENT_KEY,
  54. KEYDOWN: "keydown" + EVENT_KEY,
  55. FOCUS: "focus" + EVENT_KEY,
  56. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,
  57. //emitted
  58. UPDATE: "update" + EVENT_KEY,
  59. ERROR: "error" + EVENT_KEY,
  60. HIDE: "hide" + EVENT_KEY,
  61. SHOW: "show" + EVENT_KEY
  62. },
  63. DatePickerModes = [{
  64. CLASS_NAME: 'days',
  65. NAV_FUNCTION: 'M',
  66. NAV_STEP: 1
  67. }, {
  68. CLASS_NAME: 'months',
  69. NAV_FUNCTION: 'y',
  70. NAV_STEP: 1
  71. }, {
  72. CLASS_NAME: 'years',
  73. NAV_FUNCTION: 'y',
  74. NAV_STEP: 10
  75. }, {
  76. CLASS_NAME: 'decades',
  77. NAV_FUNCTION: 'y',
  78. NAV_STEP: 100
  79. }],
  80. KeyMap = {
  81. 'up': 38,
  82. 38: 'up',
  83. 'down': 40,
  84. 40: 'down',
  85. 'left': 37,
  86. 37: 'left',
  87. 'right': 39,
  88. 39: 'right',
  89. 'tab': 9,
  90. 9: 'tab',
  91. 'escape': 27,
  92. 27: 'escape',
  93. 'enter': 13,
  94. 13: 'enter',
  95. 'pageUp': 33,
  96. 33: 'pageUp',
  97. 'pageDown': 34,
  98. 34: 'pageDown',
  99. 'shift': 16,
  100. 16: 'shift',
  101. 'control': 17,
  102. 17: 'control',
  103. 'space': 32,
  104. 32: 'space',
  105. 't': 84,
  106. 84: 't',
  107. 'delete': 46,
  108. 46: 'delete'
  109. },
  110. ViewModes = ['times', 'days', 'months', 'years', 'decades'],
  111. keyState = {},
  112. keyPressHandled = {},
  113. optionsSortMap = {
  114. timeZone: -39,
  115. format: -38,
  116. dayViewHeaderFormat: -37,
  117. extraFormats: -36,
  118. stepping: -35,
  119. minDate: -34,
  120. maxDate: -33,
  121. useCurrent: -32,
  122. collapse: -31,
  123. locale: -30,
  124. defaultDate: -29,
  125. disabledDates: -28,
  126. enabledDates: -27,
  127. icons: -26,
  128. tooltips: -25,
  129. useStrict: -24,
  130. sideBySide: -23,
  131. daysOfWeekDisabled: -22,
  132. calendarWeeks: -21,
  133. viewMode: -20,
  134. toolbarPlacement: -19,
  135. buttons: -18,
  136. widgetPositioning: -17,
  137. widgetParent: -16,
  138. ignoreReadonly: -15,
  139. keepOpen: -14,
  140. focusOnShow: -13,
  141. inline: -12,
  142. keepInvalid: -11,
  143. keyBinds: -10,
  144. debug: -9,
  145. allowInputToggle: -8,
  146. disabledTimeIntervals: -7,
  147. disabledHours: -6,
  148. enabledHours: -5,
  149. viewDate: -4,
  150. allowMultidate: -3,
  151. multidateSeparator: -2,
  152. updateOnlyThroughDateOption: -1,
  153. date: 1
  154. },
  155. defaultFeatherIcons = {
  156. time: 'clock',
  157. date: 'calendar',
  158. up: 'arrow-up',
  159. down: 'arrow-down',
  160. previous: 'arrow-left',
  161. next: 'arrow-right',
  162. today: 'arrow-down-circle',
  163. clear: 'trash-2',
  164. close: 'x'
  165. };
  166. function optionsSortFn(optionKeyA, optionKeyB) {
  167. if (optionsSortMap[optionKeyA] && optionsSortMap[optionKeyB]) {
  168. if (optionsSortMap[optionKeyA] < 0 && optionsSortMap[optionKeyB] < 0) {
  169. return Math.abs(optionsSortMap[optionKeyB]) - Math.abs(optionsSortMap[optionKeyA]);
  170. } else if (optionsSortMap[optionKeyA] < 0) {
  171. return -1;
  172. } else if (optionsSortMap[optionKeyB] < 0) {
  173. return 1;
  174. }
  175. return optionsSortMap[optionKeyA] - optionsSortMap[optionKeyB];
  176. } else if (optionsSortMap[optionKeyA]) {
  177. return optionsSortMap[optionKeyA];
  178. } else if (optionsSortMap[optionKeyB]) {
  179. return optionsSortMap[optionKeyB];
  180. }
  181. return 0;
  182. }
  183. var Default = {
  184. timeZone: '',
  185. format: false,
  186. dayViewHeaderFormat: 'MMMM YYYY',
  187. extraFormats: false,
  188. stepping: 1,
  189. minDate: false,
  190. maxDate: false,
  191. useCurrent: true,
  192. collapse: true,
  193. locale: moment.locale(),
  194. defaultDate: false,
  195. disabledDates: false,
  196. enabledDates: false,
  197. icons: {
  198. type: 'class',
  199. time: 'fa fa-clock-o',
  200. date: 'fa fa-calendar',
  201. up: 'fa fa-arrow-up',
  202. down: 'fa fa-arrow-down',
  203. previous: 'fa fa-chevron-left',
  204. next: 'fa fa-chevron-right',
  205. today: 'fa fa-calendar-check-o',
  206. clear: 'fa fa-trash',
  207. close: 'fa fa-times'
  208. },
  209. tooltips: {
  210. today: 'Go to today',
  211. clear: 'Clear selection',
  212. close: 'Close the picker',
  213. selectMonth: 'Select Month',
  214. prevMonth: 'Previous Month',
  215. nextMonth: 'Next Month',
  216. selectYear: 'Select Year',
  217. prevYear: 'Previous Year',
  218. nextYear: 'Next Year',
  219. selectDecade: 'Select Decade',
  220. prevDecade: 'Previous Decade',
  221. nextDecade: 'Next Decade',
  222. prevCentury: 'Previous Century',
  223. nextCentury: 'Next Century',
  224. pickHour: 'Pick Hour',
  225. incrementHour: 'Increment Hour',
  226. decrementHour: 'Decrement Hour',
  227. pickMinute: 'Pick Minute',
  228. incrementMinute: 'Increment Minute',
  229. decrementMinute: 'Decrement Minute',
  230. pickSecond: 'Pick Second',
  231. incrementSecond: 'Increment Second',
  232. decrementSecond: 'Decrement Second',
  233. togglePeriod: 'Toggle Period',
  234. selectTime: 'Select Time',
  235. selectDate: 'Select Date'
  236. },
  237. useStrict: false,
  238. sideBySide: false,
  239. daysOfWeekDisabled: false,
  240. calendarWeeks: false,
  241. viewMode: 'days',
  242. toolbarPlacement: 'default',
  243. buttons: {
  244. showToday: false,
  245. showClear: false,
  246. showClose: false
  247. },
  248. widgetPositioning: {
  249. horizontal: 'auto',
  250. vertical: 'auto'
  251. },
  252. widgetParent: null,
  253. readonly: false,
  254. ignoreReadonly: false,
  255. keepOpen: false,
  256. focusOnShow: true,
  257. inline: false,
  258. keepInvalid: false,
  259. keyBinds: {
  260. up: function up() {
  261. if (!this.widget) {
  262. return false;
  263. }
  264. var d = this._dates[0] || this.getMoment();
  265. if (this.widget.find('.datepicker').is(':visible')) {
  266. this.date(d.clone().subtract(7, 'd'));
  267. } else {
  268. this.date(d.clone().add(this.stepping(), 'm'));
  269. }
  270. return true;
  271. },
  272. down: function down() {
  273. if (!this.widget) {
  274. this.show();
  275. return false;
  276. }
  277. var d = this._dates[0] || this.getMoment();
  278. if (this.widget.find('.datepicker').is(':visible')) {
  279. this.date(d.clone().add(7, 'd'));
  280. } else {
  281. this.date(d.clone().subtract(this.stepping(), 'm'));
  282. }
  283. return true;
  284. },
  285. 'control up': function controlUp() {
  286. if (!this.widget) {
  287. return false;
  288. }
  289. var d = this._dates[0] || this.getMoment();
  290. if (this.widget.find('.datepicker').is(':visible')) {
  291. this.date(d.clone().subtract(1, 'y'));
  292. } else {
  293. this.date(d.clone().add(1, 'h'));
  294. }
  295. return true;
  296. },
  297. 'control down': function controlDown() {
  298. if (!this.widget) {
  299. return false;
  300. }
  301. var d = this._dates[0] || this.getMoment();
  302. if (this.widget.find('.datepicker').is(':visible')) {
  303. this.date(d.clone().add(1, 'y'));
  304. } else {
  305. this.date(d.clone().subtract(1, 'h'));
  306. }
  307. return true;
  308. },
  309. left: function left() {
  310. if (!this.widget) {
  311. return false;
  312. }
  313. var d = this._dates[0] || this.getMoment();
  314. if (this.widget.find('.datepicker').is(':visible')) {
  315. this.date(d.clone().subtract(1, 'd'));
  316. }
  317. return true;
  318. },
  319. right: function right() {
  320. if (!this.widget) {
  321. return false;
  322. }
  323. var d = this._dates[0] || this.getMoment();
  324. if (this.widget.find('.datepicker').is(':visible')) {
  325. this.date(d.clone().add(1, 'd'));
  326. }
  327. return true;
  328. },
  329. pageUp: function pageUp() {
  330. if (!this.widget) {
  331. return false;
  332. }
  333. var d = this._dates[0] || this.getMoment();
  334. if (this.widget.find('.datepicker').is(':visible')) {
  335. this.date(d.clone().subtract(1, 'M'));
  336. }
  337. return true;
  338. },
  339. pageDown: function pageDown() {
  340. if (!this.widget) {
  341. return false;
  342. }
  343. var d = this._dates[0] || this.getMoment();
  344. if (this.widget.find('.datepicker').is(':visible')) {
  345. this.date(d.clone().add(1, 'M'));
  346. }
  347. return true;
  348. },
  349. enter: function enter() {
  350. if (!this.widget) {
  351. return false;
  352. }
  353. this.hide();
  354. return true;
  355. },
  356. escape: function escape() {
  357. if (!this.widget) {
  358. return false;
  359. }
  360. this.hide();
  361. return true;
  362. },
  363. 'control space': function controlSpace() {
  364. if (!this.widget) {
  365. return false;
  366. }
  367. if (this.widget.find('.timepicker').is(':visible')) {
  368. this.widget.find('.btn[data-action="togglePeriod"]').click();
  369. }
  370. return true;
  371. },
  372. t: function t() {
  373. if (!this.widget) {
  374. return false;
  375. }
  376. this.date(this.getMoment());
  377. return true;
  378. },
  379. 'delete': function _delete() {
  380. if (!this.widget) {
  381. return false;
  382. }
  383. this.clear();
  384. return true;
  385. }
  386. },
  387. debug: false,
  388. allowInputToggle: false,
  389. disabledTimeIntervals: false,
  390. disabledHours: false,
  391. enabledHours: false,
  392. viewDate: false,
  393. allowMultidate: false,
  394. multidateSeparator: ', ',
  395. updateOnlyThroughDateOption: false,
  396. promptTimeOnDateChange: false,
  397. promptTimeOnDateChangeTransitionDelay: 200
  398. }; // ReSharper restore InconsistentNaming
  399. // ReSharper disable once DeclarationHides
  400. // ReSharper disable once InconsistentNaming
  401. var DateTimePicker = /*#__PURE__*/function () {
  402. /** @namespace eData.dateOptions */
  403. /** @namespace moment.tz */
  404. function DateTimePicker(element, options) {
  405. this._options = this._getOptions(options);
  406. this._element = element;
  407. this._dates = [];
  408. this._datesFormatted = [];
  409. this._viewDate = null;
  410. this.unset = true;
  411. this.component = false;
  412. this.widget = false;
  413. this.use24Hours = null;
  414. this.actualFormat = null;
  415. this.parseFormats = null;
  416. this.currentViewMode = null;
  417. this.MinViewModeNumber = 0;
  418. this.isInitFormatting = false;
  419. this.isInit = false;
  420. this.isDateUpdateThroughDateOptionFromClientCode = false;
  421. this.hasInitDate = false;
  422. this.initDate = void 0;
  423. this._notifyChangeEventContext = void 0;
  424. this._currentPromptTimeTimeout = null;
  425. this._int();
  426. }
  427. /**
  428. * @return {string}
  429. */
  430. var _proto = DateTimePicker.prototype;
  431. //private
  432. _proto._int = function _int() {
  433. this.isInit = true;
  434. var targetInput = this._element.data('target-input');
  435. if (this._element.is('input')) {
  436. this.input = this._element;
  437. } else if (targetInput !== undefined) {
  438. if (targetInput === 'nearest') {
  439. this.input = this._element.find('input');
  440. } else {
  441. this.input = $(targetInput);
  442. }
  443. }
  444. this._dates = [];
  445. this._dates[0] = this.getMoment();
  446. this._viewDate = this.getMoment().clone();
  447. $.extend(true, this._options, this._dataToOptions());
  448. this.hasInitDate = false;
  449. this.initDate = void 0;
  450. this.options(this._options);
  451. this.isInitFormatting = true;
  452. this._initFormatting();
  453. this.isInitFormatting = false;
  454. if (this.input !== undefined && this.input.is('input') && this.input.val().trim().length !== 0) {
  455. this._setValue(this._parseInputDate(this.input.val().trim()), 0);
  456. } else if (this._options.defaultDate && this.input !== undefined && this.input.attr('placeholder') === undefined) {
  457. this._setValue(this._options.defaultDate, 0);
  458. }
  459. if (this.hasInitDate) {
  460. this.date(this.initDate);
  461. }
  462. if (this._options.inline) {
  463. this.show();
  464. }
  465. this.isInit = false;
  466. };
  467. _proto._update = function _update() {
  468. if (!this.widget) {
  469. return;
  470. }
  471. this._fillDate();
  472. this._fillTime();
  473. };
  474. _proto._setValue = function _setValue(targetMoment, index) {
  475. var noIndex = typeof index === 'undefined',
  476. isClear = !targetMoment && noIndex,
  477. isDateUpdateThroughDateOptionFromClientCode = this.isDateUpdateThroughDateOptionFromClientCode,
  478. isNotAllowedProgrammaticUpdate = !this.isInit && this._options.updateOnlyThroughDateOption && !isDateUpdateThroughDateOptionFromClientCode;
  479. var outpValue = '',
  480. isInvalid = false,
  481. oldDate = this.unset ? null : this._dates[index];
  482. if (!oldDate && !this.unset && noIndex && isClear) {
  483. oldDate = this._dates[this._dates.length - 1];
  484. } // case of calling setValue(null or false)
  485. if (!targetMoment) {
  486. if (isNotAllowedProgrammaticUpdate) {
  487. this._notifyEvent({
  488. type: DateTimePicker.Event.CHANGE,
  489. date: targetMoment,
  490. oldDate: oldDate,
  491. isClear: isClear,
  492. isInvalid: isInvalid,
  493. isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,
  494. isInit: this.isInit
  495. });
  496. return;
  497. }
  498. if (!this._options.allowMultidate || this._dates.length === 1 || isClear) {
  499. this.unset = true;
  500. this._dates = [];
  501. this._datesFormatted = [];
  502. } else {
  503. outpValue = "" + this._element.data('date') + this._options.multidateSeparator;
  504. outpValue = oldDate && outpValue.replace("" + oldDate.format(this.actualFormat) + this._options.multidateSeparator, '').replace("" + this._options.multidateSeparator + this._options.multidateSeparator, '').replace(new RegExp(escapeRegExp(this._options.multidateSeparator) + "\\s*$"), '') || '';
  505. this._dates.splice(index, 1);
  506. this._datesFormatted.splice(index, 1);
  507. }
  508. outpValue = trim(outpValue);
  509. if (this.input !== undefined) {
  510. this.input.val(outpValue);
  511. this.input.trigger('input');
  512. }
  513. this._element.data('date', outpValue);
  514. this._notifyEvent({
  515. type: DateTimePicker.Event.CHANGE,
  516. date: false,
  517. oldDate: oldDate,
  518. isClear: isClear,
  519. isInvalid: isInvalid,
  520. isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,
  521. isInit: this.isInit
  522. });
  523. this._update();
  524. return;
  525. }
  526. targetMoment = targetMoment.clone().locale(this._options.locale);
  527. if (this._hasTimeZone()) {
  528. targetMoment.tz(this._options.timeZone);
  529. }
  530. if (this._options.stepping !== 1) {
  531. targetMoment.minutes(Math.round(targetMoment.minutes() / this._options.stepping) * this._options.stepping).seconds(0);
  532. }
  533. if (this._isValid(targetMoment)) {
  534. if (isNotAllowedProgrammaticUpdate) {
  535. this._notifyEvent({
  536. type: DateTimePicker.Event.CHANGE,
  537. date: targetMoment.clone(),
  538. oldDate: oldDate,
  539. isClear: isClear,
  540. isInvalid: isInvalid,
  541. isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,
  542. isInit: this.isInit
  543. });
  544. return;
  545. }
  546. this._dates[index] = targetMoment;
  547. this._datesFormatted[index] = targetMoment.format('YYYY-MM-DD');
  548. this._viewDate = targetMoment.clone();
  549. if (this._options.allowMultidate && this._dates.length > 1) {
  550. for (var i = 0; i < this._dates.length; i++) {
  551. outpValue += "" + this._dates[i].format(this.actualFormat) + this._options.multidateSeparator;
  552. }
  553. outpValue = outpValue.replace(new RegExp(this._options.multidateSeparator + "\\s*$"), '');
  554. } else {
  555. outpValue = this._dates[index].format(this.actualFormat);
  556. }
  557. outpValue = trim(outpValue);
  558. if (this.input !== undefined) {
  559. this.input.val(outpValue);
  560. this.input.trigger('input');
  561. }
  562. this._element.data('date', outpValue);
  563. this.unset = false;
  564. this._update();
  565. this._notifyEvent({
  566. type: DateTimePicker.Event.CHANGE,
  567. date: this._dates[index].clone(),
  568. oldDate: oldDate,
  569. isClear: isClear,
  570. isInvalid: isInvalid,
  571. isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,
  572. isInit: this.isInit
  573. });
  574. } else {
  575. isInvalid = true;
  576. if (!this._options.keepInvalid) {
  577. if (this.input !== undefined) {
  578. this.input.val("" + (this.unset ? '' : this._dates[index].format(this.actualFormat)));
  579. this.input.trigger('input');
  580. }
  581. } else {
  582. this._notifyEvent({
  583. type: DateTimePicker.Event.CHANGE,
  584. date: targetMoment,
  585. oldDate: oldDate,
  586. isClear: isClear,
  587. isInvalid: isInvalid,
  588. isDateUpdateThroughDateOptionFromClientCode: isDateUpdateThroughDateOptionFromClientCode,
  589. isInit: this.isInit
  590. });
  591. }
  592. this._notifyEvent({
  593. type: DateTimePicker.Event.ERROR,
  594. date: targetMoment,
  595. oldDate: oldDate
  596. });
  597. }
  598. };
  599. _proto._change = function _change(e) {
  600. var val = $(e.target).val().trim(),
  601. parsedDate = val ? this._parseInputDate(val) : null;
  602. this._setValue(parsedDate, 0);
  603. e.stopImmediatePropagation();
  604. return false;
  605. } //noinspection JSMethodCanBeStatic
  606. ;
  607. _proto._getOptions = function _getOptions(options) {
  608. options = $.extend(true, {}, Default, options && options.icons && options.icons.type === 'feather' ? {
  609. icons: defaultFeatherIcons
  610. } : {}, options);
  611. return options;
  612. };
  613. _proto._hasTimeZone = function _hasTimeZone() {
  614. return moment.tz !== undefined && this._options.timeZone !== undefined && this._options.timeZone !== null && this._options.timeZone !== '';
  615. };
  616. _proto._isEnabled = function _isEnabled(granularity) {
  617. if (typeof granularity !== 'string' || granularity.length > 1) {
  618. throw new TypeError('isEnabled expects a single character string parameter');
  619. }
  620. switch (granularity) {
  621. case 'y':
  622. return this.actualFormat.indexOf('Y') !== -1;
  623. case 'M':
  624. return this.actualFormat.indexOf('M') !== -1;
  625. case 'd':
  626. return this.actualFormat.toLowerCase().indexOf('d') !== -1;
  627. case 'h':
  628. case 'H':
  629. return this.actualFormat.toLowerCase().indexOf('h') !== -1;
  630. case 'm':
  631. return this.actualFormat.indexOf('m') !== -1;
  632. case 's':
  633. return this.actualFormat.indexOf('s') !== -1;
  634. case 'a':
  635. case 'A':
  636. return this.actualFormat.toLowerCase().indexOf('a') !== -1;
  637. default:
  638. return false;
  639. }
  640. };
  641. _proto._hasTime = function _hasTime() {
  642. return this._isEnabled('h') || this._isEnabled('m') || this._isEnabled('s');
  643. };
  644. _proto._hasDate = function _hasDate() {
  645. return this._isEnabled('y') || this._isEnabled('M') || this._isEnabled('d');
  646. };
  647. _proto._dataToOptions = function _dataToOptions() {
  648. var eData = this._element.data();
  649. var dataOptions = {};
  650. if (eData.dateOptions && eData.dateOptions instanceof Object) {
  651. dataOptions = $.extend(true, dataOptions, eData.dateOptions);
  652. }
  653. $.each(this._options, function (key) {
  654. var attributeName = "date" + key.charAt(0).toUpperCase() + key.slice(1); //todo data api key
  655. if (eData[attributeName] !== undefined) {
  656. dataOptions[key] = eData[attributeName];
  657. } else {
  658. delete dataOptions[key];
  659. }
  660. });
  661. return dataOptions;
  662. };
  663. _proto._format = function _format() {
  664. return this._options.format || 'YYYY-MM-DD HH:mm';
  665. };
  666. _proto._areSameDates = function _areSameDates(a, b) {
  667. var format = this._format();
  668. return a && b && (a.isSame(b) || moment(a.format(format), format).isSame(moment(b.format(format), format)));
  669. };
  670. _proto._notifyEvent = function _notifyEvent(e) {
  671. if (e.type === DateTimePicker.Event.CHANGE) {
  672. this._notifyChangeEventContext = this._notifyChangeEventContext || 0;
  673. this._notifyChangeEventContext++;
  674. if (e.date && this._areSameDates(e.date, e.oldDate) || !e.isClear && !e.date && !e.oldDate || this._notifyChangeEventContext > 1) {
  675. this._notifyChangeEventContext = void 0;
  676. return;
  677. }
  678. this._handlePromptTimeIfNeeded(e);
  679. }
  680. this._element.trigger(e);
  681. this._notifyChangeEventContext = void 0;
  682. };
  683. _proto._handlePromptTimeIfNeeded = function _handlePromptTimeIfNeeded(e) {
  684. if (this._options.promptTimeOnDateChange) {
  685. if (!e.oldDate && this._options.useCurrent) {
  686. // First time ever. If useCurrent option is set to true (default), do nothing
  687. // because the first date is selected automatically.
  688. return;
  689. } else if (e.oldDate && e.date && (e.oldDate.format('YYYY-MM-DD') === e.date.format('YYYY-MM-DD') || e.oldDate.format('YYYY-MM-DD') !== e.date.format('YYYY-MM-DD') && e.oldDate.format('HH:mm:ss') !== e.date.format('HH:mm:ss'))) {
  690. // Date didn't change (time did) or date changed because time did.
  691. return;
  692. }
  693. var that = this;
  694. clearTimeout(this._currentPromptTimeTimeout);
  695. this._currentPromptTimeTimeout = setTimeout(function () {
  696. if (that.widget) {
  697. that.widget.find('[data-action="togglePicker"]').click();
  698. }
  699. }, this._options.promptTimeOnDateChangeTransitionDelay);
  700. }
  701. };
  702. _proto._viewUpdate = function _viewUpdate(e) {
  703. if (e === 'y') {
  704. e = 'YYYY';
  705. }
  706. this._notifyEvent({
  707. type: DateTimePicker.Event.UPDATE,
  708. change: e,
  709. viewDate: this._viewDate.clone()
  710. });
  711. };
  712. _proto._showMode = function _showMode(dir) {
  713. if (!this.widget) {
  714. return;
  715. }
  716. if (dir) {
  717. this.currentViewMode = Math.max(this.MinViewModeNumber, Math.min(3, this.currentViewMode + dir));
  718. }
  719. this.widget.find('.datepicker > div').hide().filter(".datepicker-" + DatePickerModes[this.currentViewMode].CLASS_NAME).show();
  720. };
  721. _proto._isInDisabledDates = function _isInDisabledDates(testDate) {
  722. return this._options.disabledDates[testDate.format('YYYY-MM-DD')] === true;
  723. };
  724. _proto._isInEnabledDates = function _isInEnabledDates(testDate) {
  725. return this._options.enabledDates[testDate.format('YYYY-MM-DD')] === true;
  726. };
  727. _proto._isInDisabledHours = function _isInDisabledHours(testDate) {
  728. return this._options.disabledHours[testDate.format('H')] === true;
  729. };
  730. _proto._isInEnabledHours = function _isInEnabledHours(testDate) {
  731. return this._options.enabledHours[testDate.format('H')] === true;
  732. };
  733. _proto._isValid = function _isValid(targetMoment, granularity) {
  734. if (!targetMoment || !targetMoment.isValid()) {
  735. return false;
  736. }
  737. if (this._options.disabledDates && granularity === 'd' && this._isInDisabledDates(targetMoment)) {
  738. return false;
  739. }
  740. if (this._options.enabledDates && granularity === 'd' && !this._isInEnabledDates(targetMoment)) {
  741. return false;
  742. }
  743. if (this._options.minDate && targetMoment.isBefore(this._options.minDate, granularity)) {
  744. return false;
  745. }
  746. if (this._options.maxDate && targetMoment.isAfter(this._options.maxDate, granularity)) {
  747. return false;
  748. }
  749. if (this._options.daysOfWeekDisabled && granularity === 'd' && this._options.daysOfWeekDisabled.indexOf(targetMoment.day()) !== -1) {
  750. return false;
  751. }
  752. if (this._options.disabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && this._isInDisabledHours(targetMoment)) {
  753. return false;
  754. }
  755. if (this._options.enabledHours && (granularity === 'h' || granularity === 'm' || granularity === 's') && !this._isInEnabledHours(targetMoment)) {
  756. return false;
  757. }
  758. if (this._options.disabledTimeIntervals && (granularity === 'h' || granularity === 'm' || granularity === 's')) {
  759. var found = false;
  760. $.each(this._options.disabledTimeIntervals, function () {
  761. if (targetMoment.isBetween(this[0], this[1])) {
  762. found = true;
  763. return false;
  764. }
  765. });
  766. if (found) {
  767. return false;
  768. }
  769. }
  770. return true;
  771. };
  772. _proto._parseInputDate = function _parseInputDate(inputDate, _temp) {
  773. var _ref = _temp === void 0 ? {} : _temp,
  774. _ref$isPickerShow = _ref.isPickerShow,
  775. isPickerShow = _ref$isPickerShow === void 0 ? false : _ref$isPickerShow;
  776. if (this._options.parseInputDate === undefined || isPickerShow) {
  777. if (!moment.isMoment(inputDate)) {
  778. inputDate = this.getMoment(inputDate);
  779. }
  780. } else {
  781. inputDate = this._options.parseInputDate(inputDate);
  782. } //inputDate.locale(this.options.locale);
  783. return inputDate;
  784. };
  785. _proto._keydown = function _keydown(e) {
  786. var handler = null,
  787. index,
  788. index2,
  789. keyBindKeys,
  790. allModifiersPressed;
  791. var pressedKeys = [],
  792. pressedModifiers = {},
  793. currentKey = e.which,
  794. pressed = 'p';
  795. keyState[currentKey] = pressed;
  796. for (index in keyState) {
  797. if (keyState.hasOwnProperty(index) && keyState[index] === pressed) {
  798. pressedKeys.push(index);
  799. if (parseInt(index, 10) !== currentKey) {
  800. pressedModifiers[index] = true;
  801. }
  802. }
  803. }
  804. for (index in this._options.keyBinds) {
  805. if (this._options.keyBinds.hasOwnProperty(index) && typeof this._options.keyBinds[index] === 'function') {
  806. keyBindKeys = index.split(' ');
  807. if (keyBindKeys.length === pressedKeys.length && KeyMap[currentKey] === keyBindKeys[keyBindKeys.length - 1]) {
  808. allModifiersPressed = true;
  809. for (index2 = keyBindKeys.length - 2; index2 >= 0; index2--) {
  810. if (!(KeyMap[keyBindKeys[index2]] in pressedModifiers)) {
  811. allModifiersPressed = false;
  812. break;
  813. }
  814. }
  815. if (allModifiersPressed) {
  816. handler = this._options.keyBinds[index];
  817. break;
  818. }
  819. }
  820. }
  821. }
  822. if (handler) {
  823. if (handler.call(this)) {
  824. e.stopPropagation();
  825. e.preventDefault();
  826. }
  827. }
  828. } //noinspection JSMethodCanBeStatic,SpellCheckingInspection
  829. ;
  830. _proto._keyup = function _keyup(e) {
  831. keyState[e.which] = 'r';
  832. if (keyPressHandled[e.which]) {
  833. keyPressHandled[e.which] = false;
  834. e.stopPropagation();
  835. e.preventDefault();
  836. }
  837. };
  838. _proto._indexGivenDates = function _indexGivenDates(givenDatesArray) {
  839. // Store given enabledDates and disabledDates as keys.
  840. // This way we can check their existence in O(1) time instead of looping through whole array.
  841. // (for example: options.enabledDates['2014-02-27'] === true)
  842. var givenDatesIndexed = {},
  843. self = this;
  844. $.each(givenDatesArray, function () {
  845. var dDate = self._parseInputDate(this);
  846. if (dDate.isValid()) {
  847. givenDatesIndexed[dDate.format('YYYY-MM-DD')] = true;
  848. }
  849. });
  850. return Object.keys(givenDatesIndexed).length ? givenDatesIndexed : false;
  851. };
  852. _proto._indexGivenHours = function _indexGivenHours(givenHoursArray) {
  853. // Store given enabledHours and disabledHours as keys.
  854. // This way we can check their existence in O(1) time instead of looping through whole array.
  855. // (for example: options.enabledHours['2014-02-27'] === true)
  856. var givenHoursIndexed = {};
  857. $.each(givenHoursArray, function () {
  858. givenHoursIndexed[this] = true;
  859. });
  860. return Object.keys(givenHoursIndexed).length ? givenHoursIndexed : false;
  861. };
  862. _proto._initFormatting = function _initFormatting() {
  863. var format = this._options.format || 'L LT',
  864. self = this;
  865. this.actualFormat = format.replace(/(\[[^\[]*])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, function (formatInput) {
  866. return (self.isInitFormatting && self._options.date === null ? self.getMoment() : self._dates[0]).localeData().longDateFormat(formatInput) || formatInput; //todo taking the first date should be ok
  867. });
  868. this.parseFormats = this._options.extraFormats ? this._options.extraFormats.slice() : [];
  869. if (this.parseFormats.indexOf(format) < 0 && this.parseFormats.indexOf(this.actualFormat) < 0) {
  870. this.parseFormats.push(this.actualFormat);
  871. }
  872. this.use24Hours = this.actualFormat.toLowerCase().indexOf('a') < 1 && this.actualFormat.replace(/\[.*?]/g, '').indexOf('h') < 1;
  873. if (this._isEnabled('y')) {
  874. this.MinViewModeNumber = 2;
  875. }
  876. if (this._isEnabled('M')) {
  877. this.MinViewModeNumber = 1;
  878. }
  879. if (this._isEnabled('d')) {
  880. this.MinViewModeNumber = 0;
  881. }
  882. this.currentViewMode = Math.max(this.MinViewModeNumber, this.currentViewMode);
  883. if (!this.unset) {
  884. this._setValue(this._dates[0], 0);
  885. }
  886. };
  887. _proto._getLastPickedDate = function _getLastPickedDate() {
  888. var lastPickedDate = this._dates[this._getLastPickedDateIndex()];
  889. if (!lastPickedDate && this._options.allowMultidate) {
  890. lastPickedDate = moment(new Date());
  891. }
  892. return lastPickedDate;
  893. };
  894. _proto._getLastPickedDateIndex = function _getLastPickedDateIndex() {
  895. return this._dates.length - 1;
  896. } //public
  897. ;
  898. _proto.getMoment = function getMoment(d) {
  899. var returnMoment;
  900. if (d === undefined || d === null) {
  901. // TODO: Should this use format?
  902. returnMoment = moment().clone().locale(this._options.locale);
  903. } else if (this._hasTimeZone()) {
  904. // There is a string to parse and a default time zone
  905. // parse with the tz function which takes a default time zone if it is not in the format string
  906. returnMoment = moment.tz(d, this.parseFormats, this._options.locale, this._options.useStrict, this._options.timeZone);
  907. } else {
  908. returnMoment = moment(d, this.parseFormats, this._options.locale, this._options.useStrict);
  909. }
  910. if (this._hasTimeZone()) {
  911. returnMoment.tz(this._options.timeZone);
  912. }
  913. return returnMoment;
  914. };
  915. _proto.toggle = function toggle() {
  916. return this.widget ? this.hide() : this.show();
  917. };
  918. _proto.readonly = function readonly(_readonly) {
  919. if (arguments.length === 0) {
  920. return this._options.readonly;
  921. }
  922. if (typeof _readonly !== 'boolean') {
  923. throw new TypeError('readonly() expects a boolean parameter');
  924. }
  925. this._options.readonly = _readonly;
  926. if (this.input !== undefined) {
  927. this.input.prop('readonly', this._options.readonly);
  928. }
  929. if (this.widget) {
  930. this.hide();
  931. this.show();
  932. }
  933. };
  934. _proto.ignoreReadonly = function ignoreReadonly(_ignoreReadonly) {
  935. if (arguments.length === 0) {
  936. return this._options.ignoreReadonly;
  937. }
  938. if (typeof _ignoreReadonly !== 'boolean') {
  939. throw new TypeError('ignoreReadonly() expects a boolean parameter');
  940. }
  941. this._options.ignoreReadonly = _ignoreReadonly;
  942. };
  943. _proto.options = function options(newOptions) {
  944. if (arguments.length === 0) {
  945. return $.extend(true, {}, this._options);
  946. }
  947. if (!(newOptions instanceof Object)) {
  948. throw new TypeError('options() this.options parameter should be an object');
  949. }
  950. $.extend(true, this._options, newOptions);
  951. var self = this,
  952. optionsKeys = Object.keys(this._options).sort(optionsSortFn);
  953. $.each(optionsKeys, function (i, key) {
  954. var value = self._options[key];
  955. if (self[key] !== undefined) {
  956. if (self.isInit && key === 'date') {
  957. self.hasInitDate = true;
  958. self.initDate = value;
  959. return;
  960. }
  961. self[key](value);
  962. }
  963. });
  964. };
  965. _proto.date = function date(newDate, index) {
  966. index = index || 0;
  967. if (arguments.length === 0) {
  968. if (this.unset) {
  969. return null;
  970. }
  971. if (this._options.allowMultidate) {
  972. return this._dates.join(this._options.multidateSeparator);
  973. } else {
  974. return this._dates[index].clone();
  975. }
  976. }
  977. if (newDate !== null && typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
  978. throw new TypeError('date() parameter must be one of [null, string, moment or Date]');
  979. }
  980. if (typeof newDate === 'string' && isValidDateTimeStr(newDate)) {
  981. newDate = new Date(newDate);
  982. }
  983. this._setValue(newDate === null ? null : this._parseInputDate(newDate), index);
  984. };
  985. _proto.updateOnlyThroughDateOption = function updateOnlyThroughDateOption(_updateOnlyThroughDateOption) {
  986. if (typeof _updateOnlyThroughDateOption !== 'boolean') {
  987. throw new TypeError('updateOnlyThroughDateOption() expects a boolean parameter');
  988. }
  989. this._options.updateOnlyThroughDateOption = _updateOnlyThroughDateOption;
  990. };
  991. _proto.format = function format(newFormat) {
  992. if (arguments.length === 0) {
  993. return this._options.format;
  994. }
  995. if (typeof newFormat !== 'string' && (typeof newFormat !== 'boolean' || newFormat !== false)) {
  996. throw new TypeError("format() expects a string or boolean:false parameter " + newFormat);
  997. }
  998. this._options.format = newFormat;
  999. if (this.actualFormat) {
  1000. this._initFormatting(); // reinitialize formatting
  1001. }
  1002. };
  1003. _proto.timeZone = function timeZone(newZone) {
  1004. if (arguments.length === 0) {
  1005. return this._options.timeZone;
  1006. }
  1007. if (typeof newZone !== 'string') {
  1008. throw new TypeError('newZone() expects a string parameter');
  1009. }
  1010. this._options.timeZone = newZone;
  1011. };
  1012. _proto.dayViewHeaderFormat = function dayViewHeaderFormat(newFormat) {
  1013. if (arguments.length === 0) {
  1014. return this._options.dayViewHeaderFormat;
  1015. }
  1016. if (typeof newFormat !== 'string') {
  1017. throw new TypeError('dayViewHeaderFormat() expects a string parameter');
  1018. }
  1019. this._options.dayViewHeaderFormat = newFormat;
  1020. };
  1021. _proto.extraFormats = function extraFormats(formats) {
  1022. if (arguments.length === 0) {
  1023. return this._options.extraFormats;
  1024. }
  1025. if (formats !== false && !(formats instanceof Array)) {
  1026. throw new TypeError('extraFormats() expects an array or false parameter');
  1027. }
  1028. this._options.extraFormats = formats;
  1029. if (this.parseFormats) {
  1030. this._initFormatting(); // reinit formatting
  1031. }
  1032. };
  1033. _proto.disabledDates = function disabledDates(dates) {
  1034. if (arguments.length === 0) {
  1035. return this._options.disabledDates ? $.extend({}, this._options.disabledDates) : this._options.disabledDates;
  1036. }
  1037. if (!dates) {
  1038. this._options.disabledDates = false;
  1039. this._update();
  1040. return true;
  1041. }
  1042. if (!(dates instanceof Array)) {
  1043. throw new TypeError('disabledDates() expects an array parameter');
  1044. }
  1045. this._options.disabledDates = this._indexGivenDates(dates);
  1046. this._options.enabledDates = false;
  1047. this._update();
  1048. };
  1049. _proto.enabledDates = function enabledDates(dates) {
  1050. if (arguments.length === 0) {
  1051. return this._options.enabledDates ? $.extend({}, this._options.enabledDates) : this._options.enabledDates;
  1052. }
  1053. if (!dates) {
  1054. this._options.enabledDates = false;
  1055. this._update();
  1056. return true;
  1057. }
  1058. if (!(dates instanceof Array)) {
  1059. throw new TypeError('enabledDates() expects an array parameter');
  1060. }
  1061. this._options.enabledDates = this._indexGivenDates(dates);
  1062. this._options.disabledDates = false;
  1063. this._update();
  1064. };
  1065. _proto.daysOfWeekDisabled = function daysOfWeekDisabled(_daysOfWeekDisabled) {
  1066. if (arguments.length === 0) {
  1067. return this._options.daysOfWeekDisabled.splice(0);
  1068. }
  1069. if (typeof _daysOfWeekDisabled === 'boolean' && !_daysOfWeekDisabled) {
  1070. this._options.daysOfWeekDisabled = false;
  1071. this._update();
  1072. return true;
  1073. }
  1074. if (!(_daysOfWeekDisabled instanceof Array)) {
  1075. throw new TypeError('daysOfWeekDisabled() expects an array parameter');
  1076. }
  1077. this._options.daysOfWeekDisabled = _daysOfWeekDisabled.reduce(function (previousValue, currentValue) {
  1078. currentValue = parseInt(currentValue, 10);
  1079. if (currentValue > 6 || currentValue < 0 || isNaN(currentValue)) {
  1080. return previousValue;
  1081. }
  1082. if (previousValue.indexOf(currentValue) === -1) {
  1083. previousValue.push(currentValue);
  1084. }
  1085. return previousValue;
  1086. }, []).sort();
  1087. if (this._options.useCurrent && !this._options.keepInvalid) {
  1088. for (var i = 0; i < this._dates.length; i++) {
  1089. var tries = 0;
  1090. while (!this._isValid(this._dates[i], 'd')) {
  1091. this._dates[i].add(1, 'd');
  1092. if (tries === 31) {
  1093. throw 'Tried 31 times to find a valid date';
  1094. }
  1095. tries++;
  1096. }
  1097. this._setValue(this._dates[i], i);
  1098. }
  1099. }
  1100. this._update();
  1101. };
  1102. _proto.maxDate = function maxDate(_maxDate) {
  1103. if (arguments.length === 0) {
  1104. return this._options.maxDate ? this._options.maxDate.clone() : this._options.maxDate;
  1105. }
  1106. if (typeof _maxDate === 'boolean' && _maxDate === false) {
  1107. this._options.maxDate = false;
  1108. this._update();
  1109. return true;
  1110. }
  1111. if (typeof _maxDate === 'string') {
  1112. if (_maxDate === 'now' || _maxDate === 'moment') {
  1113. _maxDate = this.getMoment();
  1114. }
  1115. }
  1116. var parsedDate = this._parseInputDate(_maxDate);
  1117. if (!parsedDate.isValid()) {
  1118. throw new TypeError("maxDate() Could not parse date parameter: " + _maxDate);
  1119. }
  1120. if (this._options.minDate && parsedDate.isBefore(this._options.minDate)) {
  1121. throw new TypeError("maxDate() date parameter is before this.options.minDate: " + parsedDate.format(this.actualFormat));
  1122. }
  1123. this._options.maxDate = parsedDate;
  1124. for (var i = 0; i < this._dates.length; i++) {
  1125. if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isAfter(_maxDate)) {
  1126. this._setValue(this._options.maxDate, i);
  1127. }
  1128. }
  1129. if (this._viewDate.isAfter(parsedDate)) {
  1130. this._viewDate = parsedDate.clone().subtract(this._options.stepping, 'm');
  1131. }
  1132. this._update();
  1133. };
  1134. _proto.minDate = function minDate(_minDate) {
  1135. if (arguments.length === 0) {
  1136. return this._options.minDate ? this._options.minDate.clone() : this._options.minDate;
  1137. }
  1138. if (typeof _minDate === 'boolean' && _minDate === false) {
  1139. this._options.minDate = false;
  1140. this._update();
  1141. return true;
  1142. }
  1143. if (typeof _minDate === 'string') {
  1144. if (_minDate === 'now' || _minDate === 'moment') {
  1145. _minDate = this.getMoment();
  1146. }
  1147. }
  1148. var parsedDate = this._parseInputDate(_minDate);
  1149. if (!parsedDate.isValid()) {
  1150. throw new TypeError("minDate() Could not parse date parameter: " + _minDate);
  1151. }
  1152. if (this._options.maxDate && parsedDate.isAfter(this._options.maxDate)) {
  1153. throw new TypeError("minDate() date parameter is after this.options.maxDate: " + parsedDate.format(this.actualFormat));
  1154. }
  1155. this._options.minDate = parsedDate;
  1156. for (var i = 0; i < this._dates.length; i++) {
  1157. if (this._options.useCurrent && !this._options.keepInvalid && this._dates[i].isBefore(_minDate)) {
  1158. this._setValue(this._options.minDate, i);
  1159. }
  1160. }
  1161. if (this._viewDate.isBefore(parsedDate)) {
  1162. this._viewDate = parsedDate.clone().add(this._options.stepping, 'm');
  1163. }
  1164. this._update();
  1165. };
  1166. _proto.defaultDate = function defaultDate(_defaultDate) {
  1167. if (arguments.length === 0) {
  1168. return this._options.defaultDate ? this._options.defaultDate.clone() : this._options.defaultDate;
  1169. }
  1170. if (!_defaultDate) {
  1171. this._options.defaultDate = false;
  1172. return true;
  1173. }
  1174. if (typeof _defaultDate === 'string') {
  1175. if (_defaultDate === 'now' || _defaultDate === 'moment') {
  1176. _defaultDate = this.getMoment();
  1177. } else {
  1178. _defaultDate = this.getMoment(_defaultDate);
  1179. }
  1180. }
  1181. var parsedDate = this._parseInputDate(_defaultDate);
  1182. if (!parsedDate.isValid()) {
  1183. throw new TypeError("defaultDate() Could not parse date parameter: " + _defaultDate);
  1184. }
  1185. if (!this._isValid(parsedDate)) {
  1186. throw new TypeError('defaultDate() date passed is invalid according to component setup validations');
  1187. }
  1188. this._options.defaultDate = parsedDate;
  1189. if (this._options.defaultDate && this._options.inline || this.input !== undefined && this.input.val().trim() === '') {
  1190. this._setValue(this._options.defaultDate, 0);
  1191. }
  1192. };
  1193. _proto.locale = function locale(_locale) {
  1194. if (arguments.length === 0) {
  1195. return this._options.locale;
  1196. }
  1197. if (!moment.localeData(_locale)) {
  1198. throw new TypeError("locale() locale " + _locale + " is not loaded from moment locales!");
  1199. }
  1200. this._options.locale = _locale;
  1201. for (var i = 0; i < this._dates.length; i++) {
  1202. this._dates[i].locale(this._options.locale);
  1203. }
  1204. this._viewDate.locale(this._options.locale);
  1205. if (this.actualFormat) {
  1206. this._initFormatting(); // reinitialize formatting
  1207. }
  1208. if (this.widget) {
  1209. this.hide();
  1210. this.show();
  1211. }
  1212. };
  1213. _proto.stepping = function stepping(_stepping) {
  1214. if (arguments.length === 0) {
  1215. return this._options.stepping;
  1216. }
  1217. _stepping = parseInt(_stepping, 10);
  1218. if (isNaN(_stepping) || _stepping < 1) {
  1219. _stepping = 1;
  1220. }
  1221. this._options.stepping = _stepping;
  1222. };
  1223. _proto.useCurrent = function useCurrent(_useCurrent) {
  1224. var useCurrentOptions = ['year', 'month', 'day', 'hour', 'minute'];
  1225. if (arguments.length === 0) {
  1226. return this._options.useCurrent;
  1227. }
  1228. if (typeof _useCurrent !== 'boolean' && typeof _useCurrent !== 'string') {
  1229. throw new TypeError('useCurrent() expects a boolean or string parameter');
  1230. }
  1231. if (typeof _useCurrent === 'string' && useCurrentOptions.indexOf(_useCurrent.toLowerCase()) === -1) {
  1232. throw new TypeError("useCurrent() expects a string parameter of " + useCurrentOptions.join(', '));
  1233. }
  1234. this._options.useCurrent = _useCurrent;
  1235. };
  1236. _proto.collapse = function collapse(_collapse) {
  1237. if (arguments.length === 0) {
  1238. return this._options.collapse;
  1239. }
  1240. if (typeof _collapse !== 'boolean') {
  1241. throw new TypeError('collapse() expects a boolean parameter');
  1242. }
  1243. if (this._options.collapse === _collapse) {
  1244. return true;
  1245. }
  1246. this._options.collapse = _collapse;
  1247. if (this.widget) {
  1248. this.hide();
  1249. this.show();
  1250. }
  1251. };
  1252. _proto.icons = function icons(_icons) {
  1253. if (arguments.length === 0) {
  1254. return $.extend({}, this._options.icons);
  1255. }
  1256. if (!(_icons instanceof Object)) {
  1257. throw new TypeError('icons() expects parameter to be an Object');
  1258. }
  1259. $.extend(this._options.icons, _icons);
  1260. if (this.widget) {
  1261. this.hide();
  1262. this.show();
  1263. }
  1264. };
  1265. _proto.tooltips = function tooltips(_tooltips) {
  1266. if (arguments.length === 0) {
  1267. return $.extend({}, this._options.tooltips);
  1268. }
  1269. if (!(_tooltips instanceof Object)) {
  1270. throw new TypeError('tooltips() expects parameter to be an Object');
  1271. }
  1272. $.extend(this._options.tooltips, _tooltips);
  1273. if (this.widget) {
  1274. this.hide();
  1275. this.show();
  1276. }
  1277. };
  1278. _proto.useStrict = function useStrict(_useStrict) {
  1279. if (arguments.length === 0) {
  1280. return this._options.useStrict;
  1281. }
  1282. if (typeof _useStrict !== 'boolean') {
  1283. throw new TypeError('useStrict() expects a boolean parameter');
  1284. }
  1285. this._options.useStrict = _useStrict;
  1286. };
  1287. _proto.sideBySide = function sideBySide(_sideBySide) {
  1288. if (arguments.length === 0) {
  1289. return this._options.sideBySide;
  1290. }
  1291. if (typeof _sideBySide !== 'boolean') {
  1292. throw new TypeError('sideBySide() expects a boolean parameter');
  1293. }
  1294. this._options.sideBySide = _sideBySide;
  1295. if (this.widget) {
  1296. this.hide();
  1297. this.show();
  1298. }
  1299. };
  1300. _proto.viewMode = function viewMode(_viewMode) {
  1301. if (arguments.length === 0) {
  1302. return this._options.viewMode;
  1303. }
  1304. if (typeof _viewMode !== 'string') {
  1305. throw new TypeError('viewMode() expects a string parameter');
  1306. }
  1307. if (DateTimePicker.ViewModes.indexOf(_viewMode) === -1) {
  1308. throw new TypeError("viewMode() parameter must be one of (" + DateTimePicker.ViewModes.join(', ') + ") value");
  1309. }
  1310. this._options.viewMode = _viewMode;
  1311. this.currentViewMode = Math.max(DateTimePicker.ViewModes.indexOf(_viewMode) - 1, this.MinViewModeNumber);
  1312. this._showMode();
  1313. };
  1314. _proto.calendarWeeks = function calendarWeeks(_calendarWeeks) {
  1315. if (arguments.length === 0) {
  1316. return this._options.calendarWeeks;
  1317. }
  1318. if (typeof _calendarWeeks !== 'boolean') {
  1319. throw new TypeError('calendarWeeks() expects parameter to be a boolean value');
  1320. }
  1321. this._options.calendarWeeks = _calendarWeeks;
  1322. this._update();
  1323. };
  1324. _proto.buttons = function buttons(_buttons) {
  1325. if (arguments.length === 0) {
  1326. return $.extend({}, this._options.buttons);
  1327. }
  1328. if (!(_buttons instanceof Object)) {
  1329. throw new TypeError('buttons() expects parameter to be an Object');
  1330. }
  1331. $.extend(this._options.buttons, _buttons);
  1332. if (typeof this._options.buttons.showToday !== 'boolean') {
  1333. throw new TypeError('buttons.showToday expects a boolean parameter');
  1334. }
  1335. if (typeof this._options.buttons.showClear !== 'boolean') {
  1336. throw new TypeError('buttons.showClear expects a boolean parameter');
  1337. }
  1338. if (typeof this._options.buttons.showClose !== 'boolean') {
  1339. throw new TypeError('buttons.showClose expects a boolean parameter');
  1340. }
  1341. if (this.widget) {
  1342. this.hide();
  1343. this.show();
  1344. }
  1345. };
  1346. _proto.keepOpen = function keepOpen(_keepOpen) {
  1347. if (arguments.length === 0) {
  1348. return this._options.keepOpen;
  1349. }
  1350. if (typeof _keepOpen !== 'boolean') {
  1351. throw new TypeError('keepOpen() expects a boolean parameter');
  1352. }
  1353. this._options.keepOpen = _keepOpen;
  1354. };
  1355. _proto.focusOnShow = function focusOnShow(_focusOnShow) {
  1356. if (arguments.length === 0) {
  1357. return this._options.focusOnShow;
  1358. }
  1359. if (typeof _focusOnShow !== 'boolean') {
  1360. throw new TypeError('focusOnShow() expects a boolean parameter');
  1361. }
  1362. this._options.focusOnShow = _focusOnShow;
  1363. };
  1364. _proto.inline = function inline(_inline) {
  1365. if (arguments.length === 0) {
  1366. return this._options.inline;
  1367. }
  1368. if (typeof _inline !== 'boolean') {
  1369. throw new TypeError('inline() expects a boolean parameter');
  1370. }
  1371. this._options.inline = _inline;
  1372. };
  1373. _proto.clear = function clear() {
  1374. this._setValue(null); //todo
  1375. };
  1376. _proto.keyBinds = function keyBinds(_keyBinds) {
  1377. if (arguments.length === 0) {
  1378. return this._options.keyBinds;
  1379. }
  1380. this._options.keyBinds = _keyBinds;
  1381. };
  1382. _proto.debug = function debug(_debug) {
  1383. if (typeof _debug !== 'boolean') {
  1384. throw new TypeError('debug() expects a boolean parameter');
  1385. }
  1386. this._options.debug = _debug;
  1387. };
  1388. _proto.allowInputToggle = function allowInputToggle(_allowInputToggle) {
  1389. if (arguments.length === 0) {
  1390. return this._options.allowInputToggle;
  1391. }
  1392. if (typeof _allowInputToggle !== 'boolean') {
  1393. throw new TypeError('allowInputToggle() expects a boolean parameter');
  1394. }
  1395. this._options.allowInputToggle = _allowInputToggle;
  1396. };
  1397. _proto.keepInvalid = function keepInvalid(_keepInvalid) {
  1398. if (arguments.length === 0) {
  1399. return this._options.keepInvalid;
  1400. }
  1401. if (typeof _keepInvalid !== 'boolean') {
  1402. throw new TypeError('keepInvalid() expects a boolean parameter');
  1403. }
  1404. this._options.keepInvalid = _keepInvalid;
  1405. };
  1406. _proto.datepickerInput = function datepickerInput(_datepickerInput) {
  1407. if (arguments.length === 0) {
  1408. return this._options.datepickerInput;
  1409. }
  1410. if (typeof _datepickerInput !== 'string') {
  1411. throw new TypeError('datepickerInput() expects a string parameter');
  1412. }
  1413. this._options.datepickerInput = _datepickerInput;
  1414. };
  1415. _proto.parseInputDate = function parseInputDate(_parseInputDate2) {
  1416. if (arguments.length === 0) {
  1417. return this._options.parseInputDate;
  1418. }
  1419. if (typeof _parseInputDate2 !== 'function') {
  1420. throw new TypeError('parseInputDate() should be as function');
  1421. }
  1422. this._options.parseInputDate = _parseInputDate2;
  1423. };
  1424. _proto.disabledTimeIntervals = function disabledTimeIntervals(_disabledTimeIntervals) {
  1425. if (arguments.length === 0) {
  1426. return this._options.disabledTimeIntervals ? $.extend({}, this._options.disabledTimeIntervals) : this._options.disabledTimeIntervals;
  1427. }
  1428. if (!_disabledTimeIntervals) {
  1429. this._options.disabledTimeIntervals = false;
  1430. this._update();
  1431. return true;
  1432. }
  1433. if (!(_disabledTimeIntervals instanceof Array)) {
  1434. throw new TypeError('disabledTimeIntervals() expects an array parameter');
  1435. }
  1436. this._options.disabledTimeIntervals = _disabledTimeIntervals;
  1437. this._update();
  1438. };
  1439. _proto.disabledHours = function disabledHours(hours) {
  1440. if (arguments.length === 0) {
  1441. return this._options.disabledHours ? $.extend({}, this._options.disabledHours) : this._options.disabledHours;
  1442. }
  1443. if (!hours) {
  1444. this._options.disabledHours = false;
  1445. this._update();
  1446. return true;
  1447. }
  1448. if (!(hours instanceof Array)) {
  1449. throw new TypeError('disabledHours() expects an array parameter');
  1450. }
  1451. this._options.disabledHours = this._indexGivenHours(hours);
  1452. this._options.enabledHours = false;
  1453. if (this._options.useCurrent && !this._options.keepInvalid) {
  1454. for (var i = 0; i < this._dates.length; i++) {
  1455. var tries = 0;
  1456. while (!this._isValid(this._dates[i], 'h')) {
  1457. this._dates[i].add(1, 'h');
  1458. if (tries === 24) {
  1459. throw 'Tried 24 times to find a valid date';
  1460. }
  1461. tries++;
  1462. }
  1463. this._setValue(this._dates[i], i);
  1464. }
  1465. }
  1466. this._update();
  1467. };
  1468. _proto.enabledHours = function enabledHours(hours) {
  1469. if (arguments.length === 0) {
  1470. return this._options.enabledHours ? $.extend({}, this._options.enabledHours) : this._options.enabledHours;
  1471. }
  1472. if (!hours) {
  1473. this._options.enabledHours = false;
  1474. this._update();
  1475. return true;
  1476. }
  1477. if (!(hours instanceof Array)) {
  1478. throw new TypeError('enabledHours() expects an array parameter');
  1479. }
  1480. this._options.enabledHours = this._indexGivenHours(hours);
  1481. this._options.disabledHours = false;
  1482. if (this._options.useCurrent && !this._options.keepInvalid) {
  1483. for (var i = 0; i < this._dates.length; i++) {
  1484. var tries = 0;
  1485. while (!this._isValid(this._dates[i], 'h')) {
  1486. this._dates[i].add(1, 'h');
  1487. if (tries === 24) {
  1488. throw 'Tried 24 times to find a valid date';
  1489. }
  1490. tries++;
  1491. }
  1492. this._setValue(this._dates[i], i);
  1493. }
  1494. }
  1495. this._update();
  1496. };
  1497. _proto.viewDate = function viewDate(newDate) {
  1498. if (arguments.length === 0) {
  1499. return this._viewDate.clone();
  1500. }
  1501. if (!newDate) {
  1502. this._viewDate = (this._dates[0] || this.getMoment()).clone();
  1503. return true;
  1504. }
  1505. if (typeof newDate !== 'string' && !moment.isMoment(newDate) && !(newDate instanceof Date)) {
  1506. throw new TypeError('viewDate() parameter must be one of [string, moment or Date]');
  1507. }
  1508. this._viewDate = this._parseInputDate(newDate);
  1509. this._update();
  1510. this._viewUpdate(DatePickerModes[this.currentViewMode] && DatePickerModes[this.currentViewMode].NAV_FUNCTION);
  1511. };
  1512. _proto._fillDate = function _fillDate() {};
  1513. _proto._useFeatherIcons = function _useFeatherIcons() {
  1514. return this._options.icons.type === 'feather';
  1515. };
  1516. _proto.allowMultidate = function allowMultidate(_allowMultidate) {
  1517. if (typeof _allowMultidate !== 'boolean') {
  1518. throw new TypeError('allowMultidate() expects a boolean parameter');
  1519. }
  1520. this._options.allowMultidate = _allowMultidate;
  1521. };
  1522. _proto.multidateSeparator = function multidateSeparator(_multidateSeparator) {
  1523. if (arguments.length === 0) {
  1524. return this._options.multidateSeparator;
  1525. }
  1526. if (typeof _multidateSeparator !== 'string') {
  1527. throw new TypeError('multidateSeparator expects a string parameter');
  1528. }
  1529. this._options.multidateSeparator = _multidateSeparator;
  1530. };
  1531. _createClass(DateTimePicker, null, [{
  1532. key: "NAME",
  1533. get: function get() {
  1534. return NAME;
  1535. }
  1536. /**
  1537. * @return {string}
  1538. */
  1539. }, {
  1540. key: "DATA_KEY",
  1541. get: function get() {
  1542. return DATA_KEY;
  1543. }
  1544. /**
  1545. * @return {string}
  1546. */
  1547. }, {
  1548. key: "EVENT_KEY",
  1549. get: function get() {
  1550. return EVENT_KEY;
  1551. }
  1552. /**
  1553. * @return {string}
  1554. */
  1555. }, {
  1556. key: "DATA_API_KEY",
  1557. get: function get() {
  1558. return DATA_API_KEY;
  1559. }
  1560. }, {
  1561. key: "DatePickerModes",
  1562. get: function get() {
  1563. return DatePickerModes;
  1564. }
  1565. }, {
  1566. key: "ViewModes",
  1567. get: function get() {
  1568. return ViewModes;
  1569. }
  1570. }, {
  1571. key: "Event",
  1572. get: function get() {
  1573. return Event;
  1574. }
  1575. }, {
  1576. key: "Selector",
  1577. get: function get() {
  1578. return Selector;
  1579. }
  1580. }, {
  1581. key: "Default",
  1582. get: function get() {
  1583. return Default;
  1584. },
  1585. set: function set(value) {
  1586. Default = value;
  1587. }
  1588. }, {
  1589. key: "ClassName",
  1590. get: function get() {
  1591. return ClassName;
  1592. }
  1593. }]);
  1594. return DateTimePicker;
  1595. }();
  1596. return DateTimePicker;
  1597. }(jQuery, moment); //noinspection JSUnusedGlobalSymbols
  1598. /* global DateTimePicker */
  1599. /* global feather */
  1600. var TempusDominusBootstrap4 = function ($) {
  1601. // eslint-disable-line no-unused-vars
  1602. // ReSharper disable once InconsistentNaming
  1603. var JQUERY_NO_CONFLICT = $.fn[DateTimePicker.NAME],
  1604. verticalModes = ['top', 'bottom', 'auto'],
  1605. horizontalModes = ['left', 'right', 'auto'],
  1606. toolbarPlacements = ['default', 'top', 'bottom'],
  1607. getSelectorFromElement = function getSelectorFromElement($element) {
  1608. var selector = $element.data('target'),
  1609. $selector;
  1610. if (!selector) {
  1611. selector = $element.attr('href') || '';
  1612. selector = /^#[a-z]/i.test(selector) ? selector : null;
  1613. }
  1614. $selector = $(selector);
  1615. if ($selector.length === 0) {
  1616. return $element;
  1617. }
  1618. if (!$selector.data(DateTimePicker.DATA_KEY)) {
  1619. $.extend({}, $selector.data(), $(this).data());
  1620. }
  1621. return $selector;
  1622. }; // ReSharper disable once InconsistentNaming
  1623. var TempusDominusBootstrap4 = /*#__PURE__*/function (_DateTimePicker) {
  1624. _inheritsLoose(TempusDominusBootstrap4, _DateTimePicker);
  1625. function TempusDominusBootstrap4(element, options) {
  1626. var _this;
  1627. _this = _DateTimePicker.call(this, element, options) || this;
  1628. _this._init();
  1629. return _this;
  1630. }
  1631. var _proto2 = TempusDominusBootstrap4.prototype;
  1632. _proto2._init = function _init() {
  1633. if (this._element.hasClass('input-group')) {
  1634. var datepickerButton = this._element.find('.datepickerbutton');
  1635. if (datepickerButton.length === 0) {
  1636. this.component = this._element.find('[data-toggle="datetimepicker"]');
  1637. } else {
  1638. this.component = datepickerButton;
  1639. }
  1640. }
  1641. };
  1642. _proto2._iconTag = function _iconTag(iconName) {
  1643. if (typeof feather !== 'undefined' && this._useFeatherIcons() && feather.icons[iconName]) {
  1644. return $('<span>').html(feather.icons[iconName].toSvg());
  1645. } else {
  1646. return $('<span>').addClass(iconName);
  1647. }
  1648. };
  1649. _proto2._getDatePickerTemplate = function _getDatePickerTemplate() {
  1650. var headTemplate = $('<thead>').append($('<tr>').append($('<th>').addClass('prev').attr('data-action', 'previous').append(this._iconTag(this._options.icons.previous))).append($('<th>').addClass('picker-switch').attr('data-action', 'pickerSwitch').attr('colspan', "" + (this._options.calendarWeeks ? '6' : '5'))).append($('<th>').addClass('next').attr('data-action', 'next').append(this._iconTag(this._options.icons.next)))),
  1651. contTemplate = $('<tbody>').append($('<tr>').append($('<td>').attr('colspan', "" + (this._options.calendarWeeks ? '8' : '7'))));
  1652. return [$('<div>').addClass('datepicker-days').append($('<table>').addClass('table table-sm').append(headTemplate).append($('<tbody>'))), $('<div>').addClass('datepicker-months').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-years').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone())), $('<div>').addClass('datepicker-decades').append($('<table>').addClass('table-condensed').append(headTemplate.clone()).append(contTemplate.clone()))];
  1653. };
  1654. _proto2._getTimePickerMainTemplate = function _getTimePickerMainTemplate() {
  1655. var topRow = $('<tr>'),
  1656. middleRow = $('<tr>'),
  1657. bottomRow = $('<tr>');
  1658. if (this._isEnabled('h')) {
  1659. topRow.append($('<td>').append($('<a>').attr({
  1660. href: '#',
  1661. tabindex: '-1',
  1662. 'title': this._options.tooltips.incrementHour
  1663. }).addClass('btn').attr('data-action', 'incrementHours').append(this._iconTag(this._options.icons.up))));
  1664. middleRow.append($('<td>').append($('<span>').addClass('timepicker-hour').attr({
  1665. 'data-time-component': 'hours',
  1666. 'title': this._options.tooltips.pickHour
  1667. }).attr('data-action', 'showHours')));
  1668. bottomRow.append($('<td>').append($('<a>').attr({
  1669. href: '#',
  1670. tabindex: '-1',
  1671. 'title': this._options.tooltips.decrementHour
  1672. }).addClass('btn').attr('data-action', 'decrementHours').append(this._iconTag(this._options.icons.down))));
  1673. }
  1674. if (this._isEnabled('m')) {
  1675. if (this._isEnabled('h')) {
  1676. topRow.append($('<td>').addClass('separator'));
  1677. middleRow.append($('<td>').addClass('separator').html(':'));
  1678. bottomRow.append($('<td>').addClass('separator'));
  1679. }
  1680. topRow.append($('<td>').append($('<a>').attr({
  1681. href: '#',
  1682. tabindex: '-1',
  1683. 'title': this._options.tooltips.incrementMinute
  1684. }).addClass('btn').attr('data-action', 'incrementMinutes').append(this._iconTag(this._options.icons.up))));
  1685. middleRow.append($('<td>').append($('<span>').addClass('timepicker-minute').attr({
  1686. 'data-time-component': 'minutes',
  1687. 'title': this._options.tooltips.pickMinute
  1688. }).attr('data-action', 'showMinutes')));
  1689. bottomRow.append($('<td>').append($('<a>').attr({
  1690. href: '#',
  1691. tabindex: '-1',
  1692. 'title': this._options.tooltips.decrementMinute
  1693. }).addClass('btn').attr('data-action', 'decrementMinutes').append(this._iconTag(this._options.icons.down))));
  1694. }
  1695. if (this._isEnabled('s')) {
  1696. if (this._isEnabled('m')) {
  1697. topRow.append($('<td>').addClass('separator'));
  1698. middleRow.append($('<td>').addClass('separator').html(':'));
  1699. bottomRow.append($('<td>').addClass('separator'));
  1700. }
  1701. topRow.append($('<td>').append($('<a>').attr({
  1702. href: '#',
  1703. tabindex: '-1',
  1704. 'title': this._options.tooltips.incrementSecond
  1705. }).addClass('btn').attr('data-action', 'incrementSeconds').append(this._iconTag(this._options.icons.up))));
  1706. middleRow.append($('<td>').append($('<span>').addClass('timepicker-second').attr({
  1707. 'data-time-component': 'seconds',
  1708. 'title': this._options.tooltips.pickSecond
  1709. }).attr('data-action', 'showSeconds')));
  1710. bottomRow.append($('<td>').append($('<a>').attr({
  1711. href: '#',
  1712. tabindex: '-1',
  1713. 'title': this._options.tooltips.decrementSecond
  1714. }).addClass('btn').attr('data-action', 'decrementSeconds').append(this._iconTag(this._options.icons.down))));
  1715. }
  1716. if (!this.use24Hours) {
  1717. topRow.append($('<td>').addClass('separator'));
  1718. middleRow.append($('<td>').append($('<button>').addClass('btn btn-primary').attr({
  1719. 'data-action': 'togglePeriod',
  1720. tabindex: '-1',
  1721. 'title': this._options.tooltips.togglePeriod
  1722. })));
  1723. bottomRow.append($('<td>').addClass('separator'));
  1724. }
  1725. return $('<div>').addClass('timepicker-picker').append($('<table>').addClass('table-condensed').append([topRow, middleRow, bottomRow]));
  1726. };
  1727. _proto2._getTimePickerTemplate = function _getTimePickerTemplate() {
  1728. var hoursView = $('<div>').addClass('timepicker-hours').append($('<table>').addClass('table-condensed')),
  1729. minutesView = $('<div>').addClass('timepicker-minutes').append($('<table>').addClass('table-condensed')),
  1730. secondsView = $('<div>').addClass('timepicker-seconds').append($('<table>').addClass('table-condensed')),
  1731. ret = [this._getTimePickerMainTemplate()];
  1732. if (this._isEnabled('h')) {
  1733. ret.push(hoursView);
  1734. }
  1735. if (this._isEnabled('m')) {
  1736. ret.push(minutesView);
  1737. }
  1738. if (this._isEnabled('s')) {
  1739. ret.push(secondsView);
  1740. }
  1741. return ret;
  1742. };
  1743. _proto2._getToolbar = function _getToolbar() {
  1744. var row = [];
  1745. if (this._options.buttons.showToday) {
  1746. row.push($('<td>').append($('<a>').attr({
  1747. href: '#',
  1748. tabindex: '-1',
  1749. 'data-action': 'today',
  1750. 'title': this._options.tooltips.today
  1751. }).append(this._iconTag(this._options.icons.today))));
  1752. }
  1753. if (!this._options.sideBySide && this._options.collapse && this._hasDate() && this._hasTime()) {
  1754. var title, icon;
  1755. if (this._options.viewMode === 'times') {
  1756. title = this._options.tooltips.selectDate;
  1757. icon = this._options.icons.date;
  1758. } else {
  1759. title = this._options.tooltips.selectTime;
  1760. icon = this._options.icons.time;
  1761. }
  1762. row.push($('<td>').append($('<a>').attr({
  1763. href: '#',
  1764. tabindex: '-1',
  1765. 'data-action': 'togglePicker',
  1766. 'title': title
  1767. }).append(this._iconTag(icon))));
  1768. }
  1769. if (this._options.buttons.showClear) {
  1770. row.push($('<td>').append($('<a>').attr({
  1771. href: '#',
  1772. tabindex: '-1',
  1773. 'data-action': 'clear',
  1774. 'title': this._options.tooltips.clear
  1775. }).append(this._iconTag(this._options.icons.clear))));
  1776. }
  1777. if (this._options.buttons.showClose) {
  1778. row.push($('<td>').append($('<a>').attr({
  1779. href: '#',
  1780. tabindex: '-1',
  1781. 'data-action': 'close',
  1782. 'title': this._options.tooltips.close
  1783. }).append(this._iconTag(this._options.icons.close))));
  1784. }
  1785. return row.length === 0 ? '' : $('<table>').addClass('table-condensed').append($('<tbody>').append($('<tr>').append(row)));
  1786. };
  1787. _proto2._getTemplate = function _getTemplate() {
  1788. var template = $('<div>').addClass(("bootstrap-datetimepicker-widget dropdown-menu " + (this._options.calendarWeeks ? 'tempusdominus-bootstrap-datetimepicker-widget-with-calendar-weeks' : '') + " " + ((this._useFeatherIcons() ? 'tempusdominus-bootstrap-datetimepicker-widget-with-feather-icons' : '') + " ")).trim()),
  1789. dateView = $('<div>').addClass('datepicker').append(this._getDatePickerTemplate()),
  1790. timeView = $('<div>').addClass('timepicker').append(this._getTimePickerTemplate()),
  1791. content = $('<ul>').addClass('list-unstyled'),
  1792. toolbar = $('<li>').addClass(("picker-switch" + (this._options.collapse ? ' accordion-toggle' : '') + " " + ("" + (this._useFeatherIcons() ? 'picker-switch-with-feathers-icons' : ''))).trim()).append(this._getToolbar());
  1793. if (this._options.inline) {
  1794. template.removeClass('dropdown-menu');
  1795. }
  1796. if (this.use24Hours) {
  1797. template.addClass('usetwentyfour');
  1798. }
  1799. if (this.input !== undefined && this.input.prop('readonly') || this._options.readonly) {
  1800. template.addClass('bootstrap-datetimepicker-widget-readonly');
  1801. }
  1802. if (this._isEnabled('s') && !this.use24Hours) {
  1803. template.addClass('wider');
  1804. }
  1805. if (this._options.sideBySide && this._hasDate() && this._hasTime()) {
  1806. template.addClass('timepicker-sbs');
  1807. if (this._options.toolbarPlacement === 'top') {
  1808. template.append(toolbar);
  1809. }
  1810. template.append($('<div>').addClass('row').append(dateView.addClass('col-md-6')).append(timeView.addClass('col-md-6')));
  1811. if (this._options.toolbarPlacement === 'bottom' || this._options.toolbarPlacement === 'default') {
  1812. template.append(toolbar);
  1813. }
  1814. return template;
  1815. }
  1816. if (this._options.toolbarPlacement === 'top') {
  1817. content.append(toolbar);
  1818. }
  1819. if (this._hasDate()) {
  1820. content.append($('<li>').addClass(this._options.collapse && this._hasTime() ? 'collapse' : '').addClass(this._options.collapse && this._hasTime() && this._options.viewMode === 'times' ? '' : 'show').append(dateView));
  1821. }
  1822. if (this._options.toolbarPlacement === 'default') {
  1823. content.append(toolbar);
  1824. }
  1825. if (this._hasTime()) {
  1826. content.append($('<li>').addClass(this._options.collapse && this._hasDate() ? 'collapse' : '').addClass(this._options.collapse && this._hasDate() && this._options.viewMode === 'times' ? 'show' : '').append(timeView));
  1827. }
  1828. if (this._options.toolbarPlacement === 'bottom') {
  1829. content.append(toolbar);
  1830. }
  1831. return template.append(content);
  1832. };
  1833. _proto2._place = function _place(e) {
  1834. var self = e && e.data && e.data.picker || this,
  1835. vertical = self._options.widgetPositioning.vertical,
  1836. horizontal = self._options.widgetPositioning.horizontal,
  1837. parent;
  1838. var position = (self.component && self.component.length ? self.component : self._element).position(),
  1839. offset = (self.component && self.component.length ? self.component : self._element).offset();
  1840. if (self._options.widgetParent) {
  1841. parent = self._options.widgetParent.append(self.widget);
  1842. } else if (self._element.is('input')) {
  1843. parent = self._element.after(self.widget).parent();
  1844. } else if (self._options.inline) {
  1845. parent = self._element.append(self.widget);
  1846. return;
  1847. } else {
  1848. parent = self._element;
  1849. self._element.children().first().after(self.widget);
  1850. } // Top and bottom logic
  1851. if (vertical === 'auto') {
  1852. //noinspection JSValidateTypes
  1853. if (offset.top + self.widget.height() * 1.5 >= $(window).height() + $(window).scrollTop() && self.widget.height() + self._element.outerHeight() < offset.top) {
  1854. vertical = 'top';
  1855. } else {
  1856. vertical = 'bottom';
  1857. }
  1858. } // Left and right logic
  1859. if (horizontal === 'auto') {
  1860. if (parent.width() < offset.left + self.widget.outerWidth() / 2 && offset.left + self.widget.outerWidth() > $(window).width()) {
  1861. horizontal = 'right';
  1862. } else {
  1863. horizontal = 'left';
  1864. }
  1865. }
  1866. if (vertical === 'top') {
  1867. self.widget.addClass('top').removeClass('bottom');
  1868. } else {
  1869. self.widget.addClass('bottom').removeClass('top');
  1870. }
  1871. if (horizontal === 'right') {
  1872. self.widget.addClass('float-right');
  1873. } else {
  1874. self.widget.removeClass('float-right');
  1875. } // find the first parent element that has a relative css positioning
  1876. if (parent.css('position') !== 'relative') {
  1877. parent = parent.parents().filter(function () {
  1878. return $(this).css('position') === 'relative';
  1879. }).first();
  1880. }
  1881. if (parent.length === 0) {
  1882. throw new Error('datetimepicker component should be placed within a relative positioned container');
  1883. }
  1884. self.widget.css({
  1885. top: vertical === 'top' ? 'auto' : position.top + self._element.outerHeight() + 'px',
  1886. bottom: vertical === 'top' ? parent.outerHeight() - (parent === self._element ? 0 : position.top) + 'px' : 'auto',
  1887. left: horizontal === 'left' ? (parent === self._element ? 0 : position.left) + 'px' : 'auto',
  1888. right: horizontal === 'left' ? 'auto' : parent.outerWidth() - self._element.outerWidth() - (parent === self._element ? 0 : position.left) + 'px'
  1889. });
  1890. };
  1891. _proto2._fillDow = function _fillDow() {
  1892. var row = $('<tr>'),
  1893. currentDate = this._viewDate.clone().startOf('w').startOf('d');
  1894. if (this._options.calendarWeeks === true) {
  1895. row.append($('<th>').addClass('cw').text('#'));
  1896. }
  1897. while (currentDate.isBefore(this._viewDate.clone().endOf('w'))) {
  1898. row.append($('<th>').addClass('dow').text(currentDate.format('dd')));
  1899. currentDate.add(1, 'd');
  1900. }
  1901. this.widget.find('.datepicker-days thead').append(row);
  1902. };
  1903. _proto2._fillMonths = function _fillMonths() {
  1904. var spans = [],
  1905. monthsShort = this._viewDate.clone().startOf('y').startOf('d');
  1906. while (monthsShort.isSame(this._viewDate, 'y')) {
  1907. spans.push($('<span>').attr('data-action', 'selectMonth').addClass('month').text(monthsShort.format('MMM')));
  1908. monthsShort.add(1, 'M');
  1909. }
  1910. this.widget.find('.datepicker-months td').empty().append(spans);
  1911. };
  1912. _proto2._updateMonths = function _updateMonths() {
  1913. var monthsView = this.widget.find('.datepicker-months'),
  1914. monthsViewHeader = monthsView.find('th'),
  1915. months = monthsView.find('tbody').find('span'),
  1916. self = this,
  1917. lastPickedDate = this._getLastPickedDate();
  1918. monthsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevYear);
  1919. monthsViewHeader.eq(1).attr('title', this._options.tooltips.selectYear);
  1920. monthsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextYear);
  1921. monthsView.find('.disabled').removeClass('disabled');
  1922. if (!this._isValid(this._viewDate.clone().subtract(1, 'y'), 'y')) {
  1923. monthsViewHeader.eq(0).addClass('disabled');
  1924. }
  1925. monthsViewHeader.eq(1).text(this._viewDate.year());
  1926. if (!this._isValid(this._viewDate.clone().add(1, 'y'), 'y')) {
  1927. monthsViewHeader.eq(2).addClass('disabled');
  1928. }
  1929. months.removeClass('active');
  1930. if (lastPickedDate && lastPickedDate.isSame(this._viewDate, 'y') && !this.unset) {
  1931. months.eq(lastPickedDate.month()).addClass('active');
  1932. }
  1933. months.each(function (index) {
  1934. if (!self._isValid(self._viewDate.clone().month(index), 'M')) {
  1935. $(this).addClass('disabled');
  1936. }
  1937. });
  1938. };
  1939. _proto2._getStartEndYear = function _getStartEndYear(factor, year) {
  1940. var step = factor / 10,
  1941. startYear = Math.floor(year / factor) * factor,
  1942. endYear = startYear + step * 9,
  1943. focusValue = Math.floor(year / step) * step;
  1944. return [startYear, endYear, focusValue];
  1945. };
  1946. _proto2._updateYears = function _updateYears() {
  1947. var yearsView = this.widget.find('.datepicker-years'),
  1948. yearsViewHeader = yearsView.find('th'),
  1949. yearCaps = this._getStartEndYear(10, this._viewDate.year()),
  1950. startYear = this._viewDate.clone().year(yearCaps[0]),
  1951. endYear = this._viewDate.clone().year(yearCaps[1]);
  1952. var html = '';
  1953. yearsViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevDecade);
  1954. yearsViewHeader.eq(1).attr('title', this._options.tooltips.selectDecade);
  1955. yearsViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextDecade);
  1956. yearsView.find('.disabled').removeClass('disabled');
  1957. if (this._options.minDate && this._options.minDate.isAfter(startYear, 'y')) {
  1958. yearsViewHeader.eq(0).addClass('disabled');
  1959. }
  1960. yearsViewHeader.eq(1).text(startYear.year() + "-" + endYear.year());
  1961. if (this._options.maxDate && this._options.maxDate.isBefore(endYear, 'y')) {
  1962. yearsViewHeader.eq(2).addClass('disabled');
  1963. }
  1964. html += "<span data-action=\"selectYear\" class=\"year old" + (!this._isValid(startYear, 'y') ? ' disabled' : '') + "\">" + (startYear.year() - 1) + "</span>";
  1965. while (!startYear.isAfter(endYear, 'y')) {
  1966. html += "<span data-action=\"selectYear\" class=\"year" + (startYear.isSame(this._getLastPickedDate(), 'y') && !this.unset ? ' active' : '') + (!this._isValid(startYear, 'y') ? ' disabled' : '') + "\">" + startYear.year() + "</span>";
  1967. startYear.add(1, 'y');
  1968. }
  1969. html += "<span data-action=\"selectYear\" class=\"year old" + (!this._isValid(startYear, 'y') ? ' disabled' : '') + "\">" + startYear.year() + "</span>";
  1970. yearsView.find('td').html(html);
  1971. };
  1972. _proto2._updateDecades = function _updateDecades() {
  1973. var decadesView = this.widget.find('.datepicker-decades'),
  1974. decadesViewHeader = decadesView.find('th'),
  1975. yearCaps = this._getStartEndYear(100, this._viewDate.year()),
  1976. startDecade = this._viewDate.clone().year(yearCaps[0]),
  1977. endDecade = this._viewDate.clone().year(yearCaps[1]),
  1978. lastPickedDate = this._getLastPickedDate();
  1979. var minDateDecade = false,
  1980. maxDateDecade = false,
  1981. endDecadeYear,
  1982. html = '';
  1983. decadesViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevCentury);
  1984. decadesViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextCentury);
  1985. decadesView.find('.disabled').removeClass('disabled');
  1986. if (startDecade.year() === 0 || this._options.minDate && this._options.minDate.isAfter(startDecade, 'y')) {
  1987. decadesViewHeader.eq(0).addClass('disabled');
  1988. }
  1989. decadesViewHeader.eq(1).text(startDecade.year() + "-" + endDecade.year());
  1990. if (this._options.maxDate && this._options.maxDate.isBefore(endDecade, 'y')) {
  1991. decadesViewHeader.eq(2).addClass('disabled');
  1992. }
  1993. if (startDecade.year() - 10 < 0) {
  1994. html += '<span>&nbsp;</span>';
  1995. } else {
  1996. html += "<span data-action=\"selectDecade\" class=\"decade old\" data-selection=\"" + (startDecade.year() + 6) + "\">" + (startDecade.year() - 10) + "</span>";
  1997. }
  1998. while (!startDecade.isAfter(endDecade, 'y')) {
  1999. endDecadeYear = startDecade.year() + 11;
  2000. minDateDecade = this._options.minDate && this._options.minDate.isAfter(startDecade, 'y') && this._options.minDate.year() <= endDecadeYear;
  2001. maxDateDecade = this._options.maxDate && this._options.maxDate.isAfter(startDecade, 'y') && this._options.maxDate.year() <= endDecadeYear;
  2002. html += "<span data-action=\"selectDecade\" class=\"decade" + (lastPickedDate && lastPickedDate.isAfter(startDecade) && lastPickedDate.year() <= endDecadeYear ? ' active' : '') + (!this._isValid(startDecade, 'y') && !minDateDecade && !maxDateDecade ? ' disabled' : '') + "\" data-selection=\"" + (startDecade.year() + 6) + "\">" + startDecade.year() + "</span>";
  2003. startDecade.add(10, 'y');
  2004. }
  2005. html += "<span data-action=\"selectDecade\" class=\"decade old\" data-selection=\"" + (startDecade.year() + 6) + "\">" + startDecade.year() + "</span>";
  2006. decadesView.find('td').html(html);
  2007. };
  2008. _proto2._fillDate = function _fillDate() {
  2009. _DateTimePicker.prototype._fillDate.call(this);
  2010. var daysView = this.widget.find('.datepicker-days'),
  2011. daysViewHeader = daysView.find('th'),
  2012. html = [];
  2013. var currentDate, row, clsName, i;
  2014. if (!this._hasDate()) {
  2015. return;
  2016. }
  2017. daysViewHeader.eq(0).find('span').attr('title', this._options.tooltips.prevMonth);
  2018. daysViewHeader.eq(1).attr('title', this._options.tooltips.selectMonth);
  2019. daysViewHeader.eq(2).find('span').attr('title', this._options.tooltips.nextMonth);
  2020. daysView.find('.disabled').removeClass('disabled');
  2021. daysViewHeader.eq(1).text(this._viewDate.format(this._options.dayViewHeaderFormat));
  2022. if (!this._isValid(this._viewDate.clone().subtract(1, 'M'), 'M')) {
  2023. daysViewHeader.eq(0).addClass('disabled');
  2024. }
  2025. if (!this._isValid(this._viewDate.clone().add(1, 'M'), 'M')) {
  2026. daysViewHeader.eq(2).addClass('disabled');
  2027. }
  2028. currentDate = this._viewDate.clone().startOf('M').startOf('w').startOf('d');
  2029. for (i = 0; i < 42; i++) {
  2030. //always display 42 days (should show 6 weeks)
  2031. if (currentDate.weekday() === 0) {
  2032. row = $('<tr>');
  2033. if (this._options.calendarWeeks) {
  2034. row.append("<td class=\"cw\">" + currentDate.week() + "</td>");
  2035. }
  2036. html.push(row);
  2037. }
  2038. clsName = '';
  2039. if (currentDate.isBefore(this._viewDate, 'M')) {
  2040. clsName += ' old';
  2041. }
  2042. if (currentDate.isAfter(this._viewDate, 'M')) {
  2043. clsName += ' new';
  2044. }
  2045. if (this._options.allowMultidate) {
  2046. var index = this._datesFormatted.indexOf(currentDate.format('YYYY-MM-DD'));
  2047. if (index !== -1) {
  2048. if (currentDate.isSame(this._datesFormatted[index], 'd') && !this.unset) {
  2049. clsName += ' active';
  2050. }
  2051. }
  2052. } else {
  2053. if (currentDate.isSame(this._getLastPickedDate(), 'd') && !this.unset) {
  2054. clsName += ' active';
  2055. }
  2056. }
  2057. if (!this._isValid(currentDate, 'd')) {
  2058. clsName += ' disabled';
  2059. }
  2060. if (currentDate.isSame(this.getMoment(), 'd')) {
  2061. clsName += ' today';
  2062. }
  2063. if (currentDate.day() === 0 || currentDate.day() === 6) {
  2064. clsName += ' weekend';
  2065. }
  2066. row.append("<td data-action=\"selectDay\" data-day=\"" + currentDate.format('L') + "\" class=\"day" + clsName + "\">" + currentDate.date() + "</td>");
  2067. currentDate.add(1, 'd');
  2068. }
  2069. $('body').addClass('tempusdominus-bootstrap-datetimepicker-widget-day-click');
  2070. $('body').append('<div class="tempusdominus-bootstrap-datetimepicker-widget-day-click-glass-panel"></div>');
  2071. daysView.find('tbody').empty().append(html);
  2072. $('body').find('.tempusdominus-bootstrap-datetimepicker-widget-day-click-glass-panel').remove();
  2073. $('body').removeClass('tempusdominus-bootstrap-datetimepicker-widget-day-click');
  2074. this._updateMonths();
  2075. this._updateYears();
  2076. this._updateDecades();
  2077. };
  2078. _proto2._fillHours = function _fillHours() {
  2079. var table = this.widget.find('.timepicker-hours table'),
  2080. currentHour = this._viewDate.clone().startOf('d'),
  2081. html = [];
  2082. var row = $('<tr>');
  2083. if (this._viewDate.hour() > 11 && !this.use24Hours) {
  2084. currentHour.hour(12);
  2085. }
  2086. while (currentHour.isSame(this._viewDate, 'd') && (this.use24Hours || this._viewDate.hour() < 12 && currentHour.hour() < 12 || this._viewDate.hour() > 11)) {
  2087. if (currentHour.hour() % 4 === 0) {
  2088. row = $('<tr>');
  2089. html.push(row);
  2090. }
  2091. row.append("<td data-action=\"selectHour\" class=\"hour" + (!this._isValid(currentHour, 'h') ? ' disabled' : '') + "\">" + currentHour.format(this.use24Hours ? 'HH' : 'hh') + "</td>");
  2092. currentHour.add(1, 'h');
  2093. }
  2094. table.empty().append(html);
  2095. };
  2096. _proto2._fillMinutes = function _fillMinutes() {
  2097. var table = this.widget.find('.timepicker-minutes table'),
  2098. currentMinute = this._viewDate.clone().startOf('h'),
  2099. html = [],
  2100. step = this._options.stepping === 1 ? 5 : this._options.stepping;
  2101. var row = $('<tr>');
  2102. while (this._viewDate.isSame(currentMinute, 'h')) {
  2103. if (currentMinute.minute() % (step * 4) === 0) {
  2104. row = $('<tr>');
  2105. html.push(row);
  2106. }
  2107. row.append("<td data-action=\"selectMinute\" class=\"minute" + (!this._isValid(currentMinute, 'm') ? ' disabled' : '') + "\">" + currentMinute.format('mm') + "</td>");
  2108. currentMinute.add(step, 'm');
  2109. }
  2110. table.empty().append(html);
  2111. };
  2112. _proto2._fillSeconds = function _fillSeconds() {
  2113. var table = this.widget.find('.timepicker-seconds table'),
  2114. currentSecond = this._viewDate.clone().startOf('m'),
  2115. html = [];
  2116. var row = $('<tr>');
  2117. while (this._viewDate.isSame(currentSecond, 'm')) {
  2118. if (currentSecond.second() % 20 === 0) {
  2119. row = $('<tr>');
  2120. html.push(row);
  2121. }
  2122. row.append("<td data-action=\"selectSecond\" class=\"second" + (!this._isValid(currentSecond, 's') ? ' disabled' : '') + "\">" + currentSecond.format('ss') + "</td>");
  2123. currentSecond.add(5, 's');
  2124. }
  2125. table.empty().append(html);
  2126. };
  2127. _proto2._fillTime = function _fillTime() {
  2128. var toggle, newDate;
  2129. var timeComponents = this.widget.find('.timepicker span[data-time-component]'),
  2130. lastPickedDate = this._getLastPickedDate();
  2131. if (!this.use24Hours) {
  2132. toggle = this.widget.find('.timepicker [data-action=togglePeriod]');
  2133. newDate = lastPickedDate ? lastPickedDate.clone().add(lastPickedDate.hours() >= 12 ? -12 : 12, 'h') : void 0;
  2134. lastPickedDate && toggle.text(lastPickedDate.format('A'));
  2135. if (this._isValid(newDate, 'h')) {
  2136. toggle.removeClass('disabled');
  2137. } else {
  2138. toggle.addClass('disabled');
  2139. }
  2140. }
  2141. lastPickedDate && timeComponents.filter('[data-time-component=hours]').text(lastPickedDate.format("" + (this.use24Hours ? 'HH' : 'hh')));
  2142. lastPickedDate && timeComponents.filter('[data-time-component=minutes]').text(lastPickedDate.format('mm'));
  2143. lastPickedDate && timeComponents.filter('[data-time-component=seconds]').text(lastPickedDate.format('ss'));
  2144. this._fillHours();
  2145. this._fillMinutes();
  2146. this._fillSeconds();
  2147. };
  2148. _proto2._doAction = function _doAction(e, action) {
  2149. var lastPicked = this._getLastPickedDate();
  2150. if ($(e.currentTarget).is('.disabled')) {
  2151. return false;
  2152. }
  2153. action = action || $(e.currentTarget).data('action');
  2154. switch (action) {
  2155. case 'next':
  2156. {
  2157. var navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION;
  2158. this._viewDate.add(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, navFnc);
  2159. this._fillDate();
  2160. this._viewUpdate(navFnc);
  2161. break;
  2162. }
  2163. case 'previous':
  2164. {
  2165. var _navFnc = DateTimePicker.DatePickerModes[this.currentViewMode].NAV_FUNCTION;
  2166. this._viewDate.subtract(DateTimePicker.DatePickerModes[this.currentViewMode].NAV_STEP, _navFnc);
  2167. this._fillDate();
  2168. this._viewUpdate(_navFnc);
  2169. break;
  2170. }
  2171. case 'pickerSwitch':
  2172. this._showMode(1);
  2173. break;
  2174. case 'selectMonth':
  2175. {
  2176. var month = $(e.target).closest('tbody').find('span').index($(e.target));
  2177. this._viewDate.month(month);
  2178. if (this.currentViewMode === this.MinViewModeNumber) {
  2179. this._setValue(lastPicked.clone().year(this._viewDate.year()).month(this._viewDate.month()), this._getLastPickedDateIndex());
  2180. if (!this._options.inline) {
  2181. this.hide();
  2182. }
  2183. } else {
  2184. this._showMode(-1);
  2185. this._fillDate();
  2186. }
  2187. this._viewUpdate('M');
  2188. break;
  2189. }
  2190. case 'selectYear':
  2191. {
  2192. var year = parseInt($(e.target).text(), 10) || 0;
  2193. this._viewDate.year(year);
  2194. if (this.currentViewMode === this.MinViewModeNumber) {
  2195. this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());
  2196. if (!this._options.inline) {
  2197. this.hide();
  2198. }
  2199. } else {
  2200. this._showMode(-1);
  2201. this._fillDate();
  2202. }
  2203. this._viewUpdate('YYYY');
  2204. break;
  2205. }
  2206. case 'selectDecade':
  2207. {
  2208. var _year = parseInt($(e.target).data('selection'), 10) || 0;
  2209. this._viewDate.year(_year);
  2210. if (this.currentViewMode === this.MinViewModeNumber) {
  2211. this._setValue(lastPicked.clone().year(this._viewDate.year()), this._getLastPickedDateIndex());
  2212. if (!this._options.inline) {
  2213. this.hide();
  2214. }
  2215. } else {
  2216. this._showMode(-1);
  2217. this._fillDate();
  2218. }
  2219. this._viewUpdate('YYYY');
  2220. break;
  2221. }
  2222. case 'selectDay':
  2223. {
  2224. var day = this._viewDate.clone();
  2225. if ($(e.target).is('.old')) {
  2226. day.subtract(1, 'M');
  2227. }
  2228. if ($(e.target).is('.new')) {
  2229. day.add(1, 'M');
  2230. }
  2231. var selectDate = day.date(parseInt($(e.target).text(), 10)),
  2232. index = 0;
  2233. if (this._options.allowMultidate) {
  2234. index = this._datesFormatted.indexOf(selectDate.format('YYYY-MM-DD'));
  2235. if (index !== -1) {
  2236. this._setValue(null, index); //deselect multidate
  2237. } else {
  2238. this._setValue(selectDate, this._getLastPickedDateIndex() + 1);
  2239. }
  2240. } else {
  2241. this._setValue(selectDate, this._getLastPickedDateIndex());
  2242. }
  2243. if (!this._hasTime() && !this._options.keepOpen && !this._options.inline && !this._options.allowMultidate) {
  2244. this.hide();
  2245. }
  2246. break;
  2247. }
  2248. case 'incrementHours':
  2249. {
  2250. if (!lastPicked) {
  2251. break;
  2252. }
  2253. var newDate = lastPicked.clone().add(1, 'h');
  2254. if (this._isValid(newDate, 'h')) {
  2255. if (this._getLastPickedDateIndex() < 0) {
  2256. this.date(newDate);
  2257. }
  2258. this._setValue(newDate, this._getLastPickedDateIndex());
  2259. }
  2260. break;
  2261. }
  2262. case 'incrementMinutes':
  2263. {
  2264. if (!lastPicked) {
  2265. break;
  2266. }
  2267. var _newDate = lastPicked.clone().add(this._options.stepping, 'm');
  2268. if (this._isValid(_newDate, 'm')) {
  2269. if (this._getLastPickedDateIndex() < 0) {
  2270. this.date(_newDate);
  2271. }
  2272. this._setValue(_newDate, this._getLastPickedDateIndex());
  2273. }
  2274. break;
  2275. }
  2276. case 'incrementSeconds':
  2277. {
  2278. if (!lastPicked) {
  2279. break;
  2280. }
  2281. var _newDate2 = lastPicked.clone().add(1, 's');
  2282. if (this._isValid(_newDate2, 's')) {
  2283. if (this._getLastPickedDateIndex() < 0) {
  2284. this.date(_newDate2);
  2285. }
  2286. this._setValue(_newDate2, this._getLastPickedDateIndex());
  2287. }
  2288. break;
  2289. }
  2290. case 'decrementHours':
  2291. {
  2292. if (!lastPicked) {
  2293. break;
  2294. }
  2295. var _newDate3 = lastPicked.clone().subtract(1, 'h');
  2296. if (this._isValid(_newDate3, 'h')) {
  2297. if (this._getLastPickedDateIndex() < 0) {
  2298. this.date(_newDate3);
  2299. }
  2300. this._setValue(_newDate3, this._getLastPickedDateIndex());
  2301. }
  2302. break;
  2303. }
  2304. case 'decrementMinutes':
  2305. {
  2306. if (!lastPicked) {
  2307. break;
  2308. }
  2309. var _newDate4 = lastPicked.clone().subtract(this._options.stepping, 'm');
  2310. if (this._isValid(_newDate4, 'm')) {
  2311. if (this._getLastPickedDateIndex() < 0) {
  2312. this.date(_newDate4);
  2313. }
  2314. this._setValue(_newDate4, this._getLastPickedDateIndex());
  2315. }
  2316. break;
  2317. }
  2318. case 'decrementSeconds':
  2319. {
  2320. if (!lastPicked) {
  2321. break;
  2322. }
  2323. var _newDate5 = lastPicked.clone().subtract(1, 's');
  2324. if (this._isValid(_newDate5, 's')) {
  2325. if (this._getLastPickedDateIndex() < 0) {
  2326. this.date(_newDate5);
  2327. }
  2328. this._setValue(_newDate5, this._getLastPickedDateIndex());
  2329. }
  2330. break;
  2331. }
  2332. case 'togglePeriod':
  2333. {
  2334. this._setValue(lastPicked.clone().add(lastPicked.hours() >= 12 ? -12 : 12, 'h'), this._getLastPickedDateIndex());
  2335. break;
  2336. }
  2337. case 'togglePicker':
  2338. {
  2339. var $this = $(e.target),
  2340. $link = $this.closest('a'),
  2341. $parent = $this.closest('ul'),
  2342. expanded = $parent.find('.show'),
  2343. closed = $parent.find('.collapse:not(.show)'),
  2344. $span = $this.is('span') ? $this : $this.find('span');
  2345. var collapseData, inactiveIcon, iconTest;
  2346. if (expanded && expanded.length) {
  2347. collapseData = expanded.data('collapse');
  2348. if (collapseData && collapseData.transitioning) {
  2349. return true;
  2350. }
  2351. if (expanded.collapse) {
  2352. // if collapse plugin is available through bootstrap.js then use it
  2353. expanded.collapse('hide');
  2354. closed.collapse('show');
  2355. } else {
  2356. // otherwise just toggle in class on the two views
  2357. expanded.removeClass('show');
  2358. closed.addClass('show');
  2359. }
  2360. if (this._useFeatherIcons()) {
  2361. $link.toggleClass(this._options.icons.time + ' ' + this._options.icons.date);
  2362. inactiveIcon = $link.hasClass(this._options.icons.time) ? this._options.icons.date : this._options.icons.time;
  2363. $link.html(this._iconTag(inactiveIcon));
  2364. } else {
  2365. $span.toggleClass(this._options.icons.time + ' ' + this._options.icons.date);
  2366. }
  2367. if (this._useFeatherIcons()) {
  2368. iconTest = $link.hasClass(this._options.icons.date);
  2369. } else {
  2370. iconTest = $span.hasClass(this._options.icons.date);
  2371. }
  2372. if (iconTest) {
  2373. $link.attr('title', this._options.tooltips.selectDate);
  2374. } else {
  2375. $link.attr('title', this._options.tooltips.selectTime);
  2376. }
  2377. }
  2378. }
  2379. break;
  2380. case 'showPicker':
  2381. this.widget.find('.timepicker > div:not(.timepicker-picker)').hide();
  2382. this.widget.find('.timepicker .timepicker-picker').show();
  2383. break;
  2384. case 'showHours':
  2385. this.widget.find('.timepicker .timepicker-picker').hide();
  2386. this.widget.find('.timepicker .timepicker-hours').show();
  2387. break;
  2388. case 'showMinutes':
  2389. this.widget.find('.timepicker .timepicker-picker').hide();
  2390. this.widget.find('.timepicker .timepicker-minutes').show();
  2391. break;
  2392. case 'showSeconds':
  2393. this.widget.find('.timepicker .timepicker-picker').hide();
  2394. this.widget.find('.timepicker .timepicker-seconds').show();
  2395. break;
  2396. case 'selectHour':
  2397. {
  2398. var hour = parseInt($(e.target).text(), 10);
  2399. if (!this.use24Hours) {
  2400. if (lastPicked.hours() >= 12) {
  2401. if (hour !== 12) {
  2402. hour += 12;
  2403. }
  2404. } else {
  2405. if (hour === 12) {
  2406. hour = 0;
  2407. }
  2408. }
  2409. }
  2410. this._setValue(lastPicked.clone().hours(hour), this._getLastPickedDateIndex());
  2411. if (!this._isEnabled('a') && !this._isEnabled('m') && !this._options.keepOpen && !this._options.inline) {
  2412. this.hide();
  2413. } else {
  2414. this._doAction(e, 'showPicker');
  2415. }
  2416. break;
  2417. }
  2418. case 'selectMinute':
  2419. this._setValue(lastPicked.clone().minutes(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex());
  2420. if (!this._isEnabled('a') && !this._isEnabled('s') && !this._options.keepOpen && !this._options.inline) {
  2421. this.hide();
  2422. } else {
  2423. this._doAction(e, 'showPicker');
  2424. }
  2425. break;
  2426. case 'selectSecond':
  2427. this._setValue(lastPicked.clone().seconds(parseInt($(e.target).text(), 10)), this._getLastPickedDateIndex());
  2428. if (!this._isEnabled('a') && !this._options.keepOpen && !this._options.inline) {
  2429. this.hide();
  2430. } else {
  2431. this._doAction(e, 'showPicker');
  2432. }
  2433. break;
  2434. case 'clear':
  2435. this.clear();
  2436. break;
  2437. case 'close':
  2438. this.hide();
  2439. break;
  2440. case 'today':
  2441. {
  2442. var todaysDate = this.getMoment();
  2443. if (this._isValid(todaysDate, 'd')) {
  2444. this._setValue(todaysDate, this._getLastPickedDateIndex());
  2445. }
  2446. break;
  2447. }
  2448. }
  2449. return false;
  2450. } //public
  2451. ;
  2452. _proto2.hide = function hide() {
  2453. var transitioning = false;
  2454. if (!this.widget) {
  2455. return;
  2456. } // Ignore event if in the middle of a picker transition
  2457. this.widget.find('.collapse').each(function () {
  2458. var collapseData = $(this).data('collapse');
  2459. if (collapseData && collapseData.transitioning) {
  2460. transitioning = true;
  2461. return false;
  2462. }
  2463. return true;
  2464. });
  2465. if (transitioning) {
  2466. return;
  2467. }
  2468. if (this.component && this.component.hasClass('btn')) {
  2469. this.component.toggleClass('active');
  2470. }
  2471. this.widget.hide();
  2472. $(window).off('resize', this._place);
  2473. this.widget.off('click', '[data-action]');
  2474. this.widget.off('mousedown', false);
  2475. this.widget.remove();
  2476. this.widget = false;
  2477. if (this.input !== undefined && this.input.val() !== undefined && this.input.val().trim().length !== 0) {
  2478. this._setValue(this._parseInputDate(this.input.val().trim(), {
  2479. isPickerShow: false
  2480. }), 0);
  2481. }
  2482. var lastPickedDate = this._getLastPickedDate();
  2483. this._notifyEvent({
  2484. type: DateTimePicker.Event.HIDE,
  2485. date: this.unset ? null : lastPickedDate ? lastPickedDate.clone() : void 0
  2486. });
  2487. if (this.input !== undefined) {
  2488. this.input.blur();
  2489. }
  2490. this._viewDate = lastPickedDate ? lastPickedDate.clone() : this.getMoment();
  2491. };
  2492. _proto2.show = function show() {
  2493. var currentMoment,
  2494. shouldUseCurrentIfUnset = false;
  2495. var useCurrentGranularity = {
  2496. 'year': function year(m) {
  2497. return m.month(0).date(1).hours(0).seconds(0).minutes(0);
  2498. },
  2499. 'month': function month(m) {
  2500. return m.date(1).hours(0).seconds(0).minutes(0);
  2501. },
  2502. 'day': function day(m) {
  2503. return m.hours(0).seconds(0).minutes(0);
  2504. },
  2505. 'hour': function hour(m) {
  2506. return m.seconds(0).minutes(0);
  2507. },
  2508. 'minute': function minute(m) {
  2509. return m.seconds(0);
  2510. }
  2511. };
  2512. if (this.input !== undefined) {
  2513. if (this.input.prop('disabled') || !this._options.ignoreReadonly && this.input.prop('readonly') || this.widget) {
  2514. return;
  2515. }
  2516. if (this.input.val() !== undefined && this.input.val().trim().length !== 0) {
  2517. this._setValue(this._parseInputDate(this.input.val().trim(), {
  2518. isPickerShow: true
  2519. }), 0);
  2520. } else {
  2521. shouldUseCurrentIfUnset = true;
  2522. }
  2523. } else {
  2524. shouldUseCurrentIfUnset = true;
  2525. }
  2526. if (shouldUseCurrentIfUnset && this.unset && this._options.useCurrent) {
  2527. currentMoment = this.getMoment();
  2528. if (typeof this._options.useCurrent === 'string') {
  2529. currentMoment = useCurrentGranularity[this._options.useCurrent](currentMoment);
  2530. }
  2531. this._setValue(currentMoment, 0);
  2532. }
  2533. this.widget = this._getTemplate();
  2534. this._fillDow();
  2535. this._fillMonths();
  2536. this.widget.find('.timepicker-hours').hide();
  2537. this.widget.find('.timepicker-minutes').hide();
  2538. this.widget.find('.timepicker-seconds').hide();
  2539. this._update();
  2540. this._showMode();
  2541. $(window).on('resize', {
  2542. picker: this
  2543. }, this._place);
  2544. this.widget.on('click', '[data-action]', $.proxy(this._doAction, this)); // this handles clicks on the widget
  2545. this.widget.on('mousedown', false);
  2546. if (this.component && this.component.hasClass('btn')) {
  2547. this.component.toggleClass('active');
  2548. }
  2549. this._place();
  2550. this.widget.show();
  2551. if (this.input !== undefined && this._options.focusOnShow && !this.input.is(':focus')) {
  2552. this.input.focus();
  2553. }
  2554. this._notifyEvent({
  2555. type: DateTimePicker.Event.SHOW
  2556. });
  2557. };
  2558. _proto2.destroy = function destroy() {
  2559. this.hide(); //todo doc off?
  2560. this._element.removeData(DateTimePicker.DATA_KEY);
  2561. this._element.removeData('date');
  2562. };
  2563. _proto2.disable = function disable() {
  2564. this.hide();
  2565. if (this.component && this.component.hasClass('btn')) {
  2566. this.component.addClass('disabled');
  2567. }
  2568. if (this.input !== undefined) {
  2569. this.input.prop('disabled', true); //todo disable this/comp if input is null
  2570. }
  2571. };
  2572. _proto2.enable = function enable() {
  2573. if (this.component && this.component.hasClass('btn')) {
  2574. this.component.removeClass('disabled');
  2575. }
  2576. if (this.input !== undefined) {
  2577. this.input.prop('disabled', false); //todo enable comp/this if input is null
  2578. }
  2579. };
  2580. _proto2.toolbarPlacement = function toolbarPlacement(_toolbarPlacement) {
  2581. if (arguments.length === 0) {
  2582. return this._options.toolbarPlacement;
  2583. }
  2584. if (typeof _toolbarPlacement !== 'string') {
  2585. throw new TypeError('toolbarPlacement() expects a string parameter');
  2586. }
  2587. if (toolbarPlacements.indexOf(_toolbarPlacement) === -1) {
  2588. throw new TypeError("toolbarPlacement() parameter must be one of (" + toolbarPlacements.join(', ') + ") value");
  2589. }
  2590. this._options.toolbarPlacement = _toolbarPlacement;
  2591. if (this.widget) {
  2592. this.hide();
  2593. this.show();
  2594. }
  2595. };
  2596. _proto2.widgetPositioning = function widgetPositioning(_widgetPositioning) {
  2597. if (arguments.length === 0) {
  2598. return $.extend({}, this._options.widgetPositioning);
  2599. }
  2600. if ({}.toString.call(_widgetPositioning) !== '[object Object]') {
  2601. throw new TypeError('widgetPositioning() expects an object variable');
  2602. }
  2603. if (_widgetPositioning.horizontal) {
  2604. if (typeof _widgetPositioning.horizontal !== 'string') {
  2605. throw new TypeError('widgetPositioning() horizontal variable must be a string');
  2606. }
  2607. _widgetPositioning.horizontal = _widgetPositioning.horizontal.toLowerCase();
  2608. if (horizontalModes.indexOf(_widgetPositioning.horizontal) === -1) {
  2609. throw new TypeError("widgetPositioning() expects horizontal parameter to be one of (" + horizontalModes.join(', ') + ")");
  2610. }
  2611. this._options.widgetPositioning.horizontal = _widgetPositioning.horizontal;
  2612. }
  2613. if (_widgetPositioning.vertical) {
  2614. if (typeof _widgetPositioning.vertical !== 'string') {
  2615. throw new TypeError('widgetPositioning() vertical variable must be a string');
  2616. }
  2617. _widgetPositioning.vertical = _widgetPositioning.vertical.toLowerCase();
  2618. if (verticalModes.indexOf(_widgetPositioning.vertical) === -1) {
  2619. throw new TypeError("widgetPositioning() expects vertical parameter to be one of (" + verticalModes.join(', ') + ")");
  2620. }
  2621. this._options.widgetPositioning.vertical = _widgetPositioning.vertical;
  2622. }
  2623. this._update();
  2624. };
  2625. _proto2.widgetParent = function widgetParent(_widgetParent) {
  2626. if (arguments.length === 0) {
  2627. return this._options.widgetParent;
  2628. }
  2629. if (typeof _widgetParent === 'string') {
  2630. _widgetParent = $(_widgetParent);
  2631. }
  2632. if (_widgetParent !== null && typeof _widgetParent !== 'string' && !(_widgetParent instanceof $)) {
  2633. throw new TypeError('widgetParent() expects a string or a jQuery object parameter');
  2634. }
  2635. this._options.widgetParent = _widgetParent;
  2636. if (this.widget) {
  2637. this.hide();
  2638. this.show();
  2639. }
  2640. };
  2641. _proto2.setMultiDate = function setMultiDate(multiDateArray) {
  2642. var dateFormat = this._options.format;
  2643. this.clear();
  2644. for (var index = 0; index < multiDateArray.length; index++) {
  2645. var date = moment(multiDateArray[index], dateFormat);
  2646. this._setValue(date, index);
  2647. }
  2648. } //static
  2649. ;
  2650. TempusDominusBootstrap4._jQueryHandleThis = function _jQueryHandleThis(me, option, argument) {
  2651. var data = $(me).data(DateTimePicker.DATA_KEY);
  2652. if (typeof option === 'object') {
  2653. $.extend({}, DateTimePicker.Default, option);
  2654. }
  2655. if (!data) {
  2656. data = new TempusDominusBootstrap4($(me), option);
  2657. $(me).data(DateTimePicker.DATA_KEY, data);
  2658. }
  2659. if (typeof option === 'string') {
  2660. if (data[option] === undefined) {
  2661. throw new Error("No method named \"" + option + "\"");
  2662. }
  2663. if (argument === undefined) {
  2664. return data[option]();
  2665. } else {
  2666. if (option === 'date') {
  2667. data.isDateUpdateThroughDateOptionFromClientCode = true;
  2668. }
  2669. var ret = data[option](argument);
  2670. data.isDateUpdateThroughDateOptionFromClientCode = false;
  2671. return ret;
  2672. }
  2673. }
  2674. };
  2675. TempusDominusBootstrap4._jQueryInterface = function _jQueryInterface(option, argument) {
  2676. if (this.length === 1) {
  2677. return TempusDominusBootstrap4._jQueryHandleThis(this[0], option, argument);
  2678. }
  2679. return this.each(function () {
  2680. TempusDominusBootstrap4._jQueryHandleThis(this, option, argument);
  2681. });
  2682. };
  2683. return TempusDominusBootstrap4;
  2684. }(DateTimePicker);
  2685. /**
  2686. * ------------------------------------------------------------------------
  2687. * jQuery
  2688. * ------------------------------------------------------------------------
  2689. */
  2690. $(document).on(DateTimePicker.Event.CLICK_DATA_API, DateTimePicker.Selector.DATA_TOGGLE, function () {
  2691. var $originalTarget = $(this),
  2692. $target = getSelectorFromElement($originalTarget),
  2693. config = $target.data(DateTimePicker.DATA_KEY);
  2694. if ($target.length === 0) {
  2695. return;
  2696. }
  2697. if (config._options.allowInputToggle && $originalTarget.is('input[data-toggle="datetimepicker"]')) {
  2698. return;
  2699. }
  2700. TempusDominusBootstrap4._jQueryInterface.call($target, 'toggle');
  2701. }).on(DateTimePicker.Event.CHANGE, "." + DateTimePicker.ClassName.INPUT, function (event) {
  2702. var $target = getSelectorFromElement($(this));
  2703. if ($target.length === 0 || event.isInit) {
  2704. return;
  2705. }
  2706. TempusDominusBootstrap4._jQueryInterface.call($target, '_change', event);
  2707. }).on(DateTimePicker.Event.BLUR, "." + DateTimePicker.ClassName.INPUT, function (event) {
  2708. var $target = getSelectorFromElement($(this)),
  2709. config = $target.data(DateTimePicker.DATA_KEY);
  2710. if ($target.length === 0) {
  2711. return;
  2712. }
  2713. if (config._options.debug || window.debug) {
  2714. return;
  2715. }
  2716. TempusDominusBootstrap4._jQueryInterface.call($target, 'hide', event);
  2717. }).on(DateTimePicker.Event.KEYDOWN, "." + DateTimePicker.ClassName.INPUT, function (event) {
  2718. var $target = getSelectorFromElement($(this));
  2719. if ($target.length === 0) {
  2720. return;
  2721. }
  2722. TempusDominusBootstrap4._jQueryInterface.call($target, '_keydown', event);
  2723. }).on(DateTimePicker.Event.KEYUP, "." + DateTimePicker.ClassName.INPUT, function (event) {
  2724. var $target = getSelectorFromElement($(this));
  2725. if ($target.length === 0) {
  2726. return;
  2727. }
  2728. TempusDominusBootstrap4._jQueryInterface.call($target, '_keyup', event);
  2729. }).on(DateTimePicker.Event.FOCUS, "." + DateTimePicker.ClassName.INPUT, function (event) {
  2730. var $target = getSelectorFromElement($(this)),
  2731. config = $target.data(DateTimePicker.DATA_KEY);
  2732. if ($target.length === 0) {
  2733. return;
  2734. }
  2735. if (!config._options.allowInputToggle) {
  2736. return;
  2737. }
  2738. TempusDominusBootstrap4._jQueryInterface.call($target, 'show', event);
  2739. });
  2740. $.fn[DateTimePicker.NAME] = TempusDominusBootstrap4._jQueryInterface;
  2741. $.fn[DateTimePicker.NAME].Constructor = TempusDominusBootstrap4;
  2742. $.fn[DateTimePicker.NAME].noConflict = function () {
  2743. $.fn[DateTimePicker.NAME] = JQUERY_NO_CONFLICT;
  2744. return TempusDominusBootstrap4._jQueryInterface;
  2745. };
  2746. return TempusDominusBootstrap4;
  2747. }(jQuery);
  2748. }();