-
Notifications
You must be signed in to change notification settings - Fork 3
/
views-layouts-_main_menu.html.haml. javascript function
23 lines (23 loc) · 2.36 KB
/
views-layouts-_main_menu.html.haml. javascript function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function load_menu_from_plugins(){
<haml_silent> FedenaPlugin::AVAILABLE_MODULES.each do |mod|
</haml_silent><haml_block><haml_silent> unless mod[:more_menu].blank?
</haml_silent><haml_block><haml_silent> sub_menu_flag = 0
</haml_silent><haml_silent> unless mod[:sub_menus].blank?
</haml_silent><haml_block><haml_silent> mod[:sub_menus].each do|mnu|
</haml_silent><haml_block><haml_silent> if can_access_request?(mnu[:action].to_sym, mnu[:controller].to_sym) and mnu[:target_id]==mod[:name]
</haml_silent><haml_block><haml_silent> sub_menu_flag = 1
</haml_silent></haml_block></haml_block></haml_block><haml_silent> arrow = sub_menu_flag==1 ? "<span class=right-arrow>\#{arrow_dir}</span>" : ""
</haml_silent><haml_silent> if mod[:more_menu][:target_id].present?
</haml_silent><haml_block><haml_silent> if can_access_request?(mod[:more_menu][:action].to_sym,mod[:more_menu][:controller].to_sym)
</haml_silent><haml_block><haml_silent> if sub_menu_flag==1
</haml_silent><haml_block> $('#{mod[:more_menu][:target_id]}').insert({bottom: '<li>#{link_to "\#{t(mod[:more_menu][:title]).gsub("'","'")}\#{arrow}", :controller => "\#{mod[:more_menu][:controller]}", :action => "\#{mod[:more_menu][:action]}"}<ul class="level-2" id="#{mod[:name]}"></ul></li>'})
</haml_block><haml_silent> else
</haml_silent><haml_block> $('#{mod[:more_menu][:target_id]}').insert({bottom: '<li>#{link_to "\#{t(mod[:more_menu][:title]).gsub("'","'")}\#{arrow}",:controller => "\#{mod[:more_menu][:controller]}", :action=>"\#{mod[:more_menu][:action]}"}</li>'})
</haml_block></haml_block><haml_silent> unless mod[:sub_menus].blank?
</haml_silent><haml_block><haml_silent> mod[:sub_menus].each do |submenu|
</haml_silent><haml_block><haml_silent> if submenu[:target_id].present?
</haml_silent><haml_block> if ($('#{submenu[:target_id]}')!=null)
{
$('#{submenu[:target_id]}').insert({bottom: '<li>#{link_to "\#{t(submenu[:title]).gsub("'","'")}",:controller => "\#{submenu[:controller]}", :action=>"\#{submenu[:action]}" if can_access_request? "\#{submenu[:action]}".to_sym,"\#{submenu[:controller]}".to_sym}</li>'})
}
</haml_block></haml_block></haml_block></haml_block></haml_block></haml_block>}