2009-03-24 04:22:56 +08:00
|
|
|
var Actions = {
|
|
|
|
init: function() {
|
2009-04-01 00:24:12 +08:00
|
|
|
var selectAll = document.getElementById('action-toggle');
|
2009-03-24 04:22:56 +08:00
|
|
|
if (selectAll) {
|
|
|
|
selectAll.style.display = 'inline';
|
2009-03-24 11:11:38 +08:00
|
|
|
addEvent(selectAll, 'click', function() {
|
|
|
|
Actions.checker(selectAll.checked);
|
2009-03-24 04:22:56 +08:00
|
|
|
});
|
|
|
|
}
|
2009-04-01 00:24:12 +08:00
|
|
|
var changelistTable = document.getElementsBySelector('#changelist table')[0];
|
2009-04-11 19:32:50 +08:00
|
|
|
if (changelistTable) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2009-04-01 00:24:12 +08:00
|
|
|
},
|
|
|
|
toggleRow: function(tr, checked) {
|
2009-04-01 01:10:23 +08:00
|
|
|
if (checked && tr.className.indexOf('selected') == -1) {
|
2009-04-01 00:24:12 +08:00
|
|
|
tr.className += ' selected';
|
2009-04-01 01:10:23 +08:00
|
|
|
} else if (!checked) {
|
2009-04-01 00:24:12 +08:00
|
|
|
tr.className = tr.className.replace(' selected', '');
|
|
|
|
}
|
2009-03-24 04:22:56 +08:00
|
|
|
},
|
|
|
|
checker: function(checked) {
|
2009-04-01 00:24:12 +08:00
|
|
|
var actionCheckboxes = document.getElementsBySelector('tr input.action-select');
|
2009-03-24 04:22:56 +08:00
|
|
|
for(var i = 0; i < actionCheckboxes.length; i++) {
|
|
|
|
actionCheckboxes[i].checked = checked;
|
2009-04-01 00:24:12 +08:00
|
|
|
Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, checked);
|
2009-03-24 04:22:56 +08:00
|
|
|
}
|
|
|
|
}
|
2009-04-01 00:24:12 +08:00
|
|
|
};
|
2009-03-24 04:22:56 +08:00
|
|
|
|
|
|
|
addEvent(window, 'load', Actions.init);
|