summaryrefslogtreecommitdiff
path: root/lib/gallery.dialog.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gallery.dialog.js')
-rw-r--r--lib/gallery.dialog.js86
1 files changed, 28 insertions, 58 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js
index 3115532b..b4557493 100644
--- a/lib/gallery.dialog.js
+++ b/lib/gallery.dialog.js
@@ -1,6 +1,12 @@
-
(function($) {
$.widget("ui.gallery_dialog", {
+ options: {
+ autoOpen: false,
+ autoResize: true,
+ modal: true,
+ resizable: false,
+ position: "center"
+ },
_init: function() {
var self = this;
if (!self.options.immediate) {
@@ -22,6 +28,9 @@
$("#g-dialog").dialog("close");
}
$("body").append(eDialog);
+ if (!self.options.zIndex) {
+ self.options.zIndex = 9999;
+ }
if (!self.options.close) {
self.options.close = self.close_dialog;
@@ -33,22 +42,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;
}
@@ -72,9 +71,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() {
@@ -90,7 +89,7 @@
} else if ($("#g-dialog .g-dialog-panel").length) {
dialogWidth = size.width() - 100;
$("#g-dialog").dialog("option", "height", size.height() - 100);
- } else if (childWidth == "" || childWidth > 300) {
+ } else {
dialogWidth = 500;
}
$("#g-dialog").dialog('option', 'width', dialogWidth);
@@ -131,41 +130,22 @@
_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) {
+ if (data.result == "error") {
+ // This is an odd case that arises from the watermarks module. This is because we
+ // have a fake xhr, and we rawurlencode the results because the JS code that uploads
+ // the file buffers it in an iframe which entitizes the HTML and makes it difficult
+ // for the JS to process. See ticket #797.
+ data.html = unescape(data.html);
+ }
$("#g-dialog").html(data.html);
$("#g-dialog").dialog("option", "position", "center");
$("#g-dialog form :submit").removeClass("ui-state-disabled")
@@ -185,11 +165,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();
+ }
});
},
@@ -208,14 +188,4 @@
form_closing: function(event, ui) {},
dialog_closing: function(event, ui) {}
});
-
- $.extend($.ui.gallery_dialog, {
- defaults: {
- autoOpen: false,
- autoResize: true,
- modal: true,
- resizable: false,
- position: "center"
- }
- });
})(jQuery);