Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let catalog = [];
- let catalogTitle = [];
- if (JSON.parse(localStorage.getItem('requested-catalog-id')) != null) {
- catalog = JSON.parse(localStorage.getItem('requested-catalog-id'));
- catalogTitle = JSON.parse(localStorage.getItem('requested-catalog-title'));
- }
- $('.catalog .box-item .box-heading input[type=checkbox]').on('change', function () {
- let $parent = $(this).parent();
- let $box = $parent.closest('.box-heading');
- let id = $box.attr('data-catalog-id');
- let title = $box.attr('data-catalog-title');
- let showBigCheckBox = $(".catalog .box-heading span#" + id);
- let $check = $(this);
- // let checked = !!$check.val();
- let valueChecked = $check.val();
- let checked = valueChecked === $check.val();
- if (checked) {
- if (catalog.length >= 3) {
- $('#staticBackdrop').modal({
- keyboard: false,
- static: true,
- focus: true,
- show: true,
- });
- checked.checked = false;
- return false;
- } else {
- catalog.push(id);
- catalogTitle.push(title);
- localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
- localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
- showBigCheckBox.addClass('selected');
- }
- } else {
- catalog.splice($.inArray(id, catalog), 1);
- catalogTitle.splice($.inArray(title, catalogTitle), 1);
- localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
- localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
- showBigCheckBox.removeClass('selected');
- }
- if ($("#requestedCatalog").length) {
- fetchRequestedCatalog();
- goToCatalogueForm(catalogTitle);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement