EventList.js:修订间差异
来自卡厄思梦境WIKI
无编辑摘要 |
无编辑摘要 |
||
| 第2行: | 第2行: | ||
mw.loader.load( mw.util.getUrl( 'MediaWiki:EventList.css', { action: 'raw', ctype: 'text/css' } ), 'text/css' ); | mw.loader.load( mw.util.getUrl( 'MediaWiki:EventList.css', { action: 'raw', ctype: 'text/css' } ), 'text/css' ); | ||
// 计算并设置容器高度 | // 计算并设置容器高度 | ||
function calculateHeight($container) { | function calculateHeight($container) { | ||
| 第44行: | 第12行: | ||
}); | }); | ||
// | // 计算所有效果的高度 | ||
$container.find('.event-effect | $container.find('.event-effect').each(function() { | ||
totalHeight += $(this).outerHeight(true); | totalHeight += $(this).outerHeight(true); | ||
}); | }); | ||
| 第64行: | 第32行: | ||
calculateHeight($(this)); | calculateHeight($(this)); | ||
}); | }); | ||
// 图片点击跳转 | |||
$('.event-image').click(function(e) { | |||
var $container = $(this).closest('.event-container'); | |||
var eventId = $container.data('event-id'); | |||
var $link = $(this).find('a'); | |||
if ($link.length > 0) { | |||
window.location.href = $link.attr('href'); | |||
} | |||
}).css('cursor', 'pointer'); | |||
}); | }); | ||
2025年10月18日 (六) 13:32的版本
$(function() {
mw.loader.load( mw.util.getUrl( 'MediaWiki:EventList.css', { action: 'raw', ctype: 'text/css' } ), 'text/css' );
// 计算并设置容器高度
function calculateHeight($container) {
var baseHeight = 170; // 基础高度(到选项区域)
var totalHeight = baseHeight;
// 计算所有选项的高度
$container.find('.event-option').each(function() {
totalHeight += $(this).outerHeight(true);
});
// 计算所有效果的高度
$container.find('.event-effect').each(function() {
totalHeight += $(this).outerHeight(true);
});
// 添加底部间距
totalHeight += 15;
// 设置容器和背景高度
$container.css('min-height', totalHeight + 'px');
// 背景高度 = 总高度 - 顶部偏移
var bgHeight = totalHeight - 160;
$container.find('.event-background').css('height', bgHeight + 'px');
}
// 初始化时计算所有容器的高度
$('.event-container').each(function() {
calculateHeight($(this));
});
// 图片点击跳转
$('.event-image').click(function(e) {
var $container = $(this).closest('.event-container');
var eventId = $container.data('event-id');
var $link = $(this).find('a');
if ($link.length > 0) {
window.location.href = $link.attr('href');
}
}).css('cursor', 'pointer');
});