// details.js

(function($) {

$(document).ready(function(event) {
	if (!('open' in document.createElement('details'))) {
		$(document).bind("DOMNodeInserted", handle);
		handle(event);
	}
});

function select(node, selector) {
	var set = $(node).find(selector);
	if (node && $(node).is(selector)) {
		set = set.add(node);
	}
	return set;
}

function handle(event) {
    // Loop through all `details` elements
    select(event.target, "details").each(function() {

      // Store a reference to the current `details` element in a variable
      var $details = $(this),
          // Store a reference to the `summary` element of the current `details` element (if any) in a variable
          $detailsSummary = $('summary', $details),
          // Do the same for the info within the `details` element
          $detailsNotSummary = $details.children().filter(function(){return this.tagName != 'summary';}),
          // This will be used later to look for direct child text nodes
          $detailsNotSummaryContents = $details.contents().filter(function(){return this.tagName != 'summary';});

	$details.css("display", "list-item");
	$detailsSummary.css("outline", "none");

      // If there is no `summary` in the current `details` element…
      if (!$detailsSummary.length) {
        // …create one with default text
        $detailsSummary = $(document.createElement('summary')).text('Details').prependTo($details);
      }

      // Look for direct child text nodes
      if ($detailsNotSummary.length !== $detailsNotSummaryContents.length) {
        // Wrap child text nodes in a `span` element
        $detailsNotSummaryContents.filter(function() {
          // Only keep the node in the collection if it’s a text node containing more than only whitespace
          return (this.nodeType === 3) && (/[^\t\n\r ]/.test(this.data));
        }).wrap('<span>');
        // There are now no direct child text nodes anymore — they’re wrapped in `span` elements
        $detailsNotSummary = $details.children().filter(function(){return this.tagName != 'summary';});
      }

      // Hide content unless there’s an `open` attribute
      // Chrome 10 already recognizes the `open` attribute as a boolean (even though it doesn’t support rendering `<details>` yet
      // Other browsers without `<details>` support treat it as a string
      try {
        open = $details.attr('open');
      } catch (e) {}
      if (typeof open == 'string' || (typeof open == 'boolean' && open)) {
        $details.addClass('open');
        $detailsNotSummary.show();
      } else {
        $detailsNotSummary.hide();
      }

      // Set the `tabIndex` of the `summary` element to 0 to make it keyboard accessible
      $detailsSummary.attr('tabIndex', 0).click(function() {
        // Focus on the `summary` element
        $detailsSummary.focus();
        // Toggle the `open` attribute of the `details` element
        typeof $details.attr('open') !== 'undefined' ? $details.removeAttr('open') : $details.attr('open', 'open');
        // Toggle the additional information in the `details` element
        $detailsNotSummary.toggle(0);
        $details.toggleClass('open');
      }).keyup(function(event) {
        if (13 === event.keyCode || 32 === event.keyCode) {
          // Enter or Space is pressed — trigger the `click` event on the `summary` element
          // Opera already seems to trigger the `click` event when Enter is pressed
          if (!($.browser.opera && 13 === event.keyCode)) {
            event.preventDefault();
            $detailsSummary.click();
          }
        }
      });

    });

  }

})(window.jQuery);


@@ -335,16 +335,106 @@
 set;%0A%7D%0A%0A
+function notSummary()%7B%0A%09return this.tagName != 'summary' && this.tagName != 'SUMMARY';%0A%7D%0A%0A
 function
@@ -945,53 +945,18 @@
 ter(
-function()%7Breturn this.tagName != 's
+notS
 ummary
-';%7D
 ),%0A 
@@ -1097,53 +1097,18 @@
 ter(
-function()%7Breturn this.tagName != 's
+notS
 ummary
-';%7D
 );%0A%0A
@@ -1116,16 +1116,23 @@
 $details
+Summary
 .css(%22di
@@ -1155,26 +1155,34 @@
 em%22)
-;%0A%09$detailsSummary
+.css(%22margin-left%22, %221em%22)
 .css
@@ -2050,53 +2050,18 @@
 ter(
-function()%7Breturn this.tagName != 's
+notS
 ummary
-';%7D
 );%0A 

Fix details/summary in FF and Safari