Ticket #10615: admin-actions-counter-10625-3.diff

File admin-actions-counter-10625-3.diff, 4.1 KB (added by Martin Mahner, 15 years ago)
  • django/contrib/admin/media/css/changelists.css

    diff --git a/django/contrib/admin/media/css/changelists.css b/django/contrib/admin/media/css/changelists.css
    index 4303378..65ae083 100644
    a b  
    228228    border-right: 1px solid #ddd;
    229229}
    230230
     231.action_counter{
     232    font-size: 11px;
     233    margin: 0 0.5em;
     234    padding-right: 0.5em;
     235    border-right: 1px solid #ccc;
     236    display: none;
     237}
     238
    231239#changelist table input {
    232240    margin: 0;
    233241}
  • 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
    index d34488a..b82bd13 100644
    a b  
    11var Actions = {
    22    init: function() {
    3         var selectAll = document.getElementById('action-toggle');
     3        counterSpans = document.getElementsBySelector('span._acnt');
     4        counterContainer = document.getElementsBySelector('span.action_counter');
     5        actionCheckboxes = document.getElementsBySelector('tr input.action-select');
     6        selectAll = document.getElementById('action-toggle');
     7        for(var i = 0; i < counterContainer.length; i++) {
     8            counterContainer[i].style.display = 'inline';
     9        }
    410        if (selectAll) {
    511            selectAll.style.display = 'inline';
    612            addEvent(selectAll, 'click', function() {
    713                Actions.checker(selectAll.checked);
     14                Actions.counter();
     15            });
     16        }       
     17        for(var i = 0; i < actionCheckboxes.length; i++) {
     18            addEvent(actionCheckboxes[i], 'click', function() {
     19                Actions.counter();
    820            });
    921        }
    1022        var changelistTable = document.getElementsBySelector('#changelist table')[0];
    var Actions = {  
    1628                if (target.className == 'action-select') {
    1729                    var tr = target.parentNode.parentNode;
    1830                    Actions.toggleRow(tr, target.checked);
     31                    Actions.checked();
    1932                }
    2033            });
    2134        }
    var Actions = {  
    2740            tr.className = tr.className.replace(' selected', '');
    2841        } 
    2942    },
     43    checked: function() {
     44        selectAll.checked = false;
     45    },
    3046    checker: function(checked) {
    31         var actionCheckboxes = document.getElementsBySelector('tr input.action-select');
    3247        for(var i = 0; i < actionCheckboxes.length; i++) {
    3348            actionCheckboxes[i].checked = checked;
    3449            Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, checked);
    3550        }
     51    },
     52    counter: function() {
     53        counter = 0;
     54        for(var i = 0; i < actionCheckboxes.length; i++) {
     55            if(actionCheckboxes[i].checked){
     56                counter++;
     57            }
     58        }
     59        for(var i = 0; i < counterSpans.length; i++) {
     60            counterSpans[i].innerHTML = counter;
     61        }
    3662    }
    3763};
    3864
    39 addEvent(window, 'load', Actions.init);
     65addEvent(window, 'load', Actions.init);
     66 No newline at end of file
  • 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
    index bf4b975..4fea071 100644
    a b  
    11{% load i18n %}
    22<div class="actions">
     3    <span class="action_counter">
     4    {% ifequal cl.result_count 1 %}
     5        {% blocktrans with cl.result_count as total_count and cl.opts.verbose_name as module_name %}<span class="_acnt">0</span> of {{ total_count }} {{ module_name }} selected{% endblocktrans %}
     6    {% else %}
     7        {% blocktrans with cl.result_count as total_count and cl.opts.verbose_name_plural as module_name %}<span class="_acnt">0</span> of {{ total_count }} {{ module_name }} selected{% endblocktrans %}
     8    {% endifequal %}
     9    </span>
    310    {% for field in action_form %}<label>{{ field.label }} {{ field }}</label>{% endfor %}
    411    <button type="submit" class="button" title="{% trans "Run the selected action" %}" name="index" value="{{ action_index|default:0 }}">{% trans "Go" %}</button>
    512</div>
Back to Top