<commit_before>/** @jsx React.DOM */
/*
 * == BSD2 LICENSE ==
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 * == BSD2 LICENSE ==
 */
var bows = require('bows');
var React = require('react');
var cx = require('react/lib/cx');

var tideline = {
  log: bows('Header')
};

var TidelineHeader = React.createClass({
  propTypes: {
    chartType: React.PropTypes.string.isRequired,
    inTransition: React.PropTypes.bool.isRequired,
    atMostRecent: React.PropTypes.bool.isRequired,
    title: React.PropTypes.string.isRequired,
    onClickBack: React.PropTypes.func,
    onClickModal: React.PropTypes.func,
    onClickMostRecent: React.PropTypes.func,
    onClickNext: React.PropTypes.func,
    onClickOneDay: React.PropTypes.func,
    onClickTwoWeeks: React.PropTypes.func,
    onClickSettings: React.PropTypes.func
  },
  render: function() {
    var dayLinkClass = cx({
      'patient-data-subnav-active': this.props.chartType === 'daily',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    var modalLinkClass = cx({
      'patient-data-subnav-active': this.props.chartType === 'modal',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    var weekLinkClass = cx({
      'patient-data-subnav-active': this.props.chartType === 'weekly',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    var dateLinkClass = cx({
      'patient-data-subnav-text' : this.props.chartType === 'daily' || this.props.chartType === 'weekly' || this.props.chartType === 'modal',
      'patient-data-subnav-dates-daily': this.props.chartType === 'daily',
      'patient-data-subnav-dates-weekly': this.props.chartType === 'weekly',
      'patient-data-subnav-dates-modal': this.props.chartType === 'modal'
    });

    var mostRecentLinkClass = cx({
      'patient-data-subnav-active': !this.props.atMostRecent && !this.props.inTransition,
      'patient-data-subnav-disabled': this.props.atMostRecent || this.props.inTransition,
      'patient-data-subnav-hidden': this.props.chartType === 'no-data' ||
        this.props.chartType === 'modal'
    });

    var backClass = cx({
      'patient-data-subnav-active': !this.props.inTransition,
      'patient-data-subnav-disabled': this.props.inTransition,
      'patient-data-subnav-hidden': this.props.chartType === 'settings' ||
        this.props.chartType === 'no-data' || this.props.chartType === 'modal'
    });

    var nextClass = cx({
      'patient-data-subnav-active': !this.props.atMostRecent && !this.props.inTransition,
      'patient-data-subnav-disabled': this.props.atMostRecent || this.props.inTransition,
      'patient-data-subnav-hidden': this.props.chartType === 'settings' ||
        this.props.chartType === 'no-data' || this.props.chartType === 'modal'
    });

    var settingsLinkClass = cx({
      'patient-data-subnav-right': true,
      'patient-data-subnav-right-label': true,
      'patient-data-subnav-active': this.props.chartType === 'settings',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    /* jshint ignore:start */
    return (
      <div className="container-box-outer patient-data-subnav-outer">
        <div className="container-box-inner patient-data-subnav-inner">
          <div className="grid patient-data-subnav">
            <div className="grid-item one-whole large-one-quarter">
                <a href="" className={dayLinkClass} onClick={this.props.onClickOneDay}>Daily</a>
                <a href="" className={weekLinkClass} onClick={this.props.onClickTwoWeeks}>Weekly</a>
                <a href="" className={modalLinkClass} onClick={this.props.onClickModal}>Trends</a>
            </div>
            <div className="grid-item one-whole large-one-half patient-data-subnav-center" id="tidelineLabel">
              <a href="" className={backClass} onClick={this.props.onClickBack}><i className={this.props.iconBack}/></a>
              <div className={dateLinkClass}>
                {this.props.title}
              </div>
              <a href="" className={nextClass} onClick={this.props.onClickNext}><i className={this.props.iconNext}/></a>
              <a href="" className={mostRecentLinkClass} onClick={this.props.onClickMostRecent}><i className={this.props.iconMostRecent}/></a>
            </div>
            <div className="grid-item one-whole large-one-quarter">
              <a href="" className={settingsLinkClass} onClick={this.props.onClickSettings}>Device settings</a>
            </div>
          </div>
        </div>
      </div>
      );
    /* jshint ignore:end */
  }
});

module.exports = TidelineHeader;<commit_msg>disable navigation buttons when in transition<commit_after>/** @jsx React.DOM */
/*
 * == BSD2 LICENSE ==
 * Copyright (c) 2014, Tidepool Project
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the associated License, which is identical to the BSD 2-Clause
 * License as published by the Open Source Initiative at opensource.org.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the License for more details.
 *
 * You should have received a copy of the License along with this program; if
 * not, you can obtain one from Tidepool Project at tidepool.org.
 * == BSD2 LICENSE ==
 */
var bows = require('bows');
var React = require('react');
var cx = require('react/lib/cx');

var tideline = {
  log: bows('Header')
};

var TidelineHeader = React.createClass({
  propTypes: {
    chartType: React.PropTypes.string.isRequired,
    inTransition: React.PropTypes.bool.isRequired,
    atMostRecent: React.PropTypes.bool.isRequired,
    title: React.PropTypes.string.isRequired,
    onClickBack: React.PropTypes.func,
    onClickModal: React.PropTypes.func,
    onClickMostRecent: React.PropTypes.func,
    onClickNext: React.PropTypes.func,
    onClickOneDay: React.PropTypes.func,
    onClickTwoWeeks: React.PropTypes.func,
    onClickSettings: React.PropTypes.func
  },
  render: function() {
    var dayLinkClass = cx({
      'patient-data-subnav-active': this.props.chartType === 'daily',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    var modalLinkClass = cx({
      'patient-data-subnav-active': this.props.chartType === 'modal',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    var weekLinkClass = cx({
      'patient-data-subnav-active': this.props.chartType === 'weekly',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    var dateLinkClass = cx({
      'patient-data-subnav-text' : this.props.chartType === 'daily' || this.props.chartType === 'weekly' || this.props.chartType === 'modal',
      'patient-data-subnav-dates-daily': this.props.chartType === 'daily',
      'patient-data-subnav-dates-weekly': this.props.chartType === 'weekly',
      'patient-data-subnav-dates-modal': this.props.chartType === 'modal'
    });

    var mostRecentClass = cx({
      'patient-data-subnav-active': !this.props.atMostRecent && !this.props.inTransition,
      'patient-data-subnav-disabled': this.props.atMostRecent || this.props.inTransition,
      'patient-data-subnav-hidden': this.props.chartType === 'no-data' ||
        this.props.chartType === 'modal'
    });

    var backClass = cx({
      'patient-data-subnav-active': !this.props.inTransition,
      'patient-data-subnav-disabled': this.props.inTransition,
      'patient-data-subnav-hidden': this.props.chartType === 'settings' ||
        this.props.chartType === 'no-data' || this.props.chartType === 'modal'
    });

    var nextClass = cx({
      'patient-data-subnav-active': !this.props.atMostRecent && !this.props.inTransition,
      'patient-data-subnav-disabled': this.props.atMostRecent || this.props.inTransition,
      'patient-data-subnav-hidden': this.props.chartType === 'settings' ||
        this.props.chartType === 'no-data' || this.props.chartType === 'modal'
    });

    var settingsLinkClass = cx({
      'patient-data-subnav-right': true,
      'patient-data-subnav-right-label': true,
      'patient-data-subnav-active': this.props.chartType === 'settings',
      'patient-data-subnav-hidden': this.props.chartType === 'no-data'
    });

    /* jshint ignore:start */
    return (
      <div className="container-box-outer patient-data-subnav-outer">
        <div className="container-box-inner patient-data-subnav-inner">
          <div className="grid patient-data-subnav">
            <div className="grid-item one-whole large-one-quarter">
                <a href="" className={dayLinkClass} onClick={this.props.onClickOneDay}>Daily</a>
                <a href="" className={weekLinkClass} onClick={this.props.onClickTwoWeeks}>Weekly</a>
                <a href="" className={modalLinkClass} onClick={this.props.onClickModal}>Trends</a>
            </div>
            <div className="grid-item one-whole large-one-half patient-data-subnav-center" id="tidelineLabel">
              {this.renderNavButton(backClass, this.props.onClickBack, this.props.iconBack)}
              <div className={dateLinkClass}>
                {this.props.title}
              </div>
              {this.renderNavButton(nextClass, this.props.onClickNext, this.props.iconNext)}
              {this.renderNavButton(mostRecentClass, this.props.onClickMostRecent, this.props.iconMostRecent)}
            </div>
            <div className="grid-item one-whole large-one-quarter">
              <a href="" className={settingsLinkClass} onClick={this.props.onClickSettings}>Device settings</a>
            </div>
          </div>
        </div>
      </div>
      );
    /* jshint ignore:end */
  },

  /**
   * Helper function for rendering the various navigation buttons in the header.
   * It accounts for the transition state and disables the button if it is currently processing.
   * 
   * @param  {String} buttonClass
   * @param  {Function} clickAction
   * @param  {String} icon
   * 
   * @return {ReactElement}
   */
  renderNavButton: function(buttonClass, clickAction, icon) {
    var nullAction = function(e) {
      if (e) {
        e.preventDefault();
      }
    };
    if (this.props.inTransition) {
      /* jshint ignore:start */
      return (<a href="" className={buttonClass} onClick={nullAction}><i className={icon}/></a>)
      /* jshint ignore:end */
    } else {
      /* jshint ignore:start */
      return (<a href="" className={buttonClass} onClick={clickAction}><i className={icon}/></a>)
      /* jshint ignore:end */
    }
  }
});

module.exports = TidelineHeader;
{'fraction_non_alphanumeric': 0.1487048006365485, 'fraction_numerical': 0.0012377331800901778, 'mean_word_length': 3.11046511627907, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 62, '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': '2860695', 'n_tokens_mistral': 3441, 'n_tokens_neox': 3367, 'n_words': 714}