<commit_before>#= require submachine
#= require eventspitter
#= require jquery

namespace "Lib.StatefulWidget", ->

  # The StatefulWidget provides an abstraction over DOM elements, much like a
  # Backbone view. The resulting object is eventful, you can listen and respond
  # to javascript events (for example, DOM events). It's also stateful and you
  # can provide specific behaviour and DOM styling for its states.
  #
  # To use it, make a new class that extends it.
  #
  # Example:
  #
  #   class MenuWidget extends Lib.StatefulWidget
  #     @hasStates 'active', 'inactive'
  #
  #     @transition from: 'inactive', to: 'active',   on: 'activate'
  #     @transition from: 'active',   to: 'inactive', on: 'deactivate'
  #
  #     @mapEvents
  #       mouseover: 'activate'
  #       mouseout:  'deactivate'
  #
  #     @onEnter 'active',   showTheMenu
  #     @onEnter 'inactive', hideTheMenu
  #
  #   menu = new MenuWidget('.menu')
  #
  #   menu.on 'enterState:active', ->
  #     Counter.increment 'userActivatedMenu'
  #
  # See:
  #
  #   Submachine:   https://github.com/lucaong/submachine
  #   EventSpitter: https://github.com/lucaong/eventspitter
  #
  class StatefulWidget extends Lib.Module

    @extendAndInclude Submachine
    @extendAndInclude EventSpitter

    @onEnter "*", ->
      @$el.addClass @state
      @emit "enterState:#{@state}"

    @onLeave "*", ->
      @$el.removeClass @state
      @emit "leaveState:#{@state}"

    constructor: ( selector ) ->
      @_uid ?= @_generateUID()
      @$el = $( selector )
      @el = @$el[0]<commit_msg>Throw error when using the selector failed<commit_after>#= require submachine
#= require eventspitter
#= require jquery

namespace "Lib.StatefulWidget", ->

  # The StatefulWidget provides an abstraction over DOM elements, much like a
  # Backbone view. The resulting object is eventful, you can listen and respond
  # to javascript events (for example, DOM events). It's also stateful and you
  # can provide specific behaviour and DOM styling for its states.
  #
  # To use it, make a new class that extends it.
  #
  # Example:
  #
  #   class MenuWidget extends Lib.StatefulWidget
  #     @hasStates 'active', 'inactive'
  #
  #     @transition from: 'inactive', to: 'active',   on: 'activate'
  #     @transition from: 'active',   to: 'inactive', on: 'deactivate'
  #
  #     @mapEvents
  #       mouseover: 'activate'
  #       mouseout:  'deactivate'
  #
  #     @onEnter 'active',   showTheMenu
  #     @onEnter 'inactive', hideTheMenu
  #
  #   menu = new MenuWidget('.menu')
  #
  #   menu.on 'enterState:active', ->
  #     Counter.increment 'userActivatedMenu'
  #
  # See:
  #
  #   Submachine:   https://github.com/lucaong/submachine
  #   EventSpitter: https://github.com/lucaong/eventspitter
  #
  class StatefulWidget extends Lib.Module

    @extendAndInclude Submachine
    @extendAndInclude EventSpitter

    @onEnter "*", ->
      @$el.addClass @state
      @emit "enterState:#{@state}"

    @onLeave "*", ->
      @$el.removeClass @state
      @emit "leaveState:#{@state}"

    constructor: ( selector ) ->
      @_uid ?= @_generateUID()
      @$el = $( selector )
      throw new Error "Unable to select DOM element with selector '#{selector}'" unless @$el.length
      @el = @$el[0]
{'fraction_non_alphanumeric': 0.12496190185918928, 'fraction_numerical': 0.0006095702529716549, 'mean_word_length': 2.9399759903961584, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 4, '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': '1980992', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1033, 'n_words': 288}