summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/UploadWizard/resources/details/uw.OtherDetailsWidget.js
blob: 5fe43d87f787e5d6dd93af3f6d2d88ca6f3d15c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
( function ( mw, uw, $, OO ) {

	/**
	 * An other informations field in UploadWizard's "Details" step form.
	 *
	 * @extends uw.DetailsWidget
	 */
	uw.OtherDetailsWidget = function UWOtherDetailsWidget() {
		uw.OtherDetailsWidget.parent.call( this );

		this.textInput = new OO.ui.MultilineTextInputWidget( {
			classes: [ 'mwe-upwiz-other-textarea', 'mwe-upwiz-otherDetailsWidget-other' ],
			autosize: true,
			rows: 2
		} );

		// Aggregate 'change' event
		// (but do not flash warnings in the user's face while they're typing)
		this.textInput.on( 'change', OO.ui.debounce( this.emit.bind( this, 'change' ), 500 ) );

		this.$element.addClass( 'mwe-upwiz-otherDetailsWidget' );
		this.$element.append(
			this.textInput.$element
		);
	};
	OO.inheritClass( uw.OtherDetailsWidget, uw.DetailsWidget );

	/**
	 * @inheritdoc
	 */
	uw.OtherDetailsWidget.prototype.getWikiText = function () {
		return this.textInput.getValue().trim();
	};

	/**
	 * @inheritdoc
	 * @return {Object} See #setSerialized
	 */
	uw.OtherDetailsWidget.prototype.getSerialized = function () {
		return {
			other: this.textInput.getValue()
		};
	};

	/**
	 * @inheritdoc
	 * @param {Object} serialized
	 * @param {string} serialized.other Other informations text
	 */
	uw.OtherDetailsWidget.prototype.setSerialized = function ( serialized ) {
		this.textInput.setValue( serialized.other );
	};

}( mediaWiki, mediaWiki.uploadWizard, jQuery, OO ) );