From 610c99cd04343233af63f3ad841e7de2bad91520 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 6 Sep 2009 11:26:33 -0700 Subject: Restore button text for any open panels when we open a new panel. Fixes ticket #723. --- lib/gallery.panel.js | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'lib/gallery.panel.js') diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js index e0bf4259..6115297d 100644 --- a/lib/gallery.panel.js +++ b/lib/gallery.panel.js @@ -10,24 +10,38 @@ var parentClass = $(parent).attr("class"); var ePanel = ""; + // We keep track of the open vs. closed state by looking to see if there' + // an orig_text attr. If that attr is missing, then the panel is closed + // and we want to open it + var should_open = !$(element).attr("orig_text"); + + // Close any open panels and reset their button text if ($("#gPanel").length) { $("#gPanel").slideUp("slow").remove(); - if ($(element).attr("orig_text")) { - $(element).children(".gButtonText").text($(element).attr("orig_text")); - } - } else { - $(parent).after(ePanel); - $("#gPanel td").html(sHref); - $.get(sHref, function(data) { - $("#gPanel td").html(data); - self._ajaxify_panel(); - if ($(element).attr("open_text")) { - $(element).attr("orig_text", $(element).children(".gButtonText").text()); - $(element).children(".gButtonText").text($(element).attr("open_text")); - } - $("#gPanel").addClass(parentClass).show().slideDown("slow"); - }); + $.each($(".gPanelLink"), + function() { + if ($(this).attr("orig_text")) { + $(this).children(".gButtonText").text($(this).attr("orig_text")); + $(this).attr("orig_text", ""); + } + } + ); } + + if (should_open) { + $(parent).after(ePanel); + $("#gPanel td").html(sHref); + $.get(sHref, function(data) { + $("#gPanel td").html(data); + self._ajaxify_panel(); + if ($(element).attr("open_text")) { + $(element).attr("orig_text", $(element).children(".gButtonText").text()); + $(element).children(".gButtonText").text($(element).attr("open_text")); + } + $("#gPanel").addClass(parentClass).show().slideDown("slow"); + }); + } + return false; }); }, -- cgit v1.2.3