Sha256: 2cc00ee47654c1f7d0dea723d8b894c28c33c700de897779e0ae97a87ec204d9
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
module MenuHelper def p_menu(id,options={},&block) output = menu_encode_markup(id,options,&block) output += menu_encode_script(id,options) end def p_submenu(label,&block) output = content_tag('li') do content_tag('h3', label); end output += capture(&block) end def p_menu_item(path,options={}) options = options.stringify_keys value = options.delete('value') options["data-icon"] = options['icon'] output = content_tag('li') do link_to(value,path,options) end end protected def menu_encode_markup(id,options={},&block) clientid = sanitize_to_id(id) options = options.stringify_keys options = options.merge(:id => clientid) output = content_tag('ul', options) do capture(&block) end output.html_safe end def menu_encode_script(id,options={}) options = options.stringify_keys clientid = sanitize_to_id(id) widgetvar = options.has_key?("widgetVar") ? options["widgetVar"] : "widget_"+clientid options_ui = options options_ui = options_ui.merge(:id => clientid) options_ui = options_ui.to_json script = '$(function() {' script += "PrimeFaces.cw('Menu','#{widgetvar}',#{options_ui})" script += '});' javascript_tag(script, "id" => clientid+"_s") end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
prime-rails-0.0.12 | app/helpers/menu_helper.rb |
prime-rails-0.0.11 | app/helpers/menu_helper.rb |
prime-rails-0.0.10 | app/helpers/menu_helper.rb |
prime-rails-0.0.9 | app/helpers/menu_helper.rb |