diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-08-08 15:46:53 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-08-08 15:46:53 -0700 |
commit | cb1ae141bb65a5da42e94910214abbf5ac367920 (patch) | |
tree | 40acc419ef8f5121c11bffcec6233c641c6211e2 | |
parent | e4eec71efa5f7b1902155a34f8655cebe523c358 (diff) |
Create an new option 'immediate' and if set to true then don't try to set up click events, but just show the dialog. Also remove the destroy method and put all the cleanup into the dialog close handler
-rw-r--r-- | lib/gallery.dialog.js | 88 | ||||
-rw-r--r-- | modules/gallery/js/quick.js | 2 | ||||
-rw-r--r-- | modules/gallery/views/after_install.html.php | 2 |
3 files changed, 47 insertions, 45 deletions
diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 51ebb21a..9aebd455 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -2,56 +2,54 @@ $.widget("ui.gallery_dialog", { _init: function() { var self = this; - this.element.click(function(event){ - event.preventDefault(); - var element = event.currentTarget; - var sHref = $(element).attr("href"); - var sTitle = $(element).attr("title"); - var eDialog = '<div id="gDialog"></div>'; - - $("body").append(eDialog); + var options = self.options; + if (!self.options.immediate) { + this.element.click(function(event) { + event.preventDefault(); + self._show($(event.currentTarget).attr("href")); + return false; + }); + } else { + self._show(this.element.attr("href")); + } + }, - if (!self.options.close) { - self.options.close = self.close_dialog; - } - $("#gDialog").dialog(self.options); + _show: function(sHref) { + var self = this; + var eDialog = '<div id="gDialog"></div>'; - $("#gDialog").gallery_show_loading(); + $("body").append(eDialog); - $.get(sHref, function(data) { - $("#gDialog").html(data).gallery_show_loading(); + if (!self.options.close) { + self.options.close = self.close_dialog; + } + $("#gDialog").dialog(self.options); - if ($("#gDialog form").length) { - self._trigger("form_loaded", null, $("#gDialog form")); - } - self._layout(); + $("#gDialog").gallery_show_loading(); - $("#gDialog").dialog("open"); - // 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) { - $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); - } + $.get(sHref, function(data) { + $("#gDialog").html(data).gallery_show_loading(); - if ($("#gDialog form").length) { - self._ajaxify_dialog(); - } - }); - $("#gDialog").dialog("option", "self", self); - return false; - }); - }, + if ($("#gDialog form").length) { + self._trigger("form_loaded", null, $("#gDialog form")); + } + self._layout(); - destroy: function() { - if ($("#gDialog form").length) { - this._trigger("form_closing", null, $("#gDialog form")); - } - this._trigger("dialog_closing", null, $("#gDialog")); + $("#gDialog").dialog("open"); + // 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) { + $("#gDialog").dialog('option', 'title', $("#gDialog fieldset legend:eq(0)").html()); + } - $("#gDialog").dialog("destroy").remove(); + if ($("#gDialog form").length) { + self._ajaxify_dialog(); + } + }); + $("#gDialog").dialog("option", "self", self); }, _layout: function() { @@ -93,7 +91,11 @@ close_dialog: function (event, ui) { var self = $("#gDialog").dialog("option", "self"); - self.destroy(); + if ($("#gDialog form").length) { + self._trigger("form_closing", null, $("#gDialog form")); + } + self._trigger("dialog_closing", null, $("#gDialog")); + $("#gDialog").dialog("destroy").remove(); }, _ajaxify_dialog: function() { diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index fda6470f..dfa61c20 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -46,7 +46,7 @@ var quick_do = function(cont, pane, img) { return false; } if (pane.hasClass("gDialogLink")) { - openDialog(pane); + $(pane).gallery_dialog({immediate: 1}); } else { img.css("opacity", "0.1"); cont.addClass("gLoadingLarge"); diff --git a/modules/gallery/views/after_install.html.php b/modules/gallery/views/after_install.html.php index bfce46f0..76b59474 100644 --- a/modules/gallery/views/after_install.html.php +++ b/modules/gallery/views/after_install.html.php @@ -16,7 +16,7 @@ title="<?= t("Edit Your Profile") ?>" id="gAfterInstallChangePasswordLink" class="gButtonLink ui-state-default ui-corners-all"><?= t("Change Password Now") ?></a> <script> - $("#gAfterInstallChangePasswordLink").gallery_dialog(); + $("#gAfterInstallChangePasswordLink").gallery_dialog({immediate: 1}); </script> </p> |