2c99d3d2b6343e8c49a506a324ecdd52e490fcd3
3 * Top section (between page title and filters) on Special:Recentchanges
5 * @extends OO.ui.Widget
8 * @param {mw.rcfilters.ui.SavedLinksListWidget} savedLinksListWidget
9 * @param {jQuery} $topLinks Content of the community-defined links
10 * @param {Object} [config] Configuration object
12 mw
.rcfilters
.ui
.RcTopSectionWidget
= function MwRcfiltersUiRcTopSectionWidget(
13 savedLinksListWidget
, $topLinks
, config
16 topLinksCookieName
= 'rcfilters-toplinks-collapsed-state',
17 topLinksCookie
= mw
.cookie
.get( topLinksCookieName
),
18 topLinksCookieValue
= topLinksCookie
|| 'collapsed',
21 config
= config
|| {};
24 mw
.rcfilters
.ui
.RcTopSectionWidget
.parent
.call( this, config
);
26 this.$topLinks
= $topLinks
;
28 toplinksTitle
= new OO
.ui
.ButtonWidget( {
30 indicator
: topLinksCookieValue
=== 'collapsed' ? 'down' : 'up',
31 flags
: [ 'progressive' ],
32 label
: $( '<span>' ).append( mw
.message( 'rcfilters-other-review-tools' ).parse() ).contents()
37 collapsed
: topLinksCookieValue
=== 'collapsed',
38 $customTogglers
: toplinksTitle
.$element
40 .on( 'beforeExpand.mw-collapsible', function () {
41 mw
.cookie
.set( topLinksCookieName
, 'expanded' );
42 toplinksTitle
.setIndicator( 'up' );
43 widget
.switchTopLinks( 'expanded' );
45 .on( 'beforeCollapse.mw-collapsible', function () {
46 mw
.cookie
.set( topLinksCookieName
, 'collapsed' );
47 toplinksTitle
.setIndicator( 'down' );
48 widget
.switchTopLinks( 'collapsed' );
51 this.$topLinks
.find( '.mw-recentchanges-toplinks-title' )
52 .replaceWith( toplinksTitle
.$element
.removeAttr( 'tabIndex' ) );
54 // Create two positions for the toplinks to toggle between
55 // in the table (first cell) or up above it
56 this.$top
= $( '<div>' )
57 .addClass( 'mw-rcfilters-ui-rcTopSectionWidget-topLinks-top' );
58 this.$tableTopLinks
= $( '<div>' )
59 .addClass( 'mw-rcfilters-ui-cell' )
60 .addClass( 'mw-rcfilters-ui-rcTopSectionWidget-topLinks-table' );
64 .addClass( 'mw-rcfilters-ui-rcTopSectionWidget' )
67 .addClass( 'mw-rcfilters-ui-table' )
70 .addClass( 'mw-rcfilters-ui-row' )
74 .addClass( 'mw-rcfilters-ui-table-placeholder' )
75 .addClass( 'mw-rcfilters-ui-cell' ),
78 .addClass( 'mw-rcfilters-ui-cell' )
79 .addClass( 'mw-rcfilters-ui-rcTopSectionWidget-savedLinks' )
80 .append( savedLinksListWidget
.$element
) :
86 // Hack: For jumpiness reasons, this should be a sibling of -head
87 $( '.rcfilters-head' ).before( this.$top
);
89 // Initialize top links position
90 widget
.switchTopLinks( topLinksCookieValue
);
95 OO
.inheritClass( mw
.rcfilters
.ui
.RcTopSectionWidget
, OO
.ui
.Widget
);
98 * Switch the top links widget from inside the table (when collapsed)
99 * to the 'top' (when open)
101 * @param {string} [state] The state of the top links widget: 'expanded' or 'collapsed'
103 mw
.rcfilters
.ui
.RcTopSectionWidget
.prototype.switchTopLinks = function ( state
) {
104 state
= state
|| 'expanded';
106 if ( state
=== 'expanded' ) {
107 this.$top
.append( this.$topLinks
);
109 this.$tableTopLinks
.append( this.$topLinks
);