Sha256: 6376ce31a50f4ea2c19c4be90d295ccb0d45d9caaf9cc87e73dbad408ec76459

Contents?: true

Size: 1.43 KB

Versions: 48

Compression:

Stored size: 1.43 KB

Contents

class SelectParser
  
  constructor: ->
    @options_index = 0
    @parsed = []

  add_node: (child) ->
    if child.nodeName is "OPTGROUP"
      this.add_group child
    else
      this.add_option child

  add_group: (group) ->
    group_position = @parsed.length
    @parsed.push
      array_index: group_position
      group: true
      label: group.label
      children: 0
      disabled: group.disabled
    this.add_option( option, group_position, group.disabled ) for option in group.childNodes

  add_option: (option, group_position, group_disabled) ->
    if option.nodeName is "OPTION"
      if option.text != ""
        if group_position?
          @parsed[group_position].children += 1
        @parsed.push
          array_index: @parsed.length
          options_index: @options_index
          value: option.value
          text: option.text
          html: option.innerHTML
          selected: option.selected
          disabled: if group_disabled is true then group_disabled else option.disabled
          group_array_index: group_position
          classes: option.className
          style: option.style.cssText
      else
        @parsed.push
          array_index: @parsed.length
          options_index: @options_index
          empty: true
      @options_index += 1

SelectParser.select_to_array = (select) ->
  parser = new SelectParser()
  parser.add_node( child ) for child in select.childNodes
  parser.parsed

this.SelectParser = SelectParser

Version data entries

48 entries across 48 versions & 4 rubygems

Version Path
fat_free_crm-0.22.1 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.22.0 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.21.0 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.20.1 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.20.0 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.19.2 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.19.0 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.18.2 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.14.2 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.15.2 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.16.4 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.17.3 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.18.1 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.18.0 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.14.1 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.15.1 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.16.3 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.17.2 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.16.2 vendor/assets/javascripts/lib/select-parser.coffee
fat_free_crm-0.17.1 vendor/assets/javascripts/lib/select-parser.coffee