MediaWiki:Gadget-GlobalScript.js: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
}
}
mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup);
mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup);
/* Fix search suggestions on mobile devices */
$(function() {
$('#searchInput').on('input', function(e) {
$(this).trigger(jQuery.Event('keydown', {
keyCode: e.keyCode,
which: e.which
}));
$(this).trigger(jQuery.Event('keypress', {
keyCode: e.keyCode,
which: e.which
}));
});
});


/* Clean-up Unicode */
/* Clean-up Unicode */
Line 29: Line 43:
setTimeout(function() { $('.header-action button').click(unicodeFixer) }, 3000);
setTimeout(function() { $('.header-action button').click(unicodeFixer) }, 3000);
}
}
});
/* Gallery videos */
$(function() {
$('.gallery').each(function(i, gallery) {
var videos = $(gallery).find('.gallerybox video');
if (!videos.length)
return;
var boxes = $(gallery).find('.gallerybox');
var onlyVideos = videos.length == boxes.length ? true : false;
videos.each(function(ii, video) {
if (onlyVideos)
$(video).css('height', 'auto');
$(video).parent().css({'max-width': 'calc(100% - 30px)', 'margin': '15px auto'});
});
var timeOut = onlyVideos ? 1000 : 0;
setTimeout(function() {
var height = 0;
$(gallery).find('.gallerybox .thumb').each(function(ii, thumb) {
if ($(thumb).innerHeight() > height)
height = $(thumb).innerHeight();
});
videos.each(function(ii, video) {
maxHeight = height - 30;
$(video).parent().parent().css({'height': height, 'display': 'flex'});
$(video).parent().css({'width': '100%', 'min-width': '125px', 'margin': 'auto'});
$(video).css({'height': 'auto', 'max-height': maxHeight});
});
}, timeOut);
});
});
});