From: Bartosz DziewoƄski Date: Wed, 10 Jun 2015 11:42:13 +0000 (+0200) Subject: Convert mediawiki.action.edit.collapsibleFooter and mediawiki.special.changeslist... X-Git-Tag: 1.31.0-rc.0~11125^2 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=964fc3246a0164959d1b7c82778fc3dbcc513716;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/resources/Resources.php b/resources/Resources.php index 8ac260026b..6c27735aae 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1123,7 +1123,7 @@ return array( 'styles' => 'resources/src/mediawiki.action/mediawiki.action.edit.collapsibleFooter.css', 'dependencies' => array( 'jquery.makeCollapsible', - 'jquery.cookie', + 'mediawiki.cookie', 'mediawiki.icon', ), ), @@ -1430,7 +1430,7 @@ return array( '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 bf1142b30b..e181472dfc 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 c9e55111ff..f217bf59aa 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, 'collapsed', cookieOptions ); - } ); -} ); + $( function () { + $( '.mw-changeslist-legend' ) + .makeCollapsible( { + collapsed: isCollapsed + } ) + .on( 'beforeExpand.mw-collapsible', function () { + mw.cookie.set( cookieName, 'expanded' ); + } ) + .on( 'beforeCollapse.mw-collapsible', function () { + mw.cookie.set( cookieName, 'collapsed' ); + } ); + } ); +}( mediaWiki, jQuery ) );