"rcfilters-savedqueries-unsetdefault": "Remove as default",
"rcfilters-savedqueries-remove": "Remove",
"rcfilters-savedqueries-new-name-label": "Name",
- "rcfilters-savedqueries-apply-label": "Save settings",
+ "rcfilters-savedqueries-new-name-placeholder": "Describe the purpose of the filter",
+ "rcfilters-savedqueries-apply-label": "Create filter",
"rcfilters-savedqueries-cancel-label": "Cancel",
"rcfilters-savedqueries-add-new-title": "Save current filter settings",
"rcfilters-restore-default-filters": "Restore default filters",
"rcfilters-savedqueries-unsetdefault": "Label for the menu option that unsets a quick filter as default in [[Special:RecentChanges]]",
"rcfilters-savedqueries-remove": "Label for the menu option that removes a quick filter as default in [[Special:RecentChanges]]\n{{Identical|Remove}}",
"rcfilters-savedqueries-new-name-label": "Label for the input that holds the name of the new saved filters in [[Special:RecentChanges]]\n{{Identical|Name}}",
- "rcfilters-savedqueries-apply-label": "Label for the button to apply saving a new filter setting in [[Special:RecentChanges]]",
+ "rcfilters-savedqueries-new-name-placeholder": "Placeholder for the input that holds the name of the new saved filters in [[Special:RecentChanges]]",
+ "rcfilters-savedqueries-apply-label": "Label for the button to apply saving a new filter setting in [[Special:RecentChanges]]. This is for a small popup, please try to use a short string.",
"rcfilters-savedqueries-cancel-label": "Label for the button to cancel the saving of a new quick link in [[Special:RecentChanges]]\n{{Identical|Cancel}}",
- "rcfilters-savedqueries-add-new-title": "Title for the popup to add new quick link in [[Special:RecentChanges]]",
+ "rcfilters-savedqueries-add-new-title": "Title for the popup to add new quick link in [[Special:RecentChanges]]. This is for a small popup, please try to use a short string.",
"rcfilters-restore-default-filters": "Label for the button that resets filters to defaults",
"rcfilters-clear-all-filters": "Title for the button that clears all filters",
"rcfilters-search-placeholder": "Placeholder for the filter search input.",
'rcfilters-savedqueries-unsetdefault',
'rcfilters-savedqueries-remove',
'rcfilters-savedqueries-new-name-label',
+ 'rcfilters-savedqueries-new-name-placeholder',
'rcfilters-savedqueries-add-new-title',
'rcfilters-savedqueries-apply-label',
'rcfilters-savedqueries-cancel-label',
this.popup.$head.prepend( ( new OO.ui.IconWidget( { icon: 'unClip' } ) ).$element );
this.input = new OO.ui.TextInputWidget( {
- validate: /\S/
+ placeholder: mw.msg( 'rcfilters-savedqueries-new-name-placeholder' )
} );
layout = new OO.ui.FieldLayout( this.input, {
label: mw.msg( 'rcfilters-savedqueries-new-name-label' ),
this.popup.connect( this, {
ready: 'onPopupReady'
} );
- this.input.connect( this, { enter: 'onInputEnter' } );
+ this.input.connect( this, {
+ change: 'onInputChange',
+ enter: 'onInputEnter'
+ } );
this.input.$input.on( {
keyup: this.onInputKeyup.bind( this )
} );
this.applyButton.connect( this, { click: 'onApplyButtonClick' } );
// Initialize
+ this.applyButton.setDisabled( !this.input.getValue() );
this.$element
.addClass( 'mw-rcfilters-ui-saveFiltersPopupButtonWidget' );
};
this.apply();
};
+ /**
+ * Respond to input change event
+ *
+ * @param {string} value Input value
+ */
+ mw.rcfilters.ui.SaveFiltersPopupButtonWidget.prototype.onInputChange = function ( value ) {
+ this.applyButton.setDisabled( !value );
+ };
+
/**
* Respond to input keyup event, this is the way to intercept 'escape' key
*
* Apply and add the new quick link
*/
mw.rcfilters.ui.SaveFiltersPopupButtonWidget.prototype.apply = function () {
- var widget = this,
- label = this.input.getValue();
-
- this.input.getValidity()
- .done( function () {
- widget.controller.saveCurrentQuery( label );
- widget.input.setValue( this.input, '' );
- widget.emit( 'saveCurrent' );
- widget.popup.toggle( false );
- } );
+ var label = this.input.getValue();
+
+ // This condition is more for sanity-check, since the
+ // apply button should be disabled if the label is empty
+ if ( label ) {
+ this.controller.saveCurrentQuery( label );
+ this.input.setValue( this.input, '' );
+ this.popup.toggle( false );
+
+ this.emit( 'saveCurrent' );
+ }
};
}( mediaWiki ) );