summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vendor/jquery.survival-kit.coffee
blob: 654e167009fb2f610f51e44538798fa17f5fb4e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Array.prototype.empty = ->
  if this.length <= 0
    return true
  else
    return false

$.ns('sk').add {
  # Search Box Helper
  searchBox: ->
    input = $('input.text', this)
    default_mes = input.val()
    input.focus(->
      if input.val() == default_mes
        input.val ''
    ).blur(->
      if input.val() == ''
       input.val default_mes
    )
    
  # Simple Form Style Helper.
  simpleForms: ->
    max = 0
    labels = $("div:not(.boolean) > label", this)
    hints  = $("div:not(.boolean) > .hint", this)
    labels.each ->
      if $(this).width() > max
        max = $(this).width()
    $('> .hint.padded', this).css 'padding-left' : max
    
    # Get the horizontal-spacing (set on the css.)
    horizontal_spacing = parseInt(labels.first().css('margin-right'))
    
    hints.css 'padding-left' : (max + horizontal_spacing)
    $('.actions', this).css 'padding-left' : (max + horizontal_spacing)
    labels.width(max)
}