<commit_before>import {Component, NgIf, NgClass, ElementRef, EventEmitter, Host} from 'angular2/angular2'

import {Content} from '../content/content';
import * as util from 'ionic/util';
import {raf, ready, CSS} from 'ionic/util/dom';


/**
 * Allows you to add pull-to-refresh to an Content component.
 *
 * Place it as the first child of your Content or Scroll element.
 *
 * When refreshing is complete, call `refresher.complete()` from your controller.
 *
 *  @usage
 *  ```ts
 *  <ion-refresher (starting)="doStarting()" (refresh)="doRefresh($event, refresher)" (pulling)="doPulling($event, amt)">
 *
 *
 *  doRefresh(refresher) {
 *    console.log('Refreshing!', refresher);
 *
 *    setTimeout(() => {
 *      console.log('Pull to refresh complete!', refresher);
 *      refresher.complete();
 *    })
 *  }
 *
 *  doStarting() {
 *    console.log('Pull started!');
 *  }
 *
 *  doPulling(amt) {
 *    console.log('You have pulled', amt);
 *  }
 *  ```
 */
@Component({
  selector: 'ion-refresher',
  inputs: [
    'pullingIcon',
    'pullingText',
    'refreshingIcon',
    'refreshingText',
    'spinner',
    'disablePullingRotation'
  ],
  outputs: ['refresh', 'starting', 'pulling'],
  host: {
    '[class.active]': 'isActive',
    '[class.refreshing]': 'isRefreshing',
    '[class.refreshingTail]': 'isRefreshingTail'
  },
  template:
    '<div class="refresher-content" [class.refresher-with-text]="pullingText || refreshingText">' +
      '<div class="icon-pulling">' +
        '<i class="icon" [ng-class]="pullingIcon"></i>' +
      '</div>' +
      '<div class="text-pulling" [inner-html]="pullingText" *ng-if="pullingText"></div>' +
      '<div class="icon-refreshing">' +
        '<i class="icon" [ng-class]="refreshingIcon"></i>' +
      '</div>' +
      '<div class="text-refreshing" [inner-html]="refreshingText" *ng-if="refreshingText"></div>' +
    '</div>',
  directives: [NgIf, NgClass]
})
export class Refresher {
  /**
   * TODO
   * @param {Content} content  TODO
   * @param {ElementRef} elementRef  TODO
   */
  constructor(
    @Host() content: Content,
    element: ElementRef
  ) {
    this.ele = element.nativeElement;
    this.ele.classList.add('content');

    this.content = content;

    this.refresh = new EventEmitter('refresh');
    this.starting = new EventEmitter('starting');
    this.pulling = new EventEmitter('pulling');
  }

  onInit() {
    this.initEvents();
  }

  /**
   * Initialize touch and scroll event listeners.
   */
  initEvents() {

    let sp = this.content.getNativeElement();
    let sc = this.content.scrollElement;

    this.isDragging = false;
    this.isOverscrolling = false;
    this.dragOffset = 0;
    this.lastOverscroll = 0;
    this.ptrThreshold = 60;
    this.activated = false;
    this.scrollTime = 500;
    this.startY = null;
    this.deltaY = null;
    this.canOverscroll = true;
    this.scrollHost = sp;
    this.scrollChild = sc;

    util.defaults(this, {
      pullingIcon: 'ion-android-arrow-down',
      refreshingIcon: 'ion-ionic'
      //refreshingText: 'Updating'
    })

    this.showSpinner = !util.isDefined(this.refreshingIcon) && this.spinner != 'none';

    this.showIcon = util.isDefined(this.refreshingIcon);

    this._touchMoveListener = this._handleTouchMov.bind(this);
    this._touchEndListener = this._handleTouchEnd.bind(this);
    this._handleScrollListener = this._handleScroll.bind(this);
    sc.addEventListener('touchmove', this._touchMoveListener);
    sc.addEventListener('touchend', this._touchEndListener);
    sc.addEventListener('scroll', this._handleScrollListener);<commit_msg>Fixing a small typo in pull-to-refresh.ts<commit_after>import {Component, NgIf, NgClass, ElementRef, EventEmitter, Host} from 'angular2/angular2'

import {Content} from '../content/content';
import * as util from 'ionic/util';
import {raf, ready, CSS} from 'ionic/util/dom';


/**
 * Allows you to add pull-to-refresh to an Content component.
 *
 * Place it as the first child of your Content or Scroll element.
 *
 * When refreshing is complete, call `refresher.complete()` from your controller.
 *
 *  @usage
 *  ```ts
 *  <ion-refresher (starting)="doStarting()" (refresh)="doRefresh($event, refresher)" (pulling)="doPulling($event, amt)">
 *
 *
 *  doRefresh(refresher) {
 *    console.log('Refreshing!', refresher);
 *
 *    setTimeout(() => {
 *      console.log('Pull to refresh complete!', refresher);
 *      refresher.complete();
 *    })
 *  }
 *
 *  doStarting() {
 *    console.log('Pull started!');
 *  }
 *
 *  doPulling(amt) {
 *    console.log('You have pulled', amt);
 *  }
 *  ```
 */
@Component({
  selector: 'ion-refresher',
  inputs: [
    'pullingIcon',
    'pullingText',
    'refreshingIcon',
    'refreshingText',
    'spinner',
    'disablePullingRotation'
  ],
  outputs: ['refresh', 'starting', 'pulling'],
  host: {
    '[class.active]': 'isActive',
    '[class.refreshing]': 'isRefreshing',
    '[class.refreshingTail]': 'isRefreshingTail'
  },
  template:
    '<div class="refresher-content" [class.refresher-with-text]="pullingText || refreshingText">' +
      '<div class="icon-pulling">' +
        '<i class="icon" [ng-class]="pullingIcon"></i>' +
      '</div>' +
      '<div class="text-pulling" [inner-html]="pullingText" *ng-if="pullingText"></div>' +
      '<div class="icon-refreshing">' +
        '<i class="icon" [ng-class]="refreshingIcon"></i>' +
      '</div>' +
      '<div class="text-refreshing" [inner-html]="refreshingText" *ng-if="refreshingText"></div>' +
    '</div>',
  directives: [NgIf, NgClass]
})
export class Refresher {
  /**
   * TODO
   * @param {Content} content  TODO
   * @param {ElementRef} elementRef  TODO
   */
  constructor(
    @Host() content: Content,
    element: ElementRef
  ) {
    this.ele = element.nativeElement;
    this.ele.classList.add('content');

    this.content = content;

    this.refresh = new EventEmitter('refresh');
    this.starting = new EventEmitter('starting');
    this.pulling = new EventEmitter('pulling');
  }

  onInit() {
    this.initEvents();
  }

  /**
   * Initialize touch and scroll event listeners.
   */
  initEvents() {

    let sp = this.content.getNativeElement();
    let sc = this.content.scrollElement;

    this.isDragging = false;
    this.isOverscrolling = false;
    this.dragOffset = 0;
    this.lastOverscroll = 0;
    this.ptrThreshold = 60;
    this.activated = false;
    this.scrollTime = 500;
    this.startY = null;
    this.deltaY = null;
    this.canOverscroll = true;
    this.scrollHost = sp;
    this.scrollChild = sc;

    util.defaults(this, {
      pullingIcon: 'ion-android-arrow-down',
      refreshingIcon: 'ion-ionic'
      //refreshingText: 'Updating'
    })

    this.showSpinner = !util.isDefined(this.refreshingIcon) && this.spinner != 'none';

    this.showIcon = util.isDefined(this.refreshingIcon);

    this._touchMoveListener = this._handleTouchMove.bind(this);
    this._touchEndListener = this._handleTouchEnd.bind(this);
    this._handleScrollListener = this._handleScroll.bind(this);
    sc.addEventListener('touchmove', this._touchMoveListener);
    sc.addEventListener('touchend', this._touchEndListener);
    sc.addEventListener('scroll', this._handleScrollListener);
{'fraction_non_alphanumeric': 0.1654437214453828, 'fraction_numerical': 0.002492039318842586, 'mean_word_length': 3.456508328192474, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, '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': '1678719', 'n_tokens_mistral': 2447, 'n_tokens_neox': 2421, 'n_words': 456}