summaryrefslogtreecommitdiff
path: root/lib/gallery.panel.js
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-07-21 07:20:24 -0700
committerBharat Mediratta <bharat@menalto.com>2010-07-31 15:44:55 -0700
commit5c0998c4ac9ad7572df68f5c2cc351f0d03a7bd2 (patch)
tree21a4de39c721a972d73e7f0bf3e50a9afd0349b9 /lib/gallery.panel.js
parent68f41c7061cc6d1227286fd541d84c5df2549cb3 (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.panel.js')
-rw-r--r--lib/gallery.panel.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js
index b94df223..e219f3d6 100644
--- a/lib/gallery.panel.js
+++ b/lib/gallery.panel.js
@@ -31,15 +31,37 @@
if (should_open) {
$(parent).after(ePanel);
$("#g-panel td").html(sHref);
- $.getJSON(sHref, function(data) {
- $("#g-panel td").html(unescape(data.form));
- self._ajaxify_panel();
- if ($(element).attr("open_text")) {
- $(element).attr("orig_text", $(element).children(".g-button-text").text());
- $(element).children(".g-button-text").text($(element).attr("open_text"));
+ $.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;
+ }
+
+ $("#g-panel td").html(content);
+ self._ajaxify_panel();
+ if ($(element).attr("open_text")) {
+ $(element).attr("orig_text", $(element).children(".g-button-text").text());
+ $(element).children(".g-button-text").text($(element).attr("open_text"));
+ }
+ $("#g-panel").addClass(parentClass).show().slideDown("slow");
}
- $("#g-panel").addClass(parentClass).show().slideDown("slow");
- });
+ });
}
return false;