<commit_before>/**
 * Wraps all controls displayed in the heading of widget.
 * Contains week controllers and functions tools.
 */

import React, { PropTypes } from 'react'
import { moment as momentPropType } from '../constants/propTypes'

import ViewDate from './ViewDate'
import WeekNav from './WeekNav'
import FunctionsBar from './FunctionsBar'
import WeekSwitcher from './WeekSwitcher'

const propTypes = {
  onWeekChange: PropTypes.func.isRequired,
  onDateChange: PropTypes.func.isRequired,
  onSelDayChange: PropTypes.func.isRequired,
  onSettingsPanelChange: PropTypes.func.isRequired,
  viewDate: momentPropType,
  days7: PropTypes.bool,
  selectedDay: PropTypes.number,
  semester: PropTypes.string,
}

class Controls extends React.Component {

  /**
   * Handles WeekNav's previous button click event
   */
  handlePrevClick () {

    // Different behaviour on different screens. Large up changes weeks, medium down changes active day
    if (window.innerWidth > 768) {
      this.props.onWeekChange(this.props.viewDate.subtract(1, 'week'))
    } else {
      this.props.onSelDayChange(-1)
    }
  }

  /**
   * Handles WeekNav's next button click event
   */
  handleNextClick () {

    // Different behaviour on different screens. Large up changes weeks, medium down changes active day
    if (window.innerWidth > 768) {
      this.props.onWeekChange(this.props.viewDate.add(1, 'week'))
    } else {
      this.props.onSelDayChange(1)
    }
  }

  /**
   * Handles a click on a week row in the WeekSelector
   */
  handleWeekClick () {
    this.refs.weekSwitcher.toggle()
  }

  render () {

    return (
      <div className="header">
        <WeekNav
          onCalClick={this.handleWeekClick.bind(this)}
          onPrevClick={this.handlePrevClick.bind(this)}
          onNextClick={this.handleNextClick.bind(this)}
          viewDate={this.props.viewDate}
          selectedDay={this.props.selectedDay}
        />
        <ViewDate
          viewDate={this.props.viewDate}
          selectedDay={this.props.selectedDay}
          days7={this.props.days7}
        /><commit_msg>Remove ViewDate from Controls component<commit_after>/**
 * Wraps all controls displayed in the heading of widget.
 * Contains week controllers and functions tools.
 */

import React, { PropTypes } from 'react'
import { moment as momentPropType } from '../constants/propTypes'

import ViewDate from './ViewDate'
import WeekNav from './WeekNav'
import FunctionsBar from './FunctionsBar'
import WeekSwitcher from './WeekSwitcher'

const propTypes = {
  onWeekChange: PropTypes.func.isRequired,
  onDateChange: PropTypes.func.isRequired,
  onSelDayChange: PropTypes.func.isRequired,
  onSettingsPanelChange: PropTypes.func.isRequired,
  viewDate: momentPropType,
  days7: PropTypes.bool,
  selectedDay: PropTypes.number,
  semester: PropTypes.string,
}

class Controls extends React.Component {

  /**
   * Handles WeekNav's previous button click event
   */
  handlePrevClick () {

    // Different behaviour on different screens. Large up changes weeks, medium down changes active day
    if (window.innerWidth > 768) {
      this.props.onWeekChange(this.props.viewDate.subtract(1, 'week'))
    } else {
      this.props.onSelDayChange(-1)
    }
  }

  /**
   * Handles WeekNav's next button click event
   */
  handleNextClick () {

    // Different behaviour on different screens. Large up changes weeks, medium down changes active day
    if (window.innerWidth > 768) {
      this.props.onWeekChange(this.props.viewDate.add(1, 'week'))
    } else {
      this.props.onSelDayChange(1)
    }
  }

  /**
   * Handles a click on a week row in the WeekSelector
   */
  handleWeekClick () {
    this.refs.weekSwitcher.toggle()
  }

  render () {

    return (
      <div className="header">
        <WeekNav
          onCalClick={this.handleWeekClick.bind(this)}
          onPrevClick={this.handlePrevClick.bind(this)}
          onNextClick={this.handleNextClick.bind(this)}
          viewDate={this.props.viewDate}
          selectedDay={this.props.selectedDay}
        />
{'fraction_non_alphanumeric': 0.1077755905511811, 'fraction_numerical': 0.005905511811023622, 'mean_word_length': 3.1185410334346506, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 12, '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': '3367696', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1191, 'n_words': 294}