     switch value
       when on   then @_setOn()
       when off  then @_setOff()
-      
+
   _setDefaultValue: (val) ->
     setTimeout =>
       val = !!val

    , 0

  _setOff:(wCallback = yes)->
    return unless @getValue()
    @inputDefaultValue = off
    @getDomElement().find("input").eq(0).attr "checked",no
    @$('a.on').removeClass('active')

class KDRySwitch extends KDInputView
  constructor:(options)->
    options = $.extend
      type : "switch"                 # mandatory
      size : options.size or "small"  # a String "small" or "big"
    ,options
    super options
    @setClass options.size
    @setPartial "<input class='checkbox hidden no-kdinput' type='checkbox' name='#{@getName()}'/>"

  setDomElement:(cssClass)->
    title = @getOptions().title or ""
    @domElement = $ "<div class='kdinput kdinputswitch-ry off #{cssClass}'>#{title}"+
                    "<a href='#' class='on' title='turn on'>ON</a><a href='#' class='off' title='turn off'>OFF</a></div>"

  setDefaultValue:(value) ->
    switch value
