<commit_before>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import React, { Component, PropTypes, Children } from 'react';
import { findDOMNode } from 'react-dom';
import classnames from 'classnames';
import Props from '../utils/Props';
import Box from './Box';
import Button from './Button';
import SpinningIcon from './icons/Spinning';
import Scroll from '../utils/Scroll';
import InfiniteScroll from '../utils/InfiniteScroll';
import Selection from '../utils/Selection';

import LinkPreviousIcon from './icons/base/LinkPrevious';
import LinkNextIcon from './icons/base/LinkNext';
import CSSClassnames from '../utils/CSSClassnames';

const CLASS_ROOT = CSSClassnames.TILES;
const TILE = CSSClassnames.TILE;
const SELECTED_CLASS = `${TILE}--selected`;
const MIN_COLUMN_SIZE = 384;  // $tile-large-size = 384px

export default class Tiles extends Component {

  constructor (props) {
    super(props);
    this._onLeft = this._onLeft.bind(this);
    this._onRight = this._onRight.bind(this);
    this._onScrollHorizontal = this._onScrollHorizontal.bind(this);
    this._onWheel = this._onWheel.bind(this);
    this._onResize = this._onResize.bind(this);
    this._layout = this._layout.bind(this);
    this._onClick = this._onClick.bind(this);
    this._minColumnWidths = Array.apply(null, Array(this.props.numColumns))
      .map((currentNumColumns, index) => (index + 1) * MIN_COLUMN_SIZE);

    this.state = {
      overflow: false,
      selected: Selection.normalizeIndexes(props.selected),
      numColumns: this.props.numColumns
    };
  }

  componentDidMount () {
    this._setSelection();
    if (this.props.onMore) {
      this._scroll = InfiniteScroll.startListeningForScroll(this.refs.more, this.props.onMore);
    }
    if ('row' === this.props.direction) {
      window.addEventListener('resize', this._onResize);
      document.addEventListener('wheel', this._onWheel);
      this._trackHorizontalScroll();
      // give browser a chance to stabilize
      setTimeout(this._layout, 10);
    } else if (this.props.masonry) {
      window.addEventListener('resize', this._onResize);
      setTimeout(this._layout, 10);
    }
  }

  componentWillReceiveProps (nextProps) {<commit_msg>allow masonry option to work with size options for Tiles<commit_after>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import React, { Component, PropTypes, Children } from 'react';
import { findDOMNode } from 'react-dom';
import classnames from 'classnames';
import Props from '../utils/Props';
import Box from './Box';
import Button from './Button';
import SpinningIcon from './icons/Spinning';
import Scroll from '../utils/Scroll';
import InfiniteScroll from '../utils/InfiniteScroll';
import Selection from '../utils/Selection';

import LinkPreviousIcon from './icons/base/LinkPrevious';
import LinkNextIcon from './icons/base/LinkNext';
import CSSClassnames from '../utils/CSSClassnames';

const CLASS_ROOT = CSSClassnames.TILES;
const TILE = CSSClassnames.TILE;
const SELECTED_CLASS = `${TILE}--selected`;
const MIN_COLUMN_SIZE_LARGE = 384;  // $tile-large-size = 384px
const MIN_COLUMN_SIZE = 192;  // $tile-size = 192px
const MIN_COLUMN_SIZE_SMALL = 92; // $tile-small-size = 92px

export default class Tiles extends Component {

  constructor (props) {
    super(props);
    this._onLeft = this._onLeft.bind(this);
    this._onRight = this._onRight.bind(this);
    this._onScrollHorizontal = this._onScrollHorizontal.bind(this);
    this._onWheel = this._onWheel.bind(this);
    this._onResize = this._onResize.bind(this);
    this._layout = this._layout.bind(this);
    this._onClick = this._onClick.bind(this);

    const tileSize = this.props.size;
    const minColumnWidth = (tileSize === 'small') ? MIN_COLUMN_SIZE_SMALL :
      ((tileSize === 'large') ? MIN_COLUMN_SIZE_LARGE : MIN_COLUMN_SIZE);
    this._minColumnWidths = Array.apply(null, Array(this.props.numColumns))
      .map((currentNumColumns, index) => (index + 1) * minColumnWidth);

    this.state = {
      overflow: false,
      selected: Selection.normalizeIndexes(props.selected),
      numColumns: this.props.numColumns
    };
  }

  componentDidMount () {
    this._setSelection();
    if (this.props.onMore) {
      this._scroll = InfiniteScroll.startListeningForScroll(this.refs.more, this.props.onMore);
    }
    if ('row' === this.props.direction) {
      window.addEventListener('resize', this._onResize);
      document.addEventListener('wheel', this._onWheel);
      this._trackHorizontalScroll();
      // give browser a chance to stabilize
      setTimeout(this._layout, 10);
    } else if (this.props.masonry) {
      window.addEventListener('resize', this._onResize);
      setTimeout(this._layout, 10);
    }
  }

  componentWillReceiveProps (nextProps) {
{'fraction_non_alphanumeric': 0.13120567375886524, 'fraction_numerical': 0.010012515644555695, 'mean_word_length': 3.9586349534643226, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4793163', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1438, 'n_words': 327}