<commit_before>function initTourModal() {
  $('#first-tour-modal').modal({backdrop: true});
  $('#first-tour-modal').modal('show');

  $('.hide-modal').live('click', function() {
    $('#first-tour-modal').modal('hide');
  });

  $('.bookmarklet').twipsy({placement:"below", offset:5});
}

function sliderSize() {
  return $("#slider > div").length - 1;
}

function setButtonsForSlide(idx) {  
  if (idx === 0) {
    // First page
    $("#next").show();
    $("#previous, #close").hide();
  } else if (idx === sliderSize()) {
    // Last page
    $("#next").hide();
    $("#previous, #close").show();    
  } else {
    // Middle page
    $("#previous, #next").show();
    $("#close").hide();
  }
}

$('#slider').cycle({
  activePagerClass: "current",
	fx:       "scrollHorz",
	timeout:  0, 
	speed:    1000,
	next: 	  "#next",
	prev:     "#previous", 
	easing:   "easeOutSine",
	nowrap: 1,
	pause: 1,
	pager:  "#pagerNav",
	before: function(current_slide) {
	},
	
  // callback fn that creates a thumbnail to use as pager anchor 
  pagerAnchorBuilder: function(idx, slide) {
    var title = $(slide).data('title');
    return '<li><a href="#">' + title + '</a></li>'; 
  },
  
  onPagerEvent: function(zeroBasedSlideIndex) {
    setButtonsForSlide(zeroBasedSlideIndex);
  },
  onPrevNextEvent: function(isNext, zeroBasedSlideIndex, slideElement) {
    setButtonsForSlide(zeroBasedSlideIndex);
  }
});<commit_msg>Fixed the double click bug in the tour<commit_after>(function(){
  var modal = $('#first-tour-modal').modal({backdrop: true});
  var hidden = true;

  modal.bind('hide', function() {
    hidden = true;
  }).bind('show', function() {
    hidden = false;
  });

  $('.take-the-tour').live('click', function() {
    modal.modal('show');

    // Load the tour
    $.ajax({
      url: "/tour",
      dataType: "html",
      success: function(data) {
        if ( !hidden ) {
          initTourModal(data);
        }
      }
    });
  });

  $('.hide-modal').live('click', function() {
    modal.modal('hide');
  });

  function initTourModal(data) {
    modal.html(data);

    $('.bookmarklet').twipsy({placement:"below", offset:5});
  }

  function sliderSize() {
    return $("#slider > div").length - 1;
  }

  function setButtonsForSlide(idx) {
    if (idx === 0) {
      // First page
      $("#next").show();
      $("#previous, #close").hide();
    } else if (idx === sliderSize()) {
      // Last page
      $("#next").hide();
      $("#previous, #close").show();
    } else {
      // Middle page
      $("#previous, #next").show();
      $("#close").hide();
    }
  }

  $('#slider').cycle({
    activePagerClass: "current",
  	fx:       "scrollHorz",
  	timeout:  0,
  	speed:    1000,
  	next: 	  "#next",
  	prev:     "#previous",
  	easing:   "easeOutSine",
  	nowrap: 1,
  	pause: 1,
  	pager:  "#pagerNav",

    // callback fn that creates a thumbnail to use as pager anchor
    pagerAnchorBuilder: function(idx, slide) {
      var title = $(slide).data('title');
      return '<li><a>' + title + '</a></li>';
    },

    onPagerEvent: function(zeroBasedSlideIndex) {
      setButtonsForSlide(zeroBasedSlideIndex);
    },
    onPrevNextEvent: function(isNext, zeroBasedSlideIndex, slideElement) {
      setButtonsForSlide(zeroBasedSlideIndex);
    }
  });
})();
{'fraction_non_alphanumeric': 0.2054794520547945, 'fraction_numerical': 0.0060882800608828, 'mean_word_length': 2.954271961492178, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4660962', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1114, 'n_words': 222}