summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/UploadWizard/resources/details/uw.OtherDetailsWidget.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/UploadWizard/resources/details/uw.OtherDetailsWidget.js')
-rw-r--r--www/wiki/extensions/UploadWizard/resources/details/uw.OtherDetailsWidget.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/www/wiki/extensions/UploadWizard/resources/details/uw.OtherDetailsWidget.js b/www/wiki/extensions/UploadWizard/resources/details/uw.OtherDetailsWidget.js
new file mode 100644
index 00000000..5fe43d87
--- /dev/null
+++ b/www/wiki/extensions/UploadWizard/resources/details/uw.OtherDetailsWidget.js
@@ -0,0 +1,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 ) );