Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
| (12 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
| + | /* Show/Hide: shows a few lines; allows searches of all hidden text too :) | ||
| + | * Related files: MediaWiki:Common.css + Template:SeeMore | ||
| + | */ | ||
| + | $(document).ready( function($) { | ||
| + | // Add expand/contract functionality to sections: | ||
| + | if ($('.see-more').height()>=100) { | ||
| + | $('.see-more').css('overflow','hidden').after('<div class="see-more-toggle" style=font-style:italic;"><span id="see-more-message">Only the first few lines are shown above.</span> <a href="#">Click to show more.</a></div>'); | ||
| + | $('.see-more-toggle > a').click(function(e){ e.preventDefault(); $(this).parent().prev('.see-more').toggleClass('expanded'); $('<style></style>').appendTo($(document.body)).remove(); if($(this).html()=='Click to show more.'){ $(this).html('Click to show less.'); $("#see-more-message").html("");} else { $(this).html('Click to show more.'); $("#see-more-message").html("<i>Only the first few lines are shown above.</i>");} }); | ||
| + | } | ||
| + | }); | ||
| − | /* | + | /* Commented out pro tem while I dither if I want to do this. |
| − | * Show/Hide | + | * Show/Hide; shows a few lines; allows searches of all hidden text too :) |
* From Ballotpedia page https://ballotpedia.org/Robert_Rowling | * From Ballotpedia page https://ballotpedia.org/Robert_Rowling | ||
| − | + | * This works for References. | |
| − | * This works for References. | ||
$(document).ready( function($) { | $(document).ready( function($) { | ||
// Add expand/contract functionality to references sections: | // Add expand/contract functionality to references sections: | ||
| Line 15: | Line 24: | ||
}); | }); | ||
*/ | */ | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 16:20, 6 August 2019
/* Any JavaScript here will be loaded for all users on every page load. */
/* Show/Hide: shows a few lines; allows searches of all hidden text too :)
* Related files: MediaWiki:Common.css + Template:SeeMore
*/
$(document).ready( function($) {
// Add expand/contract functionality to sections:
if ($('.see-more').height()>=100) {
$('.see-more').css('overflow','hidden').after('<div class="see-more-toggle" style=font-style:italic;"><span id="see-more-message">Only the first few lines are shown above.</span> <a href="#">Click to show more.</a></div>');
$('.see-more-toggle > a').click(function(e){ e.preventDefault(); $(this).parent().prev('.see-more').toggleClass('expanded'); $('<style></style>').appendTo($(document.body)).remove(); if($(this).html()=='Click to show more.'){ $(this).html('Click to show less.'); $("#see-more-message").html("");} else { $(this).html('Click to show more.'); $("#see-more-message").html("<i>Only the first few lines are shown above.</i>");} });
}
});
/* Commented out pro tem while I dither if I want to do this.
* Show/Hide; shows a few lines; allows searches of all hidden text too :)
* From Ballotpedia page https://ballotpedia.org/Robert_Rowling
* This works for References.
$(document).ready( function($) {
// Add expand/contract functionality to references sections:
if ($('.references-small').height()>=140) {
$('.references-small').css('overflow','hidden').after('<div class="references-toggle"><span id="references-message">Only the first few references on this page are shown above.</span> <a href="#">Click to show more.</a></div>');
$('.references-toggle > a').click(function(e){ e.preventDefault(); $(this).parent().prev('.references-small').toggleClass('expanded'); $('<style></style>').appendTo($(document.body)).remove(); if($(this).html()=='Click to show more.'){ $(this).html('Click to show less.'); $("#references-message").html("");} else { $(this).html('Click to show more.'); $("#references-message").html("Only the first few references on this page are shown above.");} });
}
});
*/