Ticket #13674: 0001-fix-updating-of-the-for-attribute-in-new-admin-inlin.patch

File 0001-fix-updating-of-the-for-attribute-in-new-admin-inlin.patch, 3.8 KB (added by Tay Ray Chuan, 14 years ago)
  • django/contrib/admin/media/js/inlines.js

    From 2d956284a0914f2e71c91f1d89d43db4d859970c Mon Sep 17 00:00:00 2001
    From: Tay Ray Chuan <rctay89@gmail.com>
    Date: Sat, 3 Jul 2010 20:39:44 +0800
    Subject: [PATCH] fix updating of the 'for' attribute in new admin inlines
    
    ---
     django/contrib/admin/media/js/inlines.js     |    2 +-
     django/contrib/admin/media/js/inlines.min.js |    2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/django/contrib/admin/media/js/inlines.js b/django/contrib/admin/media/js/inlines.js
    index cf79023..21e00ad 100644
    a b  
    1818        $.fn.formset = function(opts) {
    1919                var options = $.extend({}, $.fn.formset.defaults, opts);
    2020                var updateElementIndex = function(el, prefix, ndx) {
    21                         var id_regex = new RegExp("(" + prefix + "-\\d+)");
     21                        var id_regex = new RegExp(prefix + "-__prefix__");
    2222                        var replacement = prefix + "-" + ndx;
    2323                        if ($(el).attr("for")) {
    2424                                $(el).attr("for", $(el).attr("for").replace(id_regex, replacement));
  • django/contrib/admin/media/js/inlines.min.js

    diff --git a/django/contrib/admin/media/js/inlines.min.js b/django/contrib/admin/media/js/inlines.min.js
    index 9e0926f..c9e6d64 100644
    a b  
    1 (function(a){a.fn.formset=function(g){var b=a.extend({},a.fn.formset.defaults,g),l=function(e,f,j){var d=new RegExp("("+f+"-\\d+)");f=f+"-"+j;a(e).attr("for")&&a(e).attr("for",a(e).attr("for").replace(d,f));if(e.id)e.id=e.id.replace(d,f);if(e.name)e.name=e.name.replace(d,f)};g=a("#id_"+b.prefix+"-TOTAL_FORMS").attr("autocomplete","off");var 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)});
     1(function(a){a.fn.formset=function(g){var b=a.extend({},a.fn.formset.defaults,g),l=function(e,f,j){var d=new RegExp(f+"-__prefix__");f=f+"-"+j;a(e).attr("for")&&a(e).attr("for",a(e).attr("for").replace(d,f));if(e.id)e.id=e.id.replace(d,f);if(e.name)e.name=e.name.replace(d,f)};g=a("#id_"+b.prefix+"-TOTAL_FORMS").attr("autocomplete","off");var 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)});
    22if(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 e=a("#id_"+b.prefix+"-TOTAL_FORMS"),f=parseInt(e.val()),
    33j=a("#"+b.prefix+"-empty"),d=j.clone(true);d.removeClass(b.emptyCssClass).addClass(b.formCssClass).attr("id",b.prefix+"-"+f).insertBefore(a(j));d.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,f))}).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,
    44f))});if(d.is("tr"))d.children(":last").append('<div><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></div>");else d.is("ul")||d.is("ol")?d.append('<li><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></li>"):d.children(":first").append('<span><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></span>");d.find("input,select,textarea,label,a").each(function(){l(this,b.prefix,e.val())});a(e).val(f+1);h.val()!=""&&
Back to Top