summaryrefslogtreecommitdiff
path: root/lib/gallery.panel.js
diff options
context:
space:
mode:
authorChad Kieffer <chad@2tbsp.com>2009-05-26 03:59:35 +0000
committerChad Kieffer <chad@2tbsp.com>2009-05-26 03:59:35 +0000
commit88e1f02c1a250dae7b8dabeeaf9f6209f4c84942 (patch)
tree810150dedf2aa0bbc273942959202f8c3621bf07 /lib/gallery.panel.js
parent916405bc4b572ded4b60a2a2eaececb8402dba0a (diff)
Split out re-used JavaScript for common functions (messages, valign), panel toggle, and forms to external files.
Diffstat (limited to 'lib/gallery.panel.js')
-rw-r--r--lib/gallery.panel.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js
new file mode 100644
index 00000000..6ac50615
--- /dev/null
+++ b/lib/gallery.panel.js
@@ -0,0 +1,64 @@
+/**
+ * Fire togglePanel() and prevent links from opening
+ * @see openDialog()
+ */
+function handlePanelEvent(event) {
+ togglePanel(event.currentTarget);
+ event.preventDefault();
+}
+
+function togglePanel(element, on_success) {
+ var parent = $(element).parent().parent();
+ var sHref = $(element).attr("href");
+ var parentClass = $(parent).attr("class");
+ var ePanel = "<tr id=\"gPanel\"><td colspan=\"6\"></td></tr>";
+
+ if ($("#gPanel").length) {
+ $("#gPanel").slideUp("slow");
+ $("#gPanel *").remove();
+ $("#gPanel").remove();
+ if ($(element).attr("orig_text")) {
+ $(element).children(".gButtonText").text($(element).attr("orig_text"));
+ }
+ console.log("Removing existing #gPanel");
+ //togglePanel(element, on_success);
+ } else {
+ console.log("Adding #gPanel");
+ $(parent).after(ePanel);
+ //showLoading("#here");
+ $("#gPanel td").html(sHref);
+ $("#gPanel").addClass(parentClass).show().slideDown("slow");
+ $.get(sHref, function(data) {
+ $("#gPanel td").html(data);
+ ajaxify_panel = function() {
+ $("#gPanel td form").ajaxForm({
+ dataType: "json",
+ success: function(data) {
+ if (data.form) {
+ $("#gPanel td form").replaceWith(data.form);
+ ajaxify_panel();
+ }
+ if (data.result == "success") {
+ if (on_success) {
+ on_success();
+ } else if (data.location) {
+ window.location = data.location;
+ } else {
+ window.location.reload();
+ }
+ }
+ }
+ });
+ if ($("#gPanel td").hasClass("gLoadingLarge")) {
+ showLoading("#gPanel td");
+ }
+ };
+ ajaxify_panel();
+ if ($(element).attr("open_text")) {
+ $(element).attr("orig_text", $(element).children(".gButtonText").text());
+ $(element).children(".gButtonText").text($(element).attr("open_text"));
+ }
+ });
+ }
+ return false;
+}