<commit_before>$(document).ready(function() {

  var datepicker = function(){
    // Displays a date picker when suggetsion field is focused
    $('input[data-role="primary-suggestion"]').datepicker({
      nextText: "▶",
      prevText: "◀",
      dateFormat: 'D, M dd yy',
      constrainInput: false,
    });
  };

  var addRemovalAnimation = function() {
    $('div.primary > div.times > a.remove_fields').click(function(){
      $(this).parents('div.nested-fields').addClass('deleted');
    });
    $('div.secondary a.remove_fields').click(function(){
      $(this).parent('div.nested-fields').addClass('deleted');
    });
  };

  datepicker();
  addRemovalAnimation();

  $.extend($.datepicker,{_checkOffset:function(inst,offset,isFixed){
    var dpHeight = inst.dpDiv.outerHeight();
    var inputHeight = inst.input ? inst.input.outerHeight() : 0;

    offset.top -= dpHeight + inputHeight + 10;
    offset.left -= (window.innerWidth < 430 ? 20 : 0);
    return offset;
  }});

  var forms = $('form[id*=new_event], form[id*="edit_event"]');
  forms.find('div.nested-fields input').removeAttr('maxlength');

  forms.bind('insertion-callback', function(){
    datepicker();
    addRemovalAnimation();

    // Animate new nodes
    var lastNode =  forms.find('div.nested-fields.primary:not(".initial"):last');
    lastNode.addClass('animated');

    $dateTimePickers = forms.find('div.nested-fields input')
    $dateTimePickers.removeAttr('maxlength');
  });

  // Prevent initial primary suggestion fields from animating
  $('div.nested-fields.primary').addClass('initial');

  bind_to_new_time_fields();
  bind_to_changed_primary_fields();

  $('#new_event ol').bind("insertion-callback", function() {
    bind_to_new_time_fields();
    bind_to_changed_primary_fields();
  });

  function bind_to_new_time_fields() {
    $('.nested-fields.primary').bind("insertion-callback", function() {
      var primary_suggestions = $(this).find("[data-role='primary-suggestion']");
      var primary_suggestion_value = primary_suggestions.first().val();
      primary_suggestions.last().val(primary_suggestion_value);
    });
  }

  function bind_to_changed_primary_fields() {
    $("[data-role='primary-suggestion']").change(function() {
      var primary_suggestions = $(this).parents('.nested-fields.primary')
        .first().find("[data-role='primary-suggestion']");
      var primary_suggestion_value = primary_suggestions.first().val();
      primary_suggestions.each(function(index) {
        $(this).val(primary_suggestion_value);
      });
    });
  }

  // Select event URL on click
   $("input#event-url").click(function() {
     $(this).select();
   });

  // Enable dragging in touch devices on tables
  if (Modernizr.touch) {
    $('table.touch-scrollable').addClass("scrollable horizontal")
  }

  // Enable click-to-copy
  var clip = new ZeroClipboard.Client();
  clip.addEventListener( 'mouseDown', function(client) {
    clip.setText( $('input#event-url').val());
    $('input#copy-url').val('URL Copied!');
  });

  clip.addEventListener( 'mouseOver', function(client) {
    $("input#copy-url").tooltip('show');
  });

   clip.addEventListener( 'mouseOut', function(client) {
    $("input#copy-url").tooltip('hide');
  });

  clip.glue( 'copy-url', 'copy-url-container' );

  $(window).resize(function(){
    clip.reposition();
  });

  $('#auto-complete').keyup(function(){
    var inviteButton = $(this).parents("form").find('.add-invitee');
    if($(this).val() != ""){
      inviteButton.show();
    } else {
      inviteButton.hide();
    }
  });<commit_msg>Add conditional to limit zero-clipboard.js gluing to the event/show view.<commit_after>$(document).ready(function() {

  var datepicker = function(){
    // Displays a date picker when suggetsion field is focused
    $('input[data-role="primary-suggestion"]').datepicker({
      nextText: "▶",
      prevText: "◀",
      dateFormat: 'D, M dd yy',
      constrainInput: false,
    });
  };

  var addRemovalAnimation = function() {
    $('div.primary > div.times > a.remove_fields').click(function(){
      $(this).parents('div.nested-fields').addClass('deleted');
    });
    $('div.secondary a.remove_fields').click(function(){
      $(this).parent('div.nested-fields').addClass('deleted');
    });
  };

  datepicker();
  addRemovalAnimation();

  $.extend($.datepicker,{_checkOffset:function(inst,offset,isFixed){
    var dpHeight = inst.dpDiv.outerHeight();
    var inputHeight = inst.input ? inst.input.outerHeight() : 0;

    offset.top -= dpHeight + inputHeight + 10;
    offset.left -= (window.innerWidth < 430 ? 20 : 0);
    return offset;
  }});

  var forms = $('form[id*=new_event], form[id*="edit_event"]');
  forms.find('div.nested-fields input').removeAttr('maxlength');

  forms.bind('insertion-callback', function(){
    datepicker();
    addRemovalAnimation();

    // Animate new nodes
    var lastNode =  forms.find('div.nested-fields.primary:not(".initial"):last');
    lastNode.addClass('animated');

    $dateTimePickers = forms.find('div.nested-fields input')
    $dateTimePickers.removeAttr('maxlength');
  });

  // Prevent initial primary suggestion fields from animating
  $('div.nested-fields.primary').addClass('initial');

  bind_to_new_time_fields();
  bind_to_changed_primary_fields();

  $('#new_event ol').bind("insertion-callback", function() {
    bind_to_new_time_fields();
    bind_to_changed_primary_fields();
  });

  function bind_to_new_time_fields() {
    $('.nested-fields.primary').bind("insertion-callback", function() {
      var primary_suggestions = $(this).find("[data-role='primary-suggestion']");
      var primary_suggestion_value = primary_suggestions.first().val();
      primary_suggestions.last().val(primary_suggestion_value);
    });
  }

  function bind_to_changed_primary_fields() {
    $("[data-role='primary-suggestion']").change(function() {
      var primary_suggestions = $(this).parents('.nested-fields.primary')
        .first().find("[data-role='primary-suggestion']");
      var primary_suggestion_value = primary_suggestions.first().val();
      primary_suggestions.each(function(index) {
        $(this).val(primary_suggestion_value);
      });
    });
  }

  // Select event URL on click
   $("input#event-url").click(function() {
     $(this).select();
   });

  // Enable dragging in touch devices on tables
  if (Modernizr.touch) {
    $('table.touch-scrollable').addClass("scrollable horizontal")
  }

  // Enable click-to-copy
  var clip = new ZeroClipboard.Client();
  clip.addEventListener( 'mouseDown', function(client) {
    clip.setText( $('input#event-url').val());
    $('input#copy-url').val('URL Copied!');
  });

  clip.addEventListener( 'mouseOver', function(client) {
    $("input#copy-url").tooltip('show');
  });

  clip.addEventListener( 'mouseOut', function(client) {
    $("input#copy-url").tooltip('hide');
  });

  if( $("body.events-show").length > 0) {
    clip.glue( 'copy-url', 'copy-url-container' );
  }

  $(window).resize(function(){
    clip.reposition();
  });

  // Display "Invite" button on auto-complete
  $('#auto-complete').keyup(function(){
    var inviteButton = $(this).parents("form").find('.add-invitee');
    if($(this).val() != ""){
      inviteButton.show();
    } else {
      inviteButton.hide();
    }
  });
{'fraction_non_alphanumeric': 0.1860210641499111, 'fraction_numerical': 0.0025988236903296403, 'mean_word_length': 3.917283120376597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '653354', 'n_tokens_mistral': 2345, 'n_tokens_neox': 2244, 'n_words': 353}