summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-02-12 09:25:21 -0800
committerBharat Mediratta <bharat@menalto.com>2013-02-12 09:25:21 -0800
commit6e8a647d0b8de137b24fd604eb6c8ba70457be3c (patch)
treec58187f0642f69c370b0b60d46e080c86a01fc2a
parentacf4aa01b9dc11febbe4f02be5c43ec905990d98 (diff)
parentdc5b1a715b6d3dee117d23d460b2cbc521d326d3 (diff)
Merge pull request #137 from shadlaws/jquery_19_success_xhr
Updated success callbacks for gallery.panel.js and gallery.dialog.js
-rw-r--r--lib/gallery.dialog.js59
-rw-r--r--lib/gallery.panel.js12
2 files changed, 12 insertions, 59 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js
index 26de9bad..80f4f81d 100644
--- a/lib/gallery.dialog.js
+++ b/lib/gallery.dialog.js
@@ -1,4 +1,3 @@
-
(function($) {
$.widget("ui.gallery_dialog", {
_init: function() {
@@ -23,7 +22,7 @@
}
$("body").append(eDialog);
if (!self.options.zIndex) {
- self.options.zIndex = 9999;
+ self.options.zIndex = 9999;
}
if (!self.options.close) {
@@ -36,22 +35,12 @@
$.ajax({
url: sHref,
type: "GET",
- beforeSend: function(xhr) {
- // Until we convert to jquery 1.4, we need to save the XMLHttpRequest object so that we
- // can detect the mime type of the reply
- 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 = data.html;
+ content = unescape(data.html);
} else {
content = data;
}
@@ -75,9 +64,9 @@
},
error: function(xhr, textStatus, errorThrown) {
- $("#g-dialog").html(xhr.responseText);
- self._set_title();
- self._layout();
+ $("#g-dialog").html(xhr.responseText);
+ self._set_title();
+ self._layout();
},
_layout: function() {
@@ -134,40 +123,14 @@
_ajaxify_dialog: function() {
var self = this;
$("#g-dialog form").ajaxForm({
+ dataType: "json",
beforeSubmit: function(formData, form, options) {
form.find(":submit")
.addClass("ui-state-disabled")
.attr("disabled", "disabled");
return true;
},
- beforeSend: function(xhr) {
- // Until we convert to jquery 1.4, we need to save the XMLHttpRequest object so that we
- // can detect the mime type of the reply
- this.xhrData = xhr;
- },
success: function(data) {
- // Pre jquery 1.4, get the saved XMLHttpRequest object
- xhr = this.xhrData;
- if (xhr) {
- var mimeType = /^(\w+\/\w+)\;?/.exec(xhr.getResponseHeader("Content-Type"));
-
- var content = "";
- if (mimeType[1] == "application/json") {
- data = JSON.parse(data);
- } else {
- data = {"html": escape(data)};
- }
- } else {
- // Uploading files (eg: watermark) uses a fake xhr in jquery.form.js so
- // all we have is in the data field, which should be some very simple JSON.
- // Weirdly enough in Chrome the result gets wrapped in a <pre> element and
- // looks like this:
- // <pre style="word-wrap: break-word; white-space: pre-wrap;">{"result":"success",
- // "location":"\/~bharat\/gallery3\/index.php\/admin\/watermarks"}</pre>
- // bizarre. Strip that off before parsing.
- data = JSON.parse(data.match("({.*})")[0]);
- }
-
if (data.html) {
$("#g-dialog").html(data.html);
$("#g-dialog").dialog("option", "position", "center");
@@ -188,11 +151,11 @@
}
}
},
- error: function(xhr, textStatus, errorThrown) {
- $("#g-dialog").html(xhr.responseText);
- self._set_title();
- self._layout();
- }
+ error: function(xhr, textStatus, errorThrown) {
+ $("#g-dialog").html(xhr.responseText);
+ self._set_title();
+ self._layout();
+ }
});
},
diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js
index 0683c531..e5028f2a 100644
--- a/lib/gallery.panel.js
+++ b/lib/gallery.panel.js
@@ -34,21 +34,11 @@
$.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 = data.html;
+ content = unescape(data.html);
} else {
content = data;
}