Ticket #12903: 12903-r12937.diff

File 12903-r12937.diff, 9.0 KB (added by Ramiro Morales, 15 years ago)

New version of the patch, fixed a typo and changed method of passing a var from python to JS (hidden span -> JS var)

  • django/contrib/admin/media/js/actions.js

    diff --git a/django/contrib/admin/media/js/actions.js b/django/contrib/admin/media/js/actions.js
    a b  
    1212                                .parent().parent().toggleClass(options.selectedClass, checked);
    1313                }
    1414                updateCounter = function() {
    15                         var count = $(actionCheckboxes).filter(":checked").length;
    16                         $("span._acnt").html(count);
     15                        var sel = $(actionCheckboxes).filter(":checked").length;
     16                        $("span.action-counter").html(interpolate(ngettext('%(sel)s of %(cnt)s selected', '%(sel)s of %(cnt)s selected', sel), {sel: sel, cnt: _actions_icnt}, true));
    1717                        $(options.allToggle).attr("checked", function() {
    18                                 if (count == actionCheckboxes.length) {
     18                                if (sel == actionCheckboxes.length) {
    1919                                        value = true;
    2020                                        showQuestion();
    2121                                } else {
    2222                                        value = false;
    2323                                        clearAcross();
    2424                                }
    25                                 return value
     25                                return value;
    2626                        });
    2727                }
    2828                showQuestion = function() {
  • django/contrib/admin/media/js/actions.min.js

    diff --git a/django/contrib/admin/media/js/actions.min.js b/django/contrib/admin/media/js/actions.min.js
    a b  
    1 (function(a){a.fn.actions=function(g){var b=a.extend({},a.fn.actions.defaults,g),e=a(this);checker=function(c){c?showQuestion():reset();a(e).attr("checked",c).parent().parent().toggleClass(b.selectedClass,c)};updateCounter=function(){var c=a(e).filter(":checked").length;a("span._acnt").html(c);a(b.allToggle).attr("checked",function(){if(c==e.length){value=true;showQuestion()}else{value=false;clearAcross()}return value})};showQuestion=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();
    2 a(b.allContainer).hide()};showClear=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()};reset=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()};clearAcross=function(){reset();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)};a(b.counterContainer).show();a(this).filter(":checked").each(function(){a(this).parent().parent().toggleClass(b.selectedClass);
    3 updateCounter();a(b.acrossInput).val()==1&&showClear()});a(b.allToggle).show().click(function(){checker(a(this).attr("checked"));updateCounter()});a("div.actions span.question a").click(function(c){c.preventDefault();a(b.acrossInput).val(1);showClear()});a("div.actions span.clear a").click(function(c){c.preventDefault();a(b.allToggle).attr("checked",false);clearAcross();checker(0);updateCounter()});lastChecked=null;a(e).click(function(c){if(!c)c=window.event;var d=c.target?c.target:c.srcElement;if(lastChecked&&
    4 a.data(lastChecked)!=a.data(d)&&c.shiftKey==true){var f=false;a(lastChecked).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(e).each(function(){if(a.data(this)==a.data(lastChecked)||a.data(this)==a.data(d))f=f?false:true;f&&a(this).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);lastChecked=d;updateCounter()})};a.fn.actions.defaults={actionContainer:"div.actions",
    5 counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(jQuery);
     1(function(a){a.fn.actions=function(g){var b=a.extend({},a.fn.actions.defaults,g),e=a(this);checker=function(c){c?showQuestion():reset();a(e).attr("checked",c).parent().parent().toggleClass(b.selectedClass,c)};updateCounter=function(){var c=a(e).filter(":checked").length;a("span.action-counter").html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:_actions_icnt},true));a(b.allToggle).attr("checked",function(){if(c==e.length){value=true;showQuestion()}else{value=
     2false;clearAcross()}return value})};showQuestion=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()};showClear=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()};reset=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()};clearAcross=function(){reset();a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)};
     3a(b.counterContainer).show();a(this).filter(":checked").each(function(){a(this).parent().parent().toggleClass(b.selectedClass);updateCounter();a(b.acrossInput).val()==1&&showClear()});a(b.allToggle).show().click(function(){checker(a(this).attr("checked"));updateCounter()});a("div.actions span.question a").click(function(c){c.preventDefault();a(b.acrossInput).val(1);showClear()});a("div.actions span.clear a").click(function(c){c.preventDefault();a(b.allToggle).attr("checked",false);clearAcross();checker(0);
     4updateCounter()});lastChecked=null;a(e).click(function(c){if(!c)c=window.event;var d=c.target?c.target:c.srcElement;if(lastChecked&&a.data(lastChecked)!=a.data(d)&&c.shiftKey==true){var f=false;a(lastChecked).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(e).each(function(){if(a.data(this)==a.data(lastChecked)||a.data(this)==a.data(d))f=f?false:true;f&&a(this).attr("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,
     5d.checked);lastChecked=d;updateCounter()})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"}})(jQuery);
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    a b  
    10351035        else:
    10361036            action_form = None
    10371037
    1038         selection_note = ungettext('of %(count)d selected',
    1039             'of %(count)d selected', len(cl.result_list))
    10401038        selection_note_all = ungettext('%(total_count)s selected',
    10411039            'All %(total_count)s selected', cl.result_count)
    10421040
    10431041        context = {
    10441042            'module_name': force_unicode(opts.verbose_name_plural),
    1045             'selection_note': selection_note % {'count': len(cl.result_list)},
     1043            'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
    10461044            'selection_note_all': selection_note_all % {'total_count': cl.result_count},
    10471045            'title': cl.title,
    10481046            'is_popup': cl.is_popup,
  • django/contrib/admin/templates/admin/actions.html

    diff --git a/django/contrib/admin/templates/admin/actions.html b/django/contrib/admin/templates/admin/actions.html
    a b  
    33    {% for field in action_form %}{% if field.label %}<label>{{ field.label }} {% endif %}{{ field }}{% if field.label %}</label>{% endif %}{% endfor %}
    44    <button type="submit" class="button" title="{% trans "Run the selected action" %}" name="index" value="{{ action_index|default:0 }}">{% trans "Go" %}</button>
    55    {% if actions_selection_counter %}
    6         <span class="action-counter"><span class="_acnt">0</span> {{ selection_note }}</span>
     6        <script type="text/javascript">var _actions_icnt={{ cl.result_count|default_if_none:"0" }};</script>
     7        <span class="action-counter">{{ selection_note }}</span>
    78        {% if cl.result_count != cl.result_list|length %}
    89        <span class="all">{{ selection_note_all }}</span>
    910        <span class="question">
  • django/contrib/admin/templates/admin/change_list.html

    diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html
    a b  
    66  <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />
    77  {% if cl.formset %}
    88    <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />
     9  {% endif %}
     10  {% if cl.formset or action_form %}
    911    {% url admin:jsi18n as jsi18nurl %}
    1012    <script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
    1113  {% endif %}
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    a b  
    14431443        Check if the selection counter is there.
    14441444        """
    14451445        response = self.client.get('/test_admin/admin/admin_views/subscriber/')
    1446         self.assertContains(response, '<span class="_acnt">0</span> of 2 selected')
     1446        self.assertContains(response, '0 of 2 selected')
    14471447
    14481448
    14491449class TestCustomChangeList(TestCase):
Back to Top