Skip to content

Instantly share code, notes, and snippets.

@Illvili
Last active August 29, 2015 14:13
Show Gist options
  • Save Illvili/4e31fa2f48856d56507b to your computer and use it in GitHub Desktop.
Save Illvili/4e31fa2f48856d56507b to your computer and use it in GitHub Desktop.
collapsible-fix
.mw-collapsible.wikitable {
display:table;
}
.mw-collapsible.wikitable img {
max-width:100%;
}
.mw-collapsible > tbody > tr:first-child > th {
position:relative;
padding-left:3em;
}
.mw-collapsible.mw-collapsed > tbody > tr:nth-child(n+2) {
display:none;
}
.collapse-toggle {
position:absolute;
left:0;
top:0;
bottom:0;
font-family:monospace;
color:#ba0000;
font-size:90%;
width:3.5em;
}
.collapse-toggle > span {
position:absolute;
left:0;
right:0;
top:50%;
text-align:center;
transform:translateY(-50%);
-webkit-transform:translateY(-50%);
}
.mw-collapsible.mw-collapsed > tbody > tr > th > .collapse-toggle > .collapse-status-open {
display:none;
}
.mw-collapsible.mw-collapsed > tbody > tr > th > .collapse-toggle > .collapse-status-close,
.mw-collapsible > tbody > tr > th > .collapse-toggle > .collapse-status-open {
display:inline;
}
.mw-collapsible > tbody > tr > th > .collapse-toggle > .collapse-status-close {
display:none;
}
$('.mw-collapsible').each(function () {
var col_table = $(this);
if (col_table.parents('.navbox').length) return;
var col_trs = col_table.find('> tbody> tr');
var col_controler = $('<div class="collapse-toggle"><span class="collapse-status-close">[展开]</span><span class="collapse-status-open">[折叠]</span></div>');
col_controler.on('click', function () {
col_table.toggleClass('mw-collapsed');
});
col_trs.first().children().first().append(col_controler);
});
;!function(){$(function(){$(".mw-collapsible").each(function(){var l=$(this);if(!l.parents(".navbox").length){var t=l.find("> tbody> tr"),s=$('<div class="collapse-toggle"><span class="collapse-status-close">[展开]</span><span class="collapse-status-open">[折叠]</span></div>');s.on("click",function(){l.toggleClass("mw-collapsed")}),t.first().children().first().append(s)}}),$("body").append("<style>.mw-collapsible.wikitable{display:table}.mw-collapsible.wikitable img{max-width:100%}.mw-collapsible>tbody>tr:first-child>th{position:relative;padding-left:3em}.mw-collapsible.mw-collapsed>tbody>tr:nth-child(n+2){display:none}.collapse-toggle{position:absolute;left:0;top:0;bottom:0;font-family:monospace;color:#ba0000;font-size:90%;width:3.5em}.collapse-toggle>span{position:absolute;left:0;right:0;top:50%;text-align:center;transform:translateY(-50%);-webkit-transform:translateY(-50%)}.mw-collapsible.mw-collapsed>tbody>tr>th>.collapse-toggle>.collapse-status-open{display:none}.mw-collapsible.mw-collapsed>tbody>tr>th>.collapse-toggle>.collapse-status-close,.mw-collapsible>tbody>tr>th>.collapse-toggle>.collapse-status-open{display:inline}.mw-collapsible>tbody>tr>th>.collapse-toggle>.collapse-status-close{display:none}</style>")})}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment