Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             let catalog = [];
  2.             let catalogTitle = [];
  3.             if (JSON.parse(localStorage.getItem('requested-catalog-id')) != null) {
  4.                 catalog = JSON.parse(localStorage.getItem('requested-catalog-id'));
  5.                 catalogTitle = JSON.parse(localStorage.getItem('requested-catalog-title'));
  6.             }
  7.             $('.catalog .box-item .box-heading input[type=checkbox]').on('change', function () {
  8.                 let $parent = $(this).parent();
  9.                 let $box = $parent.closest('.box-heading');
  10.                 let id = $box.attr('data-catalog-id');
  11.                 let title = $box.attr('data-catalog-title');
  12.                 let showBigCheckBox = $(".catalog .box-heading span#" + id);
  13.                 let $check = $(this);
  14.                 // let checked = !!$check.val();
  15.                
  16.                 let valueChecked = $check.val();
  17.                 let checked = valueChecked === $check.val();
  18.  
  19.                 if (checked) {
  20.                     if (catalog.length >= 3) {
  21.                         $('#staticBackdrop').modal({
  22.                             keyboard: false,
  23.                             static: true,
  24.                             focus: true,
  25.                             show: true,
  26.                         });
  27.                         checked.checked = false;
  28.                         return false;
  29.                     } else {
  30.                         catalog.push(id);
  31.                         catalogTitle.push(title);
  32.                         localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
  33.                         localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
  34.                         showBigCheckBox.addClass('selected');
  35.                     }
  36.                 } else {
  37.                     catalog.splice($.inArray(id, catalog), 1);
  38.                     catalogTitle.splice($.inArray(title, catalogTitle), 1);
  39.                     localStorage.setItem('requested-catalog-id', JSON.stringify(catalog));
  40.                     localStorage.setItem('requested-catalog-title', JSON.stringify(catalogTitle));
  41.                     showBigCheckBox.removeClass('selected');
  42.                 }
  43.                 if ($("#requestedCatalog").length) {
  44.                     fetchRequestedCatalog();
  45.                     goToCatalogueForm(catalogTitle);
  46.                 }
  47.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement