MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(Character voice preview, init player on click instead of page ready to avoid TMH meddling) |
mNo edit summary |
||
Line 121: | Line 121: | ||
/* Character voice preview - start */ |
|||
$( document ).ready(function() { |
|||
initCharacterVoice(); |
|||
}); |
|||
function initCharacterVoice(){ |
|||
var voice = $(".character td.character-voice"); |
|||
if (voice.length && voice.attr('data-voice').length) { |
|||
$(".character td.character-voice-preview").on("click", playCharacterVoice()); |
|||
} |
|||
} |
|||
function playCharacterVoice(){ |
|||
var voice = $(".character td.character-voice"); |
|||
if (voice.find('audio').length == 0) { |
|||
voice.wrapInner('<span>'); |
|||
if (voice.find("span").width() > voice.width()-36 ) voice.css('padding-right', '16px'); |
|||
voice.find("span").children().unwrap(); |
|||
voice.append('<audio class="voice-clip" src="'+voice.attr('data-voice')+'"></audio>').addClass('character-voice-preview'); |
|||
voice.find('audio')[0].volume=0.6; |
|||
} |
|||
voice.find('audio')[0].play(); |
|||
} |
|||
/* Character voice preview - end */ |
|||