<commit_before>"use strict";

var _ = require('../util/helpers');
var Component = require('./Component');
var ScrollPane = require('./ScrollPane');
var $$ = Component.$$;
var Icon = require('./FontAwesomeIcon');

function TOCPanel() {
  Component.apply(this, arguments);

  var toc = this.context.toc;
  toc.connect(this, {
    'toc:updated': this.onTOCUpdated
  });
}

TOCPanel.Prototype = function() {
  this.getDocument = function() {
    return this.context.doc;
  };

  this.onTOCUpdated = function() {
    this.rerender();
  };

  this.dispose = function() {
    var toc = this.context.toc;
    toc.disconnect(this);
  };

  this.render = function() {
    var toc = this.context.toc;
    var activeEntry = toc.activeEntry;

    var tocEntries = $$("div")
      .addClass("se-toc-entries")
      .ref('tocEntries');

    _.each(toc.getEntries(), function(entry) {
      var level = entry.level;

      var tocEntryEl = $$('a')
        .addClass('se-toc-entry')
        .addClass('sm-level-'+level)
        .attr({
          href: "#",
          "data-id": entry.id,
        })
        .ref(entry.id)
        // TODO: Why does handleClick get bound to this.refs.panelEl and not this?
        // Seems that handlers will be bound to the parent, not the owner.
        .on('click', this.handleClick.bind(this))
        .append(
          $$(Icon, {icon: 'fa-caret-right'}),
          entry.name
        );
      if (activeEntry === entry.id) {
        tocEntryEl.addClass("sm-active");
      }
      tocEntries.append(tocEntryEl);
    }, this);

    var el = $$('div').addClass('sc-toc-panel').append(
      $$(ScrollPane).ref('panelEl').append(
        tocEntries
      )
    );
    return el;
  };

  this.handleClick = function(e) {
    var nodeId = e.currentTarget.dataset.id;
    e.preventDefault();
    // var toc = this.context.toc;
    // toc.emit('entry:selected', nodeId);<commit_msg>Get rid of component bug workarounds.<commit_after>"use strict";

var _ = require('../util/helpers');
var Component = require('./Component');
var ScrollPane = require('./ScrollPane');
var $$ = Component.$$;
var Icon = require('./FontAwesomeIcon');

function TOCPanel() {
  Component.apply(this, arguments);

  var toc = this.context.toc;
  toc.connect(this, {
    'toc:updated': this.onTOCUpdated
  });
}

TOCPanel.Prototype = function() {
  this.getDocument = function() {
    return this.context.doc;
  };

  this.onTOCUpdated = function() {
    this.rerender();
  };

  this.dispose = function() {
    var toc = this.context.toc;
    toc.disconnect(this);
  };

  this.render = function() {
    var toc = this.context.toc;
    var activeEntry = toc.activeEntry;

    var tocEntries = $$("div")
      .addClass("se-toc-entries")
      .ref('tocEntries');

    _.each(toc.getEntries(), function(entry) {
      var level = entry.level;

      var tocEntryEl = $$('a')
        .addClass('se-toc-entry')
        .addClass('sm-level-'+level)
        .attr({
          href: "#",
          "data-id": entry.id,
        })
        .ref(entry.id)
        // TODO: Why does handleClick get bound to this.refs.panelEl and not this?
        // Seems that handlers will be bound to the parent, not the owner.
        .on('click', this.handleClick)
        .append(
          $$(Icon, {icon: 'fa-caret-right'}),
          entry.name
        );
      if (activeEntry === entry.id) {
        tocEntryEl.addClass("sm-active");
      }
      tocEntries.append(tocEntryEl);
    }, this);

    var el = $$('div').addClass('sc-toc-panel').append(
      $$(ScrollPane).ref('panelEl').append(
        tocEntries
      )
    );
    return el;
  };

  this.handleClick = function(e) {
    var nodeId = e.currentTarget.dataset.id;
    e.preventDefault();
{'fraction_non_alphanumeric': 0.16850013415615778, 'fraction_numerical': 0.0, 'mean_word_length': 2.4296228150873964, 'pattern_counts': {'":': 2, '<': 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': '5140192', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1185, 'n_words': 243}