Widget:TalkToc:修订间差异
跳到导航
跳到搜索
imported>=海豚= ([InPageEdit] 没有编辑摘要) |
imported>=海豚= ([InPageEdit] 没有编辑摘要 (编辑自Special:Diff/43088)) |
||
第9行: | 第9行: | ||
if (localStorage.getItem('widgetTalkToc') === 'disable') { | if (localStorage.getItem('widgetTalkToc') === 'disable') { | ||
$('body').addClass('widgetTalkTocDisable'); | $('body').addClass('widgetTalkTocDisable'); | ||
$('.toctitle').after('<' + 'div style="text-align: center;">[<' + 'a class="enableWidgetTalkToc">启用讨论页面整理工具<' + '/a>]<' + '/div>'); | |||
$('.enableWidgetTalkToc').on('click', function() { | |||
localStorage.setItem('widgetTalkToc', 'enable'); | |||
$(this).text('启用成功!刷新页面中……'); | |||
setTimeout(location.reload.bind(location), 150); | setTimeout(location.reload.bind(location), 150); | ||
}); | }); | ||
第59行: | 第63行: | ||
$toc.find(".toclevel-1 > a > .tocnumber").remove(); | $toc.find(".toclevel-1 > a > .tocnumber").remove(); | ||
$toc.appendTo("#tocBox"); | $toc.appendTo("#tocBox"); | ||
/* 定义变量 */ | |||
$tocBox = $('#tocBox'); | |||
$level2 = $toc.find('.toclevel-2').hide(); | |||
$li = $toc.find('ol > li'); | |||
$svdDcs = $toc.find('.savedDiscussion'); | |||
$title = $toc.find('.toctitle').css("margin-right", "1em").append('<' + 'span id="toctoggle"><' + '/span>'); | |||
$toggle = $title.append('<' + 'div id="toggle"><' + '/div>').find('#toggle'); | |||
$tocText = $title.after('<' + 'div id="tocText"><' + '/div>').parents('#toc').find('#tocText'); | |||
appendToggleButton = function($Obj, $set, shTx, hiTx, fun) { | |||
if (!$Obj[0]) return false; | |||
$set.append($('<' + 'a/>', { | |||
text: function() { | |||
if ($Obj.is(':visible')) return hiTx; | |||
else return shTx; | |||
}, | |||
'class': 'toggleButton', | |||
href: 'javascript:void(0);', | |||
bind: { | |||
click: function() { | |||
if ($Obj.is(':visible')) { | |||
$Obj.hide(); | |||
$(this).text(shTx); | |||
} else { | |||
$Obj.show(); | |||
$(this).text(hiTx); | |||
} | |||
} | |||
} | |||
})); | |||
if (typeof fun == 'function') fun(); | |||
}; | |||
/* 业务处理*/ | |||
//添加存档讨论串标题toggle按钮 | |||
if ($svdDcs[0]) { | |||
$toggle.append($('<' + 'a/>', { | |||
text: '显示已被存档标题', | |||
'class': 'toggleButton', | |||
href: 'javascript:void(0);', | |||
on: { | |||
click: function() { | |||
if ($svdDcs.hasClass('hiddenDiscussion')) { | |||
$svdDcs.removeClass('hiddenDiscussion'); | |||
$(this).text('隐藏已被存档标题'); | |||
} else { | |||
$svdDcs.addClass('hiddenDiscussion'); | |||
$(this).text('显示已被存档标题'); | |||
} | |||
} | |||
} | |||
})); | |||
$tocText.append("<" + "div class='tocText'>(有下划线标题是已被存档标题)<" + "/div>"); | |||
} | |||
//添加二三四五级标题toggle按钮和标题数量 | |||
appendToggleButton($level2, $toggle, '显示段落', '隐藏段落', function() { | |||
$tocText.append("<" + "div class='tocText'>(中括号内数字是该大段下小段数量)<" + "/div>"); | |||
$toc.find('.toclevel-1').each(function() { | |||
var subtitleLength = $(this).find('.toctext').length - 1; | |||
if (subtitleLength) $(this).children('a').after('[' + subtitleLength + ']'); | |||
}); | |||
}); | |||
} | |||
} | |||
}); | |||
}); | |||
</script><style> | </script><style> | ||
/* <pre> */ | /* <pre> */ |
2020年5月1日 (五) 20:14的版本
Only for Talk:讨论版 & Talk:提问求助区