<commit_before>/** @jsx React.DOM */

define([
  "mousetrap",
  "React",
  "models/AppCollection",
  "jsx!components/AppListComponent",
  "jsx!components/NewAppModalComponent"
], function(Mousetrap, React, AppCollection, AppListComponent,
    NewAppModalComponent) {

  return React.createClass({
    displayName: "Marathon",

    getInitialState: function() {
      return {
        collection: new AppCollection()
      };
    },

    componentDidMount: function() {
      // Override Mousetrap's `stopCallback` to allow "esc" to trigger even within
      // input elements so the new app modal can be closed via "esc".
      var mousetrapOriginalStopCallback = Mousetrap.stopCallback;
      Mousetrap.stopCallback = function(e, element, combo) {
        if (combo === "esc" || combo === "escape") { return false; }
        return mousetrapOriginalStopCallback.apply(null, arguments);
      };

      Mousetrap.bind("c", function() {
        this.showNewAppModal(); }.bind(this), "keyup");
      Mousetrap.bind("#", function() {
        this.refs.appList.destroyActiveApp();
      }.bind(this));
    },

    handleModalCreate: function(appModel) {
      this.state.collection.create(appModel);
    },

    handleModalDestroy: function() {
      this.setState({modal: null});
    },

    showNewAppModal: function(event) {
      // Don't recreate the modal on successive calls of `showModal` if the
      // modal is already open. For example, pressing "c" to open the modal and
      // then pressing "c" again should not create new App and Modal instances
      // or data will be lost if the form is partially filled.
      if (this.state != null && this.state.modal != null &&
          this.state.modal.isMounted()) {
        return;
      }

      this.setState({
        modal: React.renderComponent(
          <NewAppModalComponent
            onCreate={this.handleModalCreate}
            onDestroy={this.handleModalDestroy} />,
          document.getElementById("lightbox")
        )
      });
    },

    render: function() {
      return (
        <div>
          <nav className="navbar navbar-inverse" role="navigation">
           <div className="container-fluid">
              <img className="h1" width="160" height="27" alt="Marathon" src="/img/marathon-logo.png" />
              <button type="button" className="btn btn-success header-btn pull-right"
                  onClick={this.showNewAppModal}>
                + New App
              </button>
            </div>
          </nav>
          <AppListComponent className="container-fluid" collection={this.state.collection} ref="appList" />
        </div>
      );
    }
  });
});<commit_msg>Review: wrapping AppListComponent in container div<commit_after>/** @jsx React.DOM */

define([
  "mousetrap",
  "React",
  "models/AppCollection",
  "jsx!components/AppListComponent",
  "jsx!components/NewAppModalComponent"
], function(Mousetrap, React, AppCollection, AppListComponent,
    NewAppModalComponent) {

  return React.createClass({
    displayName: "Marathon",

    getInitialState: function() {
      return {
        collection: new AppCollection()
      };
    },

    componentDidMount: function() {
      // Override Mousetrap's `stopCallback` to allow "esc" to trigger even within
      // input elements so the new app modal can be closed via "esc".
      var mousetrapOriginalStopCallback = Mousetrap.stopCallback;
      Mousetrap.stopCallback = function(e, element, combo) {
        if (combo === "esc" || combo === "escape") { return false; }
        return mousetrapOriginalStopCallback.apply(null, arguments);
      };

      Mousetrap.bind("c", function() {
        this.showNewAppModal(); }.bind(this), "keyup");
      Mousetrap.bind("#", function() {
        this.refs.appList.destroyActiveApp();
      }.bind(this));
    },

    handleModalCreate: function(appModel) {
      this.state.collection.create(appModel);
    },

    handleModalDestroy: function() {
      this.setState({modal: null});
    },

    showNewAppModal: function(event) {
      // Don't recreate the modal on successive calls of `showModal` if the
      // modal is already open. For example, pressing "c" to open the modal and
      // then pressing "c" again should not create new App and Modal instances
      // or data will be lost if the form is partially filled.
      if (this.state != null && this.state.modal != null &&
          this.state.modal.isMounted()) {
        return;
      }

      this.setState({
        modal: React.renderComponent(
          <NewAppModalComponent
            onCreate={this.handleModalCreate}
            onDestroy={this.handleModalDestroy} />,
          document.getElementById("lightbox")
        )
      });
    },

    render: function() {
      return (
        <div>
          <nav className="navbar navbar-inverse" role="navigation">
           <div className="container-fluid">
              <img className="h1" width="160" height="27" alt="Marathon" src="/img/marathon-logo.png" />
              <button type="button" className="btn btn-success header-btn pull-right"
                  onClick={this.showNewAppModal}>
                + New App
              </button>
            </div>
          </nav>
          <div className="container-fluid">
            <AppListComponent collection={this.state.collection} ref="appList" />
          </div>
        </div>
      );
    }
  });
});
{'fraction_non_alphanumeric': 0.12916358253145818, 'fraction_numerical': 0.0022205773501110288, 'mean_word_length': 2.4448693435309115, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '6508794', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1501, 'n_words': 361}