Code

Ticket #13674: 13674_inlines_label_ids.diff

File 13674_inlines_label_ids.diff, 6.6 KB (added by julien, 3 years ago)
Line 
1diff --git a/django/contrib/admin/media/js/inlines.js b/django/contrib/admin/media/js/inlines.js
2index ddaf355..0153a41 100644
3--- a/django/contrib/admin/media/js/inlines.js
4+++ b/django/contrib/admin/media/js/inlines.js
5@@ -75,6 +75,14 @@
6                                    }).each(function() {
7                                        var el = $(this);
8                                        el.attr("name", el.attr("name").replace(/__prefix__/g, nextIndex));
9+                                   })
10+                                   .end()
11+                                   .filter(function() {
12+                                       var el = $(this);
13+                                       return el.attr("for") && el.attr("for").search(/__prefix__/) >= 0;
14+                                   }).each(function() {
15+                                       var el = $(this);
16+                                       el.attr("for", el.attr("for").replace(/__prefix__/g, nextIndex));
17                                    });
18                                if (row.is("tr")) {
19                                        // If the forms are laid out in table rows, insert
20diff --git a/django/contrib/admin/media/js/inlines.min.js b/django/contrib/admin/media/js/inlines.min.js
21index c3336d0..fa3540b 100644
22--- a/django/contrib/admin/media/js/inlines.min.js
23+++ b/django/contrib/admin/media/js/inlines.min.js
24@@ -1,6 +1,6 @@
25-(function(a){a.fn.formset=function(g){var b=a.extend({},a.fn.formset.defaults,g),l=function(d,f,e){var c=new RegExp("("+f+"-\\d+)");f=f+"-"+e;a(d).attr("for")&&a(d).attr("for",a(d).attr("for").replace(c,f));if(d.id)d.id=d.id.replace(c,f);if(d.name)d.name=d.name.replace(c,f)};g=a("#id_"+b.prefix+"-TOTAL_FORMS").attr("autocomplete","off");var j=parseInt(g.val()),h=a("#id_"+b.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off");g=h.val()==""||h.val()-g.val()>0;a(this).each(function(){a(this).not("."+
26-b.emptyCssClass).addClass(b.formCssClass)});if(a(this).length&&g){var i;if(a(this).attr("tagName")=="TR"){g=this.eq(0).children().length;a(this).parent().append('<tr class="'+b.addCssClass+'"><td colspan="'+g+'"><a href="javascript:void(0)">'+b.addText+"</a></tr>");i=a(this).parent().find("tr:last a")}else{a(this).filter(":last").after('<div class="'+b.addCssClass+'"><a href="javascript:void(0)">'+b.addText+"</a></div>");i=a(this).filter(":last").next().find("a")}i.click(function(){var d=a("#id_"+
27-b.prefix+"-TOTAL_FORMS"),f=a("#"+b.prefix+"-empty"),e=f.clone(true);e.removeClass(b.emptyCssClass).addClass(b.formCssClass).attr("id",b.prefix+"-"+j);j+=1;e.find("*").filter(function(){var c=a(this);return c.attr("id")&&c.attr("id").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("id",c.attr("id").replace(/__prefix__/g,j))}).end().filter(function(){var c=a(this);return c.attr("name")&&c.attr("name").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("name",c.attr("name").replace(/__prefix__/g,
28-j))});if(e.is("tr"))e.children(":last").append('<div><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></div>");else e.is("ul")||e.is("ol")?e.append('<li><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></li>"):e.children(":first").append('<span><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></span>");e.find("input,select,textarea,label,a").each(function(){l(this,b.prefix,d.val())});e.insertBefore(a(f));a(d).val(parseInt(d.val())+
29-1);h.val()!=""&&h.val()-d.val()<=0&&i.parent().hide();e.find("a."+b.deleteCssClass).click(function(){var c=a(this).parents("."+b.formCssClass);c.remove();b.removed&&b.removed(c);c=a("."+b.formCssClass);a("#id_"+b.prefix+"-TOTAL_FORMS").val(c.length);if(h.val()==""||h.val()-c.length>0)i.parent().show();for(var k=0,m=c.length;k<m;k++)a(c.get(k)).find("input,select,textarea,label,a").each(function(){l(this,b.prefix,k)});return false});b.added&&b.added(e);return false})}return this};a.fn.formset.defaults=
30-{prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null}})(django.jQuery);
31+(function(a){a.fn.formset=function(g){var b=a.extend({},a.fn.formset.defaults,g),l=function(d,f,e){var c=RegExp("("+f+"-\\d+)");f=f+"-"+e;a(d).attr("for")&&a(d).attr("for",a(d).attr("for").replace(c,f));if(d.id)d.id=d.id.replace(c,f);if(d.name)d.name=d.name.replace(c,f)};g=a("#id_"+b.prefix+"-TOTAL_FORMS").attr("autocomplete","off");var i=parseInt(g.val()),h=a("#id_"+b.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off");g=h.val()==""||h.val()-g.val()>0;a(this).each(function(){a(this).not("."+b.emptyCssClass).addClass(b.formCssClass)});
32+if(a(this).length&&g){var j;if(a(this).attr("tagName")=="TR"){g=this.eq(0).children().length;a(this).parent().append('<tr class="'+b.addCssClass+'"><td colspan="'+g+'"><a href="javascript:void(0)">'+b.addText+"</a></tr>");j=a(this).parent().find("tr:last a")}else{a(this).filter(":last").after('<div class="'+b.addCssClass+'"><a href="javascript:void(0)">'+b.addText+"</a></div>");j=a(this).filter(":last").next().find("a")}j.click(function(){var d=a("#id_"+b.prefix+"-TOTAL_FORMS"),f=a("#"+b.prefix+"-empty"),
33+e=f.clone(true);e.removeClass(b.emptyCssClass).addClass(b.formCssClass).attr("id",b.prefix+"-"+i);i+=1;e.find("*").filter(function(){var c=a(this);return c.attr("id")&&c.attr("id").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("id",c.attr("id").replace(/__prefix__/g,i))}).end().filter(function(){var c=a(this);return c.attr("name")&&c.attr("name").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("name",c.attr("name").replace(/__prefix__/g,i))}).end().filter(function(){var c=
34+a(this);return c.attr("for")&&c.attr("for").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("for",c.attr("for").replace(/__prefix__/g,i))});if(e.is("tr"))e.children(":last").append('<div><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></div>");else e.is("ul")||e.is("ol")?e.append('<li><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></li>"):e.children(":first").append('<span><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+
35+b.deleteText+"</a></span>");e.find("input,select,textarea,label,a").each(function(){l(this,b.prefix,d.val())});e.insertBefore(a(f));a(d).val(parseInt(d.val())+1);h.val()!=""&&h.val()-d.val()<=0&&j.parent().hide();e.find("a."+b.deleteCssClass).click(function(){var c=a(this).parents("."+b.formCssClass);c.remove();b.removed&&b.removed(c);c=a("."+b.formCssClass);a("#id_"+b.prefix+"-TOTAL_FORMS").val(c.length);if(h.val()==""||h.val()-c.length>0)j.parent().show();for(var k=0,m=c.length;k<m;k++)a(c.get(k)).find("input,select,textarea,label,a").each(function(){l(this,
36+b.prefix,k)});return false});b.added&&b.added(e);return false})}return this};a.fn.formset.defaults={prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null}})(django.jQuery);