<commit_before>import React, { Component, PropTypes } from 'react'
import HoverComponent from './lib/HoverComponent'
import TriggerComponent from './lib/TriggerComponent'
import classnames from 'classnames'

export default class ReactHover extends Component {
  static propTypes = {
    styles: PropTypes.object.isRequired,
    componentHtml: PropTypes.object.isRequired,
    options: PropTypes.object.isRequired,
    className: PropTypes.string
  }

  constructor (props) {
    super(props)
    this.state = {
      triggerComponentStyle: this.props.styles.trigger,
      hoverComponentStyle: this.props.styles.hoverComponent
    }
  }

  render () {
    const { componentHtml, className } = this.props
    const { triggerComponentStyle, hoverComponentStyle } = this.state
    return (
      <div className={classnames(className)} >
        <TriggerComponent
          styles={triggerComponentStyle}
          componentHtml={componentHtml}
          setVisibility={this.setVisibility.bind(this)}
          getCursorPos={this.getCursorPos.bind(this)}
        />
        <HoverComponent
          styles={hoverComponentStyle}
          componentHtml={componentHtml}
        />
      </div>
    )
  }

  setVisibility (flag) {
    let { hoverComponentStyle } = this.state
    let updatedStyles = null
    if (flag) {
      updatedStyles = Object.assign({}, hoverComponentStyle, {display: 'block'})
    } else {
      updatedStyles = Object.assign({}, hoverComponentStyle, {display: 'none'})
    }
    this.setState({
      hoverComponentStyle: updatedStyles
    })
  }

  getCursorPos (e) {
    const cursorX = e.pageX
    const cursorY = e.pageY
    let {options: { followCursor, shiftX, shiftY }} = this.props
    const { hoverComponentStyle } = this.state
    let updatedStyles = null
    if (!followCursor) {
      return
    }
    if (shiftX == NaN) {
      shiftX = 0
    }
    if (shiftY == NaN) {
      shiftY = 0
    }
    updatedStyles = Object.assign({}, hoverComponentStyle, {top: cursorY + shiftY, left: cursorX + shiftX})
    this.setState({
      hoverComponentStyle: updatedStyles
    })
  }
}<commit_msg>[issue-6]: Add IE9, IE10 support<commit_after>import React, { Component, PropTypes } from 'react'
import HoverComponent from './lib/HoverComponent'
import TriggerComponent from './lib/TriggerComponent'
import classnames from 'classnames'

export default class ReactHover extends Component {
  static propTypes = {
    styles: PropTypes.object.isRequired,
    componentHtml: PropTypes.object.isRequired,
    options: PropTypes.object.isRequired,
    className: PropTypes.string
  }

  constructor (props) {
    super(props)
    this.state = {
      triggerComponentStyle: props.styles.trigger,
      hoverComponentStyle: props.styles.hoverComponent
    }
  }

  render () {
    const { componentHtml, className } = this.props
    const { triggerComponentStyle, hoverComponentStyle } = this.state
    return (
      <div className={classnames(className)} >
        <TriggerComponent
          styles={triggerComponentStyle}
          componentHtml={componentHtml}
          setVisibility={this.setVisibility.bind(this)}
          getCursorPos={this.getCursorPos.bind(this)}
        />
        <HoverComponent
          styles={hoverComponentStyle}
          componentHtml={componentHtml}
        />
      </div>
    )
  }

  setVisibility (flag) {
    let { hoverComponentStyle } = this.state
    let updatedStyles = null
    if (flag) {
      updatedStyles = {...hoverComponentStyle, display: 'block'}
    } else {
      updatedStyles = {...hoverComponentStyle, display: 'none'}
    }
    this.setState({
      hoverComponentStyle: updatedStyles
    })
  }

  getCursorPos (e) {
    const cursorX = e.pageX
    const cursorY = e.pageY
    let {options: { followCursor, shiftX, shiftY }} = this.props
    let { hoverComponentStyle } = this.state
    let updatedStyles = null
    if (!followCursor) {
      return
    }
    if (isNaN(shiftX)) {
      shiftX = 0
    }
    if (isNaN(shiftY)) {
      shiftY = 0
    }
    updatedStyles = {...hoverComponentStyle, top: cursorY + shiftY, left: cursorX + shiftX}
    this.setState({
      hoverComponentStyle: updatedStyles
    })
  }
}
{'fraction_non_alphanumeric': 0.10626638074815345, 'fraction_numerical': 0.0019061234214915416, 'mean_word_length': 2.8408051235132663, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4180709', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1195, 'n_words': 263}