1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-03-01 19:27:27 +00:00

26 lines
689 B
JavaScript
Raw Normal View History

(function($){
$.fn.enableFolding = function(autofold) {
var fragId = document.location.hash;
if (fragId && /^#no\d+$/.test(fragId)) {
fragId = parseInt(fragId.substr(3));
}
var count = 1;
return this.each(function() {
var t = $(this).text();
$(this).text("");
var trigger = $(this).append("<a href='#no" + count + "'></a>").children();
trigger.text(t);
trigger.click(function() {
if (fragId == count) { fragId = 0; return; }
$(this.parentNode.parentNode).toggleClass("collapsed");
});
if ( autofold )
trigger.click();
count++;
}).css("cursor", "pointer");
}
})(jQuery);