8,290
edits
m (restore the visibility thing I accidentally deleted) |
(selector fix) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 102: | Line 102: | ||
var qudCarouselGearbox = qudCarouselGearbox || { | var qudCarouselGearbox = qudCarouselGearbox || { | ||
initialize: function () { | initialize: function () { | ||
$( | $(".qud-sprite-carousel").each(function (idx1, elem1) { | ||
$(elem1).find('.qud-carousel-item').each(function (idx, elem) { | |||
$(elem).addClass("qud-carousel-item-number-" + idx); | |||
if ($(elem).is(":visible")) { | |||
} | window.qudCarouselGearbox.currentIndex = idx; | ||
} | |||
}); | |||
}); | }); | ||
$( | $(".qud-sprite-carousel .qud-carousel-btn-left").click(function () { | ||
window.qudCarouselGearbox.removeHighlight(); | window.qudCarouselGearbox.removeHighlight(); | ||
window.qudCarouselGearbox.rotate(-1); | window.qudCarouselGearbox.rotate($(this).closest('.qud-sprite-carousel'), -1); | ||
}); | }); | ||
$( | $(".qud-sprite-carousel .qud-carousel-btn-right").click(function () { | ||
window.qudCarouselGearbox.removeHighlight(); | window.qudCarouselGearbox.removeHighlight(); | ||
window.qudCarouselGearbox.rotate(1); | window.qudCarouselGearbox.rotate($(this).closest('.qud-sprite-carousel'), 1); | ||
}); | }); | ||
$( | $(".infobox-title").append('<div class="qud-carousel-title"></div>'); | ||
}, | }, | ||
rotate: function (amount) { | rotate: function (parentElem, amount) { | ||
items = $(' | items = $(parentElem).find('.qud-carousel-item'); | ||
curIndex = 0 | |||
$(items).each(function (idx, elem) { | $(items).each(function (idx, elem) { | ||
if ($(elem).is(":visible")) { | |||
curIndex = idx | |||
} | |||
$(elem).hide(); | $(elem).hide(); | ||
}); | }); | ||
curIndex += amount | |||
end = $(items).length - 1; | end = $(items).length - 1; | ||
if ( | if (curIndex < 0) { | ||
curIndex = end; | |||
} else if ( | } else if (curIndex > end) { | ||
curIndex = 0; | |||
} | } | ||
curItem = $( | curItem = $(parentElem).find('.qud-carousel-item-number-' + curIndex).first(); | ||
curItem.show(); | curItem.show(); | ||
/* expand infobox title to also show image label */ | /* expand infobox title to also show image label */ | ||
carouselTitle = $('.qud-carousel-title'); | carouselTitle = $(parentElem).closest('.moduleinfobox').find('.infobox-title > .qud-carousel-title').first(); | ||
carouselTitle.text(curItem.data( | carouselTitle.text(curItem.data("label")); | ||
carouselTitle.animate({ height: | carouselTitle.animate({ height: "25px" }); | ||
}, | }, | ||
removeHighlight: function () { | removeHighlight: function () { | ||
Line 153: | Line 156: | ||
/* End Qud infobox image-to-gif swapper * | /* End Qud infobox image-to-gif swapper * | ||
/****************************************/ | /****************************************/ | ||
/************************* | |||
/* Qud inline gif player * | |||
/*************************/ | |||
// Author: egocarib | |||
// Date: 2020-Oct | |||
// License: CC-BY 3.0 | |||
// Code for a simple little gif mask / click to play widget. | |||
// See Template:Masked_gif for a demo | |||
var qudInlineGifMasker = qudInlineGifMasker || { | |||
initialize: function () { | |||
$('.qud-inline-gif').click(function () { | |||
window.qudInlineGifMasker.toggle(this); | |||
}); | |||
}, | |||
toggle: function(elem) { | |||
$(elem).find('*').toggleClass('qud-invisible'); | |||
} | |||
}; | |||
window.qudInlineGifMasker = qudInlineGifMasker; | |||
$(document).ready(qudInlineGifMasker.initialize); | |||
/***************************** | |||
/* End Qud inline gif player * | |||
/*****************************/ |