X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/resources/src/mediawiki.widgets/mw.widgets.ComplexNamespaceInputWidget.js diff --git a/resources/src/mediawiki.widgets/mw.widgets.ComplexNamespaceInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.ComplexNamespaceInputWidget.js new file mode 100644 index 00000000..9edd0bd9 --- /dev/null +++ b/resources/src/mediawiki.widgets/mw.widgets.ComplexNamespaceInputWidget.js @@ -0,0 +1,136 @@ +/*! + * MediaWiki Widgets - ComplexNamespaceInputWidget class. + * + * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ +( function ( $, mw ) { + + /** + * Namespace input widget. Displays a dropdown box with the choice of available namespaces, plus + * two checkboxes to include associated namespace or to invert selection. + * + * @class + * @extends OO.ui.Widget + * + * @constructor + * @param {Object} [config] Configuration options + * @cfg {Object} namespace Configuration for the NamespaceInputWidget dropdown with list + * of namespaces + * @cfg {string} namespace.includeAllValue If specified, add a "all namespaces" + * option to the dropdown, and use this as the input value for it + * @cfg {Object} invert Configuration for the "invert selection" CheckboxInputWidget. If + * null, the checkbox will not be generated. + * @cfg {Object} associated Configuration for the "include associated namespace" + * CheckboxInputWidget. If null, the checkbox will not be generated. + * @cfg {Object} invertLabel Configuration for the FieldLayout with label wrapping the + * "invert selection" checkbox + * @cfg {string} invertLabel.label Label text for the label + * @cfg {Object} associatedLabel Configuration for the FieldLayout with label wrapping + * the "include associated namespace" checkbox + * @cfg {string} associatedLabel.label Label text for the label + */ + mw.widgets.ComplexNamespaceInputWidget = function MwWidgetsComplexNamespaceInputWidget( config ) { + // Configuration initialization + config = $.extend( + { + // Config options for nested widgets + namespace: {}, + invert: {}, + invertLabel: {}, + associated: {}, + associatedLabel: {} + }, + config + ); + + // Parent constructor + mw.widgets.ComplexNamespaceInputWidget.parent.call( this, config ); + + // Properties + this.config = config; + + this.namespace = new mw.widgets.NamespaceInputWidget( config.namespace ); + if ( config.associated !== null ) { + this.associated = new OO.ui.CheckboxInputWidget( $.extend( + { value: '1' }, + config.associated + ) ); + // TODO Should use a LabelWidget? But they don't work like HTML