<commit_before>var _ = require('underscore');
var CoreView = require('backbone/core-view');
var OptionsItemView = require('./preview-options-item-view');
var template = require('./preview-options.tpl');
var templateNotReady = require('./options-not-ready.tpl');

var REQUIRED_OPTS = [
  'mapDefinitionModel',
  'settingsCollection',
  'overlaysCollection'
];

module.exports = CoreView.extend({
  initialize: function (opts) {
    _.each(REQUIRED_OPTS, function (item) {
      if (!opts[item]) throw new Error(item + ' is required');
      this['_' + item] = opts[item];
    }, this);

    this._initBinds();
  },

  render: function () {
    this.clearSubViews();

    if (!this._overlaysCollection.hasFetched()) {
      this.$el.html(templateNotReady());
    } else {
      this.$el.html(template());
      this._initViews();
    }

    return this;
  },

  _initBinds: function () {
    this._overlaysCollection.on('sync', this.render, this);
    this.add_related_model(this._overlaysCollection);

    this._settingsCollection.on('change', this._onChangeOptions, this);
    this.add_related_model(this._settingsCollection);<commit_msg>No need to sync the UI render.<commit_after>var _ = require('underscore');
var CoreView = require('backbone/core-view');
var OptionsItemView = require('./preview-options-item-view');
var template = require('./preview-options.tpl');
var templateNotReady = require('./options-not-ready.tpl');

var REQUIRED_OPTS = [
  'mapDefinitionModel',
  'settingsCollection',
  'overlaysCollection'
];

module.exports = CoreView.extend({
  initialize: function (opts) {
    _.each(REQUIRED_OPTS, function (item) {
      if (!opts[item]) throw new Error(item + ' is required');
      this['_' + item] = opts[item];
    }, this);

    this._initBinds();
  },

  render: function () {
    this.clearSubViews();

    if (!this._overlaysCollection.hasFetched()) {
      this.$el.html(templateNotReady());
    } else {
      this.$el.html(template());
      this._initViews();
    }

    return this;
  },

  _initBinds: function () {
    this._settingsCollection.on('change', this._onChangeOptions, this);
    this.add_related_model(this._settingsCollection);
{'fraction_non_alphanumeric': 0.16069788797061524, 'fraction_numerical': 0.0, 'mean_word_length': 3.929864253393665, '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': '1568741', 'n_tokens_mistral': 684, 'n_tokens_neox': 674, 'n_words': 121}