Module: Skyline::ButtonHelper
- Defined in:
- app/helpers/skyline/button_helper.rb
Instance Method Summary collapse
-
#button_text(key) ⇒ Object
Translates the key if it’s a symbol otherwise just places key –.
- #menu_button(title, options = {}, &block) ⇒ Object
-
#submit_button(label, options = {}) ⇒ Object
Places a <button type=“submit”>..</button> tag.
- #submit_button_to(label, options = {}, html_options = {}) ⇒ Object
Instance Method Details
#button_text(key) ⇒ Object
Translates the key if it’s a symbol otherwise just places key –
26 27 28 |
# File 'app/helpers/skyline/button_helper.rb', line 26 def (key) key.kind_of?(Symbol) ? t(key, :scope => :buttons) : key end |
#menu_button(title, options = {}, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/helpers/skyline/button_helper.rb', line 3 def (title, ={}, &block) .reverse_merge! :id => Guid.new contents = capture(&block) concat <<-EOS <dl class="menubutton" id="#{[: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('#{[:id]}') </script> EOS 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
–
39 40 41 42 43 44 |
# File 'app/helpers/skyline/button_helper.rb', line 39 def (label,={}) convert_boolean_attributes!(, %w( disabled )) .reverse_merge! :type => "submit" content_tag("button", (label) ,) end |
#submit_button_to(label, options = {}, html_options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/skyline/button_helper.rb', line 46 def (label,={},={}) = .stringify_keys disabled = [:disabled] convert_boolean_attributes!(, %w( disabled )) method_tag = '' if (method = .delete('method')) && %w{put delete}.include?(method.to_s) method_tag = tag('input', :type => 'hidden', :name => '_method', :value => method.to_s) end form_method = method.to_s == 'get' ? 'get' : 'post' request_token_tag = '' if form_method == 'post' && protect_against_forgery? request_token_tag = tag(:input, :type => "hidden", :name => request_forgery_protection_token.to_s, :value => form_authenticity_token) end if confirm = .delete("confirm") ["onclick"] = "return #{confirm_javascript_function(confirm)};" end url = .is_a?(String) ? : self.url_for() name ||= url .reverse_merge! :type => "submit" "<form method=\"#{form_method}\" action=\"#{escape_once url}\" class=\"button-to\"><div>" + method_tag + content_tag("button", (label) ,) + request_token_tag + "</div></form>" end |