ui.date_box.base.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /**
  2. * DevExtreme (ui/date_box/ui.date_box.base.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var windowUtils = require("../../core/utils/window");
  11. var window = windowUtils.getWindow();
  12. var registerComponent = require("../../core/component_registrator");
  13. var typeUtils = require("../../core/utils/type");
  14. var dom = require("../../core/utils/dom");
  15. var each = require("../../core/utils/iterator").each;
  16. var compareVersions = require("../../core/utils/version").compare;
  17. var extend = require("../../core/utils/extend").extend;
  18. var support = require("../../core/utils/support");
  19. var devices = require("../../core/devices");
  20. var config = require("../../core/config");
  21. var dateUtils = require("../../core/utils/date");
  22. var uiDateUtils = require("./ui.date_utils");
  23. var dateSerialization = require("../../core/utils/date_serialization");
  24. var DropDownEditor = require("../drop_down_editor/ui.drop_down_editor");
  25. var dateLocalization = require("../../localization/date");
  26. var messageLocalization = require("../../localization/message");
  27. var DATEBOX_CLASS = "dx-datebox";
  28. var DX_AUTO_WIDTH_CLASS = "dx-auto-width";
  29. var DATEBOX_WRAPPER_CLASS = "dx-datebox-wrapper";
  30. var PICKER_TYPE = {
  31. calendar: "calendar",
  32. rollers: "rollers",
  33. list: "list",
  34. "native": "native"
  35. };
  36. var TYPE = {
  37. date: "date",
  38. datetime: "datetime",
  39. time: "time"
  40. };
  41. var STRATEGY_NAME = {
  42. calendar: "Calendar",
  43. dateView: "DateView",
  44. "native": "Native",
  45. calendarWithTime: "CalendarWithTime",
  46. list: "List"
  47. };
  48. var STRATEGY_CLASSES = {
  49. Calendar: require("./ui.date_box.strategy.calendar"),
  50. DateView: require("./ui.date_box.strategy.date_view"),
  51. Native: require("./ui.date_box.strategy.native"),
  52. CalendarWithTime: require("./ui.date_box.strategy.calendar_with_time"),
  53. List: require("./ui.date_box.strategy.list")
  54. };
  55. var isRealWidthSet = function($element) {
  56. var explicitWidth = $element[0].style.width;
  57. if (explicitWidth && "auto" !== explicitWidth && "inherit" !== explicitWidth) {
  58. return true
  59. }
  60. return false
  61. };
  62. var DateBox = DropDownEditor.inherit({
  63. _supportedKeys: function() {
  64. return extend(this.callBase(), this._strategy.supportedKeys())
  65. },
  66. _setDeprecatedOptions: function() {
  67. this.callBase();
  68. extend(this._deprecatedOptions, {
  69. maxZoomLevel: {
  70. since: "18.1",
  71. alias: "calendarOptions.maxZoomLevel"
  72. },
  73. minZoomLevel: {
  74. since: "18.1",
  75. alias: "calendarOptions.minZoomLevel"
  76. }
  77. })
  78. },
  79. _renderButtonContainers: function() {
  80. this.callBase.apply(this, arguments);
  81. this._strategy.customizeButtons()
  82. },
  83. _getDefaultOptions: function() {
  84. return extend(this.callBase(), {
  85. type: "date",
  86. showAnalogClock: true,
  87. value: null,
  88. dateSerializationFormat: void 0,
  89. min: void 0,
  90. max: void 0,
  91. displayFormat: null,
  92. interval: 30,
  93. disabledDates: null,
  94. maxZoomLevel: "month",
  95. minZoomLevel: "century",
  96. pickerType: PICKER_TYPE.calendar,
  97. invalidDateMessage: messageLocalization.format("dxDateBox-validation-datetime"),
  98. dateOutOfRangeMessage: messageLocalization.format("validation-range"),
  99. applyButtonText: messageLocalization.format("OK"),
  100. adaptivityEnabled: false,
  101. calendarOptions: {},
  102. useHiddenSubmitElement: true
  103. })
  104. },
  105. _defaultOptionsRules: function() {
  106. return this.callBase().concat([{
  107. device: {
  108. platform: "ios"
  109. },
  110. options: {
  111. showPopupTitle: true
  112. }
  113. }, {
  114. device: {
  115. platform: "android"
  116. },
  117. options: {
  118. buttonsLocation: "bottom after"
  119. }
  120. }, {
  121. device: function() {
  122. var realDevice = devices.real();
  123. var platform = realDevice.platform;
  124. return "ios" === platform || "android" === platform
  125. },
  126. options: {
  127. pickerType: PICKER_TYPE.native
  128. }
  129. }, {
  130. device: function(_device) {
  131. return "win" === _device.platform && _device.version && 8 === _device.version[0]
  132. },
  133. options: {
  134. buttonsLocation: "bottom after"
  135. }
  136. }, {
  137. device: function(_device2) {
  138. return "win" === _device2.platform && _device2.version && 10 === _device2.version[0]
  139. },
  140. options: {
  141. buttonsLocation: "bottom center"
  142. }
  143. }, {
  144. device: function(currentDevice) {
  145. var realDevice = devices.real();
  146. var platform = realDevice.platform;
  147. var version = realDevice.version;
  148. var isPhone = realDevice.phone;
  149. return "generic" === platform && "desktop" !== currentDevice.deviceType || "win" === platform && isPhone || "android" === platform && compareVersions(version, [4, 4]) < 0
  150. },
  151. options: {
  152. pickerType: PICKER_TYPE.rollers
  153. }
  154. }, {
  155. device: {
  156. platform: "generic",
  157. deviceType: "desktop"
  158. },
  159. options: {
  160. buttonsLocation: "bottom after"
  161. }
  162. }])
  163. },
  164. _initOptions: function(options) {
  165. this._userOptions = extend({}, options);
  166. this.callBase(options);
  167. this._updatePickerOptions()
  168. },
  169. _updatePickerOptions: function() {
  170. var pickerType = this.option("pickerType");
  171. var type = this.option("type");
  172. if (pickerType === PICKER_TYPE.list && (type === TYPE.datetime || type === TYPE.date)) {
  173. pickerType = PICKER_TYPE.calendar
  174. }
  175. if (type === TYPE.time && pickerType === PICKER_TYPE.calendar) {
  176. pickerType = PICKER_TYPE.list
  177. }
  178. this.option("showDropDownButton", "generic" !== devices.real().platform || pickerType !== PICKER_TYPE.native);
  179. this._pickerType = pickerType
  180. },
  181. _init: function() {
  182. this._initStrategy();
  183. this.option(extend({}, this._strategy.getDefaultOptions(), this._userOptions));
  184. delete this._userOptions;
  185. this._skipCustomValidation = false;
  186. this.callBase()
  187. },
  188. _toLowerCaseFirstLetter: function(string) {
  189. return string.charAt(0).toLowerCase() + string.substr(1)
  190. },
  191. _initStrategy: function() {
  192. var strategyName = this._getStrategyName(this._getFormatType());
  193. var strategy = STRATEGY_CLASSES[strategyName];
  194. if (!(this._strategy && this._strategy.NAME === strategyName)) {
  195. this._strategy = new strategy(this)
  196. }
  197. },
  198. _getFormatType: function() {
  199. var currentType = this.option("type");
  200. var isTime = /h|m|s/g.test(currentType);
  201. var isDate = /d|M|Y/g.test(currentType);
  202. var type = "";
  203. if (isDate) {
  204. type += TYPE.date
  205. }
  206. if (isTime) {
  207. type += TYPE.time
  208. }
  209. return type
  210. },
  211. _getStrategyName: function(type) {
  212. var pickerType = this._pickerType;
  213. if (pickerType === PICKER_TYPE.rollers) {
  214. return STRATEGY_NAME.dateView
  215. } else {
  216. if (pickerType === PICKER_TYPE.native) {
  217. return STRATEGY_NAME.native
  218. }
  219. }
  220. if (type === TYPE.date) {
  221. return STRATEGY_NAME.calendar
  222. }
  223. if (type === TYPE.datetime) {
  224. return STRATEGY_NAME.calendarWithTime
  225. }
  226. return STRATEGY_NAME.list
  227. },
  228. _initMarkup: function() {
  229. this.$element().addClass(DATEBOX_CLASS);
  230. this.callBase();
  231. this._refreshFormatClass();
  232. this._refreshPickerTypeClass();
  233. this._strategy.renderInputMinMax(this._input())
  234. },
  235. _render: function() {
  236. this.callBase();
  237. this._updateSize()
  238. },
  239. _renderDimensions: function() {
  240. this.callBase();
  241. this.$element().toggleClass(DX_AUTO_WIDTH_CLASS, !this.option("width"))
  242. },
  243. _refreshFormatClass: function() {
  244. var $element = this.$element();
  245. each(TYPE, function(_, item) {
  246. $element.removeClass(DATEBOX_CLASS + "-" + item)
  247. });
  248. $element.addClass(DATEBOX_CLASS + "-" + this.option("type"))
  249. },
  250. _refreshPickerTypeClass: function() {
  251. var $element = this.$element();
  252. each(PICKER_TYPE, function(_, item) {
  253. $element.removeClass(DATEBOX_CLASS + "-" + item)
  254. });
  255. $element.addClass(DATEBOX_CLASS + "-" + this._pickerType)
  256. },
  257. _updateSize: function() {
  258. var $element = this.$element();
  259. var widthOption = this.option("width");
  260. var isWidthSet = typeUtils.isDefined(widthOption) || isRealWidthSet($element) && !this._isSizeUpdatable;
  261. var pickerType = this._pickerType;
  262. var shouldCalculateWidth = pickerType !== PICKER_TYPE.rollers && "generic" === devices.current().platform;
  263. if (!windowUtils.hasWindow() || isWidthSet || !(shouldCalculateWidth && $element.is(":visible"))) {
  264. return
  265. }
  266. var format = this._strategy.getDisplayFormat(this.option("displayFormat"));
  267. var longestValue = dateLocalization.format(uiDateUtils.getLongestDate(format, dateLocalization.getMonthNames(), dateLocalization.getDayNames()), format);
  268. $element.width(this._calculateWidth(longestValue));
  269. this._isSizeUpdatable = true
  270. },
  271. _calculateWidth: function(value) {
  272. var IE_ROUNDING_ERROR = 10;
  273. var NATIVE_BUTTONS_WIDTH = 48;
  274. var $input = this._input();
  275. var $longestValueElement = dom.createTextElementHiddenCopy($input, value);
  276. $longestValueElement.appendTo(this.$element());
  277. var elementWidth = parseFloat(window.getComputedStyle($longestValueElement.get(0)).width);
  278. var rightPadding = parseFloat(window.getComputedStyle($input.get(0)).paddingRight);
  279. var leftPadding = parseFloat(window.getComputedStyle($input.get(0)).paddingLeft);
  280. var beforeButtonsWidth = this._$beforeButtonsContainer ? parseFloat(window.getComputedStyle(this._$beforeButtonsContainer.get(0)).width) : 0;
  281. var afterButtonsWidth = this._$afterButtonsContainer ? parseFloat(window.getComputedStyle(this._$afterButtonsContainer.get(0)).width) : 0;
  282. var width = elementWidth + rightPadding + leftPadding + IE_ROUNDING_ERROR + beforeButtonsWidth + afterButtonsWidth + ("text" !== $input.prop("type") ? NATIVE_BUTTONS_WIDTH : 0);
  283. $longestValueElement.remove();
  284. return width
  285. },
  286. _attachChildKeyboardEvents: function() {
  287. this._strategy.attachKeyboardEvents(this._keyboardProcessor)
  288. },
  289. _renderPopup: function() {
  290. this.callBase();
  291. this._popup._wrapper().addClass(DATEBOX_WRAPPER_CLASS);
  292. this._renderPopupWrapper()
  293. },
  294. _popupConfig: function() {
  295. var popupConfig = this.callBase();
  296. return extend(this._strategy.popupConfig(popupConfig), {
  297. title: this._getPopupTitle(),
  298. dragEnabled: false
  299. })
  300. },
  301. _renderPopupWrapper: function() {
  302. if (!this._popup) {
  303. return
  304. }
  305. var $element = this.$element();
  306. var classPostfixes = extend({}, TYPE, PICKER_TYPE);
  307. each(classPostfixes, function(_, item) {
  308. $element.removeClass(DATEBOX_WRAPPER_CLASS + "-" + item)
  309. }.bind(this));
  310. this._popup._wrapper().addClass(DATEBOX_WRAPPER_CLASS + "-" + this.option("type")).addClass(DATEBOX_WRAPPER_CLASS + "-" + this._pickerType)
  311. },
  312. _renderPopupContent: function() {
  313. this.callBase();
  314. this._strategy.renderPopupContent()
  315. },
  316. _getFirstPopupElement: function() {
  317. return this._strategy.getFirstPopupElement() || this.callBase()
  318. },
  319. _getLastPopupElement: function() {
  320. return this._strategy.getLastPopupElement() || this.callBase()
  321. },
  322. _popupShowingHandler: function() {
  323. this.callBase();
  324. this._strategy.popupShowingHandler()
  325. },
  326. _popupHiddenHandler: function() {
  327. this.callBase();
  328. this._strategy.popupHiddenHandler()
  329. },
  330. _visibilityChanged: function(visible) {
  331. if (visible) {
  332. this._updateSize()
  333. }
  334. },
  335. _clearValueHandler: function(e) {
  336. this.option("text", "");
  337. this.callBase(e)
  338. },
  339. _readOnlyPropValue: function() {
  340. if (this._pickerType === PICKER_TYPE.rollers) {
  341. return true
  342. }
  343. var platform = devices.real().platform;
  344. var isCustomValueDisabled = this._isNativeType() && ("ios" === platform || "android" === platform);
  345. if (isCustomValueDisabled) {
  346. return this.option("readOnly")
  347. }
  348. return this.callBase()
  349. },
  350. _isClearButtonVisible: function() {
  351. return this.callBase() && !this._isNativeType()
  352. },
  353. _renderValue: function() {
  354. var value = this.dateOption("value");
  355. this.option("text", this._getDisplayedText(value));
  356. this._strategy.renderValue();
  357. return this.callBase()
  358. },
  359. _setSubmitValue: function() {
  360. var value = this.dateOption("value");
  361. var dateSerializationFormat = this.option("dateSerializationFormat");
  362. var submitFormat = uiDateUtils.SUBMIT_FORMATS_MAP[this.option("type")];
  363. var submitValue = dateSerializationFormat ? dateSerialization.serializeDate(value, dateSerializationFormat) : uiDateUtils.toStandardDateFormat(value, submitFormat);
  364. this._getSubmitElement().val(submitValue)
  365. },
  366. _getDisplayedText: function(value) {
  367. var mode = this.option("mode");
  368. var displayedText;
  369. if ("text" === mode) {
  370. var displayFormat = this._strategy.getDisplayFormat(this.option("displayFormat"));
  371. displayedText = dateLocalization.format(value, displayFormat)
  372. } else {
  373. var format = this._getFormatByMode(mode);
  374. if (format) {
  375. displayedText = dateLocalization.format(value, format)
  376. } else {
  377. displayedText = uiDateUtils.toStandardDateFormat(value, mode)
  378. }
  379. }
  380. return displayedText
  381. },
  382. _getFormatByMode: function(mode) {
  383. return support.inputType(mode) ? null : uiDateUtils.FORMATS_MAP[mode]
  384. },
  385. _valueChangeEventHandler: function(e) {
  386. var text = this.option("text");
  387. var currentValue = this.dateOption("value");
  388. if (text === this._getDisplayedText(currentValue)) {
  389. this._validateValue(currentValue);
  390. return
  391. }
  392. var parsedDate = this._getParsedDate(text);
  393. var value = currentValue || this._getDateByDefault();
  394. var type = this.option("type");
  395. var newValue = uiDateUtils.mergeDates(value, parsedDate, type);
  396. var date = parsedDate && "time" === type ? newValue : parsedDate;
  397. if (this._applyInternalValidation(date)) {
  398. var displayedText = this._getDisplayedText(newValue);
  399. if (value && newValue && value.getTime() === newValue.getTime() && displayedText !== text) {
  400. this._renderValue()
  401. } else {
  402. this.dateValue(newValue, e)
  403. }
  404. }
  405. this._applyCustomValidation(newValue)
  406. },
  407. _getDateByDefault: function() {
  408. return this._strategy.useCurrentDateByDefault() && this._strategy.getDefaultDate()
  409. },
  410. _getParsedDate: function(text) {
  411. var displayFormat = this._strategy.getDisplayFormat(this.option("displayFormat"));
  412. var parsedText = this._strategy.getParsedText(text, displayFormat);
  413. return typeUtils.isDefined(parsedText) ? parsedText : void 0
  414. },
  415. _validateValue: function(value) {
  416. var internalResult = this._applyInternalValidation(value);
  417. var customResult = !this._skipCustomValidation ? this._applyCustomValidation(value) : true;
  418. this._skipCustomValidation = false;
  419. return internalResult && customResult
  420. },
  421. _applyInternalValidation: function(value) {
  422. var text = this.option("text");
  423. var hasText = !!text && null !== value;
  424. var isDate = !!value && typeUtils.isDate(value) && !isNaN(value.getTime());
  425. var isDateInRange = isDate && dateUtils.dateInRange(value, this.dateOption("min"), this.dateOption("max"), this.option("type"));
  426. var isValid = !hasText && !value || isDateInRange;
  427. var validationMessage = "";
  428. if (!isDate) {
  429. validationMessage = this.option("invalidDateMessage")
  430. } else {
  431. if (!isDateInRange) {
  432. validationMessage = this.option("dateOutOfRangeMessage")
  433. }
  434. }
  435. this.option({
  436. isValid: isValid,
  437. validationError: isValid ? null : {
  438. editorSpecific: true,
  439. message: validationMessage
  440. }
  441. });
  442. return isValid
  443. },
  444. _applyCustomValidation: function(value) {
  445. this.validationRequest.fire({
  446. editor: this,
  447. value: this._serializeDate(value)
  448. });
  449. return this.option("isValid")
  450. },
  451. _isValueChanged: function(newValue) {
  452. var oldValue = this.dateOption("value");
  453. var oldTime = oldValue && oldValue.getTime();
  454. var newTime = newValue && newValue.getTime();
  455. return oldTime !== newTime
  456. },
  457. _isTextChanged: function(newValue) {
  458. var oldText = this.option("text");
  459. var newText = newValue && this._getDisplayedText(newValue) || "";
  460. return oldText !== newText
  461. },
  462. _renderProps: function() {
  463. this.callBase();
  464. this._input().attr("autocomplete", "off")
  465. },
  466. _renderOpenedState: function() {
  467. if (!this._isNativeType()) {
  468. this.callBase()
  469. }
  470. if (this._strategy.isAdaptivityChanged()) {
  471. this._refreshStrategy()
  472. }
  473. this._strategy.renderOpenedState()
  474. },
  475. _getPopupTitle: function() {
  476. var placeholder = this.option("placeholder");
  477. if (placeholder) {
  478. return placeholder
  479. }
  480. var type = this.option("type");
  481. if (type === TYPE.time) {
  482. return messageLocalization.format("dxDateBox-simulatedDataPickerTitleTime")
  483. }
  484. if (type === TYPE.date || type === TYPE.datetime) {
  485. return messageLocalization.format("dxDateBox-simulatedDataPickerTitleDate")
  486. }
  487. return ""
  488. },
  489. _renderPlaceholder: function() {
  490. this._popup && this._popup.option("title", this._getPopupTitle());
  491. this.callBase()
  492. },
  493. _refreshStrategy: function() {
  494. this._strategy.dispose();
  495. this._initStrategy();
  496. this.option(this._strategy.getDefaultOptions());
  497. this._refresh()
  498. },
  499. _applyButtonHandler: function(e) {
  500. var value = this._strategy.getValue();
  501. if (this._applyInternalValidation(value)) {
  502. this.dateValue(value, e.event)
  503. }
  504. this.callBase()
  505. },
  506. _dispose: function() {
  507. this._strategy && this._strategy.dispose();
  508. this.callBase()
  509. },
  510. _isNativeType: function() {
  511. return this._pickerType === PICKER_TYPE.native
  512. },
  513. _optionChanged: function(args) {
  514. switch (args.name) {
  515. case "showClearButton":
  516. case "buttons":
  517. this.callBase.apply(this, arguments);
  518. this._updateSize();
  519. break;
  520. case "pickerType":
  521. this._updatePickerOptions({
  522. pickerType: args.value
  523. });
  524. this._refreshStrategy();
  525. this._refreshPickerTypeClass();
  526. this._invalidate();
  527. break;
  528. case "type":
  529. this._updatePickerOptions({
  530. format: args.value
  531. });
  532. this._refreshStrategy();
  533. this._refreshFormatClass();
  534. this._renderPopupWrapper();
  535. this._updateSize();
  536. break;
  537. case "placeholder":
  538. this._renderPlaceholder();
  539. break;
  540. case "min":
  541. case "max":
  542. if (this.option("isValid")) {
  543. this._applyInternalValidation(this.dateOption("value"))
  544. } else {
  545. this._validateValue(this.dateOption("value"))
  546. }
  547. this._invalidate();
  548. break;
  549. case "dateSerializationFormat":
  550. case "interval":
  551. case "disabledDates":
  552. case "calendarOptions":
  553. case "minZoomLevel":
  554. case "maxZoomLevel":
  555. this._invalidate();
  556. break;
  557. case "displayFormat":
  558. this.option("text", this._getDisplayedText(this.dateOption("value")));
  559. this._renderInputValue();
  560. break;
  561. case "formatWidthCalculator":
  562. break;
  563. case "closeOnValueChange":
  564. var applyValueMode = args.value ? "instantly" : "useButtons";
  565. this.option("applyValueMode", applyValueMode);
  566. break;
  567. case "applyValueMode":
  568. this._suppressDeprecatedWarnings();
  569. this.option("closeOnValueChange", "instantly" === args.value);
  570. this._resumeDeprecatedWarnings();
  571. this.callBase.apply(this, arguments);
  572. break;
  573. case "text":
  574. this._strategy.textChangedHandler(args.value);
  575. this.callBase.apply(this, arguments);
  576. break;
  577. case "isValid":
  578. this.callBase.apply(this, arguments);
  579. this._updateSize();
  580. break;
  581. case "showDropDownButton":
  582. this._updateSize();
  583. break;
  584. case "readOnly":
  585. this.callBase.apply(this, arguments);
  586. this._updateSize();
  587. break;
  588. case "invalidDateMessage":
  589. case "dateOutOfRangeMessage":
  590. case "adaptivityEnabled":
  591. case "showAnalogClock":
  592. break;
  593. default:
  594. this.callBase.apply(this, arguments)
  595. }
  596. },
  597. _getSerializationFormat: function() {
  598. var value = this.option("value");
  599. if (this.option("dateSerializationFormat") && config().forceIsoDateParsing) {
  600. return this.option("dateSerializationFormat")
  601. }
  602. if (typeUtils.isNumeric(value)) {
  603. return "number"
  604. }
  605. if (!typeUtils.isString(value)) {
  606. return
  607. }
  608. return dateSerialization.getDateSerializationFormat(value)
  609. },
  610. _updateValue: function(value) {
  611. this.callBase();
  612. this._validateValue(value || this.dateOption("value"))
  613. },
  614. dateValue: function(value, dxEvent) {
  615. var isValueChanged = this._isValueChanged(value);
  616. if (isValueChanged && dxEvent) {
  617. this._saveValueChangeEvent(dxEvent)
  618. }
  619. if (!isValueChanged && this._isTextChanged(value)) {
  620. this._updateValue(value)
  621. }
  622. return this.dateOption("value", value)
  623. },
  624. dateOption: function(optionName, value) {
  625. if (1 === arguments.length) {
  626. return dateSerialization.deserializeDate(this.option(optionName))
  627. }
  628. this.option(optionName, this._serializeDate(value))
  629. },
  630. _serializeDate: function(date) {
  631. var serializationFormat = this._getSerializationFormat();
  632. return dateSerialization.serializeDate(date, serializationFormat)
  633. },
  634. reset: function() {
  635. var defaultOptions = this._getDefaultOptions();
  636. this._skipCustomValidation = defaultOptions.value === this.dateOption("value");
  637. this.callBase();
  638. this._updateValue(this.dateOption("value"))
  639. }
  640. });
  641. registerComponent("dxDateBox", DateBox);
  642. module.exports = DateBox;