From 5c1c1a125443dd2219d6d9ba006c464a1c3956aa Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 9 Dec 2011 21:30:53 +0000 Subject: [PATCH] Changed admin/js/collapse.js to take advantage of jQuery chaining in three places. Should make for a slight performance boost. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17180 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/static/admin/js/collapse.js | 11 ++++------- django/contrib/admin/static/admin/js/collapse.min.js | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js index 0a1e2d8893..5e4f04cc9d 100644 --- a/django/contrib/admin/static/admin/js/collapse.js +++ b/django/contrib/admin/static/admin/js/collapse.js @@ -3,9 +3,8 @@ // Add anchor tag for Show/Hide link $("fieldset.collapse").each(function(i, elem) { // Don't hide if fields in this fieldset have errors - if ( $(elem).find("div.errors").length == 0 ) { - $(elem).addClass("collapsed"); - $(elem).find("h2").first().append(' (' + gettext("Show") + ')'); } @@ -13,13 +12,11 @@ // Add toggle to anchor tag $("fieldset.collapse a.collapse-toggle").toggle( function() { // Show - $(this).text(gettext("Hide")); - $(this).closest("fieldset").removeClass("collapsed"); + $(this).text(gettext("Hide")).closest("fieldset").removeClass("collapsed"); return false; }, function() { // Hide - $(this).text(gettext("Show")); - $(this).closest("fieldset").addClass("collapsed"); + $(this).text(gettext("Show")).closest("fieldset").addClass("collapsed"); 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 428984ee01..c55ba339d0 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");a(b).find("h2").first().append(' ('+gettext("Show")+")")}});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"); +(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);