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.js78
1 files changed, 38 insertions, 40 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js
index 10ec412a..70f577c5 100644
--- a/lib/gallery.dialog.js
+++ b/lib/gallery.dialog.js
@@ -26,63 +26,61 @@ function openDialog(element, on_success) {
var eDialog = '<div id="gDialog"></div>';
$("body").append(eDialog);
- var buttons = {};
- buttons["Submit"] = function() {
- $("#gDialog form").ajaxForm({
- dataType: "json",
- success: function(data) {
- if (data.form) {
- $("#gDialog form").replaceWith(data.form);
- }
- if (data.result == "success") {
- $("#gDialog").dialog("close");
- if (on_success) {
- on_success();
- } else if (data.location) {
- window.location = data.location;
- } else {
- window.location.reload();
- }
- }
- }
- }).submit();
- };
- buttons["Reset"] = function() {
- $("#gDialog form").resetForm();
- };
-
$("#gDialog").dialog({
+ autoOpen: false,
autoResize: false,
draggable: true,
- height: $(window).height() - 40,
+ height: "auto",
+ width: "auto",
modal: true,
overlay: {
opacity: 0.7,
background: "black"
},
resizable: true,
- title: sTitle,
- width: 600,
- buttons: buttons,
close: function (event, ui) {
- $("#gDialog").dialog('destroy').remove();
+ $("#gDialog").dialog("destroy").remove();
}
});
loading("#gDialog");
- $(".ui-dialog-content").height(400);
$("#gDialog").html(sHref);
$.get(sHref, function(data) {
loading("#gDialog");
- $("#gDialog").html(data).hide().fadeIn();
- // Get dialog and it's contents' height
- var contentHt = $(".ui-dialog-titlebar").height()
- + $(".ui-dialog-content form").height()
- + $(".ui-dialog-buttonpane").height()
- + 60;
- // Resize height if content's shorter than dialog
- if (contentHt < $("#gDialog").data("height.dialog")) {
- $(".ui-dialog").animate({height: contentHt});
+ $("#gDialog").html(data);
+ var parent = $("#gDialog").parent().parent();
+ parent.css("opacity", "0.0");
+ $("#gDialog").dialog("open");
+ $("#ui-dialog-title-gDialog").html($("#gDialog fieldset legend:eq(0)").html());
+ if (parent.width() < 400) {
+ parent.css("width", 400);
+ }
+ parent.css({"top": $(window).height() / 2 - parent.height() / 2,
+ "left": $(window).width() / 2 - parent.width() / 2,
+ "opacity": "1.0"
+ });
+
+ ajaxify_dialog = function() {
+ $("#gDialog form").ajaxForm({
+ dataType: "json",
+ success: function(data) {
+ if (data.form) {
+ $("#gDialog form").replaceWith(data.form);
+ ajaxify_dialog();
+ }
+ if (data.result == "success") {
+ $("#gDialog").dialog("close");
+ if (on_success) {
+ on_success();
+ } else if (data.location) {
+ window.location = data.location;
+ } else {
+ window.location.reload();
+ }
+ }
+ }
+ });
};
+ ajaxify_dialog();
});
return false;
}