From ec0363fd36f84c51d9fa3492004425ded2b729bd Mon Sep 17 00:00:00 2001 From: shadlaws Date: Tue, 12 Feb 2013 17:19:28 +0100 Subject: Updated success callbacks for gallery.panel.js and gallery.dialog.js - no longer need to save xhr ahead of success. Tested and seems to work well, even with watermarks on Chrome (previously an issue). --- lib/gallery.dialog.js | 50 ++++++++------------------------------------------ 1 file changed, 8 insertions(+), 42 deletions(-) (limited to 'lib/gallery.dialog.js') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 26de9bad..0197682b 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -1,4 +1,6 @@ + + (function($) { $.widget("ui.gallery_dialog", { _init: function() { @@ -23,7 +25,7 @@ } $("body").append(eDialog); if (!self.options.zIndex) { - self.options.zIndex = 9999; + self.options.zIndex = 9999; } if (!self.options.close) { @@ -36,22 +38,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 +67,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 +126,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
 element and
-             // looks like this:
-             //   
{"result":"success",
-             //   "location":"\/~bharat\/gallery3\/index.php\/admin\/watermarks"}
- // 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"); -- cgit v1.2.3 From dc5b1a715b6d3dee117d23d460b2cbc521d326d3 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Tue, 12 Feb 2013 17:27:05 +0100 Subject: Formatting: cleaned up extra lines, whitespaces, converted tabs to spaces, etc. --- lib/gallery.dialog.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/gallery.dialog.js') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 0197682b..80f4f81d 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -1,6 +1,3 @@ - - - (function($) { $.widget("ui.gallery_dialog", { _init: function() { @@ -154,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(); + } }); }, -- cgit v1.2.3