Sha256: 2dc395278948d42cc9d41e9d98eabaa7d207d837b41c20acd2a1c26dad208845
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
var buttons = document.querySelectorAll("[data-batch-action-option='button']"); var checkboxes = document.querySelectorAll("[data-batch-action-option='checkbox']"); var selectAllCheckboxes = document.querySelector("[data-batch-action-option='select_all']"); if (selectAllCheckboxes) { selectAllCheckboxes.addEventListener('click', function(){ checkboxes.forEach(function(checkbox) { checkbox.checked = selectAllCheckboxes.checked; }); }); buttons.forEach(function(button){ button.addEventListener('click', function(event){ var ids = Array.prototype.filter.call(checkboxes, function(checkbox) { if (checkbox.checked) { return checkbox } }).map(function(checkbox) { return 'batch_action_ids[]=' + checkbox.value }).join('&'); button.href += '?' + ids }); }); checkboxes.forEach(function(checkbox){ checkbox.closest('td').addEventListener('click', function(event){ event.stopImmediatePropagation(); }) checkbox.addEventListener('click', function(event) { event.stopImmediatePropagation(); }) }) }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
administrate_batch_actions-0.2.0 | app/assets/javascripts/administrate_batch_actions/script.js |
administrate_batch_actions-0.1.0 | app/assets/javascripts/administrate_batch_actions/script.js |