From cfb7e477d38d76ef33883d56d69e7c5b8eba6de4 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 9 Dec 2011 21:41:20 +0000 Subject: [PATCH] Fixed #17218 -- Fixed bug with SelectFilter where the 'to' box had a height=0 when it was within a collapsed fieldset. Thanks jimallman git-svn-id: http://code.djangoproject.com/svn/django/trunk@17181 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/static/admin/js/SelectFilter2.js | 10 +++++++++- django/contrib/admin/static/admin/js/collapse.js | 4 ++-- django/contrib/admin/static/admin/js/collapse.min.js | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js index 3af9e85926..2746be6a04 100644 --- a/django/contrib/admin/static/admin/js/SelectFilter2.js +++ b/django/contrib/admin/static/admin/js/SelectFilter2.js @@ -97,7 +97,15 @@ window.SelectFilter = { if (!is_stacked) { // In horizontal mode, give the same height to the two boxes. - $(to_box).height($(filter_p).outerHeight() + $(from_box).outerHeight()); + var j_from_box = $(from_box); + var j_to_box = $(to_box); + var resize_filters = function() { j_to_box.height($(filter_p).outerHeight() + j_from_box.outerHeight()); } + if (j_from_box.outerHeight() > 0) { + resize_filters(); // This fieldset is already open. Resize now. + } else { + // This fieldset is probably collapsed. Wait for its 'show' event. + j_to_box.closest('fieldset').one('show.fieldset', resize_filters); + } } // Initial icon refresh diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js index 5e4f04cc9d..889e1a5dfc 100644 --- a/django/contrib/admin/static/admin/js/collapse.js +++ b/django/contrib/admin/static/admin/js/collapse.js @@ -12,11 +12,11 @@ // Add toggle to anchor tag $("fieldset.collapse a.collapse-toggle").toggle( function() { // Show - $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed"); + $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset", [$(this).attr("id")]); return false; }, function() { // Hide - $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed"); + $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", [$(this).attr("id")]); return false; } ); diff --git a/django/contrib/admin/static/admin/js/collapse.min.js b/django/contrib/admin/static/admin/js/collapse.min.js index c55ba339d0..5e41b3c86c 100644 --- a/django/contrib/admin/static/admin/js/collapse.min.js +++ b/django/contrib/admin/static/admin/js/collapse.min.js @@ -1,2 +1,2 @@ -(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){if(a(b).find("div.errors").length==0){a(b).addClass("collapsed").find("h2").first().append(' ('+gettext("Show")+")")}});a("fieldset.collapse a.collapse-toggle").toggle(function(){a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed");return false},function(){a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed"); -return false})})})(django.jQuery); +(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){0==a(b).find("div.errors").length&&a(b).addClass("collapsed").find("h2").first().append(' ('+gettext("Show")+")")});a("fieldset.collapse a.collapse-toggle").toggle(function(){a(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed").trigger("show.fieldset",[a(this).attr("id")]);return!1},function(){a(this).text(gettext("Show")).closest("fieldset").addClass("collapsed").trigger("hide.fieldset", +[a(this).attr("id")]);return!1})})})(django.jQuery);