PageRenderTime 12810ms CodeModel.GetById 44ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/django/contrib/admin/media/js/collapse.js

https://code.google.com/p/mango-py/
JavaScript | 27 lines | 24 code | 0 blank | 3 comment | 2 complexity | 0612f1063a60e15292241a9e24826a08 MD5 | raw file
 1(function($) {
 2	$(document).ready(function() {
 3		// Add anchor tag for Show/Hide link
 4		$("fieldset.collapse").each(function(i, elem) {
 5			// Don't hide if fields in this fieldset have errors
 6			if ( $(elem).find("div.errors").length == 0 ) {
 7				$(elem).addClass("collapsed");
 8				$(elem).find("h2").first().append(' (<a id="fieldsetcollapser' +
 9					i +'" class="collapse-toggle" href="#">' + gettext("Show") +
10					'</a>)');
11			}
12		});
13		// Add toggle to anchor tag
14		$("fieldset.collapse a.collapse-toggle").toggle(
15			function() { // Show
16				$(this).text(gettext("Hide"));
17				$(this).closest("fieldset").removeClass("collapsed");
18				return false;
19			},
20			function() { // Hide
21				$(this).text(gettext("Show"));
22				$(this).closest("fieldset").addClass("collapsed");
23				return false;
24			}
25		);
26	});
27})(django.jQuery);