Ticket #11697: shift-check-multi.diff

File shift-check-multi.diff, 1.8 KB (added by Sean Brant, 14 years ago)

This adds support for shift-clicking checkboxes to select items in a range

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

     
    44        counterContainer = document.getElementsBySelector('span.action_counter');
    55        actionCheckboxes = document.getElementsBySelector('tr input.action-select');
    66        selectAll = document.getElementById('action-toggle');
     7        lastChecked = null;
    78        for(var i = 0; i < counterContainer.length; i++) {
    89            counterContainer[i].style.display = 'inline';
    910        }
     
    1819            addEvent(actionCheckboxes[i], 'click', function() {
    1920                Actions.counter();
    2021            });
     22            addEvent(actionCheckboxes[i], 'click', function(e) {
     23                if (!e) { var e = window.event; }
     24                var target = e.target ? e.target : e.srcElement;
     25                if (e.shiftKey == true) {
     26                    var inrange = false;
     27                    for (var i = 0; i < actionCheckboxes.length; i++) {
     28                        if (actionCheckboxes[i] == lastChecked || actionCheckboxes[i] == target) {
     29                            inrange = (inrange) ? false : true;
     30                        }
     31                        if (inrange) {
     32                            actionCheckboxes[i].checked = target.checked;
     33                            Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, target.checked);
     34                        }
     35                    }
     36                }
     37                lastChecked = target;
     38            });
    2139        }
    2240        var changelistTable = document.getElementsBySelector('#changelist table')[0];
    2341        if (changelistTable) {
Back to Top