diff options
author | Chad Kieffer <chad@2tbsp.com> | 2009-02-10 05:48:55 +0000 |
---|---|---|
committer | Chad Kieffer <chad@2tbsp.com> | 2009-02-10 05:48:55 +0000 |
commit | fc162362de2f155933baf3231a857faa9f6d46cc (patch) | |
tree | ab1c6972b64446770eaaaad5c569c4ad29c302f8 | |
parent | 62f3724acbdf60b7a17c452e74f099b5236d41cb (diff) |
Set one of 3 dialog widths keying off of form's CSS width value: 300px, 500px, or $(window).width() -100. Tested in IE 6, 7, 8 and looks good. Also, remove titlebar from progress bar dialogs.
-rw-r--r-- | lib/gallery.dialog.js | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index b325fa25..ce48d995 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -5,7 +5,7 @@ function handleDialogEvent(event) { var target = event.currentTarget; if (!target) { - target = event.srcElement; // IE7 + target = event.srcElement; } openDialog(target); event.preventDefault(); @@ -24,34 +24,47 @@ function openDialog(element, on_success) { var sHref = $(element).attr("href"); var sTitle = $(element).attr("title"); var eDialog = '<div id="gDialog"></div>'; + var dialogWidth; $("body").append(eDialog); + $("#gDialog").dialog({ autoOpen: false, autoResize: true, - height: "auto", - width: "auto", modal: true, resizable: false, close: function (event, ui) { $("#gDialog").dialog("destroy").remove(); } }); + showLoading("#gDialog"); + $.get(sHref, function(data) { showLoading("#gDialog"); $("#gDialog").html(data); - var parent = $("#gDialog").parent().parent(); + var dialogHeight = $("#gDialog").height(); + var cssWidth = new String($("#gDialog form").css("width")); + var childWidth = cssWidth.replace(/[^0-9]/g,""); + if ($("#gDialog iframe").length) { + dialogWidth = $(window).width() - 100; + // Set the iframe width and height + $("#gDialog iframe").width("100%"); + $("#gDialog iframe").height($(window).height() - 100); + } else if (childWidth == "" || childWidth > 300) { + dialogWidth = 500; + } + $("#gDialog").dialog('option', 'width', dialogWidth); $("#gDialog").dialog("open"); - if ($("#gDialog h1").length) { - sTitle = $("#gDialog h1:eq(0)").html(); + // Remove titlebar for progress dialogs or set title + if ($("#gDialog #gProgress").length) { + $(".ui-dialog-titlebar").remove(); + } else if ($("#gDialog h1").length) { + $("#gDialog").dialog('option', 'title', $("#gDialog h1:eq(0)").html()); } else if ($("#gDialog fieldset legend").length) { - sTitle = $("#gDialog fieldset legend:eq(0)").html(); - } - $("#ui-dialog-title-gDialog").html(sTitle); - if (parent.width() < 400) { - parent.css("width", 200); + $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); } + ajaxify_dialog = function() { $("#gDialog form").ajaxForm({ dataType: "json", |