~ubuntu-branches/ubuntu/oneiric/python-django/oneiric

« back to all changes in this revision

Viewing changes to django/contrib/admin/media/js/inlines.js

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2011-02-17 13:34:07 UTC
  • mfrom: (1.1.13 upstream) (4.4.12 sid)
  • Revision ID: james.westby@ubuntu.com-20110217133407-rwr88elhhq6j7ba0
Tags: 1.2.5-1ubuntu1
* Merge from Debian for security fixes (LP: #719031). Remaining changes:
  - debian/control: don't Build-Depends on locales-all, which doesn't exist
    in natty
* Drop the following patches, now included upstream:
  - debian/patches/07_security_admin_infoleak.diff
  - debian/patches/08_security_pasword_reset_dos.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
                        }
32
32
                };
33
33
                var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS").attr("autocomplete", "off");
 
34
                var nextIndex = parseInt(totalForms.val());
34
35
                var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").attr("autocomplete", "off");
35
36
                // only show the add button if we are allowed to add more items,
36
37
        // note that max_num = None translates to a blank string.
53
54
                        }
54
55
                        addButton.click(function() {
55
56
                                var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS");
56
 
                                var nextIndex = parseInt(totalForms.val());
57
57
                                var template = $("#" + options.prefix + "-empty");
58
58
                                var row = template.clone(true);
59
59
                                row.removeClass(options.emptyCssClass)
60
60
                                    .addClass(options.formCssClass)
61
 
                                    .attr("id", options.prefix + "-" + nextIndex)
62
 
                                    .insertBefore($(template));
 
61
                                    .attr("id", options.prefix + "-" + nextIndex);
 
62
                                nextIndex += 1;
63
63
                                row.find("*")
64
64
                                    .filter(function() {
65
65
                                        var el = $(this);
75
75
                                    }).each(function() {
76
76
                                        var el = $(this);
77
77
                                        el.attr("name", el.attr("name").replace(/__prefix__/g, nextIndex));
 
78
                                    })
 
79
                                    .end()
 
80
                                    .filter(function() {
 
81
                                        var el = $(this);
 
82
                                        return el.attr("for") && el.attr("for").search(/__prefix__/) >= 0;
 
83
                                    }).each(function() {
 
84
                                        var el = $(this);
 
85
                                        el.attr("for", el.attr("for").replace(/__prefix__/g, nextIndex));
78
86
                                    });
79
87
                                if (row.is("tr")) {
80
88
                                        // If the forms are laid out in table rows, insert
92
100
                                row.find("input,select,textarea,label,a").each(function() {
93
101
                                        updateElementIndex(this, options.prefix, totalForms.val());
94
102
                                });
 
103
                                // Insert the new form when it has been fully edited
 
104
                                row.insertBefore($(template));
95
105
                                // Update number of total forms
96
 
                                $(totalForms).val(nextIndex + 1);
 
106
                                $(totalForms).val(parseInt(totalForms.val()) + 1);
97
107
                                // Hide add button in case we've hit the max, except we want to add infinitely
98
108
                                if ((maxForms.val() != '') && (maxForms.val()-totalForms.val()) <= 0) {
99
109
                                        addButton.parent().hide();