Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
No edit summary
No edit summary
Line 299: Line 299:
}
}
});
});
$body.append(
$('<div>')
.addClass('wizlords-mobile-spellbook-collapse')
.attr('role', 'button')
.attr('tabindex', '0')
.attr('aria-label', 'Collapse ' + title)
);


return $book;
return $book;
Line 331: Line 339:
} else {
} else {
$header.removeAttr('aria-expanded');
$header.removeAttr('aria-expanded');
}
});
$('.wizlords-mobile-spellbook-collapse').each(function () {
var $control = $(this);
var isOpen = $control.closest('.wizlords-mobile-spellbook').hasClass('is-open');
if (spellbookQuery.matches) {
$control.attr('aria-expanded', isOpen ? 'true' : 'false');
} else {
$control.removeAttr('aria-expanded');
}
}
});
});
Line 382: Line 401:


$book.toggleClass('is-open', !isOpen);
$book.toggleClass('is-open', !isOpen);
$header.attr('aria-expanded', isOpen ? 'false' : 'true');
$book
.find('.wizlords-mobile-spellbook-header, .wizlords-mobile-spellbook-collapse')
.attr('aria-expanded', isOpen ? 'false' : 'true');
}
}


Line 403: Line 424:
$(document).on('click', '.wizlords-mobile-spellbook-header', function () {
$(document).on('click', '.wizlords-mobile-spellbook-header', function () {
toggleMobileSpellbook(this);
toggleMobileSpellbook(this);
});
$(document).on('click', '.wizlords-mobile-spellbook-collapse', function () {
toggleMobileSpellbook($(this).closest('.wizlords-mobile-spellbook').children('.wizlords-mobile-spellbook-header').first());
});
});


Line 416: Line 441:
event.preventDefault();
event.preventDefault();
toggleMobileSpellbook(this);
toggleMobileSpellbook(this);
}
});
$(document).on('keydown', '.wizlords-mobile-spellbook-collapse', function (event) {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
toggleMobileSpellbook($(this).closest('.wizlords-mobile-spellbook').children('.wizlords-mobile-spellbook-header').first());
}
}
});
});
}() );
}() );