Permalink
Browse files

Clean up indention

  • Loading branch information...
1 parent 11dbc83 commit 20e6c3301063bbe23d511aaa10ce636b831aa7c4 @tswicegood committed May 24, 2012
Showing with 69 additions and 66 deletions.
  1. +69 −66 pops/templates/admin/edit_inline/tabular.html
@@ -64,74 +64,77 @@
</div>
</div>
-<script type="text/javascript">
+<script>
(function($) {
- $(document).ready(function($) {
- $('.tabular-inline textarea').addClass('xxlarge');
- var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
- var alternatingRows = function(row) {
- $(rows).not(".add-row").removeClass("row1 row2")
- .filter(":even").addClass("row1").end()
- .filter(rows + ":odd").addClass("row2");
- }
- var reinitDateTimeShortCuts = function() {
- // Reinitialize the calendar and clock widgets by force
- if (typeof DateTimeShortcuts != "undefined") {
- $(".datetimeshortcuts").remove();
- DateTimeShortcuts.init();
- }
- }
- var updateSelectFilter = function() {
- // If any SelectFilter widgets are a part of the new form,
- // instantiate a new SelectFilter instance for it.
- if (typeof SelectFilter != "undefined"){
- $(".selectfilter").each(function(index, value){
- var namearr = value.name.split('-');
- SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
- });
- $(".selectfilterstacked").each(function(index, value){
- var namearr = value.name.split('-');
- SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
- });
- }
- }
- var initPrepopulatedFields = function(row) {
- row.find('.prepopulated_field').each(function() {
- var field = $(this);
- var input = field.find('input, select, textarea');
- var dependency_list = input.data('dependency_list') || [];
- var dependencies = [];
- $.each(dependency_list, function(i, field_name) {
- dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
- });
- if (dependencies.length) {
- input.prepopulate(dependencies, input.attr('maxlength'));
- }
+ $(document).ready(function($) {
+ $('.tabular-inline textarea').addClass('xxlarge');
+ var rows = "#{{ inline_admin_formset.formset.prefix }}-group .tabular.inline-related tbody tr";
+ var alternatingRows = function(row) {
+ $(rows).not(".add-row").removeClass("row1 row2")
+ .filter(":even").addClass("row1").end()
+ .filter(rows + ":odd").addClass("row2");
+ },
+
+ reinitDateTimeShortCuts = function() {
+ // Reinitialize the calendar and clock widgets by force
+ if (typeof DateTimeShortcuts != "undefined") {
+ $(".datetimeshortcuts").remove();
+ DateTimeShortcuts.init();
+ }
+ },
+
+ updateSelectFilter = function() {
+ // If any SelectFilter widgets are a part of the new form,
+ // instantiate a new SelectFilter instance for it.
+ if (typeof SelectFilter != "undefined"){
+ $(".selectfilter").each(function(index, value){
+ var namearr = value.name.split('-');
+ SelectFilter.init(value.id, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
+ });
+ $(".selectfilterstacked").each(function(index, value){
+ var namearr = value.name.split('-');
+ SelectFilter.init(value.id, namearr[namearr.length-1], true, "{% admin_media_prefix %}");
});
- }
- $(rows).formset({
- prefix: "{{ inline_admin_formset.formset.prefix }}",
- addText: "<i class='icon icon-plus'></i> {% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
- formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
- deleteCssClass: "inline-deletelink btn",
- addCssClass: "add-row",
- deleteText: "<i class='icon icon-minus'></i> {% trans "Remove" %}",
- emptyCssClass: "empty-form",
- removed: alternatingRows,
- added: (function(row) {
- initPrepopulatedFields(row);
- reinitDateTimeShortCuts();
- updateSelectFilter();
- alternatingRows(row);
- // Seem to be hidden w/o this...?
- $(row).show();
- jQuery(row).find(".chzn-done").each(function(i, el) {
- jQuery("#" + el.id + "_chzn").remove();
- jQuery(el).removeClass("chzn-done").chosen();
- });
- })
- })
- $("#{{ inline_admin_formset.formset.prefix }}-group").find(".add-row a").addClass("btn pull-right");
+ }
+ },
+
+ initPrepopulatedFields = function(row) {
+ row.find('.prepopulated_field').each(function() {
+ var field = $(this);
+ var input = field.find('input, select, textarea');
+ var dependency_list = input.data('dependency_list') || [];
+ var dependencies = [];
+ $.each(dependency_list, function(i, field_name) {
+ dependencies.push('#' + row.find(field_name).find('input, select, textarea').attr('id'));
+ });
+ if (dependencies.length) {
+ input.prepopulate(dependencies, input.attr('maxlength'));
+ }
+ });
+ };
+
+ $(rows).formset({
+ prefix: "{{ inline_admin_formset.formset.prefix }}",
+ addText: "<i class='icon icon-plus'></i> {% blocktrans with inline_admin_formset.opts.verbose_name|title as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
+ formCssClass: "dynamic-{{ inline_admin_formset.formset.prefix }}",
+ deleteCssClass: "inline-deletelink btn",
+ addCssClass: "add-row",
+ deleteText: "<i class='icon icon-minus'></i> {% trans "Remove" %}",
+ emptyCssClass: "empty-form",
+ removed: alternatingRows,
+ added: (function(row) {
+ initPrepopulatedFields(row);
+ reinitDateTimeShortCuts();
+ updateSelectFilter();
+ alternatingRows(row);
+ jQuery(row).find(".chzn-done").each(function(i, el) {
+ jQuery("#" + el.id + "_chzn").remove();
+ jQuery(el).removeClass("chzn-done").chosen();
+ });
+ })
});
+
+ $("#{{ inline_admin_formset.formset.prefix }}-group").find(".add-row a").addClass("btn pull-right");
+ });
})(django.jQuery);
</script>

0 comments on commit 20e6c33

Please sign in to comment.