Sha256: c85891a6a40573712895f5160c54f358455b6468ffc1e62793db9cda8ca30cdc
Contents?: true
Size: 1.76 KB
Versions: 28
Compression:
Stored size: 1.76 KB
Contents
import $ from 'jquery'; var MekariForm = function MekariForm() { checkAll(); }; var checkAll = function checkAll() { // find all class name checkallbox var $checkallWrapper = $('.checkallbox-wrapper'); $checkallWrapper.each(function () { var $datacheckall = $(this).attr('data-checkall'); var $parentCheckbox = $(this).find(".checkallbox-parent[data-checkall = '" + $datacheckall + "']"); var $arrayListCheckbox = $(this).find("input[type='checkbox'][data-checkall = '" + $datacheckall + "']").not('.checkallbox-parent'); // update check all status (init) updateCheckAll($parentCheckbox, $arrayListCheckbox); // call function for trigered when parent is change activateParentCheckAll($parentCheckbox, $arrayListCheckbox); // call function for trigered when child is change activateChildCheckAll($parentCheckbox, $arrayListCheckbox); }); }; var updateCheckAll = function updateCheckAll($parentCb, $childCb) { var $totalChildCb = $childCb.length; var $totalChildChecked = $childCb.filter(function () { return $(this).is(':checked') === true; }).length; if ($totalChildChecked === $totalChildCb && $totalChildCb > 0) { $parentCb.prop('checked', true); } else { $parentCb.prop('checked', false); } }; var activateParentCheckAll = function activateParentCheckAll($parentCb, $childCb) { $parentCb.change(function () { if ($(this).is(':checked')) { $childCb.prop('checked', true); } else { $childCb.prop('checked', false); } }); }; var activateChildCheckAll = function activateChildCheckAll($parentCb, $childCb) { $childCb.change(function () { updateCheckAll($parentCb, $childCb); }); }; $(document).ready(function () { MekariForm(); }); export default MekariForm; //# sourceMappingURL=mekari-ui-form.js.map
Version data entries
28 entries across 28 versions & 1 rubygems