<commit_before>import Ember from 'ember';

var getProperties = Ember.getProperties;
var bind = Ember.run.bind;
var on = Ember.on;

export default Ember.Component.extend({
  contextElement: null,
  offset: null,
  triggerOnce: null,
  continuous: null,
  horizontal: null,

  waypoint: function() {
    var element = this.$();

    if (!element.waypoint) { return; }

    element.waypoint.apply(element, arguments);
  },

  setupWaypoint: on('didInsertElement', function() {
    this.waypoint(this.buildOptions());
  }),

  teardownWaypoint: on('willDestroyElement', function() {
    this.waypoint('destroy');
  }),

  buildOptions: function() {
    var options = getProperties(this, [ 'contextElement', 'offset', 'triggerOnce', 'continuous', 'horizontal']);
    options.handler = bind(this, this.waypointTriggered);

    for (var option in options) {
      if (options[option] === null) {
        delete options[option];
      }
    }

    if (options.contextElement) {
      options.context = options.contextElement;
      delete options.contextElement;
    }

    return options;
  },

  waypointTriggered: function(direction) {
    this.sendAction('on-' + direction, this);
    this.sendAction('action', direction, this);
  }
});
<commit_msg>added contextElementId to the options as a simpler means of passing the context to way points<commit_after>import Ember from 'ember';

var getProperties = Ember.getProperties;
var bind = Ember.run.bind;
var on = Ember.on;

export default Ember.Component.extend({
  contextElement: null,
  offset: null,
  triggerOnce: null,
  continuous: null,
  horizontal: null,

  waypoint: function() {
    var element = this.$();

    if (!element.waypoint) { return; }

    element.waypoint.apply(element, arguments);
  },

  setupWaypoint: on('didInsertElement', function() {
    this.waypoint(this.buildOptions());
  }),

  teardownWaypoint: on('willDestroyElement', function() {
    this.waypoint('destroy');
  }),

  buildOptions: function() {
    var options = getProperties(this, [ 'contextElementId', 'contextElement', 'offset', 'triggerOnce', 'continuous', 'horizontal']);
    options.handler = bind(this, this.waypointTriggered);

    for (var option in options) {
      if (options[option] === null) {
        delete options[option];
      }
    }

    if (options.contextElement) {
      options.context = options.contextElement;
      delete options.contextElement;
    } else if (options.contextElementId) {
      options.context = document.getElementById(options.contextElementId);
      delete options.contextElementId;
    }

    return options;
  },

  waypointTriggered: function(direction) {
    this.sendAction('on-' + direction, this);
    this.sendAction('action', direction, this);
  }
});

{'fraction_non_alphanumeric': 0.13505642519111757, 'fraction_numerical': 0.0, 'mean_word_length': 3.7708333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2333305', 'n_tokens_mistral': 823, 'n_tokens_neox': 798, 'n_words': 189}