From: Alexander Ebert Date: Fri, 12 Aug 2016 15:16:03 +0000 (+0200) Subject: Added option to disable datepicker clear button X-Git-Tag: 3.0.0_Beta_1~762 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3acb6807ab24a0026701da1cd368323c66a198bd;p=GitHub%2FWoltLab%2FWCF.git Added option to disable datepicker clear button --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js index 1bb2f71481..028ea7f590 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js @@ -49,6 +49,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment var isDateTime = (elAttr(element, 'type') === 'datetime'); var isTimeOnly = (isDateTime && elDataBool(element, 'time-only')); + var disableClear = elDataBool(element, 'disable-clear'); elData(element, 'is-date-time', isDateTime); elData(element, 'is-time-only', isTimeOnly); @@ -134,16 +135,18 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment element.parentNode.insertBefore(container, element); container.insertBefore(element, button); - button = elCreate('a'); - button.className = 'inputSuffix button'; - button.addEventListener(WCF_CLICK_EVENT, this.clear.bind(this, element)); - if (isEmpty) button.style.setProperty('visibility', 'hidden', ''); - - container.appendChild(button); - - icon = elCreate('span'); - icon.className = 'icon icon16 fa-times'; - button.appendChild(icon); + if (!disableClear) { + button = elCreate('a'); + button.className = 'inputSuffix button'; + button.addEventListener(WCF_CLICK_EVENT, this.clear.bind(this, element)); + if (isEmpty) button.style.setProperty('visibility', 'hidden', ''); + + container.appendChild(button); + + icon = elCreate('span'); + icon.className = 'icon icon16 fa-times'; + button.appendChild(icon); + } // check if the date input has one of the following classes set otherwise default to 'short' var hasClass = false, knownClasses = ['tiny', 'short', 'medium', 'long']; @@ -161,6 +164,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment clearButton: button, shadow: shadowElement, + disableClear: disableClear, isDateTime: isDateTime, isEmpty: isEmpty, isTimeOnly: isTimeOnly, @@ -484,7 +488,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment _input.value = value; elData(_input, 'value', date.getTime()); - data.clearButton.style.removeProperty('visibility'); + if (!data.disableClear) data.clearButton.style.removeProperty('visibility'); data.shadow.value = shadowValue; }, @@ -718,7 +722,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment element.removeAttribute('data-value'); element.value = ''; - data.clearButton.style.setProperty('visibility', 'hidden', ''); + if (!data.disableClear) data.clearButton.style.setProperty('visibility', 'hidden', ''); data.isEmpty = true; data.shadow.value = ''; },