<commit_before>define(function(require) {

  var Backbone = require('backbone');
  var EntriesView = require('views/entries');
  var EditorView = require('views/editor');
  var AsideView = require('views/aside');
  var SearchView = require('views/search');
  var utils = require('utils');


  var AppView = Backbone.View.extend({

    el: 'body',

    initialize: function(options) {

      this.app = options.app;

      this.editor = new EditorView({ app: this.app });
      this.entries = new EntriesView({ app: this.app, collection: this.collection });
      this.search = new SearchView({ model: this.app.state, collection: this.collection });
      this.aside = new AsideView({ app: this.app, collection: this.collection });


      this.collection.on('fetch', this.editor.render);

      this.search
        .on('focus', this.aside.show)
        .on('blur', this.aside.desktopHide);

      this.editor.on('modKey', this.aside.hide);

      this.entries.on('open', this.aside.toggle);

    },

    events: {
      'click #add': 'newDoc',
      'touchend #add': 'newDoc',
      'click #menu-button': 'toggleAside',
      'touchend #menu-button': 'toggleAside',
      'keydown': 'handleKey'
    },

    newDoc: function() {
      if (utils.isMobile) this.aside.toggle();
      if (this.app.doc.isEmpty()) return this.editor.focus();
      this.collection.addNew();
      return false;
    },

    toggleAside: function() {
      this.aside.toggle();
      return false;
    },

    // global key handler for shortcuts
    handleKey: function(e) {
      if (e.which === 9) { // tab
        e.preventDefault();
      } else if (e[utils.modKey.name]) {
        this.aside.show();
        if (e.which === 78) { // n
          this.newDoc(e);
        } else if (e.which === 38) { // up
          this.previous();
          return false;
        } else if (e.which === 40) { // down
          this.next();
          return false;
        } else if (e.which === 70) // f
          this.search.focus();
      }
    },

    previous: function() {
      var doc = this.collection.before(this.app.doc.id);
      if (doc) this.app.open(doc);
    },

    next: function() {
      var doc = this.collection.after(this.app.doc.id);
      if (doc) this.app.open(doc);
    }

  });


  return AppView;
});
<commit_msg>always focus editor when clicking #add<commit_after>define(function(require) {

  var Backbone = require('backbone');
  var EntriesView = require('views/entries');
  var EditorView = require('views/editor');
  var AsideView = require('views/aside');
  var SearchView = require('views/search');
  var utils = require('utils');


  var AppView = Backbone.View.extend({

    el: 'body',

    initialize: function(options) {

      this.app = options.app;

      this.editor = new EditorView({ app: this.app });
      this.entries = new EntriesView({ app: this.app, collection: this.collection });
      this.search = new SearchView({ model: this.app.state, collection: this.collection });
      this.aside = new AsideView({ app: this.app, collection: this.collection });


      this.collection.on('fetch', this.editor.render);

      this.search
        .on('focus', this.aside.show)
        .on('blur', this.aside.desktopHide);

      this.editor.on('modKey', this.aside.hide);

      this.entries.on('open', this.aside.toggle);

    },

    events: {
      'click #add': 'newDoc',
      'touchend #add': 'newDoc',
      'click #menu-button': 'toggleAside',
      'touchend #menu-button': 'toggleAside',
      'keydown': 'handleKey'
    },

    newDoc: function() {
      if (utils.isMobile) this.aside.toggle();
      if (! this.app.doc.isEmpty()) this.collection.addNew();
      this.editor.focus();
      return false;
    },

    toggleAside: function() {
      this.aside.toggle();
      return false;
    },

    // global key handler for shortcuts
    handleKey: function(e) {
      if (e.which === 9) { // tab
        e.preventDefault();
      } else if (e[utils.modKey.name]) {
        this.aside.show();
        if (e.which === 78) { // n
          this.newDoc(e);
        } else if (e.which === 38) { // up
          this.previous();
          return false;
        } else if (e.which === 40) { // down
          this.next();
          return false;
        } else if (e.which === 70) // f
          this.search.focus();
      }
    },

    previous: function() {
      var doc = this.collection.before(this.app.doc.id);
      if (doc) this.app.open(doc);
    },

    next: function() {
      var doc = this.collection.after(this.app.doc.id);
      if (doc) this.app.open(doc);
    }

  });


  return AppView;
});

{'fraction_non_alphanumeric': 0.16673866090712744, 'fraction_numerical': 0.0038876889848812094, 'mean_word_length': 2.303138373751783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '183131', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1429, 'n_words': 320}