*/
mw.rcfilters.ui.SaveFiltersPopupButtonWidget = function MwRcfiltersUiSaveFiltersPopupButtonWidget( controller, model, config ) {
var layout,
+ checkBoxLayout,
$popupContent = $( '<div>' );
config = config || {};
align: 'top'
} );
+ this.setAsDefaultCheckbox = new OO.ui.CheckboxInputWidget();
+ checkBoxLayout = new OO.ui.FieldLayout( this.setAsDefaultCheckbox, {
+ label: mw.msg( 'rcfilters-savedqueries-setdefault' ),
+ align: 'inline'
+ } );
+
this.applyButton = new OO.ui.ButtonWidget( {
label: mw.msg( 'rcfilters-savedqueries-apply-label' ),
classes: [ 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup-buttons-apply' ],
$( '<div>' )
.addClass( 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup-layout' )
.append( layout.$element ),
+ $( '<div>' )
+ .addClass( 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup-options' )
+ .append( checkBoxLayout.$element ),
$( '<div>' )
.addClass( 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup-buttons' )
.append(
this.input.$input.on( {
keyup: this.onInputKeyup.bind( this )
} );
+ this.setAsDefaultCheckbox.connect( this, { change: 'onSetAsDefaultChange' } );
this.cancelButton.connect( this, { click: 'onCancelButtonClick' } );
this.applyButton.connect( this, { click: 'onApplyButtonClick' } );
this.input.focus();
};
+ /**
+ * Respond to "set as default" checkbox change
+ * @param {boolean} checked State of the checkbox
+ */
+ mw.rcfilters.ui.SaveFiltersPopupButtonWidget.prototype.onSetAsDefaultChange = function ( checked ) {
+ var messageKey = checked ?
+ 'rcfilters-savedqueries-apply-and-setdefault-label' :
+ 'rcfilters-savedqueries-apply-label';
+
+ this.applyButton
+ .setIcon( checked ? 'pushPin' : null )
+ .setLabel( mw.msg( messageKey ) );
+ };
+
/**
* Respond to cancel button click event
*/
// 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.controller.saveCurrentQuery( label, this.setAsDefaultCheckbox.isSelected() );
this.input.setValue( '' );
+ this.setAsDefaultCheckbox.setSelected( false );
this.popup.toggle( false );
this.emit( 'saveCurrent' );