<commit_before>import React, {PropTypes} from 'react';

var LoginView = React.createClass({
  getInitialState : function(){
    return {type: 'basic', email: '', password: ''}
  },
  update_password(event){
    this.setState({password: event.target.value})
  },
  update_email(event){
    this.setState({email: event.target.value})
  },
  handleSubmit(ev){
    ev.preventDefault()
    if ($(this.refs.el).form('validate form')){
      this.props._onSubmit(this.state)
    }
    else{
      this.props._onInvalidForm();
    }
  },
  componentDidMount( ){
    self=this
    $(this.refs.el).form({
      on: 'blur',
      fields: {
        email: 'email',
        password: '<PASSWORD>]'
      }
    })
    $(self.refs.el).find('[type=email]').focus()
  },
  render: function(){
    return (
      <form ref="el" className="ui form" method="POST" onSubmit={this.handleSubmit}>
        <div className="ui small modal active" id="login">
          <div className="header">
            Login
          </div>

          <div className="content">
            <div className="field">
              <label>Email</label>
              <input type="email" name="email" placeholder="<EMAIL>"
                onChange={this.update_email} value={this.state.email}
                />
            </div>

            <div className="field">
              <label>Password</label>
              <input type="password" name="password" placeholder="*******"
                onChange={this.update_password} value={this.state.password}
                />
            </div>
            <div className="ui error message"></div>
          </div>

          <div className="actions">
            <span className="ui checkbox action left" style={{float: "left"}}>
                <input type="checkbox" name="keep_logged_in"/>
                <label>
                Keep logged login
              </label>
            </span>
            <button type="button" className="ui positive right labeled icon button"
              onClick={this.handleSubmit}>
              Login
              <i className="caret right icon"></i>
            </button>
          </div>
        </div>
      </form>
    )
  },
  propTypes: {
    _onSubmit: PropTypes.func.isRequired
  }
})


export default LoginView
<commit_msg>Fix login better use of semantic forms, and submit on enter<commit_after>import React, {PropTypes} from 'react';

var LoginView = React.createClass({
  handleSubmit(ev){
    let $form = $(this.refs.el)
    let fields = $form.form('get values')

    console.log("%o %o", ev, fields);
    if ($form.form('validate form')){
      this.props._onSubmit(
        Object.assign({type: 'basic'}, fields)
      )
    }
    ev.preventDefault()
  },
  componentDidMount( ){
    self=this

    $(this.refs.el).form({
      on: 'blur',
      fields: {
        email: 'email',
        password: '<PASSWORD>]'
      }
    }).on('submit', self.handleSubmit)

    $(self.refs.el).find('[type=email]').focus()
  },
  render: function(){
    return (
      <form ref="el" className="ui form" method="POST">
        <div className="ui small modal active" id="login">
          <div className="header">
            Login
          </div>

          <div className="content">
            <div className="field">
              <label>Email</label>
              <input type="email" name="email" placeholder="<EMAIL>"
                />
            </div>

            <div className="field">
              <label>Password</label>
              <input type="password" name="password" placeholder="*******"
                />
            </div>
            <div className="ui error message"></div>
          </div>

          <div className="actions">
            <span className="ui checkbox action left" style={{float: "left"}}>
                <input type="checkbox" name="keep_logged_in"/>
                <label>
                Keep logged login
              </label>
            </span>
            <button type="submit" className="ui positive right labeled icon button">
              Login
              <i className="caret right icon"></i>
            </button>
          </div>
        </div>
      </form>
    )
  },
  propTypes: {
    _onSubmit: PropTypes.func.isRequired
  }
})


export default LoginView

{'fraction_non_alphanumeric': 0.1529466791393826, 'fraction_numerical': 0.0, 'mean_word_length': 1.8898648648648648, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, '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': '911362', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1184, 'n_words': 261}