From c67fe8aff987ba8465f020223a2d7f779c7230d1 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 21 May 2012 15:29:32 +0200 Subject: [PATCH] Make legend table collapsed. Change-Id: Ic545b20a51e2a039225e99ea178c099ab2db012b --- Interwiki.css | 4 ++++ Interwiki.i18n.php | 6 +++++- Interwiki.php | 5 ++++- Interwiki_body.php | 36 ++++++++++++++++++++++++------------ 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Interwiki.css b/Interwiki.css index b9c5d52c..38f4064a 100644 --- a/Interwiki.css +++ b/Interwiki.css @@ -35,3 +35,7 @@ input#mw-interwiki-url { .mw-interwikitable-modify { white-space: nowrap; } + +.mw-special-Interwiki .mw-collapsible-toggle { + float: left; +} diff --git a/Interwiki.i18n.php b/Interwiki.i18n.php index 55d1afce..faf553e0 100644 --- a/Interwiki.i18n.php +++ b/Interwiki.i18n.php @@ -29,7 +29,9 @@ $messages['en'] = array( 'interwiki' => 'View and edit interwiki data', 'interwiki-title-norights' => 'View interwiki data', 'interwiki-desc' => 'Adds a [[Special:Interwiki|special page]] to view and edit the interwiki table', - 'interwiki_intro' => 'This is an overview of the interwiki table. Meanings of the data in the columns:', + 'interwiki_intro' => 'This is an overview of the interwiki table.', + 'interwiki-legend-show' => 'Show legend', + 'interwiki-legend-hide' => 'Hide legend', 'interwiki_prefix' => 'Prefix', 'interwiki-prefix-label' => 'Prefix:', 'interwiki_prefix_intro' => 'Interwiki prefix to be used in [[prefix:pagename]] wikitext syntax.', @@ -112,6 +114,8 @@ $messages['qqq'] = array( 'interwiki-title-norights' => 'Part of the interwiki extension. This message is the title of the special page [[Special:Interwiki]] when the user has no right to edit the interwiki data, so can only view them.', 'interwiki-desc' => '{{desc}}', 'interwiki_intro' => 'Part of the interwiki extension. Shown as introductory text on [[Special:Interwiki]].', + 'interwiki-legend-show' => 'Link text for toggle to display the legend on [[Special:Interwiki]].', + 'interwiki-legend-hide' => 'Link text for toggle to hide the legend on [[Special:Interwiki]].', 'interwiki_prefix' => 'Used on [[Special:Interwiki]] as a column header of the table.', 'interwiki-prefix-label' => 'Used on [[Special:Interwiki]] as a field label in a form.', 'interwiki_prefix_intro' => 'Used on [[Special:Interwiki]] so as to explain the data in the {{msg-mw|interwiki_prefix}} column of the table. diff --git a/Interwiki.php b/Interwiki.php index 36cbe980..6b99f999 100644 --- a/Interwiki.php +++ b/Interwiki.php @@ -38,10 +38,13 @@ $wgExtensionCredits['specialpage'][] = array( $wgExtensionFunctions[] = 'setupInterwikiExtension'; -$wgResourceModules['SpecialInterwiki'] = array( +$wgResourceModules['ext.interwiki.specialpage'] = array( 'styles' => 'Interwiki.css', 'localBasePath' => dirname( __FILE__ ), 'remoteExtPath' => 'Interwiki', + 'dependencies' => array( + 'jquery.makeCollapsible', + ), ); // Set up the new special page diff --git a/Interwiki_body.php b/Interwiki_body.php index cbcf67bc..4073d924 100644 --- a/Interwiki_body.php +++ b/Interwiki_body.php @@ -32,7 +32,7 @@ class SpecialInterwiki extends SpecialPage { $out = $this->getOutput(); $request = $this->getRequest(); - $out->addModuleStyles( 'SpecialInterwiki' ); + $out->addModules( 'ext.interwiki.specialpage' ); $action = $par ? $par : $request->getVal( 'action', $par ); $return = $this->getTitle(); @@ -249,21 +249,33 @@ class SpecialInterwiki extends SpecialPage { $canModify = $this->canModify(); $this->getOutput()->addWikiMsg( 'interwiki_intro' ); + // Make collapsible. $this->getOutput()->addHTML( - Html::rawElement( 'table', array( 'class' => 'mw-interwikitable wikitable intro' ), - self::addInfoRow( 'start', 'interwiki_prefix', 'interwiki_prefix_intro' ) . - self::addInfoRow( 'start', 'interwiki_url', 'interwiki_url_intro' ) . - self::addInfoRow( 'start', 'interwiki_local', 'interwiki_local_intro' ) . - self::addInfoRow( 'end', 'interwiki_0', 'interwiki_local_0_intro' ) . - self::addInfoRow( 'end', 'interwiki_1', 'interwiki_local_1_intro' ) . - self::addInfoRow( 'start', 'interwiki_trans', 'interwiki_trans_intro' ) . - self::addInfoRow( 'end', 'interwiki_0', 'interwiki_trans_0_intro' ) . - self::addInfoRow( 'end', 'interwiki_1', 'interwiki_trans_1_intro' ) - ) . "\n" + Html::openElement( + 'div', array( + 'class' => 'mw-collapsible mw-collapsed', + 'data-collapsetext' => $this->msg( 'interwiki-legend-hide' )->escaped(), + 'data-expandtext' => $this->msg('interwiki-legend-show' )->escaped() + ) ) ); + $this->getOutput()->addHTML( + Html::rawElement( + 'table', array( 'class' => 'mw-interwikitable wikitable intro' ), + self::addInfoRow( 'start', 'interwiki_prefix', 'interwiki_prefix_intro' ) . "\n" . + self::addInfoRow( 'start', 'interwiki_url', 'interwiki_url_intro' ) . "\n" . + self::addInfoRow( 'start', 'interwiki_local', 'interwiki_local_intro' ) . "\n" . + self::addInfoRow( 'end', 'interwiki_0', 'interwiki_local_0_intro' ) . "\n" . + self::addInfoRow( 'end', 'interwiki_1', 'interwiki_local_1_intro' ) . "\n" . + self::addInfoRow( 'start', 'interwiki_trans', 'interwiki_trans_intro' ) . "\n" . + self::addInfoRow( 'end', 'interwiki_0', 'interwiki_trans_0_intro' ) . "\n" . + self::addInfoRow( 'end', 'interwiki_1', 'interwiki_trans_1_intro' ) . "\n" + ) ); + $this->getOutput()->addHTML( Html::closeElement( 'table' ) ); + $this->getOutput()->addHTML( Html::closeElement( 'div' ) ); // end collapsible. + if ( $canModify ) { - $this->getOutput()->addWikiMsg( 'interwiki_intro_footer' ); + $this->getOutput()->addHTML( "
" . $this->msg( 'interwiki_intro_footer' )->parse() ); $addtext = $this->msg( 'interwiki_addtext' )->escaped(); $addlink = Linker::linkKnown( $this->getTitle( 'add' ), $addtext ); $this->getOutput()->addHTML( '' );