<commit_before>_ = require "underscore"
Backbone = require "backbone"
Tool = require "./tool"
button_tool_template = require "./button_tool_template"

class ButtonToolButtonView extends Backbone.View
  tagName: "li"
  template: button_tool_template

  events: () ->
    # TODO (bev) this seems to work OK but maybe there is a better way
    if 'ontouchstart' of document
      return { 'touchstart .bk-toolbar-button': '_clicked' }
    else
      return { 'click .bk-toolbar-button': '_clicked' }

  initialize: (options) ->
    super(options)
    @$el.html(@template(@model.attrs_and_props()))
    @listenTo(@model, 'change:active', () => @render())
    @listenTo(@model, 'change:disabled', () => @render())
    @render()

  render: () ->
    @$el.children('button')
        .prop("disabled", @model.get('disabled'))
        .toggleClass('active', @model.get('active'))
    return @

  _clicked: (e) ->

class ButtonToolView extends Tool.View

class ButtonTool extends Tool.Model

  initialize: (attrs, options) ->
    super(attrs, options)
    @register_property('tooltip', () ->@get('tool_name'))

  nonserializable_attribute_names: () ->
    super().concat(['icon'])

  defaults: () ->
    return _.extend({}, super(), {
      active: false
      disabled: if @disabled? then @disabled else false
      tool_name: @tool_name
      icon: @icon
    })

module.exports =
  Model: ButtonTool
  View: ButtonToolView
  ButtonView: ButtonToolButtonView<commit_msg>Mark ButtonTool.disabled property as non-serializable<commit_after>_ = require "underscore"
Backbone = require "backbone"
Tool = require "./tool"
button_tool_template = require "./button_tool_template"

class ButtonToolButtonView extends Backbone.View
  tagName: "li"
  template: button_tool_template

  events: () ->
    # TODO (bev) this seems to work OK but maybe there is a better way
    if 'ontouchstart' of document
      return { 'touchstart .bk-toolbar-button': '_clicked' }
    else
      return { 'click .bk-toolbar-button': '_clicked' }

  initialize: (options) ->
    super(options)
    @$el.html(@template(@model.attrs_and_props()))
    @listenTo(@model, 'change:active', () => @render())
    @listenTo(@model, 'change:disabled', () => @render())
    @render()

  render: () ->
    @$el.children('button')
        .prop("disabled", @model.get('disabled'))
        .toggleClass('active', @model.get('active'))
    return @

  _clicked: (e) ->

class ButtonToolView extends Tool.View

class ButtonTool extends Tool.Model

  initialize: (attrs, options) ->
    super(attrs, options)
    @register_property('tooltip', () ->@get('tool_name'))

  nonserializable_attribute_names: () ->
    super().concat(['icon', 'disabled'])

  defaults: () ->
    return _.extend({}, super(), {
      active: false
      disabled: if @disabled? then @disabled else false
      tool_name: @tool_name
      icon: @icon
    })

module.exports =
  Model: ButtonTool
  View: ButtonToolView
  ButtonView: ButtonToolButtonView
{'fraction_non_alphanumeric': 0.1496301277740417, 'fraction_numerical': 0.0, 'mean_word_length': 3.6630094043887147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '7546487', 'n_tokens_mistral': 912, 'n_tokens_neox': 893, 'n_words': 222}