diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:32:59 -0400 |
commit | 6dc1997577fab2c366781fd7048144935afa0012 (patch) | |
tree | 8918d28c7ab4342f0738985e37af1dfc42d0e93a /resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js | |
parent | 150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff) | |
parent | fa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff) |
Merge commit 'fa89acd'
# Conflicts:
# .gitignore
# extensions/ArchInterWiki.sql
Diffstat (limited to 'resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js')
-rw-r--r-- | resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js new file mode 100644 index 00000000..0c6c15e4 --- /dev/null +++ b/resources/src/mediawiki.widgets/mw.widgets.ComplexTitleInputWidget.js @@ -0,0 +1,63 @@ +/*! + * MediaWiki Widgets - ComplexTitleInputWidget class. + * + * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt + * @license The MIT License (MIT); see LICENSE.txt + */ +( function ( $, mw ) { + + /** + * Like TitleInputWidget, but the namespace has to be input through a separate dropdown field. + * + * @class + * @extends OO.ui.Widget + * + * @constructor + * @param {Object} [config] Configuration options + * @cfg {Object} namespace Configuration for the NamespaceInputWidget dropdown with list of + * namespaces + * @cfg {Object} title Configuration for the TitleInputWidget text field + */ + mw.widgets.ComplexTitleInputWidget = function MwWidgetsComplexTitleInputWidget( config ) { + // Parent constructor + mw.widgets.ComplexTitleInputWidget.parent.call( this, config ); + + // Properties + this.namespace = new mw.widgets.NamespaceInputWidget( config.namespace ); + this.title = new mw.widgets.TitleInputWidget( $.extend( + {}, + config.title, + { + relative: true, + namespace: config.namespace.value || null + } + ) ); + + // Events + this.namespace.connect( this, { change: 'updateTitleNamespace' } ); + + // Initialization + this.$element + .addClass( 'mw-widget-complexTitleInputWidget' ) + .append( + this.namespace.$element, + this.title.$element + ); + this.updateTitleNamespace(); + }; + + /* Setup */ + + OO.inheritClass( mw.widgets.ComplexTitleInputWidget, OO.ui.Widget ); + + /* Methods */ + + /** + * Update the namespace to use for search suggestions of the title when the value of namespace + * dropdown changes. + */ + mw.widgets.ComplexTitleInputWidget.prototype.updateTitleNamespace = function () { + this.title.setNamespace( Number( this.namespace.getValue() ) ); + }; + +}( jQuery, mediaWiki ) ); |