This commit is contained in:
BoHung Chiu 2022-07-13 15:00:21 +08:00
parent e76355a658
commit 592eab19a2
2 changed files with 23 additions and 14 deletions

View File

@ -34,6 +34,12 @@ class CalendarsController < ApplicationController
def widget def widget
part = OrbitHelper.get_current_widget part = OrbitHelper.get_current_widget
@calendar_setting = CalendarSetting.first @calendar_setting = CalendarSetting.first
begin
extra_before_html = render_to_string(partial: 'calendars/calendar_variable', locals: {:@calendar_setting=>@calendar_setting})
rescue => e
extra_before_html = ""
puts e, e.backtrace
end
{ {
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i == "modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
2 ? 'active' : '')}}, 2 ? 'active' : '')}},
@ -44,7 +50,8 @@ class CalendarsController < ApplicationController
'widget_title' => part.title, 'widget_title' => part.title,
'widget_title_class' => part.title.blank? ? 'center' : '', 'widget_title_class' => part.title.blank? ? 'center' : '',
'calendar_title' => get_calendar_title, 'calendar_title' => get_calendar_title,
'default_column' => widget_default_column 'default_column' => widget_default_column,
'extra_before_html' => extra_before_html
} }
} }
end end

View File

@ -1,16 +1,18 @@
<script> <script>
window.calendar_variable = {}; if(window.calendar_variable == undefined){
window.calendar_variable.from = "<%=t('calendar.from')%>"; window.calendar_variable = {};
window.calendar_variable.to = "<%=t('calendar.to')%>"; window.calendar_variable.from = "<%=t('calendar.from')%>";
<% if @calendar_setting && @calendar_setting.enable %> window.calendar_variable.to = "<%=t('calendar.to')%>";
window.calendar_variable.sunday_first = <%=@calendar_setting.sunday_first%>; <% if @calendar_setting && @calendar_setting.enable %>
window.calendar_variable.week_title = <%=@calendar_setting.week_title.to_s.html_safe%>; window.calendar_variable.sunday_first = <%=@calendar_setting.sunday_first%>;
window.calendar_variable.date_type = <%=@calendar_setting.date_type%>; window.calendar_variable.week_title = <%=@calendar_setting.week_title.to_s.html_safe%>;
window.calendar_variable.dayNames = <%=@calendar_setting.days.to_s.html_safe%>; window.calendar_variable.date_type = <%=@calendar_setting.date_type%>;
<% if I18n.locale == :zh_tw %> window.calendar_variable.dayNames = <%=@calendar_setting.days.to_s.html_safe%>;
window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[-1]}.to_s.html_safe%>; <% if I18n.locale == :zh_tw %>
<% else %> window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[-1]}.to_s.html_safe%>;
window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[0...3]}.to_s.html_safe%>; <% else %>
window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[0...3]}.to_s.html_safe%>;
<% end %>
<% end %> <% end %>
<% end %> }
</script> </script>