Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

tempusdominus-bootstrap-4.js 136KB

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