<commit_before>/* Filter New */
$(document).on('click', '.button-sub-navigation', function() {

  var filter = $(this).data('filter');
  $('#sub-navigation ul.left li').removeClass('navigation-on');

  if (filter == 'in_new') {

    $('#display-new').addClass('navigation-on');
    $('tr').hide('fast', function() {
      $('tr.in_new').show('fast');
    });
  }
  else if (filter == 'in_later') {

    $('#display-later').addClass('navigation-on');
    $('tr').hide('fast', function() {
      $('tr.in_later').show('fast');
    });
  }
  else {

    $('#display-all').addClass('navigation-on');
    $('tr.result').show('fast');
  }

  return false;
});



/* Tag Add Ajax */
var pileAjaxTag = function(tag_add) {

  $.ajax({
	  url			 : mailpile.api.tag,
	  type		 : 'POST',
	  data     : {
      add: tag_add,
      mid: mailpile.bulk_cache
    },
	  dataType : 'json',
    success  : function(response) {

      if (response.status == 'success') {

        // Update Pile View
        $.each(mailpile.bulk_cache, function(key, mid) {
          $('#pile-message-' + mid).fadeOut('fast');
        });

        // Empty Bulk Cache
        mailpile.bulk_cache = [];

      } else {
        mailpile.notification(response.status, response.message);
      }
    }
  });
}


/* Bulk Action Link */
$(document).on('click', '.bulk-action', function(e) {

	e.preventDefault();
	var action = $(this).data('action');

	alert(mailpile.bulk_cache.length + ' items to ' + action);

  if (action == 'later' || action == 'archive' || action == 'trash') {
    pileAjaxTag(action);
  }
  else if (action == 'add-to-group') {
    
  }
  else if (action == 'assign-tags') {
    
  }
});


/* Result Actions */
var pileActionSelect = function(item) {

  // Add To Data Model
  mailpile.bulk_cache_add(item.data('mid'));

	// Increment Selected
	$('#bulk-actions-selected-count').html(mailpile.bulk_cache.length);

	// Style & Select Checkbox
	item.removeClass('result').addClass('result-on')
	.data('state', 'selected')
	.find('td.checkbox input[type=checkbox]')
	.val('selected')
	.prop('checked', true);
}

var pileActionUnselect = function(item) {

  // Remove From Data Model
  mailpile.bulk_cache_remove(item.data('mid'));

	// Decrement Selected
	$('#bulk-actions-selected-count').html(mailpile.bulk_cache.length);

	// Hide Actions
	if (mailpile.bulk_cache.length < 1) {

	}

	// Style & Unselect Checkbox
	item.removeClass('result-on').addClass('result')
	.data('state', 'normal')
	.find('td.checkbox input[type=checkbox]')
	.val('normal')
	.prop('checked', false);
}



/* Select & Unselect Pile Items */
$(document).on('click', '#pile-results tr.result', function(e) {
	if (e.target.href === undefined && $(this).data('state') !== 'selected') {
		pileActionSelect($(this));
	}
});

$(document).on('click', '#pile-results tr.result-on', function(e) {
	if (e.target.href === undefined && $(this).data('state') === 'selected') {
		pileActionUnselect($(this));
	}
});



/* Dragging & Dropping From Pile */
$('td.draggable').draggable({
  containment: "#container",
  scroll: false,<commit_msg>Make dragging of messages look right.<commit_after>/* Filter New */
$(document).on('click', '.button-sub-navigation', function() {

  var filter = $(this).data('filter');
  $('#sub-navigation ul.left li').removeClass('navigation-on');

  if (filter == 'in_new') {

    $('#display-new').addClass('navigation-on');
    $('tr').hide('fast', function() {
      $('tr.in_new').show('fast');
    });
  }
  else if (filter == 'in_later') {

    $('#display-later').addClass('navigation-on');
    $('tr').hide('fast', function() {
      $('tr.in_later').show('fast');
    });
  }
  else {

    $('#display-all').addClass('navigation-on');
    $('tr.result').show('fast');
  }

  return false;
});



/* Tag Add Ajax */
var pileAjaxTag = function(tag_add) {

  $.ajax({
	  url			 : mailpile.api.tag,
	  type		 : 'POST',
	  data     : {
      add: tag_add,
      mid: mailpile.bulk_cache
    },
	  dataType : 'json',
    success  : function(response) {

      if (response.status == 'success') {

        // Update Pile View
        $.each(mailpile.bulk_cache, function(key, mid) {
          $('#pile-message-' + mid).fadeOut('fast');
        });

        // Empty Bulk Cache
        mailpile.bulk_cache = [];

      } else {
        mailpile.notification(response.status, response.message);
      }
    }
  });
}


/* Bulk Action Link */
$(document).on('click', '.bulk-action', function(e) {

	e.preventDefault();
	var action = $(this).data('action');

	alert(mailpile.bulk_cache.length + ' items to ' + action);

  if (action == 'later' || action == 'archive' || action == 'trash') {
    pileAjaxTag(action);
  }
  else if (action == 'add-to-group') {
    
  }
  else if (action == 'assign-tags') {
    
  }
});


/* Result Actions */
var pileActionSelect = function(item) {

  // Add To Data Model
  mailpile.bulk_cache_add(item.data('mid'));

	// Increment Selected
	$('#bulk-actions-selected-count').html(mailpile.bulk_cache.length);

	// Style & Select Checkbox
	item.removeClass('result').addClass('result-on')
	.data('state', 'selected')
	.find('td.checkbox input[type=checkbox]')
	.val('selected')
	.prop('checked', true);
}

var pileActionUnselect = function(item) {

  // Remove From Data Model
  mailpile.bulk_cache_remove(item.data('mid'));

	// Decrement Selected
	$('#bulk-actions-selected-count').html(mailpile.bulk_cache.length);

	// Hide Actions
	if (mailpile.bulk_cache.length < 1) {

	}

	// Style & Unselect Checkbox
	item.removeClass('result-on').addClass('result')
	.data('state', 'normal')
	.find('td.checkbox input[type=checkbox]')
	.val('normal')
	.prop('checked', false);
}



/* Select & Unselect Pile Items */
$(document).on('click', '#pile-results tr.result', function(e) {
	if (e.target.href === undefined && $(this).data('state') !== 'selected') {
		pileActionSelect($(this));
	}
});

$(document).on('click', '#pile-results tr.result-on', function(e) {
	if (e.target.href === undefined && $(this).data('state') === 'selected') {
		pileActionUnselect($(this));
	}
});



/* Dragging & Dropping From Pile */
$('td.draggable').draggable({
  containment: "#container",
  appendTo: 'body',
  scroll: false,
{'fraction_non_alphanumeric': 0.21221398646471157, 'fraction_numerical': 0.0003222687721559781, 'mean_word_length': 3.3375262054507338, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2987898', 'n_tokens_mistral': 2203, 'n_tokens_neox': 2081, 'n_words': 374}