fix error for sort announcements because of get nil by call enable_manually_sort
This commit is contained in:
parent
4043dfed5c
commit
b3dbabef5b
|
@ -1,4 +1,6 @@
|
||||||
module AnnouncementsHelper
|
module AnnouncementsHelper
|
||||||
|
extend self
|
||||||
|
|
||||||
def data_to_human_type(a,set_tag_ids=nil,tmp_enable_annc_dept=false,annc_depts=[])
|
def data_to_human_type(a,set_tag_ids=nil,tmp_enable_annc_dept=false,annc_depts=[])
|
||||||
tmp_enable_annc_dept = @tmp_enable_annc_dept if @tmp_enable_annc_dept
|
tmp_enable_annc_dept = @tmp_enable_annc_dept if @tmp_enable_annc_dept
|
||||||
annc_depts = @annc_depts if @annc_depts
|
annc_depts = @annc_depts if @annc_depts
|
||||||
|
@ -464,34 +466,34 @@ module AnnouncementsHelper
|
||||||
</div>").html_safe
|
</div>").html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
class << self
|
def complementaryColor(my_hex)
|
||||||
def complementaryColor(my_hex)
|
if my_hex[0] == '#'
|
||||||
if my_hex[0] == '#'
|
my_hex = my_hex[1..-1]
|
||||||
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
|
|
||||||
end
|
end
|
||||||
def lighten_color(my_hex,percent)
|
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join}
|
||||||
if my_hex[0] == '#'
|
comp = rgb.map{|a| (255 - a.to_i(16)).to_s(16).rjust(2,'0')}
|
||||||
my_hex = my_hex[1..-1]
|
'#'+comp.join
|
||||||
end
|
end
|
||||||
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join}
|
|
||||||
comp = rgb.collect do |a|
|
def lighten_color(my_hex,percent)
|
||||||
tmp = a.to_i(16)*(1+percent/100.0)
|
if my_hex[0] == '#'
|
||||||
tmp = 255 if tmp>255
|
my_hex = my_hex[1..-1]
|
||||||
tmp = 0 if tmp < 0
|
|
||||||
tmp.to_i.to_s(16).rjust(2,'0')
|
|
||||||
end
|
|
||||||
'#'+comp.join
|
|
||||||
end
|
end
|
||||||
def enable_manually_sort
|
rgb = my_hex.split(//).each_slice(my_hex.length/3).map{|v| v.join}
|
||||||
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
comp = rgb.collect do |a|
|
||||||
OrbitHelper::SharedHash['announcement'][:enable_manually_sort]
|
tmp = a.to_i(16)*(1+percent/100.0)
|
||||||
else
|
tmp = 255 if tmp>255
|
||||||
AnnouncementSetting.first.enable_manually_sort rescue false
|
tmp = 0 if tmp < 0
|
||||||
end
|
tmp.to_i.to_s(16).rjust(2,'0')
|
||||||
|
end
|
||||||
|
'#'+comp.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def enable_manually_sort
|
||||||
|
if defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash
|
||||||
|
OrbitHelper::SharedHash['announcement'][:enable_manually_sort]
|
||||||
|
else
|
||||||
|
AnnouncementSetting.first.enable_manually_sort rescue false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue