MediaWiki

EventList.js:修订间差异

来自卡厄思梦境WIKI

律Rhyme留言 | 贡献
无编辑摘要
律Rhyme留言 | 贡献
无编辑摘要
第1行: 第1行:
$(function() {
$(function() {
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');


     // 计算并设置容器高度
     // 计算并设置容器高度
第33行: 第33行:
     });
     });
      
      
     // 图片点击跳转
     // 监听窗口大小变化,重新计算高度
     $('.event-image').click(function(e) {
     $(window).on('resize', function() {
         var $container = $(this).closest('.event-container');
         $('.event-container').each(function() {
        var eventId = $container.data('event-id');
            calculateHeight($(this));
        var $link = $(this).find('a');
         });
          
     });
        if ($link.length > 0) {
            window.location.href = $link.attr('href');
        }
     }).css('cursor', 'pointer');
});
});

2025年10月18日 (六) 13:38的版本

$(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));
    });
    
    // 监听窗口大小变化,重新计算高度
    $(window).on('resize', function() {
        $('.event-container').each(function() {
            calculateHeight($(this));
        });
    });
});