let user can choose to expand next layer
This commit is contained in:
parent
3228a30279
commit
a13b509193
|
@ -35,9 +35,9 @@ class SiteMenuWidgetsController < ApplicationController
|
|||
#item = []
|
||||
@count += 1
|
||||
if (!item1["children"].nil? && item1["children"].length!=0)
|
||||
@li_index << @count
|
||||
if children_is_current(item1['obj'])
|
||||
@ul_index << ( @li_index.length - 1 )
|
||||
@count1 += 1
|
||||
if (@expand_current_layer && children_is_current(item1['obj'])) || (@expand_next_layer && item1['obj'].id == @page_id)
|
||||
@ul_index << [@count1, @count]
|
||||
end
|
||||
create_menu_bool_object(item1['children'])
|
||||
#item = [children_is_current(item1['obj']),item1['obj'].id==@page_id,create_menu_bool_object(item1['children'])]
|
||||
|
@ -57,6 +57,8 @@ class SiteMenuWidgetsController < ApplicationController
|
|||
page = Page.where(:page_id => params[:page_id]).first
|
||||
@page_id = page.id
|
||||
@expand_layer = false
|
||||
@expand_next_layer = false
|
||||
@expand_current_layer = false
|
||||
if page.parent_page == Page.root
|
||||
@pages = page.sorted_published_child_pages
|
||||
else
|
||||
|
@ -80,25 +82,32 @@ class SiteMenuWidgetsController < ApplicationController
|
|||
value = YAML.load(select_option.value)
|
||||
if value[I18n.locale] == t('site_menu.yes')
|
||||
@expand_layer = true
|
||||
@expand_current_layer = true
|
||||
end
|
||||
elsif !(@show_options.nil?) && select_option.field_name == @show_options.keys[2].to_s
|
||||
value = YAML.load(select_option.value)
|
||||
if value[I18n.locale] == t('site_menu.yes')
|
||||
@expand_layer = true
|
||||
@expand_next_layer = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ul_index=[]
|
||||
@li_index= []
|
||||
@count = -1
|
||||
@count1 = 0
|
||||
@li_index = []
|
||||
title = subpart.title
|
||||
items = create_json(@pages)
|
||||
create_menu_bool_object(items)
|
||||
if @expand_layer
|
||||
if @expand_layer
|
||||
create_menu_bool_object(items)
|
||||
temp = @ul_index.reverse.collect do |ul_index|
|
||||
tp = @li_index[ul_index] + 1
|
||||
"var ul_tp = $('div[data-subpart-id=#{subpart.id}]').find('ul').eq(#{tp})
|
||||
ul_tp.removeClass('dropdown-menu')
|
||||
$('div[data-subpart-id=#{subpart.id}]').find('li').eq(#{@li_index[ul_index]}).find('span').eq(0).remove()
|
||||
"
|
||||
end
|
||||
"var ul_tp = $('div[data-subpart-id=#{subpart.id}]').find('ul').eq(#{ul_index[0]})
|
||||
ul_tp.removeClass('dropdown-menu')
|
||||
$('div[data-subpart-id=#{subpart.id}]').find('li').eq(#{ul_index[1]}).find('span').eq(0).remove()
|
||||
"
|
||||
end
|
||||
if temp.length != 0
|
||||
temp = temp.join(' ')
|
||||
expand_script = "<script type='text/javascript'>" +
|
||||
|
|
|
@ -2,5 +2,6 @@ en:
|
|||
site_menu:
|
||||
show_previous_layer: Show Previous Layer
|
||||
expand_current_layer: Expand Current Layer
|
||||
expand_next_layer: Expand Next Layer
|
||||
'yes': 'Yes'
|
||||
'no': 'No'
|
||||
|
|
|
@ -2,5 +2,6 @@ zh_tw:
|
|||
site_menu:
|
||||
show_previous_layer: 顯示上一層
|
||||
expand_current_layer: 展開所在的那層
|
||||
expand_next_layer: 展開下一層
|
||||
'yes': 是
|
||||
'no': 否
|
|
@ -5,16 +5,19 @@ module SiteMenuWidget
|
|||
data = {}
|
||||
key1 = {}
|
||||
key2 = {}
|
||||
key3 = {}
|
||||
value1 = {}
|
||||
value2 = {}
|
||||
translate_data.each do |t_data|
|
||||
key1[t_data.keys[0]] = t_data.values[0]['site_menu']['show_previous_layer']
|
||||
key2[t_data.keys[0]] = t_data.values[0]['site_menu']['expand_current_layer']
|
||||
key3[t_data.keys[0]] = t_data.values[0]['site_menu']['expand_next_layer']
|
||||
value2[t_data.keys[0]] = t_data.values[0]['site_menu']['no']
|
||||
value1[t_data.keys[0]] = t_data.values[0]['site_menu']['yes']
|
||||
end
|
||||
data[key1] = [value2,value1]
|
||||
data[key2] = [value2,value1]
|
||||
data[key3] = [value2,value1]
|
||||
OrbitApp.registration "SiteMenuWidget", :type => "OrbitWidget" do
|
||||
widget_label "SiteMenu"
|
||||
widget_methods ["widget"]
|
||||
|
|
Loading…
Reference in New Issue