Sha256: d1287208685d07a45eca217c1516b8f84ad05bca33cb7ed13bd69f76a9c7b8c5

Contents?: true

Size: 1.5 KB

Versions: 28

Compression:

Stored size: 1.5 KB

Contents

var Actions = {
    init: function() {
        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];
        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);
                }
            });
        }
    },
    toggleRow: function(tr, checked) {
        if (checked && tr.className.indexOf('selected') == -1) {
            tr.className += ' selected';
        } else if (!checked) {
            tr.className = tr.className.replace(' selected', '');
        }
    },
    checker: function(checked) {
        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);

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
merb-admin-0.8.8 public/javascripts/actions.js
merb-admin-0.8.7 public/javascripts/actions.js
merb-admin-0.8.6 public/javascripts/actions.js
merb-admin-0.8.1 public/javascripts/actions.js
merb-admin-0.8.0 public/javascripts/actions.js
merb-admin-0.7.6 public/javascripts/actions.js
merb-admin-0.7.5 public/javascripts/actions.js
merb-admin-0.7.4 public/javascripts/actions.js
merb-admin-0.7.3 public/javascripts/actions.js
merb-admin-0.7.2 public/javascripts/actions.js
merb-admin-0.7.1 public/javascripts/actions.js
merb-admin-0.7.0 public/javascripts/actions.js
merb-admin-0.6.9 public/javascripts/actions.js
merb-admin-0.6.8 public/javascripts/actions.js
merb-admin-0.6.7 public/javascripts/actions.js
merb-admin-0.6.6 public/javascripts/actions.js
merb-admin-0.6.5 public/javascripts/actions.js
merb-admin-0.6.4 public/javascripts/actions.js
merb-admin-0.6.3 public/javascripts/actions.js
merb-admin-0.6.2 public/javascripts/actions.js