{"size": 1768, "ext": "js", "max_stars_repo_path": "source/js/production/modules/listRowToggle.js", "max_stars_repo_name": "lorang92/DesignSystem", "max_stars_repo_stars_event_min_datetime": "2016-09-22T07:36:30.000Z", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:05:34.000Z", "max_issues_repo_path": "source/js/production/modules/listRowToggle.js", "max_issues_repo_name": "lorang92/DesignSystem", "max_issues_repo_issues_event_min_datetime": "2017-06-07T09:13:16.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-08T23:38:55.000Z", "max_forks_repo_path": "source/js/production/modules/listRowToggle.js", "max_forks_repo_name": "lorang92/DesignSystem", "max_forks_repo_forks_event_min_datetime": "2016-09-12T07:46:39.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-18T09:15:58.000Z"}
{"max_stars_count": 38, "max_issues_count": 60, "max_forks_count": 17, "avg_line_length": 29.9661016949, "max_line_length": 113, "alphanum_fraction": 0.5944570136}
/* globals goBack */
var onConfirmDeletionClick = function() {
  var $list = $('ul[data-list-selectable="true"]');
  var $segmentDone = $('.segment-done');
  var goToReceipt = false;

  if ($list.find('li.a-selected:not(.a-list-header)').length === $list.find('li:not(.a-list-header)').length) {
    goToReceipt = true;
  } else {
    $list.find('li.a-selected')
      .addClass('a-deleted')
      .addClass('a-disabled')
      .removeClass('a-selected')
      .removeAttr('tabindex');
    $segmentDone.hide();
  }

  return goToReceipt;
};

var handleModalClose = function(src, targetUrl) {
  var hasSelectedRows = $('ul[data-list-selectable="true"] li.a-selected:not(.a-list-header)').length > 0;
  if (!hasSelectedRows) {
    $(src).popover('disable');
    location.href = targetUrl;
  }
};

var setupListRowSelect = function() {
  var $list = $('ul[data-list-selectable="true"]');
  var $segmentDone = $('.segment-done');

  $list.on('click', 'li.a-selectable:not(.a-list-header)', function() {
    if (!$(this).hasClass('a-deleted')) {
      $(this).toggleClass('a-selected');
      if ($list.find('li.a-selected').length > 0) {
        $segmentDone.show();
      } else {
        $segmentDone.hide();
      }
    }
  });

  $('.a-js-add-remove-all').on('click', function() {
    if ($list.find('li.a-selected:not(.a-list-header)').length === $list.find('li:not(.a-list-header)').length) {
      $list.find('li:not(.a-list-header)').removeClass('a-selected');
      $segmentDone.hide();
    } else {
      $list.find('li:not(.a-list-header)').addClass('a-selected');
      $segmentDone.show();
    }
  });

  $('.a-js-cancel-deletion').on('click', function() {
    $list.find('li:not(.a-list-header)').removeClass('a-selected');
    $segmentDone.hide();
  });
};
