}
}
},
+ // Toggles collapsible and togglelink class and updates text label
toggleLinkDefault = function( that, e ) {
var $that = $(that),
$collapsible = $that.closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' );
e.preventDefault();
// It's expanded right now
- if ( $that.hasClass( 'mw-collapsible-toggle-expanded' ) ) {
+ if ( !$that.hasClass( 'mw-collapsible-toggle-collapsed' ) ) {
// Change link to "Show"
$that.removeClass( 'mw-collapsible-toggle-expanded' ).addClass( 'mw-collapsible-toggle-collapsed' );
if ( $that.find( '> a' ).size() ) {
}
return;
},
+ // Toggles collapsible and togglelink class
+ toggleLinkPremade = function( that, e ) {
+ var $that = $(that),
+ $collapsible = $that.closest( '.mw-collapsible.mw-made-collapsible' ).toggleClass( 'mw-collapsed' );
+ e.preventDefault();
+
+ // It's expanded right now
+ if ( !$that.hasClass( 'mw-collapsible-toggle-collapsed' ) ) {
+ // Change toggle to collapsed
+ $that.removeClass( 'mw-collapsible-toggle-expanded' ).addClass( 'mw-collapsible-toggle-collapsed' );
+ // Collapse element
+ toggleElement( $collapsible, 'collapse', $that );
+
+ // It's collapsed right now
+ } else {
+ // Change toggle to expanded
+ $that.removeClass( 'mw-collapsible-toggle-collapsed' ).addClass( 'mw-collapsible-toggle-expanded' );
+ // Expand element
+ toggleElement( $collapsible, 'expand', $that );
+ }
+ return;
+ },
+ // Toggles customcollapsible
toggleLinkCustom = function( that, e ) {
var $that = $(that),
classes = that.className.split(' ');
}
// Create toggle link with a space around the brackets ( [text] )
- var $toggleLink = $( '<a href="#">' ).text( collapsetext ).wrap( '<span class="mw-collapsible-toggle mw-collapsible-toggle-expanded">' ).parent().prepend( ' [' ).append( '] ' ).bind( 'click.mw-collapse', function(e){
+ var $toggleLink = $( '<a href="#">' ).text( collapsetext ).wrap( '<span class="mw-collapsible-toggle">' ).parent().prepend( ' [' ).append( '] ' ).bind( 'click.mw-collapse', function(e){
toggleLinkDefault( this, e );
} );
$firstRowCells.eq(-1).prepend( $toggleLink );
} else {
$toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){
- toggleLinkDefault( this, e );
+ toggleLinkPremade( this, e );
} );
}
$that.prepend( $toggleLink.wrap( '<li class="mw-collapsible-toggle-li">' ).parent() );
} else {
$toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){
- toggleLinkDefault( this, e );
+ toggleLinkPremade( this, e );
} );
}
$that.prepend( $toggleLink );
} else {
$toggleLink = $toggle.unbind( 'click.mw-collapse' ).bind( 'click.mw-collapse', function( e ){
- toggleLinkDefault( this, e );
+ toggleLinkPremade( this, e );
} );
}
}