From c823e9d7ccba303fb37ce232eb1db901ef580a2a Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Tue, 31 Mar 2009 16:24:12 +0000 Subject: [PATCH] Added row highlighting when selecting action checkmarks. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10258 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../contrib/admin/media/css/changelists.css | 4 ++++ django/contrib/admin/media/js/actions.js | 24 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/django/contrib/admin/media/css/changelists.css b/django/contrib/admin/media/css/changelists.css index 2d27a855e9..5eb66b4d36 100644 --- a/django/contrib/admin/media/css/changelists.css +++ b/django/contrib/admin/media/css/changelists.css @@ -232,6 +232,10 @@ margin: 0; } +#changelist table tbody tr.selected { + background-color: #FFFFCC; +} + #changelist .actions { color: #999; padding: 3px; diff --git a/django/contrib/admin/media/js/actions.js b/django/contrib/admin/media/js/actions.js index b5e556a04c..a644993cbb 100644 --- a/django/contrib/admin/media/js/actions.js +++ b/django/contrib/admin/media/js/actions.js @@ -1,19 +1,37 @@ var Actions = { init: function() { - selectAll = document.getElementById('action-toggle'); + var selectAll = document.getElementById('action-toggle'); if (selectAll) { selectAll.style.display = 'inline'; addEvent(selectAll, 'click', function() { Actions.checker(selectAll.checked); }); } + var changelistTable = document.getElementsBySelector('#changelist table')[0]; + addEvent(changelistTable, 'click', function(e) { + if (!e) { var e = window.event; } + var target = e.target ? e.target : e.srcElement; + if (target.nodeType == 3) { target = target.parentNode; } + if (target.className == 'action-select') { + var tr = target.parentNode.parentNode; + Actions.toggleRow(tr, target.checked); + } + }); + }, + toggleRow: function(tr, checked) { + if (checked) { + tr.className += ' selected'; + } else { + tr.className = tr.className.replace(' selected', ''); + } }, checker: function(checked) { - actionCheckboxes = document.getElementsBySelector('tr input.action-select'); + var actionCheckboxes = document.getElementsBySelector('tr input.action-select'); for(var i = 0; i < actionCheckboxes.length; i++) { actionCheckboxes[i].checked = checked; + Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, checked); } } -} +}; addEvent(window, 'load', Actions.init);