Module: Skyline::ButtonHelper

Defined in:
app/helpers/skyline/button_helper.rb

Instance Method Summary collapse

Instance Method Details

#button_text(key) ⇒ Object

Translates the key if it’s a symbol otherwise just places key –



28
29
30
# File 'app/helpers/skyline/button_helper.rb', line 28

def button_text(key)
  (key.kind_of?(Symbol) ? t(key, :scope => :buttons) : key).html_safe
end


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/skyline/button_helper.rb', line 3

def menu_button(title, options={}, &block)
  options.reverse_merge! :id => Guid.new
  
  contents = capture(&block)
  
  txt = <<-EOS
  <dl class="menubutton" id="#{options[:id]}">
    <dt>
      <span class="label">#{title}</span>
      <a class="toggle" href="#"><span><span>down</span></span></a>
    </dt>
    <dd>
      #{contents}
    </dd>
  </dl>
  <script type="text/javascript" charset="utf-8">
    new Skyline.MenuButton('#{options[:id]}')
  </script>
  EOS
  
  txt.html_safe
end

#submit_button(label, options = {}) ⇒ Object

Places a <button type=“submit”>..</button> tag

Parameters

src

The location of the image relative to the locale directory

options

Options to pass through to content_tag

Options

:value

If value is a symbol, it will be translated in scope buttons



41
42
43
44
45
46
# File 'app/helpers/skyline/button_helper.rb', line 41

def submit_button(label,options={})
  convert_boolean_attributes!(options, %w( disabled ))
  
  options.reverse_merge! :type => "submit"
  ("button", button_text(label) ,options)
end

#submit_button_to(label, options = {}, html_options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/helpers/skyline/button_helper.rb', line 48

def submit_button_to(label,options={},html_options={})
  
  html_options = html_options.stringify_keys
  disabled = html_options[:disabled]
  convert_boolean_attributes!(html_options, %w( disabled ))

  if method = html_options.delete('method')
    html_options["data-method"] = method
  else
    html_options["data-method"] = "post"
  end
  
  if confirm = html_options.delete("confirm")
    html_options["data-confirm"] = confirm
  end
  
  html_options["data-url"] = options.is_a?(String) ? options : self.url_for(options)
  
  html_options.reverse_merge! :type => "submit"
  
  ("button", button_text(label) ,html_options)
end