MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
/* Bottom collapse controls */ | /* Bottom collapse controls */ | ||
mw.loader.using('jquery.makeCollapsible').then(function () { | mw.loader.using('jquery.makeCollapsible').then(function () { | ||
function updateExampleTableState($table) { | |||
$table | |||
.children('caption') | |||
.attr('aria-expanded', $table.hasClass('mw-collapsed') ? 'false' : 'true'); | |||
} | |||
$('.wizlords-example-table.mw-collapsible').each(function () { | |||
var $table = $(this); | |||
$table | |||
.children('caption') | |||
.attr('role', 'button') | |||
.attr('tabindex', '0'); | |||
updateExampleTableState($table); | |||
}); | |||
$(document).on('click', '.wizlords-example-table.mw-collapsible > caption', function (event) { | |||
if ($(event.target).closest('.mw-collapsible-toggle').length) { | |||
return; | |||
} | |||
var $table = $(this).closest('.wizlords-example-table'); | |||
var $toggle = $table.find('> caption .mw-collapsible-toggle').first(); | |||
if ($toggle.length) { | |||
$toggle.trigger('click'); | |||
window.setTimeout(function () { | |||
updateExampleTableState($table); | |||
}, 0); | |||
} | |||
}); | |||
$(document).on('keydown', '.wizlords-example-table.mw-collapsible > caption', function (event) { | |||
if (event.key === 'Enter' || event.key === ' ') { | |||
event.preventDefault(); | |||
$(this).trigger('click'); | |||
} | |||
}); | |||
function collapseFromBottom(toggleClass, collapsibleId) { | function collapseFromBottom(toggleClass, collapsibleId) { | ||
$(document).on('click', toggleClass, function (event) { | $(document).on('click', toggleClass, function (event) { | ||