r79075 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79074‎ | r79075 | r79076 >
Date:17:37, 27 December 2010
Author:krinkle
Status:ok
Tags:
Comment:
Treat premade toggle links as a custom instead of default case (ie. dont change the text) (Follow-up r78989 CR)
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.makeCollapsible.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.makeCollapsible.js
@@ -90,13 +90,14 @@
9191 }
9292 }
9393 },
 94+ // Toggles collapsible and togglelink class and updates text label
9495 toggleLinkDefault = function( that, e ) {
9596 var $that = $(that),
9697 $collapsible = $that.closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' );
9798 e.preventDefault();
9899
99100 // It's expanded right now
100 - if ( $that.hasClass( 'mw-collapsible-toggle-expanded' ) ) {
 101+ if ( !$that.hasClass( 'mw-collapsible-toggle-collapsed' ) ) {
101102 // Change link to "Show"
102103 $that.removeClass( 'mw-collapsible-toggle-expanded' ).addClass( 'mw-collapsible-toggle-collapsed' );
103104 if ( $that.find( '> a' ).size() ) {
@@ -121,6 +122,29 @@
122123 }
123124 return;
124125 },
 126+ // Toggles collapsible and togglelink class
 127+ toggleLinkPremade = function( that, e ) {
 128+ var $that = $(that),
 129+ $collapsible = $that.closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' );
 130+ e.preventDefault();
 131+
 132+ // It's expanded right now
 133+ if ( !$that.hasClass( 'mw-collapsible-toggle-collapsed' ) ) {
 134+ // Change toggle to collapsed
 135+ $that.removeClass( 'mw-collapsible-toggle-expanded' ).addClass( 'mw-collapsible-toggle-collapsed' );
 136+ // Collapse element
 137+ toggleElement( $collapsible, 'collapse', $that );
 138+
 139+ // It's collapsed right now
 140+ } else {
 141+ // Change toggle to expanded
 142+ $that.removeClass( 'mw-collapsible-toggle-collapsed' ).addClass( 'mw-collapsible-toggle-expanded' );
 143+ // Expand element
 144+ toggleElement( $collapsible, 'expand', $that );
 145+ }
 146+ return;
 147+ },
 148+ // Toggles customcollapsible
125149 toggleLinkCustom = function( that, e ) {
126150 var $that = $(that),
127151 classes = that.className.split(' ');
@@ -147,7 +171,7 @@
148172 }
149173
150174 // Create toggle link with a space around the brackets ( [text] )
151 - var $toggleLink = $( '<a href="#">' ).text( collapsetext ).wrap( '<span class="mw-collapsible-toggle mw-collapsible-toggle-expanded">' ).parent().prepend( '&nbsp;[' ).append( ']&nbsp;' ).bind( 'click.mw-collapse', function(e){
 175+ var $toggleLink = $( '<a href="#">' ).text( collapsetext ).wrap( '<span class="mw-collapsible-toggle">' ).parent().prepend( '&nbsp;[' ).append( ']&nbsp;' ).bind( 'click.mw-collapse', function(e){
152176 toggleLinkDefault( this, e );
153177 } );
154178
@@ -195,7 +219,7 @@
196220 $firstRowCells.eq(-1).prepend( $toggleLink );
197221 } else {
198222 $toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){
199 - toggleLinkDefault( this, e );
 223+ toggleLinkPremade( this, e );
200224 } );
201225 }
202226
@@ -214,7 +238,7 @@
215239 $that.prepend( $toggleLink.wrap( '<li class="mw-collapsible-toggle-li">' ).parent() );
216240 } else {
217241 $toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){
218 - toggleLinkDefault( this, e );
 242+ toggleLinkPremade( this, e );
219243 } );
220244 }
221245
@@ -232,7 +256,7 @@
233257 $that.prepend( $toggleLink );
234258 } else {
235259 $toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){
236 - toggleLinkDefault( this, e );
 260+ toggleLinkPremade( this, e );
237261 } );
238262 }
239263 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78989Added remote binding for custom collapsibles and minor improvements...krinkle03:26, 25 December 2010

Status & tagging log