mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
b551d521f9
* SUS-3245: Emit scroll event on Portable Infobox collapsible group state change * SUS-3245 use template literal
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
(function (window, $) {
|
|
'use strict';
|
|
|
|
var ImageCollection = {
|
|
init: function($content) {
|
|
var $imageCollections = $content.find('.pi-image-collection');
|
|
|
|
$imageCollections.each( function( index ) {
|
|
var $collection = $imageCollections.eq(index),
|
|
$tabs = $collection.find('ul.pi-image-collection-tabs li'),
|
|
$tabContent = $collection.find('.pi-image-collection-tab-content');
|
|
|
|
$tabs.click( function() {
|
|
var $target = $(this),
|
|
tabId = $target.attr('data-pi-tab');
|
|
|
|
$tabs.removeClass('current');
|
|
$tabContent.removeClass('current');
|
|
|
|
$target.addClass('current');
|
|
$collection.find('#' + tabId).addClass('current');
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
var CollapsibleGroup = {
|
|
init: function($content) {
|
|
var $collapsibleGroups = $content.find('.pi-collapse');
|
|
|
|
$collapsibleGroups.each( function( index ) {
|
|
var $group = $collapsibleGroups.eq(index),
|
|
$header = $group.find('.pi-header:first');
|
|
|
|
$header.click( function() {
|
|
$group.toggleClass('pi-collapse-closed');
|
|
|
|
// SUS-3245: lazy-load any images in the un-collapsed section
|
|
$(window).trigger('scroll');
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
mw.hook('wikipage.content').add(function($content) {
|
|
ImageCollection.init($content);
|
|
CollapsibleGroup.init($content);
|
|
});
|
|
})(window, jQuery);
|