parent
8d7893a677
commit
1900dada0a
|
@ -69,10 +69,10 @@ class AnnouncementsController < ApplicationController
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
page = Page.where(url:params['url']).first
|
page = Page.where(url:params['url']).first
|
||||||
@annc_page_title = nil
|
@annc_page_title = nil
|
||||||
if params['category'] != page.categories
|
if (params['category'] != page.categories rescue true)
|
||||||
@annc_page_title = Category.find(Array(params['category']).first).title rescue nil
|
@annc_page_title = Category.find(Array(params['category']).first).title rescue nil
|
||||||
end
|
end
|
||||||
|
print params['category']
|
||||||
{
|
{
|
||||||
"announcements" => anns,
|
"announcements" => anns,
|
||||||
"extras" => {
|
"extras" => {
|
||||||
|
@ -148,6 +148,9 @@ class AnnouncementsController < ApplicationController
|
||||||
if @tab_option == 1
|
if @tab_option == 1
|
||||||
cats = ["all"] + cats
|
cats = ["all"] + cats
|
||||||
anns = anns.sort{|v1,v2| v2["postdate"]<=>v1["postdate"]}
|
anns = anns.sort{|v1,v2| v2["postdate"]<=>v1["postdate"]}
|
||||||
|
if @all_setting_option == 0
|
||||||
|
anns = anns.deep_dup.map{|a| a["category"] = "All";a}[0...OrbitHelper.widget_data_count] + anns
|
||||||
|
end
|
||||||
end
|
end
|
||||||
cats = cats.uniq
|
cats = cats.uniq
|
||||||
cats_translations = cats.map{|cat_id|
|
cats_translations = cats.map{|cat_id|
|
||||||
|
@ -160,20 +163,37 @@ class AnnouncementsController < ApplicationController
|
||||||
}.to_h
|
}.to_h
|
||||||
cats_relations = cats_translations.map{|cat_id,t|
|
cats_relations = cats_translations.map{|cat_id,t|
|
||||||
if cat_id == "all"
|
if cat_id == "all"
|
||||||
|
if @all_setting_option == 0
|
||||||
|
t = "All"
|
||||||
|
else
|
||||||
t = "all"
|
t = "all"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
[cat_id,t]
|
[cat_id,t]
|
||||||
}.to_h
|
}.to_h
|
||||||
page = Page.where(:page_id=> subpart.read_more_page_id).first rescue nil
|
page = Page.where(:page_id=> subpart.read_more_page_id).first rescue nil
|
||||||
page = Page.where(:module => "announcement").first rescue nil if page.nil?
|
page = Page.where(:module => "announcement").first rescue nil if page.nil?
|
||||||
|
all_cats = cats.dup
|
||||||
|
all_cats.delete "all"
|
||||||
|
if all_cats.count == 0
|
||||||
|
all_cats = ["all"]
|
||||||
|
end
|
||||||
if @tab_option != 0
|
if @tab_option != 0
|
||||||
OrbitHelper.set_widget_title(OrbitHelper.widget_title +
|
OrbitHelper.set_widget_title(OrbitHelper.widget_title +
|
||||||
"<div style=\"clear: both;\"></div>" +
|
"<div style=\"clear: both;\"></div>" +
|
||||||
"<ul class=\"nav_tabs_filter\">" +
|
"<ul class=\"nav_tabs_filter\">" +
|
||||||
cats.map.with_index{|cat,i|
|
cats.map.with_index{|cat,i|
|
||||||
read_more_url = "/#{I18n.locale.to_s + page.url}" rescue ""
|
read_more_url = "/#{I18n.locale.to_s + page.url}" rescue ""
|
||||||
read_more_url = read_more_url + "?" + {"category"=>cat}.to_param if read_more_url != ""
|
read_more_url = read_more_url + "?" + {"category"=>(cat == 'all' ? all_cats : cat)}.to_param if read_more_url != ""
|
||||||
"<li class=\"filter_tab#{i == 0 ? ' active' : ''}\" data-read_more=\"#{read_more_url}\" data-category=\"#{cats_relations[cat]}\">#{cats_translations[cat]}</li>"
|
read_more_text = I18n.t("announcement.more")
|
||||||
|
if cat != "all"
|
||||||
|
begin
|
||||||
|
read_more_text = I18n.t("announcement.more_") + cats_translations[cat]
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
"<li class=\"filter_tab#{i == 0 ? ' active' : ''}\" data-read_more_text=\"#{read_more_text}\" data-read_more=\"#{read_more_url}\" data-category=\"#{cats_relations[cat]}\">#{cats_translations[cat]}</li>"
|
||||||
}.join("") +
|
}.join("") +
|
||||||
"</ul>"
|
"</ul>"
|
||||||
)
|
)
|
||||||
|
@ -221,13 +241,13 @@ class AnnouncementsController < ApplicationController
|
||||||
var read_more_url = first_filter_tab.data("read_more");
|
var read_more_url = first_filter_tab.data("read_more");
|
||||||
if(read_more_url.length != 0){
|
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").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+'\"] .w-annc__more").text(first_filter_tab.data("read_more_text"));
|
||||||
}
|
}
|
||||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .filter_tab").click(function(){
|
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .filter_tab").click(function(){
|
||||||
var read_more_url = $(this).data("read_more");
|
var read_more_url = $(this).data("read_more");
|
||||||
if(read_more_url.length != 0){
|
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").attr("href",read_more_url);
|
||||||
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").text($(this).text());
|
$("[data-subpart-id=\"'+subpart.id.to_s+'\"] .w-annc__more").text($(this).data("read_more_text"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -262,7 +282,7 @@ class AnnouncementsController < ApplicationController
|
||||||
read_more_text = I18n.t("announcement.more")
|
read_more_text = I18n.t("announcement.more")
|
||||||
if cats.count == 1 && cats[0] != "all"
|
if cats.count == 1 && cats[0] != "all"
|
||||||
begin
|
begin
|
||||||
read_more_text = cats_translations[cats[0]]
|
read_more_text = I18n.t("announcement.more_") + cats_translations[cats[0]]
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
@ -305,6 +325,25 @@ class AnnouncementsController < ApplicationController
|
||||||
</script>
|
</script>
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
|
extra_after_html = ""
|
||||||
|
if @all_setting_option == 0 && @tab_option == 1
|
||||||
|
max_all_count = [OrbitHelper.widget_data_count,anns.count / 2].min
|
||||||
|
extra_after_html = "
|
||||||
|
<script>
|
||||||
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] [data-list] [data-category]\").css(\"display\",\"none\");
|
||||||
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] [data-list] [data-category]:lt(#{max_all_count})\").css(\"display\",\"\");
|
||||||
|
</script>
|
||||||
|
"
|
||||||
|
end
|
||||||
|
read_more_url = "/#{I18n.locale.to_s + page.url}" rescue ""
|
||||||
|
read_more_url = read_more_url + "?" + {"category"=>all_cats}.to_param if read_more_url != ""
|
||||||
|
if @tab_option == 0
|
||||||
|
extra_after_html += "
|
||||||
|
<script>
|
||||||
|
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] .w-annc__more\").attr(\"href\",\"#{read_more_url}\");
|
||||||
|
</script>
|
||||||
|
"
|
||||||
|
end
|
||||||
{
|
{
|
||||||
"announcements" => anns,
|
"announcements" => anns,
|
||||||
"extras" => {
|
"extras" => {
|
||||||
|
@ -319,9 +358,10 @@ class AnnouncementsController < ApplicationController
|
||||||
"category-head" => t('announcement.table.category'),
|
"category-head" => t('announcement.table.category'),
|
||||||
"link-head" => t('announcement.table.link'),
|
"link-head" => t('announcement.table.link'),
|
||||||
"file-head" => t('announcement.table.file'),
|
"file-head" => t('announcement.table.file'),
|
||||||
"read_more" => ("/#{I18n.locale.to_s + page.url}" rescue ""),
|
"read_more" => read_more_url,
|
||||||
"read_more_text" => "read more",
|
"read_more_text" => "read more",
|
||||||
"extra_brefore_html" => extra_html
|
"extra_brefore_html" => extra_html,
|
||||||
|
"extra_after_html" => extra_after_html
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -329,8 +369,10 @@ class AnnouncementsController < ApplicationController
|
||||||
subpart = OrbitHelper.get_current_widget
|
subpart = OrbitHelper.get_current_widget
|
||||||
tab_options = ["not_enable_tabs","enable_tabs_with_categories_include_all","enable_tabs_with_categories"]
|
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']
|
read_more_options = ['default','upper_left','lower_left','upper_right','lower_right']
|
||||||
|
all_setting_options = ['the_same_as_data_count','display_all_in_other_tabs']
|
||||||
@tab_option = 0
|
@tab_option = 0
|
||||||
@read_more_option = 0
|
@read_more_option = 0
|
||||||
|
@all_setting_option = 0
|
||||||
if subpart.methods.include? 'select_options'.to_sym
|
if subpart.methods.include? 'select_options'.to_sym
|
||||||
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
|
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
|
||||||
@show_options = modile_app.show_options rescue nil
|
@show_options = modile_app.show_options rescue nil
|
||||||
|
@ -360,6 +402,18 @@ class AnnouncementsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if !(@show_options.nil?) && select_option.field_name == @show_options.keys[3].to_s
|
||||||
|
value = YAML.load(select_option.value)
|
||||||
|
tmp = value[:en]
|
||||||
|
I18n.with_locale(:en) do
|
||||||
|
all_setting_options.each_with_index do |option,i|
|
||||||
|
if tmp == t("announcement.#{option}")
|
||||||
|
@all_setting_option = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -198,7 +198,7 @@ module AnnouncementsHelper
|
||||||
else
|
else
|
||||||
tags = page.tags
|
tags = page.tags
|
||||||
tags = params[:tags] if params[:tags].present?
|
tags = params[:tags] if params[:tags].present?
|
||||||
categories = params['category']=='all' ? (page.categories || []) : ([Category.find(params['category'])] rescue (page.categories || []))
|
categories = params['category']=='all' ? (page.categories || []) : (Array(params['category']) rescue (page.categories || []))
|
||||||
categories = ["all"] if params[:tags].present?
|
categories = ["all"] if params[:tags].present?
|
||||||
end
|
end
|
||||||
if !params["source"].present?
|
if !params["source"].present?
|
||||||
|
|
|
@ -3,6 +3,9 @@ en:
|
||||||
feed: Feed
|
feed: Feed
|
||||||
import: Import
|
import: Import
|
||||||
announcement:
|
announcement:
|
||||||
|
all_tabs_setting: '"All" tab setting'
|
||||||
|
the_same_as_data_count: The same as data count
|
||||||
|
display_all_in_other_tabs: Display all contents in other tabs
|
||||||
read_more_position_options: '"read more" button position'
|
read_more_position_options: '"read more" button position'
|
||||||
default: Default
|
default: Default
|
||||||
upper_left: Upper left
|
upper_left: Upper left
|
||||||
|
@ -121,6 +124,7 @@ en:
|
||||||
index: Index
|
index: Index
|
||||||
search: Search
|
search: Search
|
||||||
more: More
|
more: More
|
||||||
|
more_: 'More '
|
||||||
email_reminder: Email Reminder
|
email_reminder: Email Reminder
|
||||||
activate_email_reminder: Activate Email Reminder
|
activate_email_reminder: Activate Email Reminder
|
||||||
email_sentdate: Email Time
|
email_sentdate: Email Time
|
||||||
|
|
|
@ -3,6 +3,9 @@ zh_tw:
|
||||||
feed: 供給
|
feed: 供給
|
||||||
import: 匯入
|
import: 匯入
|
||||||
announcement:
|
announcement:
|
||||||
|
all_tabs_setting: '"全部"頁籤設定'
|
||||||
|
the_same_as_data_count: 與Data count相同
|
||||||
|
display_all_in_other_tabs: 顯示在其他頁籤的全部內容
|
||||||
read_more_position_options: '"更多"按鈕的位置'
|
read_more_position_options: '"更多"按鈕的位置'
|
||||||
default: 預設
|
default: 預設
|
||||||
upper_left: 左上
|
upper_left: 左上
|
||||||
|
@ -124,6 +127,7 @@ zh_tw:
|
||||||
index: 索引
|
index: 索引
|
||||||
search: 搜尋
|
search: 搜尋
|
||||||
more: 更多+
|
more: 更多+
|
||||||
|
more_: 更多
|
||||||
email_reminder: 寄送提醒
|
email_reminder: 寄送提醒
|
||||||
activate_email_reminder: 開啟寄送提醒
|
activate_email_reminder: 開啟寄送提醒
|
||||||
email_sentdate: 寄送時間
|
email_sentdate: 寄送時間
|
||||||
|
|
|
@ -8,9 +8,11 @@ module Announcement
|
||||||
key1 = {}
|
key1 = {}
|
||||||
key2 = {}
|
key2 = {}
|
||||||
key3 = {}
|
key3 = {}
|
||||||
|
key4 = {}
|
||||||
key1_attr = []
|
key1_attr = []
|
||||||
key2_attr = []
|
key2_attr = []
|
||||||
key3_attr = []
|
key3_attr = []
|
||||||
|
key4_attr = []
|
||||||
data_item = {}
|
data_item = {}
|
||||||
key_item1 = {}
|
key_item1 = {}
|
||||||
key_item2 = {}
|
key_item2 = {}
|
||||||
|
@ -23,6 +25,7 @@ module Announcement
|
||||||
key1_options = ['small_size','medium_size','orignal_size']
|
key1_options = ['small_size','medium_size','orignal_size']
|
||||||
key2_options = ['not_enable_tabs','enable_tabs_with_categories_include_all','enable_tabs_with_categories']
|
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']
|
key3_options = ['default','upper_left','lower_left','upper_right','lower_right']
|
||||||
|
key4_options = ['the_same_as_data_count','display_all_in_other_tabs']
|
||||||
key1_options.each_with_index do |k,i|
|
key1_options.each_with_index do |k,i|
|
||||||
key1_attr[i] = {}
|
key1_attr[i] = {}
|
||||||
end
|
end
|
||||||
|
@ -32,12 +35,16 @@ module Announcement
|
||||||
key3_options.each_with_index do |k,i|
|
key3_options.each_with_index do |k,i|
|
||||||
key3_attr[i] = {}
|
key3_attr[i] = {}
|
||||||
end
|
end
|
||||||
|
key4_options.each_with_index do |k,i|
|
||||||
|
key4_attr[i] = {}
|
||||||
|
end
|
||||||
translate_data.each do |t_data|
|
translate_data.each do |t_data|
|
||||||
v = t_data.values
|
v = t_data.values
|
||||||
k = t_data.keys[0]
|
k = t_data.keys[0]
|
||||||
key1[k] = v[0]['announcement']['picture_showing_size']
|
key1[k] = v[0]['announcement']['picture_showing_size']
|
||||||
key2[k] = v[0]['announcement']['tabs_options']
|
key2[k] = v[0]['announcement']['tabs_options']
|
||||||
key3[k] = v[0]['announcement']['read_more_position_options']
|
key3[k] = v[0]['announcement']['read_more_position_options']
|
||||||
|
key4[k] = v[0]['announcement']['all_tabs_setting']
|
||||||
key1_options.each_with_index do |kk,i|
|
key1_options.each_with_index do |kk,i|
|
||||||
key1_attr[i][k] = v[0]['announcement'][kk]
|
key1_attr[i][k] = v[0]['announcement'][kk]
|
||||||
end
|
end
|
||||||
|
@ -47,6 +54,9 @@ module Announcement
|
||||||
key3_options.each_with_index do |kk,i|
|
key3_options.each_with_index do |kk,i|
|
||||||
key3_attr[i][k] = v[0]['announcement'][kk]
|
key3_attr[i][k] = v[0]['announcement'][kk]
|
||||||
end
|
end
|
||||||
|
key4_options.each_with_index do |kk,i|
|
||||||
|
key4_attr[i][k] = v[0]['announcement'][kk]
|
||||||
|
end
|
||||||
key_item1[k] = v[0]['announcement']['showing_back_and_next']
|
key_item1[k] = v[0]['announcement']['showing_back_and_next']
|
||||||
key_item2[k] = v[0]['announcement']['enable_search']
|
key_item2[k] = v[0]['announcement']['enable_search']
|
||||||
value_item1[k] = v[0]['announcement']['not_show']
|
value_item1[k] = v[0]['announcement']['not_show']
|
||||||
|
@ -58,6 +68,7 @@ module Announcement
|
||||||
data[key1] = key1_attr
|
data[key1] = key1_attr
|
||||||
data[key2] = key2_attr
|
data[key2] = key2_attr
|
||||||
data[key3] = key3_attr
|
data[key3] = key3_attr
|
||||||
|
data[key4] = key4_attr
|
||||||
data_item[key_item1] = [value_item1,value_item2,value_item3]
|
data_item[key_item1] = [value_item1,value_item2,value_item3]
|
||||||
data_item[key_item2] = [value2_item1,value2_item2]
|
data_item[key_item2] = [value2_item1,value2_item2]
|
||||||
require File.expand_path('../../../app/models/anns_cache', __FILE__)
|
require File.expand_path('../../../app/models/anns_cache', __FILE__)
|
||||||
|
|
Loading…
Reference in New Issue