MediaWiki:Common.js: Difference between revisions
MediaWiki interface page
More actions
No edit summary |
No edit summary |
||
| Line 205: | Line 205: | ||
}; | }; | ||
function | function getSpellIcon(iconType) { | ||
var $sourceIcon = $('.wizlords-magic-intro-icon img'). | var iconIndex = iconType === 'divine' ? 1 : 0; | ||
var $sourceIcon = $('.wizlords-magic-intro-icon img').eq(iconIndex); | |||
if (!$sourceIcon.length) { | if (!$sourceIcon.length) { | ||
| Line 221: | Line 222: | ||
} | } | ||
function buildMobileSpellCard($sourceCard) { | 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 $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( | var $icon = $('<div>').addClass('wizlords-mobile-spell-card-icon').append(getSpellIcon(iconType)); | ||
var $title = $('<div>').addClass('wizlords-mobile-spell-card-title').text(title); | var $title = $('<div>').addClass('wizlords-mobile-spell-card-title').text(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] || ''); | ||
| Line 240: | Line 241: | ||
} | } | ||
function buildMobileSpellbook(sourceSelector, title, variantClass) { | function buildMobileSpellbook(sourceSelector, title, variantClass, iconType) { | ||
var $source = $(sourceSelector); | var $source = $(sourceSelector); | ||
var $content = $source.children('.mw-collapsible-content').first(); | var $content = $source.children('.mw-collapsible-content').first(); | ||
| Line 270: | Line 271: | ||
$node.children('.wizlords-spell-card').each(function () { | $node.children('.wizlords-spell-card').each(function () { | ||
$currentCategory.append(buildMobileSpellCard($(this))); | $currentCategory.append(buildMobileSpellCard($(this), iconType)); | ||
}); | }); | ||
} | } | ||
| Line 287: | Line 288: | ||
$target | $target | ||
.empty() | .empty() | ||
.append(buildMobileSpellbook('#wizlords-arcane-spellbook', 'Arcane Spellbook', 'wizlords-mobile-spellbook-arcane')) | .append(buildMobileSpellbook('#wizlords-arcane-spellbook', 'Arcane Spellbook', 'wizlords-mobile-spellbook-arcane', 'arcane')) | ||
.append(buildMobileSpellbook('#wizlords-divine-spellbook', 'Divine Spellbook', 'wizlords-mobile-spellbook-divine')); | .append(buildMobileSpellbook('#wizlords-divine-spellbook', 'Divine Spellbook', 'wizlords-mobile-spellbook-divine', 'divine')); | ||
hasBuiltMobileSpellbooks = true; | hasBuiltMobileSpellbooks = true; | ||