Add read more position option.
This commit is contained in:
parent
667c5e513b
commit
8d7893a677
|
@ -219,12 +219,16 @@ class AnnouncementsController < ApplicationController
|
|||
$(document).ready(function(){
|
||||
var first_filter_tab = $("[data-subpart-id=\"'+subpart.id.to_s+'\"] .filter_tab").eq(0);
|
||||
var read_more_url = first_filter_tab.data("read_more");
|
||||
if(read_more_url.length != 0)
|
||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").attr("href",read_more_url)
|
||||
if(read_more_url.length != 0){
|
||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").attr("href",read_more_url);
|
||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").text(first_filter_tab.text());
|
||||
}
|
||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .filter_tab").click(function(){
|
||||
var read_more_url = $(this).data("read_more");
|
||||
if(read_more_url.length != 0)
|
||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").attr("href",read_more_url)
|
||||
if(read_more_url.length != 0){
|
||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").attr("href",read_more_url);
|
||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").text($(this).text());
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
@ -255,7 +259,51 @@ class AnnouncementsController < ApplicationController
|
|||
</style>
|
||||
'
|
||||
else
|
||||
extra_html = ""
|
||||
read_more_text = I18n.t("announcement.more")
|
||||
if cats.count == 1 && cats[0] != "all"
|
||||
begin
|
||||
read_more_text = cats_translations[cats[0]]
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
extra_html = "
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-annc__more\").text(\"#{read_more_text}\");
|
||||
})
|
||||
</script>
|
||||
"
|
||||
end
|
||||
if (@read_more_option != 0 rescue false)
|
||||
extra_html += "
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
var read_more_position = #{@read_more_option};
|
||||
var read_more_block = $(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-annc__more\");
|
||||
if(read_more_position == 1 || read_more_position == 2){
|
||||
read_more_block.addClass(\"pull-left\");
|
||||
}else{
|
||||
read_more_block.addClass(\"pull-right\");
|
||||
}
|
||||
if(read_more_position == 1 || read_more_position == 3){
|
||||
var first_element = $(\"[data-subpart-id=\\\"#{subpart.id}\\\"] > *:eq(0)\");
|
||||
var div_clearfix = $('<div class=\"clearfix\"></div>')
|
||||
if(first_element.height() == 0){
|
||||
read_more_block.appendTo(div_clearfix);
|
||||
}else{
|
||||
div_clearfix = read_more_block;
|
||||
}
|
||||
first_element.before(div_clearfix);
|
||||
}else{
|
||||
var div_clearfix = $('<div class=\"clearfix\"></div>');
|
||||
read_more_block.appendTo(div_clearfix);
|
||||
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] > *:eq(-1)\").after(div_clearfix);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
"
|
||||
end
|
||||
{
|
||||
"announcements" => anns,
|
||||
|
@ -280,7 +328,9 @@ class AnnouncementsController < ApplicationController
|
|||
def get_tabs_option
|
||||
subpart = OrbitHelper.get_current_widget
|
||||
tab_options = ["not_enable_tabs","enable_tabs_with_categories_include_all","enable_tabs_with_categories"]
|
||||
read_more_options = ['default','upper_left','lower_left','upper_right','lower_right']
|
||||
@tab_option = 0
|
||||
@read_more_option = 0
|
||||
if subpart.methods.include? 'select_options'.to_sym
|
||||
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
|
||||
@show_options = modile_app.show_options rescue nil
|
||||
|
@ -298,6 +348,18 @@ class AnnouncementsController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
if !(@show_options.nil?) && select_option.field_name == @show_options.keys[2].to_s
|
||||
value = YAML.load(select_option.value)
|
||||
tmp = value[:en]
|
||||
I18n.with_locale(:en) do
|
||||
read_more_options.each_with_index do |option,i|
|
||||
if tmp == t("announcement.#{option}")
|
||||
@read_more_option = i
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,6 +3,12 @@ en:
|
|||
feed: Feed
|
||||
import: Import
|
||||
announcement:
|
||||
read_more_position_options: '"read more" button position'
|
||||
default: Default
|
||||
upper_left: Upper left
|
||||
lower_left: Lower left
|
||||
upper_right: Upper right
|
||||
lower_right: Lower right
|
||||
tabs_options: Tabs options
|
||||
not_enable_tabs: Not enable tabs
|
||||
enable_tabs_with_categories_include_all: Enable tabs with categories(include all)
|
||||
|
|
|
@ -3,6 +3,12 @@ zh_tw:
|
|||
feed: 供給
|
||||
import: 匯入
|
||||
announcement:
|
||||
read_more_position_options: '"更多"按鈕的位置'
|
||||
default: 預設
|
||||
upper_left: 左上
|
||||
lower_left: 左下
|
||||
upper_right: 右上
|
||||
lower_right: 右下
|
||||
tabs_options: 頁籤選項
|
||||
not_enable_tabs: 無頁籤
|
||||
enable_tabs_with_categories_include_all: 開啟頁籤(依類別,並包含全部所選類別之頁籤)
|
||||
|
|
|
@ -7,12 +7,10 @@ module Announcement
|
|||
data = {}
|
||||
key1 = {}
|
||||
key2 = {}
|
||||
value1 = {}
|
||||
value2 = {}
|
||||
value3 = {}
|
||||
value4 = {}
|
||||
value5 = {}
|
||||
value6 = {}
|
||||
key3 = {}
|
||||
key1_attr = []
|
||||
key2_attr = []
|
||||
key3_attr = []
|
||||
data_item = {}
|
||||
key_item1 = {}
|
||||
key_item2 = {}
|
||||
|
@ -22,17 +20,33 @@ module Announcement
|
|||
value_item3 = {}
|
||||
value2_item1 = {}
|
||||
value2_item2 = {}
|
||||
key1_options = ['small_size','medium_size','orignal_size']
|
||||
key2_options = ['not_enable_tabs','enable_tabs_with_categories_include_all','enable_tabs_with_categories']
|
||||
key3_options = ['default','upper_left','lower_left','upper_right','lower_right']
|
||||
key1_options.each_with_index do |k,i|
|
||||
key1_attr[i] = {}
|
||||
end
|
||||
key2_options.each_with_index do |k,i|
|
||||
key2_attr[i] = {}
|
||||
end
|
||||
key3_options.each_with_index do |k,i|
|
||||
key3_attr[i] = {}
|
||||
end
|
||||
translate_data.each do |t_data|
|
||||
v = t_data.values
|
||||
k = t_data.keys[0]
|
||||
key1[k] = v[0]['announcement']['picture_showing_size']
|
||||
key2[k] = v[0]['announcement']['tabs_options']
|
||||
value1[k] = v[0]['announcement']['small_size']
|
||||
value2[k] = v[0]['announcement']['medium_size']
|
||||
value3[k] = v[0]['announcement']['orignal_size']
|
||||
value4[k] = v[0]['announcement']['not_enable_tabs']
|
||||
value5[k] = v[0]['announcement']['enable_tabs_with_categories_include_all']
|
||||
value6[k] = v[0]['announcement']['enable_tabs_with_categories']
|
||||
key3[k] = v[0]['announcement']['read_more_position_options']
|
||||
key1_options.each_with_index do |kk,i|
|
||||
key1_attr[i][k] = v[0]['announcement'][kk]
|
||||
end
|
||||
key2_options.each_with_index do |kk,i|
|
||||
key2_attr[i][k] = v[0]['announcement'][kk]
|
||||
end
|
||||
key3_options.each_with_index do |kk,i|
|
||||
key3_attr[i][k] = v[0]['announcement'][kk]
|
||||
end
|
||||
key_item1[k] = v[0]['announcement']['showing_back_and_next']
|
||||
key_item2[k] = v[0]['announcement']['enable_search']
|
||||
value_item1[k] = v[0]['announcement']['not_show']
|
||||
|
@ -41,8 +55,9 @@ module Announcement
|
|||
value2_item1[k] = v[0]['announcement']['no']
|
||||
value2_item2[k] = v[0]['announcement']['yes']
|
||||
end
|
||||
data[key1] = [value1,value2,value3]
|
||||
data[key2] = [value4,value5,value6]
|
||||
data[key1] = key1_attr
|
||||
data[key2] = key2_attr
|
||||
data[key3] = key3_attr
|
||||
data_item[key_item1] = [value_item1,value_item2,value_item3]
|
||||
data_item[key_item2] = [value2_item1,value2_item2]
|
||||
require File.expand_path('../../../app/models/anns_cache', __FILE__)
|
||||
|
|
Loading…
Reference in New Issue