From 66172d57717a91163474dd1092a11144b5f6b4e9 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 13 Jan 2019 10:07:23 +0100 Subject: [PATCH] Explicitly support disabled date picker fields Such fields should use the same internal input elements and use the same format for the displayed date but have no UI elements to change or remove the set date. --- .../files/js/WoltLabSuite/Core/Date/Picker.js | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js index 0ca892df87..39551f64f5 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js @@ -156,34 +156,36 @@ define(['DateUtil', 'EventHandler', 'Language', 'ObjectMap', 'Dom/ChangeListener element.addEventListener(WCF_CLICK_EVENT, _callbackOpen); - // create input addon - var container = elCreate('div'); - container.className = 'inputAddon'; - - var button = elCreate('a'); - button.href = '#'; - button.className = 'inputSuffix button jsTooltip'; - button.addEventListener(WCF_CLICK_EVENT, _callbackOpen); - container.appendChild(button); - - var icon = elCreate('span'); - icon.className = 'icon icon16 fa-calendar'; - button.appendChild(icon); - - element.parentNode.insertBefore(container, element); - container.insertBefore(element, button); - - 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', ''); + if (!element.disabled) { + // create input addon + var container = elCreate('div'); + container.className = 'inputAddon'; + var button = elCreate('a'); + button.href = '#'; + button.className = 'inputSuffix button jsTooltip'; + button.addEventListener(WCF_CLICK_EVENT, _callbackOpen); container.appendChild(button); - icon = elCreate('span'); - icon.className = 'icon icon16 fa-times'; + var icon = elCreate('span'); + icon.className = 'icon icon16 fa-calendar'; button.appendChild(icon); + + element.parentNode.insertBefore(container, element); + container.insertBefore(element, button); + + 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' -- 2.20.1