diff --git a/app/helpers/event_news_helper.rb b/app/helpers/event_news_helper.rb index 303a29f..094e3c5 100644 --- a/app/helpers/event_news_helper.rb +++ b/app/helpers/event_news_helper.rb @@ -1,4 +1,6 @@ module EventNewsHelper + extend self + def data_to_human_type(a,set_tag_ids=nil) statuses = a.statuses_with_classname.collect do |status| { @@ -88,7 +90,7 @@ module EventNewsHelper sort_maps = {event_date: :asc, is_top: :desc, postdate: :asc, id: :asc} else sort_maps = {is_top: :desc} - if EventNewsHelper.is_postdate_sort_first + if is_postdate_sort_first sort_maps = sort_maps.merge({postdate: :desc, event_date: :desc, id: :desc}) else sort_maps = sort_maps.merge({event_date: :desc, postdate: :desc, id: :desc}) @@ -234,8 +236,7 @@ module EventNewsHelper end def sort_event_news(event_news_list) - enable_manually_sort = enable_manually_sort - if @show_today_data_first || !EventNewsHelper.is_postdate_sort_first + if @show_today_data_first || !is_postdate_sort_first if enable_manually_sort event_news_list = event_news_list.sort_by { |event_news| tmp1 = event_news["event_date"].blank? @@ -551,41 +552,43 @@ module EventNewsHelper ").html_safe end - class << self - def complementaryColor(my_hex) - if my_hex[0] == '#' - my_hex = my_hex[1..-1] - end - rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join} - comp = rgb.map{|a| (255 - a.to_i(16)).to_s(16).rjust(2,'0')} - '#'+comp.join + + def complementaryColor(my_hex) + if my_hex[0] == '#' + my_hex = my_hex[1..-1] end - def lighten_color(my_hex,percent) - if my_hex[0] == '#' - my_hex = my_hex[1..-1] - end - rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join} - comp = rgb.collect do |a| - tmp = a.to_i(16)*(1+percent/100.0) - tmp = 255 if tmp>255 - tmp = 0 if tmp < 0 - tmp.to_i.to_s(16).rjust(2,'0') - end - '#'+comp.join + rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join} + comp = rgb.map{|a| (255 - a.to_i(16)).to_s(16).rjust(2,'0')} + '#'+comp.join + end + + def lighten_color(my_hex,percent) + if my_hex[0] == '#' + my_hex = my_hex[1..-1] end - def enable_manually_sort - if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash - OrbitHelper::SharedHash['event_news_mod'][:enable_manually_sort] - else - EventNewsSetting.first.enable_manually_sort rescue false - end + rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join} + comp = rgb.collect do |a| + tmp = a.to_i(16)*(1+percent/100.0) + tmp = 255 if tmp>255 + tmp = 0 if tmp < 0 + tmp.to_i.to_s(16).rjust(2,'0') end - def is_postdate_sort_first - if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash - OrbitHelper::SharedHash['event_news_mod'][:is_postdate_sort_first] - else - EventNewsSetting.first.is_postdate_sort_first rescue false - end + '#'+comp.join + end + + def enable_manually_sort + if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash + OrbitHelper::SharedHash['event_news_mod'][:enable_manually_sort] + else + EventNewsSetting.first.enable_manually_sort rescue false + end + end + + def is_postdate_sort_first + if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash + OrbitHelper::SharedHash['event_news_mod'][:is_postdate_sort_first] + else + EventNewsSetting.first.is_postdate_sort_first rescue false end end end