Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 5c1c1a125443dd2219d6d9ba006c464a1c3956aa 1 parent ce24747
Adrian Holovaty adrianholovaty authored
11 django/contrib/admin/static/admin/js/collapse.js
View
@@ -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(' (<a id="fieldsetcollapser' +
+ if ($(elem).find("div.errors").length == 0) {
+ $(elem).addClass("collapsed").find("h2").first().append(' (<a id="fieldsetcollapser' +
i +'" class="collapse-toggle" href="#">' + gettext("Show") +
'</a>)');
}
@@ -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;
}
);
2  django/contrib/admin/static/admin/js/collapse.min.js
View
@@ -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(' (<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");
+(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(' (<a id="fieldsetcollapser'+c+'" class="collapse-toggle" href="#">'+gettext("Show")+"</a>)")}});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);
Please sign in to comment.
Something went wrong with that request. Please try again.