Sha256: 28e82171f0a78af6d4f359dcfee5849f39118b6dc79edca9f891d86483f18167

Contents?: true

Size: 1.11 KB

Versions: 28

Compression:

Stored size: 1.11 KB

Contents

class IuguUI.Radio
  defaults:
    none: false

  el: undefined

  @load: ( context ) ->
    selector = "[data-type='iux.form.radio']"
    if context
      elements = context.find(selector)
    else
      elements = $(selector)

    return if elements.length == 0
    
    elements.each ->
      return if $(@).data("iux.initialized") == true

      new IuguUI.Radio
        el: @

      $(@).data "iux.initialized", true

  constructor: ( options ) ->
    @initialize( options )
  
  initialize: ( options ) ->
    _.bindAll @
    @options = _.extend {}, @defaults, options

    return null unless @options.el

    @el = $(@options.el) if @options.el

    radio_classes = "radio"

    @decorator = $('<a>',
      class: radio_classes + ( if @el.is(":checked") then ' selected' else '')
      html: '<div class="outer_decorator"><div class="inner_decorator"></div></div>'
      "data-mode": "toggle"
      "data-input": @el.attr("id")
      "data-group": @el.attr("name")
    )

    @decorator.insertAfter( @el )

    new IuguUI.Button
      el: @decorator
      context: @el

@IuguUI.Radio = IuguUI.Radio

$ ->
  IuguUI.Radio.load()

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
iugu-ux-1.0.25 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.24 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.23 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.22 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.21 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.20 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.19 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.18 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.17 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.16 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.15 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.14 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.13 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.12 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.11 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.10 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.9 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.8 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.7 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee
iugu-ux-1.0.6 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-radio.js.coffee