MCPcopy
hub / github.com/TargetProcess/tauCharts / createCheckGroup

Function createCheckGroup

examples/index.js:389–418  ·  view source on GitHub ↗
(container, items, checkedItems)

Source from the content-addressed store, hash-verified

387 };
388
389 var createCheckGroup = function (container, items, checkedItems) {
390 var all = createCheckbox('all');
391 if (items.every(function (t) {
392 return checkedItems.indexOf(t) >= 0;
393 })) {
394 all.input.checked = true;
395 }
396 container.appendChild(all.node);
397 var checkboxes = items.map(function (t) {
398 var c = createCheckbox(t);
399 if (checkedItems.indexOf(t) >= 0) {
400 c.input.checked = true;
401 }
402 container.appendChild(c.node);
403 return c;
404 });
405 container.addEventListener('change', function (e) {
406 if (e.target === all.input) {
407 // Check/uncheck all checkboxes
408 checkboxes.forEach(function (c) {
409 c.input.checked = all.input.checked;
410 });
411 } else {
412 // Check/uncheck "all" checkbox
413 all.input.checked = checkboxes.every(function (c) {
414 return c.input.checked;
415 });
416 }
417 });
418 };
419
420 var typesContainer = document.getElementById('typesContainer');
421 createCheckGroup(typesContainer, TYPES, settings.types);

Callers 1

index.jsFile · 0.85

Calls 1

createCheckboxFunction · 0.85

Tested by

no test coverage detected