mw.special.apisandbox: Don't pass $label to OO.ui.FieldLayout
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 2 May 2017 16:35:27 +0000 (12:35 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 2 May 2017 16:35:27 +0000 (12:35 -0400)
They removed that functionality. Instead, access the FieldLayout's
$label property to attach the click event handler we need. It's not
documented (I think), but seems stable.

Bug: T164149
Change-Id: I30e7ad51dc1a484203138919c19a55f77552f330

resources/src/mediawiki.special/mediawiki.special.apisandbox.js

index 7cb67b0..3cfce3f 100644 (file)
 
                Util.fetchModuleInfo( this.apiModule )
                        .done( function ( pi ) {
-                               var prefix, i, j, descriptionContainer, widget, $widgetLabel, widgetField, helpField, tmp, flag, count,
+                               var prefix, i, j, descriptionContainer, widget, widgetField, helpField, tmp, flag, count,
                                        items = [],
                                        deprecatedItems = [],
                                        buttons = [],
                                                        }
                                                );
 
-                                               $widgetLabel = $( '<span>' );
                                                widgetField = new OO.ui.FieldLayout(
                                                        widget,
                                                        {
                                                                align: 'left',
                                                                classes: [ 'mw-apisandbox-widget-field' ],
-                                                               label: prefix + pi.parameters[ i ].name,
-                                                               $label: $widgetLabel
+                                                               label: prefix + pi.parameters[ i ].name
                                                        }
                                                );
 
-                                               // FieldLayout only does click for InputElement
-                                               // widgets. So supply our own click handler.
-                                               $widgetLabel.on( 'click', widgetLabelOnClick.bind( widgetField ) );
+                                               // We need our own click handler on the widget label to
+                                               // turn off the disablement.
+                                               widgetField.$label.on( 'click', widgetLabelOnClick.bind( widgetField ) );
 
                                                // Don't grey out the label when the field is disabled,
                                                // it makes it too hard to read and our "disabled"