Sha256: 54e208a3e8cd6b2868b19056d6e81474ac0eab042a08654d342dd720ba726360

Contents?: true

Size: 894 Bytes

Versions: 4

Compression:

Stored size: 894 Bytes

Contents

## nice labeled inputs

labelHander = (input) ->
  label = input.closest('label')
  window.setTimeout (->
    hasValue = if input.val().length > 0 then true else false
    if hasValue
      label.addClass "has-value"
    else
      label.removeClass "has-value"
    return
  ), 10
  return

$ ->
  
  if $("label.wrapping").length > 0
    $("label.wrapping input, label.wrapping select").each ->
      labelHander( $(@) )
  $("body").on "focus", "label.wrapping input, label.wrapping select", ->
    inpt = $(@)
    inpt.closest('label').addClass "has-focus"
    labelHander inpt
  $("body").on "keydown", "label.wrapping input", ->
    labelHander( $(@) )
  $("body").on "change", "label.wrapping select", ->
    labelHander( $(@) )
  $("body").on "blur", "label.wrapping input, label.wrapping select", ->
    inpt = $(@)
    inpt.closest('label').removeClass "has-focus"
    labelHander inpt

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
magic_stylez-0.0.330 vendor/assets/javascripts/magic/wrapped_fields.js.coffee
magic_stylez-0.1.1 vendor/assets/javascripts/magic/wrapped_fields.js.coffee
magic_stylez-0.1.0 vendor/assets/javascripts/magic/wrapped_fields.js.coffee
magic_stylez-0.0.0.99 vendor/assets/javascripts/magic/wrapped_fields.js.coffee