Sha256: 7a50d24af44360a68ee6db4348a6b6760f980fa98c95ba1a34bd9f27d7ae4fb3

Contents?: true

Size: 1.72 KB

Versions: 7

Compression:

Stored size: 1.72 KB

Contents

### = Description
 ## Simple button component, designed to be extended for any
 ## actual functionality above regular HControl.
 ###
HButton = HControl.extend

  componentName: 'button'
  optimizeWidthOnRefresh: true
  controlDefaults: HControlDefaults.extend
    defaultKeyClick: false # use defaultResponder instead; it's a better name
    defaultResponder: false
    pack: false

  defaultEvents:
    click: true

  ###
  # = Description
  # setStyle function for button.
  #
  ###
  setStyle: (_name, _value, _setElemStyle)->
    if _setElemStyle?
      @base(_name,_value)
    else
      @setStyleOfPart('label',_name,_value)
    @

  defaultKey: ->
    if @enabled and ( @options.defaultKeyClick or @options.defaultResponder )
      if @options.defaultKeyClick and !@isProduction
        console.warn("defaultKeyClick is deprecated; use defaultResponder instead (sorry)")
      @setCSSClass('clickeffect')
      @timeouts.push( setTimeout( =>
        @unsetCSSClass('clickeffect')
      , 200 ) )
      @click()
      return false
    null

  click: ->
    console.log('no click action defined in HButton') if !@isProduction

  refresh: ->
    @base()
    if @options.defaultKeyClick or @options.defaultResponder
      if @options.defaultKeyClick and !@isProduction
        console.warn("defaultKeyClick is deprecated; use defaultResponder instead (sorry)")
      @setCSSClass('action')
    else
      @unsetCSSClass('action')

  labelPadding: 0
  optimizeWidth: ->
    _labelWidth = @stringWidth(@label,null,@markupElemIds.label)
    _labelWidth += @labelPadding+Math.floor(@rect.height*0.6)
    if @rect.width != _labelWidth
      # console.log(@viewId,'labelWidth:',@rect.width,'->',_labelWidth)
      @rect.setWidth(_labelWidth)
      @drawRect()

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rsence-pre-3.0.0.16 client/js/controls/button/button.coffee
rsence-pre-3.0.0.15 client/js/controls/button/button.coffee
rsence-pre-3.0.0.14 client/js/controls/button/button.coffee
rsence-pre-3.0.0.12 client/js/controls/button/button.coffee
rsence-pre-3.0.0.11 client/js/controls/button/button.coffee
rsence-pre-3.0.0.10 client/js/controls/button/button.coffee
rsence-pre-3.0.0.9 client/js/controls/button/button.coffee