diff options
-rw-r--r-- | lib/gallery.panel.js | 44 |
1 files changed, 29 insertions, 15 deletions
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 = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>"; + // 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; }); }, |