diff --git a/core/misc/collapse.js b/core/misc/collapse.js index 2f67dc4..c26ab55 100644 --- a/core/misc/collapse.js +++ b/core/misc/collapse.js @@ -5,15 +5,9 @@ /** * The collapsible details object represents a single collapsible details element. */ -function CollapsibleDetails(node, settings) { +function CollapsibleDetails (node) { this.$node = $(node); this.$node.data('details', this); - this.settings = $.extend({ - duration:'fast', - easing:'linear' - }, - settings - ); // Expand details if there are errors inside, or if it contains an // element that is targeted by the URI fragment identifier. var anchor = location.hash && location.hash !== '#' ? ', ' + location.hash : ''; @@ -41,10 +35,6 @@ $.extend(CollapsibleDetails, { */ $.extend(CollapsibleDetails.prototype, { /** - * Flag preventing multiple simultaneous animations. - */ - animating: false, - /** * Initialize and setup summary events and markup. */ setupSummary: function () { @@ -91,32 +81,27 @@ $.extend(CollapsibleDetails.prototype, { * Toggle the visibility of a details element using smooth animations. */ toggle: function () { - // Don't animate multiple times. - if (this.animating) { - return; - } - if (!this.$node.attr('open')) { - this.$node.find('> .details-wrapper').show(); - this.$node.attr('open', true); - this.$node.find('> summary span.details-summary-prefix').html(Drupal.t('Hide')); + var isOpen = !!this.$node.attr('open'); + var $summaryPrefix = this.$node.find('> summary span.details-summary-prefix'); + if (isOpen) { + $summaryPrefix.html(Drupal.t('Show')); } else { - this.$node.find('> .details-wrapper').hide(); - this.$node.attr('open', false); - this.$node.find('> summary span.details-summary-prefix').html(Drupal.t('Show')); + $summaryPrefix.html(Drupal.t('Hide')); } + this.$node.attr('open', !isOpen); } }); Drupal.behaviors.collapse = { - attach: function (context, settings) { + attach: function (context) { if (Modernizr.details) { return; } var $collapsibleDetails = $(context).find('details').once('collapse'); if ($collapsibleDetails.length) { for (var i = 0; i < $collapsibleDetails.length; i++) { - CollapsibleDetails.instances.push(new CollapsibleDetails($collapsibleDetails[i], settings.collapsibleDetails)); + CollapsibleDetails.instances.push(new CollapsibleDetails($collapsibleDetails[i])); } } }