From 3b87ed54c203badadd9223e6f9a12395c72160d7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 5 Feb 2013 11:32:49 -0500 Subject: force the dialog to the top of the page --- lib/gallery.dialog.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/gallery.dialog.js') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 3115532b..26de9bad 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -22,6 +22,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; -- cgit v1.2.3 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 ++++++++------------------------------------------ lib/gallery.panel.js | 12 +----------- 2 files changed, 9 insertions(+), 53 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"); diff --git a/lib/gallery.panel.js b/lib/gallery.panel.js index 0683c531..e5028f2a 100644 --- a/lib/gallery.panel.js +++ b/lib/gallery.panel.js @@ -34,21 +34,11 @@ $.ajax({ url: sHref, type: "GET", - beforeSend: function(xhr) { - // Until we convert to jquery 1.4, we need to save the - // XMLHttpRequest object - 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; } -- 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 From 1ac2c959d0f82c1ccef6cce96638704f40097e38 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Wed, 13 Feb 2013 00:31:43 +0100 Subject: Dialog centering, sizing, etc. seem to be fixed! Well, *if* they come from a link/menu. If they come from a context menu, they're still really broken. --- lib/gallery.dialog.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lib/gallery.dialog.js') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index 80f4f81d..b1442390 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -1,5 +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) { @@ -82,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); @@ -174,14 +181,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); -- cgit v1.2.3 From f580488fb5914b309a15396611d9b3a9177c65a0 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Wed, 13 Feb 2013 09:45:12 +0100 Subject: Fix Cancel link positioning, fix watermark error reply (seems to have already been broken in v3.0.4...) --- lib/gallery.dialog.js | 7 +++++++ themes/admin_wind/css/screen.css | 2 +- themes/wind/css/screen.css | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/gallery.dialog.js') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index b1442390..b4557493 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -139,6 +139,13 @@ }, success: function(data) { 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") diff --git a/themes/admin_wind/css/screen.css b/themes/admin_wind/css/screen.css index 58942387..23d319b2 100644 --- a/themes/admin_wind/css/screen.css +++ b/themes/admin_wind/css/screen.css @@ -989,7 +989,7 @@ div#g-action-status { } #g-dialog .g-cancel { - margin: .4em 1em; + margin: .59em 1em; } #g-panel { diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index 0e4819ee..e19427f3 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -1048,7 +1048,7 @@ div#g-action-status { } #g-dialog .g-cancel { - margin: .4em 1em; + margin: .59em 1em; } #g-panel { -- cgit v1.2.3 From 4dd7b708b24a40ed90ed324d9853aa87b3ec46a0 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Fri, 15 Feb 2013 19:31:20 +0100 Subject: Dialog sizing, titles, and z-index. This should ensure the small <500px dialogs are correct, all titles are correctly sized, and the dialog boxes go to the top for older themes, too. --- lib/gallery.dialog.js | 11 +++++------ modules/gallery/css/gallery.css | 9 +++++++++ themes/wind/css/screen.css | 4 ---- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'lib/gallery.dialog.js') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index b4557493..a771adcb 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -28,9 +28,6 @@ $("#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; @@ -79,8 +76,7 @@ _layout: function() { var dialogWidth; var dialogHeight = $("#g-dialog").height(); - var cssWidth = new String($("#g-dialog form").css("width")); - var childWidth = cssWidth.replace(/[^0-9]/g,""); + var childWidth = $("#g-dialog form").width(); var size = $.gallery_get_viewport_size(); if ($("#g-dialog iframe").length) { dialogWidth = size.width() - 100; @@ -89,8 +85,10 @@ } else if ($("#g-dialog .g-dialog-panel").length) { dialogWidth = size.width() - 100; $("#g-dialog").dialog("option", "height", size.height() - 100); - } else { + } else if (childWidth <= 150 || childWidth > 300) { dialogWidth = 500; + } else { + dialogWidth = 300; } $("#g-dialog").dialog('option', 'width', dialogWidth); }, @@ -183,6 +181,7 @@ } else if ($("#g-dialog fieldset legend").length) { $("#g-dialog").dialog('option', 'title', $("#g-dialog fieldset legend:eq(0)").html()); } + $(".ui-dialog-title").width('auto'); }, form_closing: function(event, ui) {}, diff --git a/modules/gallery/css/gallery.css b/modules/gallery/css/gallery.css index 7e711156..d3f7dcca 100644 --- a/modules/gallery/css/gallery.css +++ b/modules/gallery/css/gallery.css @@ -149,6 +149,15 @@ text-align: center; } +/* Dialogs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/** + * Newer Themeroller-based themes do this on their own, but older + * themes need help ensuring that dialogs and overlays are on top + */ +.ui-front { + z-index: 1000 +} + /** ******************************************************************* * 2) Admin **********************************************************************/ diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css index e19427f3..6f98cbba 100644 --- a/themes/wind/css/screen.css +++ b/themes/wind/css/screen.css @@ -886,10 +886,6 @@ ul.sf-menu li li li.sfHover ul { opacity: .7; } -.ui-dialog { - z-index: 9999; -} - /* Buttons ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ .g-button { -- cgit v1.2.3 From 7c5d9db61c0b7214631d425958fb025f26d778c2 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Fri, 15 Feb 2013 19:32:01 +0100 Subject: Fixed formatting in gallery.dialog.js (no functional changes). --- lib/gallery.dialog.js | 372 +++++++++++++++++++++++++------------------------- 1 file changed, 186 insertions(+), 186 deletions(-) (limited to 'lib/gallery.dialog.js') diff --git a/lib/gallery.dialog.js b/lib/gallery.dialog.js index a771adcb..e9f4aa03 100644 --- a/lib/gallery.dialog.js +++ b/lib/gallery.dialog.js @@ -1,190 +1,190 @@ (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) { - this.element.click(function(event) { - event.preventDefault(); - self._show($(event.currentTarget).attr("href")); - return false; - }); - } else { - self._show(this.element.attr("href")); - } - }, - - _show: function(sHref) { - var self = this; - var eDialog = '
'; - - if ($("#g-dialog").length) { - $("#g-dialog").dialog("close"); - } - $("body").append(eDialog); - - if (!self.options.close) { - self.options.close = self.close_dialog; - } - $("#g-dialog").dialog(self.options); - - $("#g-dialog").gallery_show_loading(); - - $.ajax({ - url: sHref, - type: "GET", - success: function(data, textStatus, xhr) { - var mimeType = /^(\w+\/\w+)\;?/.exec(xhr.getResponseHeader("Content-Type")); - - var content = ""; - if (mimeType[1] == "application/json") { - content = unescape(data.html); - } else { - content = data; - } - - $("#g-dialog").html(content).gallery_show_loading(); - - if ($("#g-dialog form").length) { - self.form_loaded(null, $("#g-dialog form")); - } - self._layout(); - - $("#g-dialog").dialog("open"); - self._set_title(); - - if ($("#g-dialog form").length) { - self._ajaxify_dialog(); - } - } - }); - $("#g-dialog").dialog("option", "self", self); - }, - - error: function(xhr, textStatus, errorThrown) { - $("#g-dialog").html(xhr.responseText); - self._set_title(); - self._layout(); - }, - - _layout: function() { - var dialogWidth; - var dialogHeight = $("#g-dialog").height(); - var childWidth = $("#g-dialog form").width(); - var size = $.gallery_get_viewport_size(); - if ($("#g-dialog iframe").length) { - dialogWidth = size.width() - 100; - // Set the iframe width and height - $("#g-dialog iframe").width("100%").height(size.height() - 100); - } else if ($("#g-dialog .g-dialog-panel").length) { - dialogWidth = size.width() - 100; - $("#g-dialog").dialog("option", "height", size.height() - 100); - } else if (childWidth <= 150 || childWidth > 300) { - dialogWidth = 500; - } else { - dialogWidth = 300; - } - $("#g-dialog").dialog('option', 'width', dialogWidth); - }, - - form_loaded: function(event, ui) { - // Should be defined (and localized) in the theme - MSG_CANCEL = MSG_CANCEL || 'Cancel'; - var eCancel = '' + MSG_CANCEL + ''; - if ($("#g-dialog .submit").length) { - $("#g-dialog .submit").addClass("ui-state-default ui-corner-all"); - $.fn.gallery_hover_init(); - $("#g-dialog .submit").parent().append(eCancel); - $("#g-dialog .g-cancel").click(function(event) { - $("#g-dialog").dialog("close"); - event.preventDefault(); - }); + $.widget("ui.gallery_dialog", { + options: { + autoOpen: false, + autoResize: true, + modal: true, + resizable: false, + position: "center" + }, + _init: function() { + var self = this; + 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")); + } + }, + + _show: function(sHref) { + var self = this; + var eDialog = '
'; + + if ($("#g-dialog").length) { + $("#g-dialog").dialog("close"); + } + $("body").append(eDialog); + + if (!self.options.close) { + self.options.close = self.close_dialog; + } + $("#g-dialog").dialog(self.options); + + $("#g-dialog").gallery_show_loading(); + + $.ajax({ + url: sHref, + type: "GET", + success: function(data, textStatus, xhr) { + var mimeType = /^(\w+\/\w+)\;?/.exec(xhr.getResponseHeader("Content-Type")); + + var content = ""; + if (mimeType[1] == "application/json") { + content = unescape(data.html); + } else { + content = data; + } + + $("#g-dialog").html(content).gallery_show_loading(); + + if ($("#g-dialog form").length) { + self.form_loaded(null, $("#g-dialog form")); + } + self._layout(); + + $("#g-dialog").dialog("open"); + self._set_title(); + + if ($("#g-dialog form").length) { + self._ajaxify_dialog(); + } } - $("#g-dialog .ui-state-default").hover( - function() { - $(this).addClass("ui-state-hover"); - }, - function() { - $(this).removeClass("ui-state-hover"); - } - ); - }, - - close_dialog: function(event, ui) { - var self = $("#g-dialog").dialog("option", "self"); - if ($("#g-dialog form").length) { - self._trigger("form_closing", null, $("#g-dialog form")); - } - self._trigger("dialog_closing", null, $("#g-dialog")); - $("#g-dialog").dialog("destroy").remove(); - }, - - _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; - }, - success: function(data) { - 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") - .attr("disabled", null); - self._set_title(); - self._ajaxify_dialog(); - self.form_loaded(null, $("#g-dialog form")); - if (typeof data.reset == 'function') { - eval(data.reset + '()'); - } - } - if (data.result == "success") { - if (data.location) { - window.location = data.location; - } else { - window.location.reload(); - } - } - }, - error: function(xhr, textStatus, errorThrown) { - $("#g-dialog").html(xhr.responseText); - self._set_title(); - self._layout(); - } - }); - }, - - _set_title: function() { - // Remove titlebar for progress dialogs or set title - if ($("#g-dialog #g-progress").length) { - $(".ui-dialog-titlebar").remove(); - } else if ($("#g-dialog h1").length) { - $("#g-dialog").dialog('option', 'title', $("#g-dialog h1:eq(0)").html()); - $("#g-dialog h1:eq(0)").hide(); - } else if ($("#g-dialog fieldset legend").length) { - $("#g-dialog").dialog('option', 'title', $("#g-dialog fieldset legend:eq(0)").html()); + }); + $("#g-dialog").dialog("option", "self", self); + }, + + error: function(xhr, textStatus, errorThrown) { + $("#g-dialog").html(xhr.responseText); + self._set_title(); + self._layout(); + }, + + _layout: function() { + var dialogWidth; + var dialogHeight = $("#g-dialog").height(); + var childWidth = $("#g-dialog form").width(); + var size = $.gallery_get_viewport_size(); + if ($("#g-dialog iframe").length) { + dialogWidth = size.width() - 100; + // Set the iframe width and height + $("#g-dialog iframe").width("100%").height(size.height() - 100); + } else if ($("#g-dialog .g-dialog-panel").length) { + dialogWidth = size.width() - 100; + $("#g-dialog").dialog("option", "height", size.height() - 100); + } else if (childWidth <= 150 || childWidth > 300) { + dialogWidth = 500; + } else { + dialogWidth = 300; + } + $("#g-dialog").dialog('option', 'width', dialogWidth); + }, + + form_loaded: function(event, ui) { + // Should be defined (and localized) in the theme + MSG_CANCEL = MSG_CANCEL || 'Cancel'; + var eCancel = '' + MSG_CANCEL + ''; + if ($("#g-dialog .submit").length) { + $("#g-dialog .submit").addClass("ui-state-default ui-corner-all"); + $.fn.gallery_hover_init(); + $("#g-dialog .submit").parent().append(eCancel); + $("#g-dialog .g-cancel").click(function(event) { + $("#g-dialog").dialog("close"); + event.preventDefault(); + }); } - $(".ui-dialog-title").width('auto'); - }, - - form_closing: function(event, ui) {}, - dialog_closing: function(event, ui) {} - }); + $("#g-dialog .ui-state-default").hover( + function() { + $(this).addClass("ui-state-hover"); + }, + function() { + $(this).removeClass("ui-state-hover"); + } + ); + }, + + close_dialog: function(event, ui) { + var self = $("#g-dialog").dialog("option", "self"); + if ($("#g-dialog form").length) { + self._trigger("form_closing", null, $("#g-dialog form")); + } + self._trigger("dialog_closing", null, $("#g-dialog")); + $("#g-dialog").dialog("destroy").remove(); + }, + + _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; + }, + success: function(data) { + 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") + .attr("disabled", null); + self._set_title(); + self._ajaxify_dialog(); + self.form_loaded(null, $("#g-dialog form")); + if (typeof data.reset == 'function') { + eval(data.reset + '()'); + } + } + if (data.result == "success") { + if (data.location) { + window.location = data.location; + } else { + window.location.reload(); + } + } + }, + error: function(xhr, textStatus, errorThrown) { + $("#g-dialog").html(xhr.responseText); + self._set_title(); + self._layout(); + } + }); + }, + + _set_title: function() { + // Remove titlebar for progress dialogs or set title + if ($("#g-dialog #g-progress").length) { + $(".ui-dialog-titlebar").remove(); + } else if ($("#g-dialog h1").length) { + $("#g-dialog").dialog('option', 'title', $("#g-dialog h1:eq(0)").html()); + $("#g-dialog h1:eq(0)").hide(); + } else if ($("#g-dialog fieldset legend").length) { + $("#g-dialog").dialog('option', 'title', $("#g-dialog fieldset legend:eq(0)").html()); + } + $(".ui-dialog-title").width('auto'); + }, + + form_closing: function(event, ui) {}, + dialog_closing: function(event, ui) {} + }); })(jQuery); -- cgit v1.2.3