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