index_006.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //<source lang="javascript">
  2. // Faster Collapsible Containers
  3. // Maintainer: [[User:Darklama]]
  4. // images to use for hide/show states
  5. var collapse_action_hide = 'http://upload.wikimedia.org/wikipedia/commons/1/10/MediaWiki_Vector_skin_action_arrow.png';
  6. var collapse_action_show = 'http://upload.wikimedia.org/wikipedia/commons/4/41/MediaWiki_Vector_skin_right_arrow.png';
  7. // toggle state of collapsible boxes
  8. function collapsible_boxes()
  9. {
  10. $('div.collapsible').each( function() {
  11. var $that = $(this), css_width = $that.css('width'), attr_width = $that.attr('width');
  12. var which = $that.hasClass('selected') ? collapse_action_show : collapse_action_hide;
  13. if ( (!css_width || css_width == 'auto') && (!attr_width || attr_width == 'auto') ) {
  14. $that.css('width', $that.width() );
  15. }
  16. $(this).children('.title').each( function() {
  17. $(this).prepend('<span class="action"><a><img src="'+which+'" /></a></span>').click( function() {
  18. var which = $that.toggleClass('selected').hasClass('selected')
  19. ? collapse_action_show : collapse_action_hide;
  20. $(this).find('span.action img').attr('src', which);
  21. if ( which == collapse_action_show ) {
  22. $(this).siblings(':not(.title)').stop(true, true).fadeOut();
  23. } else {
  24. $(this).siblings(':not(.title)').stop(true, true).fadeIn();
  25. }
  26. }).click();
  27. });
  28. });
  29. $( "table.collapsible" ).each( function() {
  30. var $table = $(this), rows = this.rows, cell = rows.item(0).cells.item(0);
  31. var which = $table.hasClass('selected') ? collapse_action_show : collapse_action_hide;
  32. var css_width = $table.css('width'), attr_width = $table.attr('width');
  33. if ( (!css_width || css_width == 'auto') && (!attr_width || attr_width == 'auto') ) {
  34. $table.css('width', $table.width() );
  35. }
  36. $(cell).prepend('<span class="action"><a><img src="'+which+'" /></a></span>');
  37. $(rows.item(0)).click( function() {
  38. var which = $table.toggleClass('selected').hasClass('selected')
  39. ? collapse_action_show : collapse_action_hide;
  40. $(cell).find('span.action img').attr('src', which);
  41. if ( which == collapse_action_show ) {
  42. $(rows).next().stop(true, true).fadeOut();
  43. } else {
  44. $(rows).next().stop(true, true).fadeIn();
  45. }
  46. }).click();
  47. });
  48. }
  49. $(document).ready( collapsible_boxes );
  50. //</source>