[MediaWiki-commits] [Gerrit] Convert mediawiki.action.edit.collapsibleFooter and mediawik... - change (mediawiki/core)
jenkins-bot has submitted this change and it was merged. Change subject: Convert mediawiki.action.edit.collapsibleFooter and mediawiki.special.changeslist.legend to using mw.cookie .. Convert mediawiki.action.edit.collapsibleFooter and mediawiki.special.changeslist.legend to using mw.cookie Remove redundant parameters, use sane defaults. This changes the cookie name due to mw.cookie adding the standard cookie prefix. This will cause existing values to be lost. Bug: T67384 Change-Id: I00ba66b271cef4635ab4c31226c854583b8ba79e --- M resources/Resources.php M resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js M resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js 3 files changed, 24 insertions(+), 24 deletions(-) Approvals: Gilles: Looks good to me, approved jenkins-bot: Verified diff --git a/resources/Resources.php b/resources/Resources.php index 8ac2600..6c27735 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1123,7 +1123,7 @@ 'styles' = 'resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.css', 'dependencies' = array( 'jquery.makeCollapsible', - 'jquery.cookie', + 'mediawiki.cookie', 'mediawiki.icon', ), ), @@ -1430,7 +1430,7 @@ 'scripts' = 'resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js', 'dependencies' = array( 'jquery.makeCollapsible', - 'jquery.cookie', + 'mediawiki.cookie', ), ), 'mediawiki.special.changeslist.enhanced' = array( diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js b/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js index bf1142b..e181472 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js @@ -1,4 +1,4 @@ -( function ( mw, $ ) { +( function ( mw ) { var collapsibleLists, handleOne; // Collapsible lists of categories and templates @@ -21,7 +21,8 @@ ]; handleOne = function ( $list, $toggler, cookieName ) { - var isCollapsed = $.cookie( cookieName ) !== 'expanded'; + // Collapsed by default + var isCollapsed = mw.cookie.get( cookieName ) !== 'expanded'; // Style the toggler with an arrow icon and add a tabIndex and a role for accessibility $toggler.addClass( 'mw-editfooter-toggler' ).prop( 'tabIndex', 0 ).attr( 'role', 'button' ); @@ -38,12 +39,12 @@ $list.on( 'beforeExpand.mw-collapsible', function () { $toggler.removeClass( 'mw-icon-arrow-collapsed' ).addClass( 'mw-icon-arrow-expanded' ); - $.cookie( cookieName, 'expanded' ); + mw.cookie.set( cookieName, 'expanded' ); } ); $list.on( 'beforeCollapse.mw-collapsible', function () { $toggler.removeClass( 'mw-icon-arrow-expanded' ).addClass( 'mw-icon-arrow-collapsed' ); - $.cookie( cookieName, 'collapsed' ); + mw.cookie.set( cookieName, 'collapsed' ); } ); }; @@ -58,4 +59,4 @@ ); } } ); -}( mediaWiki, jQuery ) ); +}( mediaWiki ) ); diff --git a/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js b/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js index c9e5511..f217bf5 100644 --- a/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js +++ b/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js @@ -3,23 +3,22 @@ */ /* Remember the collapse state of the legend on recent changes and watchlist pages. */ -jQuery( document ).ready( function ( $ ) { +( function ( mw, $ ) { var cookieName = 'changeslist-state', - cookieOptions = { - expires: 30, - path: '/' - }, - isCollapsed = $.cookie( cookieName ) === 'collapsed'; + // Expanded by default + isCollapsed = mw.cookie.get( cookieName ) === 'collapsed'; - $( '.mw-changeslist-legend' ) - .makeCollapsible( { - collapsed: isCollapsed - } ) - .on( 'beforeExpand.mw-collapsible', function () { - $.cookie( cookieName, 'expanded', cookieOptions ); - } ) - .on( 'beforeCollapse.mw-collapsible', function () { - $.cookie( cookieName,
[MediaWiki-commits] [Gerrit] Convert mediawiki.action.edit.collapsibleFooter and mediawik... - change (mediawiki/core)
Bartosz DziewoĆski has uploaded a new change for review. https://gerrit.wikimedia.org/r/211409 Change subject: Convert mediawiki.action.edit.collapsibleFooter and mediawiki.special.changeslist.legend to using mw.cookie .. Convert mediawiki.action.edit.collapsibleFooter and mediawiki.special.changeslist.legend to using mw.cookie Remove redundant parameters, use sane defaults. This changes the cookie name due to mw.cookie adding the standard cookie prefix. This will cause existing values to be lost. Bug: T67384 Change-Id: I00ba66b271cef4635ab4c31226c854583b8ba79e --- M resources/Resources.php M resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js M resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js 3 files changed, 60 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/09/211409/1 diff --git a/resources/Resources.php b/resources/Resources.php index 5f51702..44cf27d 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1098,7 +1098,7 @@ 'styles' = 'resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.css', 'dependencies' = array( 'jquery.makeCollapsible', - 'jquery.cookie', + 'mediawiki.cookie', 'mediawiki.icon', ), ), @@ -1399,7 +1399,7 @@ 'scripts' = 'resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js', 'dependencies' = array( 'jquery.makeCollapsible', - 'jquery.cookie', + 'mediawiki.cookie', ), ), 'mediawiki.special.changeslist.enhanced' = array( diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js b/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js index 7ae51ab..de8c975 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.js @@ -1,27 +1,15 @@ -jQuery( document ).ready( function ( $ ) { - var collapsibleLists, i, handleOne; - - // Collapsible lists of categories and templates - collapsibleLists = [ - { - $list: $( '.templatesUsed ul' ), - $toggler: $( '.mw-templatesUsedExplanation' ), - cookieName: 'templates-used-list' - }, - { - $list: $( '.hiddencats ul' ), - $toggler: $( '.mw-hiddenCategoriesExplanation' ), - cookieName: 'hidden-categories-list' - }, - { - $list: $( '.preview-limit-report-wrapper' ), - $toggler: $( '.mw-limitReportExplanation' ), - cookieName: 'preview-limit-report' - } - ]; - - handleOne = function ( $list, $toggler, cookieName ) { - var isCollapsed = $.cookie( cookieName ) !== 'expanded'; +( function ( mw, $ ) { + /** +* Make a footer area collapsible. +* +* @param {jQuery} $list Footer area +* @param {jQuery} $toggler Expand/collapse button +* @param {string} cookieName Name of the cookie used to remember state +* @private +*/ + function makeFooterCollapsible( $list, $toggler, cookieName ) { + // Collapsed by default + var isCollapsed = mw.cookie.get( cookieName ) !== 'expanded'; // Style the toggler with an arrow icon and add a tabIndex and a role for accessibility $toggler.addClass( 'mw-editfooter-toggler' ).prop( 'tabIndex', 0 ).attr( 'role', 'button' ); @@ -38,17 +26,39 @@ $list.on( 'beforeExpand.mw-collapsible', function () { $toggler.removeClass( 'mw-icon-arrow-collapsed' ).addClass( 'mw-icon-arrow-expanded' ); - $.cookie( cookieName, 'expanded' ); + mw.cookie.set( cookieName, 'expanded' ); } ); $list.on( 'beforeCollapse.mw-collapsible', function () { $toggler.removeClass( 'mw-icon-arrow-expanded' ).addClass( 'mw-icon-arrow-collapsed' ); - $.cookie( cookieName, 'collapsed' ); + mw.cookie.set( cookieName, 'collapsed' ); } ); - }; - - for ( i = 0; i collapsibleLists.length; i++ ) { - // Pass to a function for iteration-local variables - handleOne( collapsibleLists[i].$list, collapsibleLists[i].$toggler, collapsibleLists[i].cookieName ); } -} ); + + $( function () { + var