Ticket #17218: select-filter-waits-for-collapsed-fieldset.diff

File select-filter-waits-for-collapsed-fieldset.diff, 3.4 KB (added by jimallman <jim@…>, 13 years ago)

Simple event trigger on fieldset, resizes each select filter just once.

  • django/contrib/admin/static/admin/js/SelectFilter2.js

    diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js
    index 2eb67e8..b68b4c3 100644
    a b window.SelectFilter = {  
    9999
    100100        if (!is_stacked) {
    101101            // In horizontal mode, give the same height to the two boxes.
    102             $(to_box).height($(filter_p).outerHeight() + $(from_box).outerHeight());
     102            if ($(from_box).outerHeight() > 0) {
     103                // this fieldset is already open, resize now
     104                $(to_box).height($(filter_p).outerHeight() + $(from_box).outerHeight());
     105            } else {
     106                // this fieldset is probably collapsed (not safe to resize); wait for its 'show' event
     107                $(to_box).closest('fieldset').bind('show.fieldset', function( event, fieldsetID ) {
     108                    $(to_box).height($(filter_p).outerHeight() + $(from_box).outerHeight());
     109                    $(this).unbind(event);   // unbinds ONLY this handler (no need to resize repeatedly)
     110                });
     111            }
    103112        }
    104113
    105114        // Initial icon refresh
  • django/contrib/admin/static/admin/js/collapse.js

    diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js
    index 0a1e2d8..b4a882f 100644
    a b  
    1515                        function() { // Show
    1616                                $(this).text(gettext("Hide"));
    1717                                $(this).closest("fieldset").removeClass("collapsed");
     18                                $(this).closest("fieldset").trigger("show.fieldset",[$(this).attr("id")]);
    1819                                return false;
    1920                        },
    2021                        function() { // Hide
    2122                                $(this).text(gettext("Show"));
    2223                                $(this).closest("fieldset").addClass("collapsed");
     24                                $(this).closest("fieldset").trigger("hide.fieldset",[$(this).attr("id")]);
    2325                                return false;
    2426                        }
    2527                );
  • django/contrib/admin/static/admin/js/collapse.min.js

    diff --git a/django/contrib/admin/static/admin/js/collapse.min.js b/django/contrib/admin/static/admin/js/collapse.min.js
    index 428984e..5f5dafa 100644
    a b  
    1 (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");a(b).find("h2").first().append(' (<a id="fieldsetcollapser'+c+'" class="collapse-toggle" href="#">'+gettext("Show")+"</a>)")}});a("fieldset.collapse a.collapse-toggle").toggle(function(){a(this).text(gettext("Hide"));a(this).closest("fieldset").removeClass("collapsed");return false},function(){a(this).text(gettext("Show"));a(this).closest("fieldset").addClass("collapsed");
    2 return false})})})(django.jQuery);
     1(function(a){a(document).ready(function(){a("fieldset.collapse").each(function(c,b){a(b).find("div.errors").length==0&&(a(b).addClass("collapsed"),a(b).find("h2").first().append(' (<a id="fieldsetcollapser'+c+'" class="collapse-toggle" href="#">'+gettext("Show")+"</a>)"))});a("fieldset.collapse a.collapse-toggle").toggle(function(){a(this).text(gettext("Hide"));a(this).closest("fieldset").removeClass("collapsed");a(this).closest("fieldset").trigger("show.fieldset",[a(this).attr("id")]);return false},
     2function(){a(this).text(gettext("Show"));a(this).closest("fieldset").addClass("collapsed");a(this).closest("fieldset").trigger("hide.fieldset",[a(this).attr("id")]);return false})})})(django.jQuery);
Back to Top