打开/关闭菜单
Toggle preferences menu
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Gadget-collapsed.js

MediaWiki界面页面
Cirno.9讨论 | 贡献2023年2月11日 (六) 16:46的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
function bindCollpase() {
    $('.collpased-container').each(function (i,v) {
        $(this).attr('id','collapsed-'+i)
        $(this).attr('defheight',$('.data-folded').height())
        $(this).children('.collpased-title').bind('click',function(){
        	toggleCollapse('#collapsed-'+i)
        })
    })
}

function toggleCollapse(selector, openSpeed, closeSpeed){
    openSpeed = openSpeed !== undefined ? openSpeed : 'fast'
    closeSpeed = closeSpeed !== undefined ? closeSpeed : 'fast'
    selector = $(selector)
    var defaultHeight = selector.attr('defheight')*1
    var paddingHeight = 10
    var targetHeight = defaultHeight + paddingHeight + selector.children('.collpased-content').height()
    console.log(defaultHeight,targetHeight)
    var currentHeight = selector.height()
    if(defaultHeight === currentHeight){
        selector.animate({
            height: targetHeight
        }, openSpeed,function () {
            selector.removeClass('data-folded')
            selector.css('height','auto')
        });

    }else {
        selector.animate({
            height: defaultHeight
        }, closeSpeed);
        selector.addClass('data-folded')
    }
}

function tollgeAllCo(){
    $('.collpased-a').each(function () {
        $(this).click()
    })
}
bindCollpase()