From e2a40f01416b0ab4006df9c37eab61102c9f7d4c Mon Sep 17 00:00:00 2001 From: jlukic Date: Thu, 20 Feb 2014 21:35:12 -0500 Subject: [PATCH] Fixes #616 accordion removes inline styles --- src/modules/accordion.js | 47 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/modules/accordion.js b/src/modules/accordion.js index 4bceeb083..cf91e51bd 100755 --- a/src/modules/accordion.js +++ b/src/modules/accordion.js @@ -85,15 +85,23 @@ $.fn.accordion = function(parameters) { ; module.toggle(index); }, - resetStyle: function() { - module.verbose('Resetting styles on element', this); - $(this) - .attr('style', '') - .removeAttr('style') - .children() + resetDisplay: function() { + $(this).css('display', ''); + if( $(this).attr('style') == '') { + $(this) .attr('style', '') .removeAttr('style') - ; + ; + } + }, + resetOpacity: function() { + $(this).css('opacity', ''); + if( $(this).attr('style') == '') { + $(this) + .attr('style', '') + .removeAttr('style') + ; + } } }, @@ -134,19 +142,17 @@ $.fn.accordion = function(parameters) { $previousContent .stop() .children() + .stop() .animate({ opacity: 0 - }, settings.duration, module.event.resetStyle) + }, settings.duration, module.event.resetOpacity) .end() .slideUp(settings.duration , settings.easing, function() { $previousContent .removeClass(className.active) - .attr('style', '') - .removeAttr('style') .children() - .attr('style', '') - .removeAttr('style') ; + $.proxy(module.event.resetDisplay, this)(); }) ; } @@ -156,15 +162,16 @@ $.fn.accordion = function(parameters) { $activeContent .stop() .children() - .attr('style', '') - .removeAttr('style') + .stop() + .animate({ + opacity: 1 + }, settings.duration) .end() .slideDown(settings.duration, settings.easing, function() { $activeContent .addClass(className.active) - .attr('style', '') - .removeAttr('style') ; + $.proxy(module.event.resetDisplay, this)(); $.proxy(settings.onOpen, $activeContent)(); $.proxy(settings.onChange, $activeContent)(); }) @@ -186,15 +193,13 @@ $.fn.accordion = function(parameters) { .show() .stop() .children() + .stop() .animate({ opacity: 0 - }, settings.duration, module.event.resetStyle) + }, settings.duration, module.event.resetOpacity) .end() .slideUp(settings.duration, settings.easing, function(){ - $activeContent - .attr('style', '') - .removeAttr('style') - ; + $.proxy(module.event.resetDisplay, this)(); $.proxy(settings.onClose, $activeContent)(); $.proxy(settings.onChange, $activeContent)(); })