X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fui%2Fmw.rcfilters.ui.SaveFiltersPopupButtonWidget.js;h=f546d9748e197ab72d6fe29ebb2749db28032740;hb=220bda9175a18458449e9d754fb48830c1f76f25;hp=dfb188d7f81dba7b294dc84389a46dda85fe9f6d;hpb=af420fe8b5e2f56346c58c3bdf8dcb7bd2b10f9b;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.SaveFiltersPopupButtonWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.SaveFiltersPopupButtonWidget.js index dfb188d7f8..f546d9748e 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.SaveFiltersPopupButtonWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.SaveFiltersPopupButtonWidget.js @@ -14,6 +14,7 @@ */ mw.rcfilters.ui.SaveFiltersPopupButtonWidget = function MwRcfiltersUiSaveFiltersPopupButtonWidget( controller, model, config ) { var layout, + checkBoxLayout, $popupContent = $( '
' ); config = config || {}; @@ -25,7 +26,6 @@ mw.rcfilters.ui.SaveFiltersPopupButtonWidget.parent.call( this, $.extend( { framed: false, icon: 'unClip', - $overlay: this.$overlay, title: mw.msg( 'rcfilters-savedqueries-add-new-title' ), popup: { classes: [ 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup' ], @@ -46,6 +46,12 @@ 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' ], @@ -61,6 +67,9 @@ $( '
' ) .addClass( 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup-layout' ) .append( layout.$element ), + $( '
' ) + .addClass( 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup-options' ) + .append( checkBoxLayout.$element ), $( '
' ) .addClass( 'mw-rcfilters-ui-saveFiltersPopupButtonWidget-popup-buttons' ) .append( @@ -80,6 +89,7 @@ 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' } ); @@ -114,7 +124,7 @@ * Respond to input keyup event, this is the way to intercept 'escape' key * * @param {jQuery.Event} e Event data - * @returns {boolean} false + * @return {boolean} false */ mw.rcfilters.ui.SaveFiltersPopupButtonWidget.prototype.onInputKeyup = function ( e ) { if ( e.which === OO.ui.Keys.ESCAPE ) { @@ -130,6 +140,20 @@ 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 */ @@ -153,8 +177,9 @@ // 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' );