Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
| Line 17: | Line 17: | ||
$(document).ready( function($) { | $(document).ready( function($) { | ||
// Add expand/contract functionality to references sections: | // Add expand/contract functionality to references sections: | ||
| − | if ($('.structure-small').height()>= | + | if ($('.structure-small').height()>=100) { |
$('.structure-small').css('overflow','hidden').after('<div class="structure-toggle"><span id="structure-message">Only the first few references on this page are shown above.</span> <a href="#">Click to show more.</a></div>'); | $('.structure-small').css('overflow','hidden').after('<div class="structure-toggle"><span id="structure-message">Only the first few references on this page are shown above.</span> <a href="#">Click to show more.</a></div>'); | ||
$('.structure-toggle > a').click(function(e){ e.preventDefault(); $(this).parent().prev('.structure-small').toggleClass('expanded'); $('<style></style>').appendTo($(document.body)).remove(); if($(this).html()=='Click to show more.'){ $(this).html('Click to show less.'); $("#structure-message").html("");} else { $(this).html('Click to show more.'); $("#structure-message").html("Only the first few references on this page are shown above.");} }); | $('.structure-toggle > a').click(function(e){ e.preventDefault(); $(this).parent().prev('.structure-small').toggleClass('expanded'); $('<style></style>').appendTo($(document.body)).remove(); if($(this).html()=='Click to show more.'){ $(this).html('Click to show less.'); $("#structure-message").html("");} else { $(this).html('Click to show more.'); $("#structure-message").html("Only the first few references on this page are shown above.");} }); | ||
} | } | ||
}); | }); | ||
Revision as of 14:11, 18 July 2019
/* Any JavaScript here will be loaded for all users on every page load. */
/*
* Show/Hide for Company Structure
* From Ballotpedia page https://ballotpedia.org/Robert_Rowling
* Testing out on [[Tetragon Financial Group Ltd]]
* 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.");} });
}
});
*/
$(document).ready( function($) {
// Add expand/contract functionality to references sections:
if ($('.structure-small').height()>=100) {
$('.structure-small').css('overflow','hidden').after('<div class="structure-toggle"><span id="structure-message">Only the first few references on this page are shown above.</span> <a href="#">Click to show more.</a></div>');
$('.structure-toggle > a').click(function(e){ e.preventDefault(); $(this).parent().prev('.structure-small').toggleClass('expanded'); $('<style></style>').appendTo($(document.body)).remove(); if($(this).html()=='Click to show more.'){ $(this).html('Click to show less.'); $("#structure-message").html("");} else { $(this).html('Click to show more.'); $("#structure-message").html("Only the first few references on this page are shown above.");} });
}
});