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 –
28 29 30 |
# File 'app/helpers/skyline/button_helper.rb', line 28 def (key) (key.kind_of?(Symbol) ? t(key, :scope => :buttons) : key).html_safe 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 23 24 |
# File 'app/helpers/skyline/button_helper.rb', line 3 def (title, ={}, &block) .reverse_merge! :id => Guid.new contents = capture(&block) txt = <<-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 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 (label,={}) convert_boolean_attributes!(, %w( disabled )) .reverse_merge! :type => "submit" content_tag("button", (label) ,) 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 (label,={},={}) = .stringify_keys disabled = [:disabled] convert_boolean_attributes!(, %w( disabled )) if method = .delete('method') ["data-method"] = method else ["data-method"] = "post" end if confirm = .delete("confirm") ["data-confirm"] = confirm end ["data-url"] = .is_a?(String) ? : self.url_for() .reverse_merge! :type => "submit" content_tag("button", (label) ,) end |