<commit_before>
/**
 * tabbed pane.
 * if contains n views inside it and shows only one at once
 *
 * usage:
 *
 * var pane = new cbd.ui.common.TabPane();
 * pane.addTab('tab1', new OtherView());
 * pane.addTab('tab2', new OtherView2());
 * pane.addTab('tab3', new OtherView3());
 * 
 * pane.active('tab1');
 *
 * pane.bind('tabEnabled', function(tabName, tabView) {
 * pane.bind('tabDisabled', function(tabName, tabView) {
 * });
 */
cdb.ui.common.TabPane = cdb.core.View.extend({

  initialize: function() {
      this.tabs = {};
      this.activeTab = null;
  },

  addTab: function(name, view) {
    if(this.tabs[name] !== undefined) {
      cdb.log.debug(name + "already added");
    } else {
      this.tabs[name] = view.cid;
      this.addView(view);
      this.$el.append(view.el);
      this.trigger('tabAdded', name, view);
      this.active(name);
    }
  },

  removeTab: function(name) {
    if(this.tabs[name] === undefined) {
      cdb.log.debug("trying to remove non existing pane " + name);
    } else {
      var vid = this.tabs[name];
      this._subviews[vid].clean();
      delete this.tabs[name];
      //TODO: activate other
      if(_.size(this.tabs)) {
        this.active(_.keys(this.tabs)[0]);
      }
    }
  },

  active: function(name) {
    var self = this;
    var vid = this.tabs[name];
    if(vid === undefined) {
      cdb.log.debug("trying to switch to non existing pane " + name);
    } else {
      if(this.activeTab !== name) {
        var v = this._subviews[vid];
        this.activeTab = name;
        _(this._subviews).each(function(v) {
          if(v.cid === vid) {
            v.show();
            self.trigger('tabEnabled', name, v);
          } else {
            v.hide();
            self.trigger('tabDisabled', '' , v);
          }
        });
      }
    }

  },

  render: function() {
      return this;
  }

});
<commit_msg>added per tab triggers in tabpane<commit_after>
/**
 * tabbed pane.
 * if contains n views inside it and shows only one at once
 *
 * usage:
 *
 * var pane = new cbd.ui.common.TabPane();
 * pane.addTab('tab1', new OtherView());
 * pane.addTab('tab2', new OtherView2());
 * pane.addTab('tab3', new OtherView3());
 * 
 * pane.active('tab1');
 *
 * pane.bind('tabEnabled', function(tabName, tabView) {
 * pane.bind('tabDisabled', function(tabName, tabView) {
 * });
 */
cdb.ui.common.TabPane = cdb.core.View.extend({

  initialize: function() {
      this.tabs = {};
      this.activeTab = null;
  },

  addTab: function(name, view) {
    if(this.tabs[name] !== undefined) {
      cdb.log.debug(name + "already added");
    } else {
      this.tabs[name] = view.cid;
      this.addView(view);
      this.$el.append(view.el);
      this.trigger('tabAdded', name, view);
      this.active(name);
    }
  },

  removeTab: function(name) {
    if(this.tabs[name] === undefined) {
      cdb.log.debug("trying to remove non existing pane " + name);
    } else {
      var vid = this.tabs[name];
      this._subviews[vid].clean();
      delete this.tabs[name];
      //TODO: activate other
      if(_.size(this.tabs)) {
        this.active(_.keys(this.tabs)[0]);
      }
    }
  },

  active: function(name) {
    var self = this;
    var vid = this.tabs[name];
    if(vid === undefined) {
      cdb.log.debug("trying to switch to non existing pane " + name);
    } else {
      if(this.activeTab !== name) {
        var v = this._subviews[vid];
        this.activeTab = name;
        _(this._subviews).each(function(v) {
          if(v.cid === vid) {
            v.show();
            self.trigger('tabEnabled', name, v);
            self.trigger('tabEnabled:' + name,  v);
          } else {
            v.hide();
            self.trigger('tabDisabled', '' , v);
            self.trigger('tabDiabled:' + name,  v);
          }
        });
      }
    }

  },

  render: function() {
      return this;
  }

});

{'fraction_non_alphanumeric': 0.17465224111282843, 'fraction_numerical': 0.0036063884595569293, 'mean_word_length': 2.2412353923205344, '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': '2817213', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1296, 'n_words': 259}