Explicitly support disabled date picker fields
authorMatthias Schmidt <gravatronics@live.com>
Sun, 13 Jan 2019 09:07:23 +0000 (10:07 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 13 Jan 2019 09:07:23 +0000 (10:07 +0100)
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.

wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js

index 0ca892df87d5dd73ff5f316878a26e6ca405706b..39551f64f5bdc08870dae2b1c2148c436e0d9d68 100644 (file)
@@ -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'