<commit_before>/* jshint browser: true, devel: true, indent: 2, curly: true, eqeqeq: true, futurehostile: true, latedef: true, undef: true, unused: true */
/* global $, jQuery, document, Modernizr, Ajaxy */

var basicAnimationSpeed = 800;
var fastAnimationSpeed = basicAnimationSpeed / 2;

var Twitter = {
  tweetsWidth: undefined,
  animation: undefined,
  $twitterFeed: $('#twitter-feed'),
  $holder: $('#twitter-marquee-holder'),
  init: function() {
    var _this = this;
    var tweets = $('.twitter-marquee').first();

    // clone tweets to avoid blank space
    tweets.clone().appendTo('#twitter-marquee-holder');

    // set width for animation
    _this.tweetsWidth = tweets.width();

    // setup animation
    _this.startAnimation();

    // bind hovers
    _this.bind();
  },

  bind: function() {
    var _this = this;

    _this.$twitterFeed.on({
      'mouseenter.twitterHover': function() {
        _this.stopAnimation();
      },

      'mouseleave.twitterHover': function() {
        _this.startAnimation();
      },
    });

  },

  unbind: function() {

    this.$twitterFeed.off('.twitterHover');

  },

  startAnimation: function() {
    var _this = this;

    return _this.animation = setInterval(function() {

      var left = parseInt(_this.$holder.css('left'));

      if (left < - _this.tweetsWidth) {
        _this.$holder.css('left', '0px');
      } else {
        _this.$holder.css('left', (left - 1) + 'px');
      }

    }, 25);

  },

  stopAnimation: function() {

    return clearInterval(this.animation);

  },
};

var Menu = {
  init: function() {

    this.bind();

  },

  bind: function() {
    var _this = this;

    return $('.js-nav-trigger').on({
      'click.nav-trigger': function() {
        var target = $(this).data('nav-target');

        _this.click(target);
      },
    });

  },

  unbind: function() {

    return $('.js-nav-trigger').off('click.nav-trigger');

  },

  click: function(target) {

    return $('#drawer-' + target).slideToggle(basicAnimationSpeed);

  },

  closeBelowMenu: function() {
    // for after AJAX loads or clicks?

    return $('#drawer-search, #drawer-follow, #drawer-categorias').slideUp(basicAnimationSpeed);

  },
};

// AJAX
Ajaxy = {
  init: function() {
    var _this = this;

    // This var is checked below. It helps prevent Safari's popstate on load to
    // reload (ajax) the site.
    _this.firstLoad = true;
    
    // Bind links
    _this.bindLinks();

    $(window).bind('popstate', function(event) {
      if( !_this.firstLoad ) {
        _this.load(document.location.origin + document.location.pathname, false);
      }
    });

  },

  bindLinks: function() {
    var _this = this;

    var siteURL = "http://" + top.location.host.toString();

    _this.$ajaxyLinks = $("a[href^='" + siteURL + "'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']");
    //_this.$elementsToHide = $('.nav, #main-container, #three-scene');

    // Find all ajaxy links and bind ajax event
    _this.$ajaxyLinks.click(function(event) {
      event.preventDefault();

      var url = event.currentTarget.href;

      _this.load(url);

    });
  },

  reset: function() {
    var _this = this;

    // Unbind click from all ajax links
    _this.$ajaxyLinks.unbind('click');

    // Re initiate
    _this.bindLinks();
  },

  /* 
   * Load a new URL thru ajax
   * @url {String}: URL to load
   * @pushState {Bool}: Make false if a new state doens't need to be pushed (Default: true). Ex, going back
   */
  load: function(url, pushState) {
    var _this = this;

    _this.firstLoad = false;

    // Default pushState to true
    pushState = typeof pushState !== 'undefined' ? pushState : true;
<commit_msg>fix #56 - expected behavior on cmd+click / ctrl+click on ajaxified links<commit_after>/* jshint browser: true, devel: true, indent: 2, curly: true, eqeqeq: true, futurehostile: true, latedef: true, undef: true, unused: true */
/* global $, jQuery, document, Modernizr, Ajaxy */

var basicAnimationSpeed = 800;
var fastAnimationSpeed = basicAnimationSpeed / 2;

var Twitter = {
  tweetsWidth: undefined,
  animation: undefined,
  $twitterFeed: $('#twitter-feed'),
  $holder: $('#twitter-marquee-holder'),
  init: function() {
    var _this = this;
    var tweets = $('.twitter-marquee').first();

    // clone tweets to avoid blank space
    tweets.clone().appendTo('#twitter-marquee-holder');

    // set width for animation
    _this.tweetsWidth = tweets.width();

    // setup animation
    _this.startAnimation();

    // bind hovers
    _this.bind();
  },

  bind: function() {
    var _this = this;

    _this.$twitterFeed.on({
      'mouseenter.twitterHover': function() {
        _this.stopAnimation();
      },

      'mouseleave.twitterHover': function() {
        _this.startAnimation();
      },
    });

  },

  unbind: function() {

    this.$twitterFeed.off('.twitterHover');

  },

  startAnimation: function() {
    var _this = this;

    return _this.animation = setInterval(function() {

      var left = parseInt(_this.$holder.css('left'));

      if (left < - _this.tweetsWidth) {
        _this.$holder.css('left', '0px');
      } else {
        _this.$holder.css('left', (left - 1) + 'px');
      }

    }, 25);

  },

  stopAnimation: function() {

    return clearInterval(this.animation);

  },
};

var Menu = {
  init: function() {

    this.bind();

  },

  bind: function() {
    var _this = this;

    return $('.js-nav-trigger').on({
      'click.nav-trigger': function() {
        var target = $(this).data('nav-target');

        _this.click(target);
      },
    });

  },

  unbind: function() {

    return $('.js-nav-trigger').off('click.nav-trigger');

  },

  click: function(target) {

    return $('#drawer-' + target).slideToggle(basicAnimationSpeed);

  },

  closeBelowMenu: function() {
    // for after AJAX loads or clicks?

    return $('#drawer-search, #drawer-follow, #drawer-categorias').slideUp(basicAnimationSpeed);

  },
};

// AJAX
Ajaxy = {
  init: function() {
    var _this = this;

    // This var is checked below. It helps prevent Safari's popstate on load to
    // reload (ajax) the site.
    _this.firstLoad = true;
    
    // Bind links
    _this.bindLinks();

    $(window).bind('popstate', function(event) {
      if( !_this.firstLoad ) {
        _this.load(document.location.origin + document.location.pathname, false);
      }
    });

  },

  bindLinks: function() {
    var _this = this;

    var siteURL = "http://" + top.location.host.toString();

    _this.$ajaxyLinks = $("a[href^='" + siteURL + "'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']");
    //_this.$elementsToHide = $('.nav, #main-container, #three-scene');

    // Find all ajaxy links and bind ajax event
    _this.$ajaxyLinks.click(function(event) {

      // Detect if is cmd+click or ctrl+click or has been defaultPrevented somewhere else
      if ( !event.isDefaultPrevented() && !event.metaKey && !event.ctrlKey ) {
        event.preventDefault();

        var url = event.currentTarget.href;

        _this.load(url);
      }

      return;

    });
  },

  reset: function() {
    var _this = this;

    // Unbind click from all ajax links
    _this.$ajaxyLinks.unbind('click');

    // Re initiate
    _this.bindLinks();
  },

  /* 
   * Load a new URL thru ajax
   * @url {String}: URL to load
   * @pushState {Bool}: Make false if a new state doens't need to be pushed (Default: true). Ex, going back
   */
  load: function(url, pushState) {
    var _this = this;

    _this.firstLoad = false;

    // Default pushState to true
    pushState = typeof pushState !== 'undefined' ? pushState : true;

{'fraction_non_alphanumeric': 0.16579634464751958, 'fraction_numerical': 0.0026109660574412533, 'mean_word_length': 2.6673049305887986, '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': '7001019', 'n_tokens_mistral': 2578, 'n_tokens_neox': 2407, 'n_words': 588}