summaryrefslogtreecommitdiff
path: root/lib/gallery.dialog.js
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-07-21 07:20:24 -0700
committerTim Almdal <tnalmdal@shaw.ca>2010-07-23 23:05:38 -0700
commitb1cd0b7e97ed3b354bd350f5238f064671525ee3 (patch)
tree75913b2b89ffa680040cac84e8a3ed39d6b08cb2 /lib/gallery.dialog.js
parent9534a1c82a8ebc5cc56ba4cc256ce33570701a16 (diff)
Partial fix for #1225. Change the dialog and panel handling to look at the mime type returned to determine the content type.
Diffstat (limited to 'lib/gallery.dialog.js')
-rw-r--r--lib/gallery.dialog.js45
1 files changed, 34 insertions, 11 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js
index cc35f5cd..7b9d4b94 100644
--- a/lib/gallery.dialog.js
+++ b/lib/gallery.dialog.js
@@ -27,19 +27,42 @@
$("#g-dialog").gallery_show_loading();
- $.getJSON(sHref, function(data) {
- $("#g-dialog").html(unescape(data.form)).gallery_show_loading();
+ $.ajax({
+ url: sHref,
+ type: "GET",
+ beforeSend: function(xhr) {
+ // Until we convert to jquery 1.4, we need to save the
+ // XMLHttpRequest object
+ this.xhrData = xhr;
+ },
+ success: function(data, textStatus, xhr) {
+ // Pre jquery 1.4, get the saved XMLHttpRequest object
+ if (xhr == undefined) {
+ xhr = this.xhrData;
+ }
+ var mimeType = /^(\w+\/\w+)\;?/.exec(xhr.getResponseHeader("Content-Type"));
+
+ var content = "";
+ if (mimeType[1] == "application/json") {
+ data = JSON.parse(data);
+ content = unescape(data.form);
+ } else {
+ content = data;
+ }
- if ($("#g-dialog form").length) {
- self.form_loaded(null, $("#g-dialog form"));
- }
- self._layout();
+ $("#g-dialog").html(content).gallery_show_loading();
- $("#g-dialog").dialog("open");
- self._set_title();
+ if ($("#g-dialog form").length) {
+ self.form_loaded(null, $("#g-dialog form"));
+ }
+ self._layout();
+
+ $("#g-dialog").dialog("open");
+ self._set_title();
- if ($("#g-dialog form").length) {
- self._ajaxify_dialog();
+ if ($("#g-dialog form").length) {
+ self._ajaxify_dialog();
+ }
}
});
$("#g-dialog").dialog("option", "self", self);
@@ -108,7 +131,7 @@
},
success: function(data) {
if (data.form) {
- var formData = unescape(data.form);
+ var formData = unescape(data.content);
$("#g-dialog form").replaceWith(formData);
$("#g-dialog").dialog("option", "position", "center");
$("#g-dialog form :submit").removeClass("ui-state-disabled")