(Criou a página com "→Qualquer JavaScript aqui será carregado para usuários que usam o site móvel: /************************************ /* Main Page Mobile Collapse Script * /**********...") |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
− | /* |
+ | /* Any JavaScript here will be loaded for users using the mobile site */ |
− | |||
/************************************ |
/************************************ |
||
/* Main Page Mobile Collapse Script * |
/* Main Page Mobile Collapse Script * |
||
Linha 8: | Linha 7: | ||
// License: CC-BY 3.0 |
// License: CC-BY 3.0 |
||
− | // This script, paired with .mobilecollapsible styles in MediaWiki:Mobile.css, supports making . |
+ | // This script, paired with .mobilecollapsible styles in MediaWiki:Mobile.css, supports making .fp-box collapsible in the mobile view using both the standard |
// 2 or 3-column responsive front pages. |
// 2 or 3-column responsive front pages. |
||
− | // Making an . |
+ | // Making an .fp-box collapsible in mobile view involves the following: |
− | // 1. Adding "mobilecollapsible" as another class alongside " |
+ | // 1. Adding "mobilecollapsible" as another class alongside "fp-box". |
− | // 2. Making sure there is a heading identified by the "heading" class. |
+ | // 2. Making sure there is a heading identified by the "fp-heading" class. |
// * Links inside headings can still work, but aren't recommended because they'll be easy to fat-finger while trying to collapse/expand the box. |
// * Links inside headings can still work, but aren't recommended because they'll be easy to fat-finger while trying to collapse/expand the box. |
||
// * The script allows multiple headings and automatically ignores any with the "nomobile" or "notoggle" class. |
// * The script allows multiple headings and automatically ignores any with the "nomobile" or "notoggle" class. |
||
// * If there are still multiple headings after excluding those, only the first is turned into a collapsing toggle link. |
// * If there are still multiple headings after excluding those, only the first is turned into a collapsing toggle link. |
||
− | // 3. Placing the area that should be hidden when collapsed inside a div or other block with the "body" class. |
+ | // 3. Placing the area that should be hidden when collapsed inside a div or other block with the "fp-body" class. |
// * It's usually best for this to be everything in the box *except* the heading. |
// * It's usually best for this to be everything in the box *except* the heading. |
||
// 4. Optionally add "expanded" next to "mobilecollapsible" to leave the box expanded by default. |
// 4. Optionally add "expanded" next to "mobilecollapsible" to leave the box expanded by default. |
||
Linha 24: | Linha 23: | ||
initialize : function() { |
initialize : function() { |
||
var index = 0; |
var index = 0; |
||
− | $( '. |
+ | $( '.fp-box.mobilecollapsible' ).each( function() { |
− | var heading = $( this ).children( '.heading' ).not( '.nomobile, .notoggle' ); |
+ | var heading = $( this ).children( '.fp-heading' ).not( '.nomobile, .notoggle' ); |
− | if ( heading.length > 0 && $( this ).children( '.body' ).length > 0 ) { |
+ | if ( heading.length > 0 && $( this ).children( '.fp-body' ).length > 0 ) { |
$( this ).addClass( 'mobilecollapsible' + index ); |
$( this ).addClass( 'mobilecollapsible' + index ); |
||
if ( !( $( this ).hasClass( 'expanded') ) ) { |
if ( !( $( this ).hasClass( 'expanded') ) ) { |
||
Linha 37: | Linha 36: | ||
}, |
}, |
||
toggle : function( index ) { |
toggle : function( index ) { |
||
− | $( '. |
+ | $( '.fp-box.mobilecollapsible' + index ).each( function() { |
if ( $( this ).hasClass( 'collapsed' ) ) { |
if ( $( this ).hasClass( 'collapsed' ) ) { |
||
$( this ).removeClass( 'collapsed' ); |
$( this ).removeClass( 'collapsed' ); |
Edição atual desde as 02h14min de 27 de julho de 2019
/* Any JavaScript here will be loaded for users using the mobile site */
/************************************
/* Main Page Mobile Collapse Script *
/************************************/
// Author: Shawn Bruckner
// Date: 2018-Jun-7
// License: CC-BY 3.0
// This script, paired with .mobilecollapsible styles in MediaWiki:Mobile.css, supports making .fp-box collapsible in the mobile view using both the standard
// 2 or 3-column responsive front pages.
// Making an .fp-box collapsible in mobile view involves the following:
// 1. Adding "mobilecollapsible" as another class alongside "fp-box".
// 2. Making sure there is a heading identified by the "fp-heading" class.
// * Links inside headings can still work, but aren't recommended because they'll be easy to fat-finger while trying to collapse/expand the box.
// * The script allows multiple headings and automatically ignores any with the "nomobile" or "notoggle" class.
// * If there are still multiple headings after excluding those, only the first is turned into a collapsing toggle link.
// 3. Placing the area that should be hidden when collapsed inside a div or other block with the "fp-body" class.
// * It's usually best for this to be everything in the box *except* the heading.
// 4. Optionally add "expanded" next to "mobilecollapsible" to leave the box expanded by default.
var fpmobilecollapse = fpmobilecollapse || {
initialize : function() {
var index = 0;
$( '.fp-box.mobilecollapsible' ).each( function() {
var heading = $( this ).children( '.fp-heading' ).not( '.nomobile, .notoggle' );
if ( heading.length > 0 && $( this ).children( '.fp-body' ).length > 0 ) {
$( this ).addClass( 'mobilecollapsible' + index );
if ( !( $( this ).hasClass( 'expanded') ) ) {
$( this ).addClass( 'collapsed' );
}
heading.first().html( $( '<a class="togglecollapse" href="javascript:fpmobilecollapse.toggle( ' + index + ' )"></a>' ).html( heading.html() ) );
}
++index;
} );
},
toggle : function( index ) {
$( '.fp-box.mobilecollapsible' + index ).each( function() {
if ( $( this ).hasClass( 'collapsed' ) ) {
$( this ).removeClass( 'collapsed' );
$( this ).addClass( 'expanded' );
} else {
$( this ).removeClass( 'expanded' );
$( this ).addClass( 'collapsed' );
}
} );
}
}
window.fpmobilecollapse = fpmobilecollapse;
$( document ).ready( fpmobilecollapse.initialize );
/****************************************
/* End Main Page Mobile Collapse Script *
/****************************************/