You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
689 B

  1. (function($){
  2. $.fn.enableFolding = function(autofold) {
  3. var fragId = document.location.hash;
  4. if (fragId && /^#no\d+$/.test(fragId)) {
  5. fragId = parseInt(fragId.substr(3));
  6. }
  7. var count = 1;
  8. return this.each(function() {
  9. var t = $(this).text();
  10. $(this).text("");
  11. var trigger = $(this).append("<a href='#no" + count + "'></a>").children();
  12. trigger.text(t);
  13. trigger.click(function() {
  14. if (fragId == count) { fragId = 0; return; }
  15. $(this.parentNode.parentNode).toggleClass("collapsed");
  16. });
  17. if ( autofold )
  18. trigger.click();
  19. count++;
  20. }).css("cursor", "pointer");
  21. }
  22. })(jQuery);