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

MediaWiki:Gadget-collapsed.js:修订间差异

MediaWiki界面页面
无编辑摘要
无编辑摘要
 
(未显示同一用户的9个中间版本)
第1行: 第1行:
function bindCollpase() {
function bindCollpase() {
     $('.collpased-container').each(function () {
     $('.collpased-container').each(function (i,v) {
         $(this).children('.collpased-head').after('<a href="#" class="collpased-a">▼点击展开▼</a>')
         $(this).attr('id','collapsed-'+i)
         $(this).children('.collpased-a').bind('click',{t:$(this)},function (event) {
        $(this).attr('defheight',$('.data-folded').height())
            toggleCollapse(event.data.t)
         $(this).children('.collpased-title').bind('click',function(){
        toggleCollapse('#collapsed-'+i)
         })
         })
     })
     })
}
}
function openAllCollapse(){
 
    $('.collpased-container').each(function () {
function toggleCollapse(selector, openSpeed, closeSpeed){
        openCollapse($(this))
     openSpeed = openSpeed !== undefined ? openSpeed : 'fast'
    })
     closeSpeed = closeSpeed !== undefined ? closeSpeed : 'fast'
}
     selector = $(selector)
function openCollapse(obj){
     var defaultHeight = selector.attr('defheight')*1
     var temp = $('<div class="collpased-temp"></div>')
     var paddingHeight = 10
    temp.html(obj.children('.collpased-content').html())
     var targetHeight = defaultHeight + paddingHeight + selector.children('.collpased-content').height()
     temp.css('display','none')
     console.log(defaultHeight,targetHeight)
    temp.appendTo(obj)
     var currentHeight = selector.height()
     var defHeight = $('.collpased-temp').height()
     if(defaultHeight === currentHeight){
     var slideHeight = 0;
         selector.animate({
    var curHeight = obj.children('.collpased-content').height();
             height: targetHeight
     var move = 3+obj.children('.collpased-head').height()/2
         }, openSpeed,function () {
     console.log(curHeight)
            selector.removeClass('data-folded')
    if(curHeight===slideHeight){
            selector.css('height','auto')
        obj.addClass('blue-border')
         });
        obj.children('.collpased-a').css('display','none')
 
        obj.children('.collpased-head').animate({
            top: '-='+move+'px',
        }, "normal");
        obj.children('.collpased-content').animate({
            height: defHeight
        }, "normal");
        obj.children('.collpased-a').html('▲点击收起▲');
        obj.children('.collpased-a').fadeIn('fast')
     }
}
function closeAllCollapse(){
    $('.collpased-container').each(function () {
        closeCollapse($(this))
    })
}
function closeCollapse(obj){
    var temp = $('<div class="collpased-temp"></div>')
    temp.html(obj.children('.collpased-content').html())
    temp.css('display','none')
    temp.appendTo(obj)
     var defHeight = $('.collpased-temp').height()
     var slideHeight = 0;
    var curHeight = obj.children('.collpased-content').height();
    var move = 3+obj.children('.collpased-head').height()/2
    console.log(curHeight)
    if(curHeight!==slideHeight){
         obj.children('.collpased-a').css('display','none')
        obj.removeClass('blue-border')
        obj.children('.collpased-head').animate({
             top: '+='+move+'px',
            border: '1px solid red'
         }, "normal");
        obj.children('.collpased-content').animate({
            height: slideHeight
        }, "normal");
        obj.children('.collpased-a').html('▼点击展开▼');
        obj.children('.collpased-a').fadeIn('fast')
    }
}
function toggleCollapse(obj){
    var temp = $('<div class="collpased-temp"></div>')
    temp.html(obj.children('.collpased-content').html())
    temp.css('display','none')
    temp.appendTo(obj)
    var defHeight = $('.collpased-temp').height()
    var slideHeight = 0;
    var curHeight = obj.children('.collpased-content').height();
    var move = 3+obj.children('.collpased-head').height()/2
    console.log(curHeight)
    if(curHeight===slideHeight){
        obj.addClass('blue-border')
        obj.children('.collpased-a').css('display','none')
        obj.children('.collpased-head').animate({
            top: '-='+move+'px',
        }, "normal");
        obj.children('.collpased-content').animate({
            height: defHeight
         }, "normal");
        obj.children('.collpased-a').html('▲点击收起▲');
        obj.children('.collpased-a').fadeIn('fast')
     }else {
     }else {
         obj.children('.collpased-a').css('display','none')
         selector.animate({
        obj.removeClass('blue-border')
             height: defaultHeight
        obj.children('.collpased-head').animate({
         }, closeSpeed);
            top: '+='+move+'px',
         selector.addClass('data-folded')
            border: '1px solid red'
        }, "normal");
        obj.children('.collpased-content').animate({
             height: slideHeight
         }, "normal");
         obj.children('.collpased-a').html('▼点击展开▼');
        obj.children('.collpased-a').fadeIn('fast')
     }
     }
    $('.collpased-temp').remove()
}
}



2023年2月11日 (六) 16:46的最新版本

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()