Ticket #12044: 0003-Ticket-15569.patch

File 0003-Ticket-15569.patch, 6.6 KB (added by anonymous, 12 years ago)

Patched against 1.4.2

  • django/contrib/admin/static/admin/js/inlines.js

    From 1a8b4f275fe4fe0e45d0044198fcbcb94020d431 Mon Sep 17 00:00:00 2001
    From: root <root@vbox5.ascorp.net>
    Date: Fri, 16 Mar 2012 20:04:59 +0000
    Subject: [PATCH 3/3] Ticket 15569
    
    Signed-off-by: root <root@vbox5.ascorp.net>
    ---
     django/contrib/admin/static/admin/js/inlines.js    |    8 ++++----
     .../contrib/admin/static/admin/js/inlines.min.js   |   10 +++++-----
     2 files changed, 9 insertions(+), 9 deletions(-)
    
    diff --git a/django/contrib/admin/static/admin/js/inlines.js b/django/contrib/admin/static/admin/js/inlines.js
    index bddd6f7..8410588 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+|__prefix__))");
     21                        var id_regex = new RegExp("(" + prefix + "-(\\d+|__prefix__))","g");
    2222                        var replacement = prefix + "-" + ndx;
    23                         if ($(el).attr("for")) {
    24                                 $(el).attr("for", $(el).attr("for").replace(id_regex, replacement));
     23                        if (el.getAttribute("for")) {
     24                                el.setAttribute("for", el.getAttribute("for").replace(id_regex, replacement));
    2525                        }
    2626                        if (el.id) {
    2727                                el.id = el.id.replace(id_regex, replacement);
     
    7373                                        row.children(":first").append('<span><a class="' + options.deleteCssClass + '" href="javascript:void(0)">' + options.deleteText + "</a></span>");
    7474                                }
    7575                                row.find("*").each(function() {
    76                                         updateElementIndex(this, options.prefix, totalForms.val());
     76                                        updateElementIndex(this, options.prefix, nextIndex);
    7777                                });
    7878                                // Insert the new form when it has been fully edited
    7979                                row.insertBefore($(template));
  • django/contrib/admin/static/admin/js/inlines.min.js

    diff --git a/django/contrib/admin/static/admin/js/inlines.min.js b/django/contrib/admin/static/admin/js/inlines.min.js
    index 5631cd5..95ec6ff 100644
    a b  
    1 (function(b){b.fn.formset=function(c){var a=b.extend({},b.fn.formset.defaults,c),j=function(a,e,d){var i=RegExp("("+e+"-(\\d+|__prefix__))"),e=e+"-"+d;b(a).attr("for")&&b(a).attr("for",b(a).attr("for").replace(i,e));if(a.id)a.id=a.id.replace(i,e);if(a.name)a.name=a.name.replace(i,e)},c=b("#id_"+a.prefix+"-TOTAL_FORMS").attr("autocomplete","off"),g=parseInt(c.val()),f=b("#id_"+a.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off"),c=""==f.val()||0<f.val()-c.val();b(this).each(function(){b(this).not("."+
    2 a.emptyCssClass).addClass(a.formCssClass)});if(b(this).length&&c){var h;"TR"==b(this).attr("tagName")?(c=this.eq(0).children().length,b(this).parent().append('<tr class="'+a.addCssClass+'"><td colspan="'+c+'"><a href="javascript:void(0)">'+a.addText+"</a></tr>"),h=b(this).parent().find("tr:last a")):(b(this).filter(":last").after('<div class="'+a.addCssClass+'"><a href="javascript:void(0)">'+a.addText+"</a></div>"),h=b(this).filter(":last").next().find("a"));h.click(function(){var c=b("#id_"+a.prefix+
    3 "-TOTAL_FORMS"),e=b("#"+a.prefix+"-empty"),d=e.clone(!0);d.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+g);d.is("tr")?d.children(":last").append('<div><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></div>"):d.is("ul")||d.is("ol")?d.append('<li><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></li>"):d.children(":first").append('<span><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+
    4 "</a></span>");d.find("*").each(function(){j(this,a.prefix,c.val())});d.insertBefore(b(e));b(c).val(parseInt(c.val())+1);g+=1;""!=f.val()&&0>=f.val()-c.val()&&h.parent().hide();d.find("a."+a.deleteCssClass).click(function(){var c=b(this).parents("."+a.formCssClass);c.remove();g-=1;a.removed&&a.removed(c);c=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(c.length);(""==f.val()||0<f.val()-c.length)&&h.parent().show();for(var d=0,e=c.length;d<e;d++)j(b(c).get(d),a.prefix,d),b(c.get(d)).find("*").each(function(){j(this,
    5 a.prefix,d)});return!1});a.added&&a.added(d);return!1})}return this};b.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);
     1(function(b){b.fn.formset=function(d){var a=b.extend({},b.fn.formset.defaults,d),j=function(a,b,c){var i=RegExp("("+b+"-(\\d+|__prefix__))","g"),b=b+"-"+c;a.getAttribute("for")&&a.setAttribute("for",a.getAttribute("for").replace(i,b));a.id&&(a.id=a.id.replace(i,b));a.name&&(a.name=a.name.replace(i,b))},d=b("#id_"+a.prefix+"-TOTAL_FORMS").attr("autocomplete","off"),e=parseInt(d.val()),f=b("#id_"+a.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off"),d=""==f.val()||0<f.val()-d.val();b(this).each(function(){b(this).not("."+
     2a.emptyCssClass).addClass(a.formCssClass)});if(b(this).length&&d){var g;"TR"==b(this).attr("tagName")?(d=this.eq(0).children().length,b(this).parent().append('<tr class="'+a.addCssClass+'"><td colspan="'+d+'"><a href="javascript:void(0)">'+a.addText+"</a></tr>"),g=b(this).parent().find("tr:last a")):(b(this).filter(":last").after('<div class="'+a.addCssClass+'"><a href="javascript:void(0)">'+a.addText+"</a></div>"),g=b(this).filter(":last").next().find("a"));g.click(function(){var d=b("#id_"+a.prefix+
     3"-TOTAL_FORMS"),h=b("#"+a.prefix+"-empty"),c=h.clone(!0);c.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+e);c.is("tr")?c.children(":last").append('<div><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></div>"):c.is("ul")||c.is("ol")?c.append('<li><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+"</a></li>"):c.children(":first").append('<span><a class="'+a.deleteCssClass+'" href="javascript:void(0)">'+a.deleteText+
     4"</a></span>");c.find("*").each(function(){j(this,a.prefix,e)});c.insertBefore(b(h));b(d).val(parseInt(d.val())+1);e+=1;""!=f.val()&&0>=f.val()-d.val()&&g.parent().hide();c.find("a."+a.deleteCssClass).click(function(){var c=b(this).parents("."+a.formCssClass);c.remove();e-=1;a.removed&&a.removed(c);c=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(c.length);(""==f.val()||0<f.val()-c.length)&&g.parent().show();for(var d=0,h=c.length;d<h;d++)j(b(c).get(d),a.prefix,d),b(c.get(d)).find("*").each(function(){j(this,
     5a.prefix,d)});return!1});a.added&&a.added(c);return!1})}return this};b.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);
Back to Top