X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.rcfilters%2Fui%2FFilterWrapperWidget.js;h=ce9656eb27ec55524d6e23d0296f1c90977b40f5;hb=e3c745fea0c5231cc425a0223c9d4567152171a0;hp=2674cc2efb65a6f66da2a4039de9e4e0cec903de;hpb=9eafd89011b9b031d902a4381e13254fb67e1e07;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js index 2674cc2efb..ce9656eb27 100644 --- a/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/FilterWrapperWidget.js @@ -1,139 +1,137 @@ -( function () { - var FilterTagMultiselectWidget = require( './FilterTagMultiselectWidget.js' ), - LiveUpdateButtonWidget = require( './LiveUpdateButtonWidget.js' ), - ChangesLimitAndDateButtonWidget = require( './ChangesLimitAndDateButtonWidget.js' ), - FilterWrapperWidget; - - /** - * List displaying all filter groups - * - * @class mw.rcfilters.ui.FilterWrapperWidget - * @extends OO.ui.Widget - * @mixins OO.ui.mixin.PendingElement - * - * @constructor - * @param {mw.rcfilters.Controller} controller Controller - * @param {mw.rcfilters.dm.FiltersViewModel} model View model - * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model - * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel - * @param {Object} [config] Configuration object - * @cfg {Object} [filters] A definition of the filter groups in this list - * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups - * @cfg {jQuery} [$wrapper] A jQuery object for the wrapper of the general - * system. If not given, falls back to this widget's $element - * @cfg {boolean} [collapsed] Filter area is collapsed - */ - FilterWrapperWidget = function MwRcfiltersUiFilterWrapperWidget( - controller, model, savedQueriesModel, changesListModel, config - ) { - var $bottom; - config = config || {}; - - // Parent - FilterWrapperWidget.parent.call( this, config ); - // Mixin constructors - OO.ui.mixin.PendingElement.call( this, config ); - - this.controller = controller; - this.model = model; - this.queriesModel = savedQueriesModel; - this.changesListModel = changesListModel; - this.$overlay = config.$overlay || this.$element; - this.$wrapper = config.$wrapper || this.$element; - - this.filterTagWidget = new FilterTagMultiselectWidget( - this.controller, - this.model, - this.queriesModel, - { - $overlay: this.$overlay, - collapsed: config.collapsed, - $wrapper: this.$wrapper - } +var FilterTagMultiselectWidget = require( './FilterTagMultiselectWidget.js' ), + LiveUpdateButtonWidget = require( './LiveUpdateButtonWidget.js' ), + ChangesLimitAndDateButtonWidget = require( './ChangesLimitAndDateButtonWidget.js' ), + FilterWrapperWidget; + +/** + * List displaying all filter groups + * + * @class mw.rcfilters.ui.FilterWrapperWidget + * @extends OO.ui.Widget + * @mixins OO.ui.mixin.PendingElement + * + * @constructor + * @param {mw.rcfilters.Controller} controller Controller + * @param {mw.rcfilters.dm.FiltersViewModel} model View model + * @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model + * @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel + * @param {Object} [config] Configuration object + * @cfg {Object} [filters] A definition of the filter groups in this list + * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups + * @cfg {jQuery} [$wrapper] A jQuery object for the wrapper of the general + * system. If not given, falls back to this widget's $element + * @cfg {boolean} [collapsed] Filter area is collapsed + */ +FilterWrapperWidget = function MwRcfiltersUiFilterWrapperWidget( + controller, model, savedQueriesModel, changesListModel, config +) { + var $bottom; + config = config || {}; + + // Parent + FilterWrapperWidget.parent.call( this, config ); + // Mixin constructors + OO.ui.mixin.PendingElement.call( this, config ); + + this.controller = controller; + this.model = model; + this.queriesModel = savedQueriesModel; + this.changesListModel = changesListModel; + this.$overlay = config.$overlay || this.$element; + this.$wrapper = config.$wrapper || this.$element; + + this.filterTagWidget = new FilterTagMultiselectWidget( + this.controller, + this.model, + this.queriesModel, + { + $overlay: this.$overlay, + collapsed: config.collapsed, + $wrapper: this.$wrapper + } + ); + + this.liveUpdateButton = new LiveUpdateButtonWidget( + this.controller, + this.changesListModel + ); + + this.numChangesAndDateWidget = new ChangesLimitAndDateButtonWidget( + this.controller, + this.model, + { + $overlay: this.$overlay + } + ); + + this.showNewChangesLink = new OO.ui.ButtonWidget( { + icon: 'reload', + framed: false, + label: mw.msg( 'rcfilters-show-new-changes' ), + flags: [ 'progressive' ], + classes: [ 'mw-rcfilters-ui-filterWrapperWidget-showNewChanges' ] + } ); + + // Events + this.filterTagWidget.menu.connect( this, { toggle: [ 'emit', 'menuToggle' ] } ); + this.changesListModel.connect( this, { newChangesExist: 'onNewChangesExist' } ); + this.showNewChangesLink.connect( this, { click: 'onShowNewChangesClick' } ); + this.showNewChangesLink.toggle( false ); + + // Initialize + this.$top = $( '
' ) + .addClass( 'mw-rcfilters-ui-filterWrapperWidget-top' ); + + $bottom = $( '
' ) + .addClass( 'mw-rcfilters-ui-filterWrapperWidget-bottom' ) + .append( + this.showNewChangesLink.$element, + this.numChangesAndDateWidget.$element ); - this.liveUpdateButton = new LiveUpdateButtonWidget( - this.controller, - this.changesListModel - ); + if ( this.controller.pollingRate ) { + $bottom.prepend( this.liveUpdateButton.$element ); + } - this.numChangesAndDateWidget = new ChangesLimitAndDateButtonWidget( - this.controller, - this.model, - { - $overlay: this.$overlay - } + this.$element + .addClass( 'mw-rcfilters-ui-filterWrapperWidget' ) + .append( + this.$top, + this.filterTagWidget.$element, + $bottom ); - - this.showNewChangesLink = new OO.ui.ButtonWidget( { - icon: 'reload', - framed: false, - label: mw.msg( 'rcfilters-show-new-changes' ), - flags: [ 'progressive' ], - classes: [ 'mw-rcfilters-ui-filterWrapperWidget-showNewChanges' ] - } ); - - // Events - this.filterTagWidget.menu.connect( this, { toggle: [ 'emit', 'menuToggle' ] } ); - this.changesListModel.connect( this, { newChangesExist: 'onNewChangesExist' } ); - this.showNewChangesLink.connect( this, { click: 'onShowNewChangesClick' } ); - this.showNewChangesLink.toggle( false ); - - // Initialize - this.$top = $( '
' ) - .addClass( 'mw-rcfilters-ui-filterWrapperWidget-top' ); - - $bottom = $( '
' ) - .addClass( 'mw-rcfilters-ui-filterWrapperWidget-bottom' ) - .append( - this.showNewChangesLink.$element, - this.numChangesAndDateWidget.$element - ); - - if ( mw.config.get( 'StructuredChangeFiltersLiveUpdatePollingRate' ) ) { - $bottom.prepend( this.liveUpdateButton.$element ); - } - - this.$element - .addClass( 'mw-rcfilters-ui-filterWrapperWidget' ) - .append( - this.$top, - this.filterTagWidget.$element, - $bottom - ); - }; - - /* Initialization */ - - OO.inheritClass( FilterWrapperWidget, OO.ui.Widget ); - OO.mixinClass( FilterWrapperWidget, OO.ui.mixin.PendingElement ); - - /* Methods */ - - /** - * Set the content of the top section - * - * @param {jQuery} $topSectionElement - */ - FilterWrapperWidget.prototype.setTopSection = function ( $topSectionElement ) { - this.$top.append( $topSectionElement ); - }; - - /** - * Respond to the user clicking the 'show new changes' button - */ - FilterWrapperWidget.prototype.onShowNewChangesClick = function () { - this.controller.showNewChanges(); - }; - - /** - * Respond to changes list model newChangesExist - * - * @param {boolean} newChangesExist Whether new changes exist - */ - FilterWrapperWidget.prototype.onNewChangesExist = function ( newChangesExist ) { - this.showNewChangesLink.toggle( newChangesExist ); - }; - - module.exports = FilterWrapperWidget; -}() ); +}; + +/* Initialization */ + +OO.inheritClass( FilterWrapperWidget, OO.ui.Widget ); +OO.mixinClass( FilterWrapperWidget, OO.ui.mixin.PendingElement ); + +/* Methods */ + +/** + * Set the content of the top section + * + * @param {jQuery} $topSectionElement + */ +FilterWrapperWidget.prototype.setTopSection = function ( $topSectionElement ) { + this.$top.append( $topSectionElement ); +}; + +/** + * Respond to the user clicking the 'show new changes' button + */ +FilterWrapperWidget.prototype.onShowNewChangesClick = function () { + this.controller.showNewChanges(); +}; + +/** + * Respond to changes list model newChangesExist + * + * @param {boolean} newChangesExist Whether new changes exist + */ +FilterWrapperWidget.prototype.onNewChangesExist = function ( newChangesExist ) { + this.showNewChangesLink.toggle( newChangesExist ); +}; + +module.exports = FilterWrapperWidget;