summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-09-06 11:26:33 -0700
committerBharat Mediratta <bharat@menalto.com>2009-09-06 11:26:33 -0700
commit610c99cd04343233af63f3ad841e7de2bad91520 (patch)
treeeb26ec7a513e90f2dff35a7ad182f43bbb08e73d /lib
parentac8c9d6670b5dc0b56e1acf7cb468d5fa846fc28 (diff)
Restore button text for any open panels when we open a new panel.
Fixes ticket #723.
Diffstat (limited to 'lib')
-rw-r--r--lib/gallery.panel.js44
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;
});
},