Widget:chibiCostumeSwitcher: Difference between revisions
Jump to navigation
Jump to search
Initial setup for testing |
Changed the way chibi costume IDs are determined |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly><script> | <includeonly><script> | ||
RLQ.push(function () { | RLQ.push(['jquery', function () { | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// Let's make sure the correct values are shown | // Let's make sure the correct values are shown | ||
$('. | $('.chibi-costume-switcher').change(); | ||
}); | }); | ||
}); | }]); | ||
function swap_costume(element, targetId) { | |||
function swap_costume(element) { | |||
var neededGadgets = [ 'ext.gadget.md5hasher' ]; | var neededGadgets = [ 'ext.gadget.md5hasher' ]; | ||
if (mw.user.options.get("gadget-chibiAnimation") == 1) { | if (mw.user.options.get("gadget-chibiAnimation") == 1) { | ||
Line 26: | Line 15: | ||
// Switch costume when everything is ready | // Switch costume when everything is ready | ||
mw.loader.using(neededGadgets).then(function () { | mw.loader.using(neededGadgets).then(function () { | ||
swap_costume_intern(element); | swap_costume_intern(element, targetId); | ||
}); | }); | ||
} | } | ||
function swap_costume_intern(element) { | function swap_costume_intern(element, targetId) { | ||
var selectBox = $(element); | var selectBox = $(element); | ||
var chibiCostumeName = selectBox.val(); | |||
if (chibiCostumeName != "") { | |||
chibiCostumeName = "_" + chibiCostumeName; | |||
chibiCostumeName = " | |||
} | } | ||
var | var targetSelector = targetId == "" ? ".chibiAnimationContainer" : ("#" + targetId); | ||
$(targetSelector).attr('data-tdoll-costume', chibiCostumeName); | |||
$(targetSelector).find('.chibiAnimation').trigger("costume_changed", chibiCostumeName); | |||
var tdollId = selectBox.closest('.costumeContainer').find('.tdoll_chibi').data('tdollId'); | var tdollId = selectBox.closest('.costumeContainer').find('.tdoll_chibi').data('tdollId'); | ||
var costumeId = tdollId + chibiCostumeName; | var costumeId = tdollId + chibiCostumeName; | ||
Line 48: | Line 37: | ||
var cpp = window.gfUtils.createWikiPathPart; | var cpp = window.gfUtils.createWikiPathPart; | ||
var | var basePath = "/"; | ||
var chibiPath = basePath + cpp(costumeId +"_chibi.png") + costumeId +"_chibi.png"; | var chibiPath = basePath + cpp(costumeId +"_chibi.png") + costumeId +"_chibi.png"; | ||
Line 55: | Line 44: | ||
</script> | </script> | ||
<select class="gf-droplist chibi-costume-switcher" autocomplete="off" onchange="swap_costume(this, '<!--{$target|escape:'html'}-->')" > | |||
<select class="gf-droplist" autocomplete="off" onchange="swap_costume(this)" > | <option value="" selected="selected">Default</option> | ||
<option value=" | |||
<!--{foreach from=$costumes key=key item=item}--> | <!--{foreach from=$costumes key=key item=item}--> | ||
<!--{if $item neq ''}--><option value="<!--{$key|escape:'html'}-->"><!--{$item|escape:'html'}--></option><!--{/if}--> | |||
<!--{/foreach}--> | <!--{/foreach}--> | ||
</select | </select></includeonly> | ||
<noinclude> | <noinclude> | ||
{{#widget:chibiCostumeSwitcher | {{#widget:chibiCostumeSwitcher | ||
|target=enemyChibiAnimation | |target=enemyChibiAnimation | ||
|costumes. | |costumes.costume1=Elite form | ||
|costumes. | |costumes.costume2=Another variant | ||
|costumes. | |costumes.costume3=Third variant | ||
|costumes.costume4= | |||
|costumes.costume5= | |||
|costumes.costume6= | |||
}} | }} | ||
<div id="enemyChibiAnimation" class="chibiAnimationContainer" data-tdoll-id="Executioner" data-tdoll-hidedormbutton="true"></div> | <div id="enemyChibiAnimation" class="chibiAnimationContainer" data-tdoll-id="Executioner" data-tdoll-hidedormbutton="true" style="border: thin dashed gray;"> </div> | ||
</noinclude> | </noinclude> |
Latest revision as of 23:26, 7 April 2020