<commit_before>goog.provide 'athena.lib.ToolbarView'

goog.require 'athena.lib.View'

# view for generating and containing buttons
class athena.lib.ToolbarView extends athena.lib.View

  initialize: =>
    super
    @buttons = @options.buttons ? []

  render: =>
    super
    @$el.empty()
    _.each @buttons, @renderButton
    @

  renderButton: (button) ->
    # append views.
    if button instanceof Backbone.View
      @$el.append button.render().el

    # append selectors
    else if button instanceof $
      @$el.append button

    # bootstrap btn-toolbar from array
    else if _.isArray button
      # TODO implement bootstrap btn-toolbar setup.

    # bootstrap btn-group (dropdown) from object
    else if _.isObject(button) && _.isArray button.dropdown
      # TODO implement renderDropdownButtonObject
      # @renderDropdownButtonObject button

    # render each button
    else if _.isObject(button)
      @$el.append @buttonFromObject button

  buttonFromObject: (button) ->
    btn = $ '<button>'
    btn.addClass 'btn'
    btn.text button.text

    btn.addClass(button.className) if button.className
    btn.attr('id', button.id) if button.id

    _.each (button.events ? {}), (callback, eventName) =>
      btn.on eventName, callback

    btn<commit_msg>ToolbarView: -> -> =><commit_after>goog.provide 'athena.lib.ToolbarView'

goog.require 'athena.lib.View'

# view for generating and containing buttons
class athena.lib.ToolbarView extends athena.lib.View

  initialize: =>
    super
    @buttons = @options.buttons ? []

  render: =>
    super
    @$el.empty()
    _.each @buttons, @renderButton
    @

  renderButton: (button) =>
    # append views.
    if button instanceof Backbone.View
      @$el.append button.render().el

    # append selectors
    else if button instanceof $
      @$el.append button

    # bootstrap btn-toolbar from array
    else if _.isArray button
      # TODO implement bootstrap btn-toolbar setup.

    # bootstrap btn-group (dropdown) from object
    else if _.isObject(button) && _.isArray button.dropdown
      # TODO implement renderDropdownButtonObject
      # @renderDropdownButtonObject button

    # render each button
    else if _.isObject(button)
      @$el.append @buttonFromObject button

  buttonFromObject: (button) =>
    btn = $ '<button>'
    btn.addClass 'btn'
    btn.text button.text

    btn.addClass(button.className) if button.className
    btn.attr('id', button.id) if button.id

    _.each (button.events ? {}), (callback, eventName) =>
      btn.on eventName, callback

    btn
{'fraction_non_alphanumeric': 0.106640625, 'fraction_numerical': 0.0, 'mean_word_length': 2.94, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, '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': '1195372', 'n_tokens_mistral': 768, 'n_tokens_neox': 742, 'n_words': 204}