Widget:chibiCostumeSwitcher: Difference between revisions
Jump to navigation
Jump to search
Initial setup for testing |
Trying to get the costume array to run |
||
Line 18: | Line 18: | ||
} | } | ||
function swap_costume(element) { | function swap_costume(element, targetId) { | ||
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 26: | ||
// 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); | ||
Line 39: | Line 39: | ||
chibiCostumeName = "_costume" + costumeSelectionIndex | chibiCostumeName = "_costume" + costumeSelectionIndex | ||
} | } | ||
var | var targetSelector = targetId == "" ? ".chibiAnimationContainer" : ("#" + targetId); | ||
$(targetSelector).find('.chibiAnimation,.live2dAnimation,.artTab').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 48: | ||
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 55: | ||
</script> | </script> | ||
<select class="gf-droplist" autocomplete="off" onchange="swap_costume(this, '<!--{$target|escape:'html'}-->')" > | |||
<select class="gf-droplist" autocomplete="off" onchange="swap_costume(this)" > | |||
<option value="{{BASEPAGENAME}}" selected="selected">Default</option> | <option value="{{BASEPAGENAME}}" selected="selected">Default</option> | ||
<!--{foreach from=$costumes key=key item=item}--> | <!--{foreach from=$costumes key=key item=item}--> | ||
<!--{if $item ''}--><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> |
Revision as of 15:10, 7 July 2018