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 212: Line 212:
'Summon Greater Arcane Servant': 'Greater Servant'
'Summon Greater Arcane Servant': 'Greater Servant'
};
};
var tabletSpellTitles = {
'Summon Arcane Servant - Attack': 'Arcane Servant – Attack',
'Summon Arcane Servant - Defend': 'Arcane Servant – Defend',
'Summon Minor Arcane Servant - Attack': 'Minor Arcane Servant – Attack',
'Summon Minor Arcane Servant - Defend': 'Minor Arcane Servant – Defend',
'Summon Greater Arcane Servant': 'Greater Arcane Servant'
};
function getMobileSpellTitle(title) {
if (window.matchMedia('(min-width: 600px) and (max-width: 899px)').matches) {
return tabletSpellTitles[title] || title;
}
return mobileSpellTitles[title] || title;
}
function updateMobileSpellTitles() {
$('.wizlords-mobile-spell-card-title[data-wizlords-source-title]').each(function () {
var $title = $(this);
$title.text(getMobileSpellTitle($title.attr('data-wizlords-source-title')));
});
}


function getSpellIcon(iconType) {
function getSpellIcon(iconType) {
Line 237: Line 261:
function buildMobileSpellCard($sourceCard, iconType) {
function buildMobileSpellCard($sourceCard, iconType) {
var title = $.trim($sourceCard.children('.wizlords-spell-card-title').first().text());
var title = $.trim($sourceCard.children('.wizlords-spell-card-title').first().text());
var mobileTitle = mobileSpellTitles[title] || title;
var $card = $('<div>').addClass('wizlords-mobile-spell-card');
var $card = $('<div>').addClass('wizlords-mobile-spell-card');
var $icon = $('<div>').addClass('wizlords-mobile-spell-card-icon').append(getSpellIcon(iconType));
var $icon = $('<div>').addClass('wizlords-mobile-spell-card-icon').append(getSpellIcon(iconType));
var $title = $('<div>').addClass('wizlords-mobile-spell-card-title').text(mobileTitle);
var $title = $('<div>')
.addClass('wizlords-mobile-spell-card-title')
.attr('data-wizlords-source-title', title)
.text(getMobileSpellTitle(title));
var $summary = $('<div>').addClass('wizlords-mobile-spell-card-summary').text(spellSummaries[title] || '');
var $summary = $('<div>').addClass('wizlords-mobile-spell-card-summary').text(spellSummaries[title] || '');
var $rules = $('<div>').addClass('wizlords-mobile-spell-card-rules');
var $rules = $('<div>').addClass('wizlords-mobile-spell-card-rules');
Line 357: Line 383:
function initialiseMobileSpellCards() {
function initialiseMobileSpellCards() {
buildMobileSpellbooks();
buildMobileSpellbooks();
updateMobileSpellTitles();


$('.wizlords-spellbooks-mobile').attr('aria-hidden', spellbookQuery.matches ? 'false' : 'true');
$('.wizlords-spellbooks-mobile').attr('aria-hidden', spellbookQuery.matches ? 'false' : 'true');