2015-10-20 16:40:56 +00:00
|
|
|
(function (window, $) {
|
|
|
|
'use strict';
|
|
|
|
|
2018-08-12 13:56:54 +00:00
|
|
|
var MediaCollection = {
|
2015-12-04 20:38:10 +00:00
|
|
|
init: function($content) {
|
2018-08-12 13:56:54 +00:00
|
|
|
var $mediaCollections = $content.find('.pi-media-collection');
|
2015-10-20 16:40:56 +00:00
|
|
|
|
2018-08-12 13:56:54 +00:00
|
|
|
$mediaCollections.each( function( index ) {
|
|
|
|
var $collection = $mediaCollections.eq(index),
|
|
|
|
$tabs = $collection.find('ul.pi-media-collection-tabs li'),
|
|
|
|
$tabContent = $collection.find('.pi-media-collection-tab-content');
|
2015-10-20 16:40:56 +00:00
|
|
|
|
2015-10-21 02:55:23 +00:00
|
|
|
$tabs.click( function() {
|
|
|
|
var $target = $(this),
|
|
|
|
tabId = $target.attr('data-pi-tab');
|
2015-10-20 16:40:56 +00:00
|
|
|
|
2015-10-21 02:55:23 +00:00
|
|
|
$tabs.removeClass('current');
|
|
|
|
$tabContent.removeClass('current');
|
2015-10-20 16:40:56 +00:00
|
|
|
|
2015-10-21 02:55:23 +00:00
|
|
|
$target.addClass('current');
|
|
|
|
$collection.find('#' + tabId).addClass('current');
|
|
|
|
});
|
2015-10-20 16:40:56 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-26 22:18:28 +00:00
|
|
|
var CollapsibleGroup = {
|
2015-12-04 20:38:10 +00:00
|
|
|
init: function($content) {
|
|
|
|
var $collapsibleGroups = $content.find('.pi-collapse');
|
2015-10-26 22:18:28 +00:00
|
|
|
|
2017-11-14 10:32:16 +00:00
|
|
|
$collapsibleGroups.each( function( index ) {
|
2015-10-26 22:18:28 +00:00
|
|
|
var $group = $collapsibleGroups.eq(index),
|
2017-01-11 13:43:45 +00:00
|
|
|
$header = $group.find('.pi-header:first');
|
2015-10-26 22:18:28 +00:00
|
|
|
|
|
|
|
$header.click( function() {
|
|
|
|
$group.toggleClass('pi-collapse-closed');
|
2017-11-14 10:32:16 +00:00
|
|
|
|
|
|
|
// SUS-3245: lazy-load any images in the un-collapsed section
|
|
|
|
$(window).trigger('scroll');
|
2015-10-26 22:18:28 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2015-12-04 20:38:10 +00:00
|
|
|
};
|
2015-10-26 22:18:28 +00:00
|
|
|
|
2019-02-26 18:51:42 +00:00
|
|
|
var Panel = {
|
|
|
|
init: function($content) {
|
|
|
|
var $panels = $content.find('.pi-panel');
|
|
|
|
|
|
|
|
$panels.each( function( index ) {
|
|
|
|
var $panel = $panels.eq(index),
|
|
|
|
$toggles = $panel.find('.pi-section-navigation');
|
|
|
|
|
|
|
|
$toggles.on('click', function(e) {
|
|
|
|
var toggle = e.target.closest('.pi-section-tab');
|
|
|
|
|
|
|
|
if (toggle !== null) {
|
|
|
|
var $newActiveToggle = $(toggle),
|
|
|
|
newRef = $newActiveToggle.attr('data-ref'),
|
|
|
|
$oldActiveToggle = $toggles.find('.pi-section-active'),
|
|
|
|
$oldActiveContent = $panel.find('.pi-section-content.pi-section-active'),
|
|
|
|
$newActiveContent = $panel.find('.pi-section-content[data-ref=' + newRef + ']');
|
|
|
|
|
|
|
|
$oldActiveToggle.removeClass('pi-section-active');
|
|
|
|
$oldActiveContent.removeClass('pi-section-active');
|
|
|
|
|
|
|
|
$newActiveToggle.addClass('pi-section-active');
|
|
|
|
$newActiveContent.addClass('pi-section-active');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2015-12-04 20:38:10 +00:00
|
|
|
mw.hook('wikipage.content').add(function($content) {
|
2018-08-12 13:56:54 +00:00
|
|
|
MediaCollection.init($content);
|
2015-12-04 20:38:10 +00:00
|
|
|
CollapsibleGroup.init($content);
|
2019-02-26 18:51:42 +00:00
|
|
|
Panel.init($content);
|
2015-12-04 20:38:10 +00:00
|
|
|
});
|
2015-10-20 16:40:56 +00:00
|
|
|
})(window, jQuery);
|