<commit_before>const {CompositeDisposable} = require('atom');
const { ToolBarItem, addTooltip } = require('./tool-bar-item');
class ToolBarButtonView extends ToolBarItem {
  constructor (options, group) {
    // first calling the super (ToolBarItem) constructor
    super({
      element: document.createElement('button'),
      priority: options.priority
    }, group);

    this.options = options;
    this.enabled = true;


    const classNames = ['btn', 'btn-default', 'tool-bar-btn'];
    if (this.priority < 0) {
      this.putAtEnd();
    }

    if (options.icon) {
      this.addIcon();
    }

    if (options.text) {
      this.addText();
    }

    if (options.tooltip) {
      this.subscriptions = new CompositeDisposable();
      this.subscriptions.add(
        addTooltip(this.options.tooltip, this.options.callback)
      );
    }

    if (options.color) {
      this.addColor();
    }
    if (options.background) {
      this.element.style.background = options.background;
    }

    if (options.class) {
      if (Array.isArray(options.class)) {
        this.element.classList.add(...options.class);
  /** Put the button at the end of the toolbar using 'tool-bar-item-align-end' class. */
  putAtEnd () {
    this.classNames.push('tool-bar-item-align-end');
  }

  /** Add an icon for the button using built-in icons. */
  addIcon () {
    if (this.options.iconset) {
      if (this.options.iconset.startsWith('fa')) {
        this.classNames.push(this.options.iconset, `fa-${this.options.icon}`);
      } else {
        this.classNames.push(this.options.iconset, `${this.options.iconset}-${this.options.icon}`);
      }
    } else {
      this.classNames.push(`icon-${this.options.icon}`);
    }
  }

    this.element.classList.add(...classNames);
  /** Adds a text/html to the button */
  addText () {
    if (this.options.html) {
      this.element.innerHTML = this.options.text;
    } else {
      this.element.textContent = this.options.text;
    }
  }

    this._onMouseDown = this._onMouseDown.bind(this);
    this._onClick = this._onClick.bind(this);
  /** Add color to the button */
  addColor () {
    this.element.style.color = this.options.color;
  }

    this.element.addEventListener('mousedown', this._onMouseDown);
    this.element.addEventListener('click', this._onClick);
  }

  setEnabled (enabled) {
    if (enabled) {
      this.element.classList.remove('disabled');
    } else {
      this.element.classList.add('disabled');
    }
    this.enabled = enabled;
  }

  setSelected (selected) {
    if (selected) {
      this.element.classList.add('selected');
    } else {
      this.element.classList.remove('selected');
    }
  }

  getSelected () {
    return this.element.classList.contains('selected');
  }

  destroy () {
    if (this.subscriptions) {
      this.subscriptions.dispose();
      this.subscriptions = null;
    }
    this.element.removeEventListener('mousedown', this._onMouseDown);
    this.element.removeEventListener('click', this._onClick);
    super.destroy(); // call super.destroy() in the end<commit_msg>addBackgraoundColor refractor<commit_after>const {CompositeDisposable} = require('atom');
const { ToolBarItem, addTooltip } = require('./tool-bar-item');
class ToolBarButtonView extends ToolBarItem {
  constructor (options, group) {
    // first calling the super (ToolBarItem) constructor
    super({
      element: document.createElement('button'),
      priority: options.priority
    }, group);

    this.options = options;
    this.enabled = true;


    const classNames = ['btn', 'btn-default', 'tool-bar-btn'];
    if (this.priority < 0) {
      this.putAtEnd();
    }

    if (options.icon) {
      this.addIcon();
    }

    if (options.text) {
      this.addText();
    }

    if (options.tooltip) {
      this.subscriptions = new CompositeDisposable();
      this.subscriptions.add(
        addTooltip(this.options.tooltip, this.options.callback)
      );
    }

    if (options.color) {
      this.addColor();
    }
    if (options.background) {
      this.addBackgroundColor();
    }

    if (options.class) {
      if (Array.isArray(options.class)) {
        this.element.classList.add(...options.class);
  /** Put the button at the end of the toolbar using 'tool-bar-item-align-end' class. */
  putAtEnd () {
    this.classNames.push('tool-bar-item-align-end');
  }

  /** Add an icon for the button using built-in icons. */
  addIcon () {
    if (this.options.iconset) {
      if (this.options.iconset.startsWith('fa')) {
        this.classNames.push(this.options.iconset, `fa-${this.options.icon}`);
      } else {
        this.classNames.push(this.options.iconset, `${this.options.iconset}-${this.options.icon}`);
      }
    } else {
      this.classNames.push(`icon-${this.options.icon}`);
    }
  }

    this.element.classList.add(...classNames);
  /** Adds a text/html to the button */
  addText () {
    if (this.options.html) {
      this.element.innerHTML = this.options.text;
    } else {
      this.element.textContent = this.options.text;
    }
  }

    this._onMouseDown = this._onMouseDown.bind(this);
    this._onClick = this._onClick.bind(this);
  /** Add color to the button */
  addColor () {
    this.element.style.color = this.options.color;
  }

    this.element.addEventListener('mousedown', this._onMouseDown);
    this.element.addEventListener('click', this._onClick);
  /** Add background color to the button */
  addBackgroundColor () {
    this.element.style.background = this.options.background;
  }
  }

  setEnabled (enabled) {
    if (enabled) {
      this.element.classList.remove('disabled');
    } else {
      this.element.classList.add('disabled');
    }
    this.enabled = enabled;
  }

  setSelected (selected) {
    if (selected) {
      this.element.classList.add('selected');
    } else {
      this.element.classList.remove('selected');
    }
  }

  getSelected () {
    return this.element.classList.contains('selected');
  }

  destroy () {
    if (this.subscriptions) {
      this.subscriptions.dispose();
      this.subscriptions = null;
    }
    this.element.removeEventListener('mousedown', this._onMouseDown);
    this.element.removeEventListener('click', this._onClick);
    super.destroy(); // call super.destroy() in the end
{'fraction_non_alphanumeric': 0.15143769968051118, 'fraction_numerical': 0.0003194888178913738, 'mean_word_length': 2.7648827420324715, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1536272', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1946, 'n_words': 340}