<commit_before>var Backbone = require('backbone');
var Module = require('src/common/module');
var Radio = require('backbone.radio');
var LayoutView = require('./layout-view');

var modalChannel = Radio.channel('modal');

module.exports = Module.extend({
  initialize: function () {
    this.container = this.options.container;
    this.start();
  },

  onStart: function() {
    this._showLayoutView();
    this._bindChannelCommands();
  },

  onStop: function() {
    this.stopListening();
  },

  openModal: function (options) {
    this.layout.openModal(options);
    this.listenToOnce(Backbone.history, 'route', function () {
      this.destroyModal();
    });
  },

  destroyModal: function (options) {
    this.layout.destroyModal(options);
  },

  _showLayoutView: function() {
    this.layout = new LayoutView();
    this.container.show(this.layout);
  },

  _bindChannelCommands: function() {
    modalChannel.comply('open', this.openModal, this);
    modalChannel.comply('destroy', this.destroyModal, this);
  }
});<commit_msg>Update controller.js<commit_after>var Backbone = require('backbone');
var Module = require('src/common/module');
var Radio = require('backbone.radio');
var LayoutView = require('./layout-view');

var modalChannel = Radio.channel('modal');

module.exports = Module.extend({
  initialize: function () {
    this.container = this.options.container;
    this.start();
  },

  onStart: function() {
    this._showLayoutView();
    this._bindChannelCommands();
  },

  onStop: function() {
    this.stopListening();
  },

  openModal: function (options) {
    this.layout.openModal(options);
    this.originalFragment = Backbone.history.fragment;
    this.listenToOnce(Backbone.history, 'route', function () {
      if (Backbone.history.fragment != this.originalFragment) {
        this.destroyModal();
      }
    });
  },

  destroyModal: function (options) {
    this.layout.destroyModal(options);
  },

  _showLayoutView: function() {
    this.layout = new LayoutView();
    this.container.show(this.layout);
  },

  _bindChannelCommands: function() {
    modalChannel.comply('open', this.openModal, this);
    modalChannel.comply('destroy', this.destroyModal, this);
  },

  onRoute: function() {
    if (Backbone.history.fragment != this.originalFragment) {
      this.destroyModal();
      delete this.originalFragment;
    }
  }
});
{'fraction_non_alphanumeric': 0.1552087726697596, 'fraction_numerical': 0.0, 'mean_word_length': 3.830957230142566, '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': '5749859', 'n_tokens_mistral': 713, 'n_tokens_neox': 703, 'n_words': 124}