Module: ApplicationHelper
- Defined in:
- lib/html_helpers/form_object.rb,
lib/html_helpers/icons_helper.rb,
lib/html_helpers/inside_layout.rb
Constant Summary collapse
- DefaultIconCategory =
"default"
Instance Method Summary collapse
- #icon_path(category, icon, root = '') ⇒ Object
- #icon_src(category, icon, root = '') ⇒ Object
- #icon_tag(icon, options = {}) ⇒ Object
- #inside_layout(layout, &block) ⇒ Object
- #submit_button(value = "Save changes", url_for_options = {}, options = {}, *parameters_for_url) ⇒ Object
Instance Method Details
#icon_path(category, icon, root = '') ⇒ Object
14 15 16 |
# File 'lib/html_helpers/icons_helper.rb', line 14 def icon_path(category, icon, root = '') File.join('', root, 'images', category.to_s, icon.to_s + '.png') end |
#icon_src(category, icon, root = '') ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/html_helpers/icons_helper.rb', line 18 def icon_src(category, icon, root = '') paths = [] paths << icon_path(category, icon) paths << icon_path(category, icon, root) paths << icon_path(DefaultIconCategory, icon, root) paths << icon_path(DefaultIconCategory, icon) paths.each { |p| $stderr.puts ("Icon Path: " + File.join(RAILS_ROOT, 'public', p)) } return paths.find { |p| File.exist?(File.join(RAILS_ROOT, 'public', p)) } end |
#icon_tag(icon, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/html_helpers/icons_helper.rb', line 29 def icon_tag(icon, = {}) category = .delete(:controller) || .delete(:category) || controller.controller_name root = .delete('root') || '' if defined? Engines.plugins plugin = .delete(:plugin) || IconHelper::current_plugin(caller) root = File.join("plugin_assets", plugin.name) unless plugin.nil? end css_class = .delete(:class) || 'icon' src = icon_src(category, icon, root) if src return tag('img', {'class' => css_class, 'src' => src}) else return [:unavailable] end end |
#inside_layout(layout, &block) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/html_helpers/inside_layout.rb', line 3 def inside_layout(layout, &block) @template.instance_variable_set("@content_for_layout", capture(&block)) layout = layout.include?("/") ? layout : "layouts/#{layout}" if layout buffer = eval("_erbout", block.binding) buffer.concat(@template.render_file(layout, true)) end |
#submit_button(value = "Save changes", url_for_options = {}, options = {}, *parameters_for_url) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/html_helpers/form_object.rb', line 2 def (value = "Save changes", = {}, = {}, *parameters_for_url) .stringify_keys! ["action"] = url_for(, *parameters_for_url) if .size != 0 if disable_with = .delete("disable_with") ["onclick"] = "this.disabled=true;this.value='#{disable_with}';this.form.submit();#{["onclick"]}" end if action = .delete("action") ["onclick"] = "this.form.action='#{escape_javascript(action)}';#{['onclick']}" end if method = .delete("method") ["onclick"] = "this.form.method='#{escape_javascript(method)}';#{['onclick']}" end if confirm = .delete("confirm") ["onclick"] = "if (!#{confirm_javascript_function(confirm)}){return false};#{['onclick']}" end tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(.stringify_keys) end |