add new index template and fix some error
This commit is contained in:
parent
5207eb1d61
commit
cf9c46a543
|
@ -635,7 +635,7 @@ var AgendaView = function(calendar){
|
|||
dateFormat = $.fullCalendar.formatDates(s, e, "ddd dd, MMM - {ddd dd, MMM}");
|
||||
e_t.find("td:first").text(dateFormat);
|
||||
e_t.find("td.event_time").text((event.allDay ? "All Day" : $.fullCalendar.formatDate(s, "hh:mm")));
|
||||
e_t.find("div.event").text(event.title).css("color",event.color);
|
||||
e_t.find("div.event").html(event.title).css("color",event.color);
|
||||
return e_t;
|
||||
}
|
||||
|
||||
|
|
|
@ -431,7 +431,7 @@ var AgendaView = function(calendar){
|
|||
dateFormat = $.fullCalendar.formatDates(s, e, "ddd dd, MMM - {ddd dd, MMM}");
|
||||
e_t.find("td:first").text(dateFormat);
|
||||
e_t.find("td.event_time").text((event.allDay ? "All Day" : $.fullCalendar.formatDate(s, "hh:mm")));
|
||||
e_t.find("div.event").text(event.title).css("color",event.color);
|
||||
e_t.find("div.event").html(event.title).css("color",event.color);
|
||||
return e_t;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CalendarModuleMonth = function(date,dom,subpart,url){
|
||||
var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||
_this = this;
|
||||
var events = {}
|
||||
var template = dom.find(".month_template"),
|
||||
|
@ -317,7 +317,7 @@
|
|||
usd_target = Math.round(first_target_day/1000),
|
||||
ued_target = Math.round(last_target_day/1000);
|
||||
$.ajax({
|
||||
url : "/xhr/calendars/agenda",
|
||||
url : (index_flag ? "/xhr/calendars/index_agenda" : "/xhr/calendars/agenda"),
|
||||
data : {"month_start" : usd,"unix_start" : usd_target, "unix_end" : ued_target, "subpart_id" : subpartid, "locale" : $('html').attr('lang')},
|
||||
dataType : "json",
|
||||
type : "get"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CalendarModuleMonth = function(date,dom,subpart,url){
|
||||
var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
|
||||
_this = this;
|
||||
var events = {}
|
||||
var template = dom.find(".month_template"),
|
||||
|
@ -456,7 +456,7 @@
|
|||
usd_target = Math.round(first_target_day/1000),
|
||||
ued_target = Math.round(last_target_day/1000);
|
||||
$.ajax({
|
||||
url : "/xhr/calendars/agenda",
|
||||
url : (index_flag ? "/xhr/calendars/index_agenda" : "/xhr/calendars/agenda"),
|
||||
data : {"month_start" : usd,"unix_start" : usd_target, "unix_end" : ued_target, "subpart_id" : subpartid, "locale" : $('html').attr('lang')},
|
||||
dataType : "json",
|
||||
type : "get"
|
||||
|
|
|
@ -4062,7 +4062,7 @@ function AgendaEventRenderer() {
|
|||
htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
|
||||
"</div>" +
|
||||
"<div class='fc-event-title'>" +
|
||||
htmlEscape(event.title) +
|
||||
event.title +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"<div class='fc-event-bg'></div>";
|
||||
|
@ -4807,7 +4807,7 @@ function DayEventRenderer() {
|
|||
"</span>";
|
||||
}
|
||||
html +=
|
||||
"<span class='fc-event-title'>" + htmlEscape(event.title) + "</span>" +
|
||||
"<span class='fc-event-title'>" + event.title + "</span>" +
|
||||
"</div>";
|
||||
if (seg.isEnd && isEventResizable(event)) {
|
||||
html +=
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
class CalendarsController < ApplicationController
|
||||
# GET /events
|
||||
# GET /events.json
|
||||
|
||||
include ActionView::Helpers::AssetTagHelper
|
||||
|
||||
def index
|
||||
page = Page.where(page_id: OrbitHelper.params[:page_id]).first
|
||||
style_file = page.layout=='index3' ? 'calendar_widget2' : 'calendar_widget1'
|
||||
{
|
||||
"extras" => {
|
||||
"page_id" => OrbitHelper.params[:page_id]
|
||||
"page_id" => OrbitHelper.params[:page_id],
|
||||
'widget_title' => page.name,
|
||||
'calendar_title' => get_calendar_title,
|
||||
'style_tag' => stylesheet_link_tag(style_file)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
@ -48,6 +53,29 @@ class CalendarsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def index_agenda
|
||||
I18n.with_locale(params[:locale]||I18n.locale) do
|
||||
if !params[:subpart_id].nil?
|
||||
subpartid = params[:subpart_id]
|
||||
page = Page.where(page_id: subpartid).first
|
||||
calendar_types = page.categories
|
||||
else
|
||||
calendar_types = []
|
||||
end
|
||||
if params[:unix_start].present? && params[:unix_end].present?
|
||||
agenda_start = Time.at(params[:unix_start].to_i).to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).to_s
|
||||
if !calendar_types.blank?
|
||||
events = Event.where(:calendar_type_id.in => calendar_types).agenda_events(agenda_start,agenda_end)
|
||||
else
|
||||
events = Event.agenda_events(agenda_start,agenda_end)
|
||||
end
|
||||
end
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i))}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
|
||||
def agenda
|
||||
I18n.with_locale(params[:locale]||I18n.locale) do
|
||||
if !params[:subpart_id].nil?
|
||||
|
|
|
@ -27,7 +27,7 @@ class Event
|
|||
field :url
|
||||
def get_module_url
|
||||
page = !self.model_page_id.blank? ? Page.find(self.model_page_id): Page.where(:module => self.module_key).where(:categories.in => Array(self.model_cat)+[[]],:tags.in=>Array(self.model_tags)+[[]]).first
|
||||
page.nil? ? '' : (page.url+'/'+eval(self.model_class).where(:id=>self.model_id).first.to_param)
|
||||
page.nil? ? '' : (page.url+'/'+eval(self.model_class).where(:id=>self.model_id).first.to_calendar_param)
|
||||
end
|
||||
def url_to_fronted
|
||||
self.url.blank? ? (self.model_class.blank? ? '' : self.get_module_url) : self.url
|
||||
|
|
|
@ -11,6 +11,8 @@ Rails.application.routes.draw do
|
|||
|
||||
get "/xhr/calendars/events" => "calendars#events"
|
||||
get "/xhr/calendars/agenda" => "calendars#agenda"
|
||||
get "/xhr/calendars/index_agenda" => "calendars#index_agenda"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
tag.onload = function(){
|
||||
$("div.widget-calendar-1[data-module=calendar]").each(function(index){
|
||||
var calendar = $(this),
|
||||
cmi = new CalendarModuleMonth(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}");
|
||||
cmi = new CalendarModuleMonth1(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
||||
cmi.currentMonth();
|
||||
calendar.find("div.w-calendar-nav a").on("click",function(){
|
||||
var el = $(this);
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
tag.onload = function(){
|
||||
$("div.widget-calendar-2[data-module=calendar]").each(function(index){
|
||||
var calendar = $(this),
|
||||
cmi = new CalendarModuleMonth(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}");
|
||||
cmi = new CalendarModuleMonth2(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
||||
cmi.currentMonth();
|
||||
calendar.find("div.w-calendar-nav a").on("click",function(){
|
||||
var el = $(this);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<script type="text/javascript" src="/assets/calendar_widget.js" id="calendar-index_module"></script>
|
||||
{{style_tag}}
|
||||
<div class="w-calendar widget-calendar-1 index2" data-module="calendar" data-page-id="{{page_id}}">
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<span class="text"></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
<div class="w-calendar-nav">
|
||||
<a href="#" class="w-calendar-nav-prev">
|
||||
<i class="fa fa-chevron-left"></i>
|
||||
<span class="w-calendar-nav-prev-text hide">Prev</span>
|
||||
</a>
|
||||
<a href="#" class="w-calendar-nav-next">
|
||||
<i class="fa fa-chevron-right"></i>
|
||||
<span class="w-calendar-nav-next-text hide">Next</span>
|
||||
</a>
|
||||
</div>
|
||||
<table class="table table-condensed w-calendar-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sun</th>
|
||||
<th>Mon</th>
|
||||
<th>Tue</th>
|
||||
<th>Wed</th>
|
||||
<th>Thu</th>
|
||||
<th>Fri</th>
|
||||
<th>Sat</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="calendar-events" style="display: none;">
|
||||
<div class="close_box">X</div>
|
||||
<div class="event-header"></div>
|
||||
<div class="event-containers">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("div.index2[data-module=calendar]").each(function(index){
|
||||
var calendar = $(this),
|
||||
cmi = new CalendarModuleMonth1(new Date(), calendar,calendar.data("page-id"),"",true);
|
||||
cmi.currentMonth();
|
||||
calendar.find("div.w-calendar-nav a").on("click",function(){
|
||||
var el = $(this);
|
||||
if(el.hasClass("w-calendar-nav-prev")){
|
||||
cmi.prevMonth();
|
||||
}else if(el.hasClass("w-calendar-nav-next")){
|
||||
cmi.nextMonth();
|
||||
}
|
||||
return false;
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,75 @@
|
|||
<script type="text/javascript" src="/assets/calendar_widget2.js" id="calendar-index_module2"></script>
|
||||
{{style_tag}}
|
||||
<div class="w-calendar widget-calendar-2 index3" data-module="calendar" data-page-id="{{page_id}}">
|
||||
<div class="w-calendar-title">
|
||||
<span>{{widget_title}}</span>
|
||||
<span>{{calendar_title}}</span>
|
||||
</div>
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<span class="text"></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
<div class="w-calendar-nav">
|
||||
<a href="#" class="w-calendar-nav-prev">
|
||||
<i class="fa fa-chevron-left"></i>
|
||||
<span class="w-calendar-nav-prev-text hide">Prev</span>
|
||||
</a>
|
||||
<a href="#" class="w-calendar-nav-next">
|
||||
<i class="fa fa-chevron-right"></i>
|
||||
<span class="w-calendar-nav-next-text hide">Next</span>
|
||||
</a>
|
||||
</div>
|
||||
<table class="table table-condensed w-calendar-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sun</th>
|
||||
<th>Mon</th>
|
||||
<th>Tue</th>
|
||||
<th>Wed</th>
|
||||
<th>Thu</th>
|
||||
<th>Fri</th>
|
||||
<th>Sat</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="calendar-events" style="display: none;">
|
||||
<div class="event">
|
||||
<div class="event-header">
|
||||
<div class="date">
|
||||
<div class="day"></div>
|
||||
<div class="month"></div>
|
||||
</div>
|
||||
<div class="event-title">
|
||||
<div class="event-inner-title"></div>
|
||||
<div class="duration"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="event-wraper">
|
||||
<div class="event-containers">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("div.index3[data-module=calendar]").each(function(index){
|
||||
var calendar = $(this),
|
||||
cmi = new CalendarModuleMonth2(new Date(), calendar,calendar.data("page-id"),"",true);
|
||||
cmi.currentMonth();
|
||||
calendar.find("div.w-calendar-nav a").on("click",function(){
|
||||
var el = $(this);
|
||||
if(el.hasClass("w-calendar-nav-prev")){
|
||||
cmi.prevMonth();
|
||||
}else if(el.hasClass("w-calendar-nav-next")){
|
||||
cmi.nextMonth();
|
||||
}
|
||||
return false;
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
|
@ -7,6 +7,22 @@
|
|||
"en" : "1. Calendar"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
},
|
||||
{
|
||||
"filename" : "index2",
|
||||
"name" : {
|
||||
"zh_tw" : "2. 行事曆(和widget樣式1同)",
|
||||
"en" : "2. Calendar(same as widget style 1)"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
},
|
||||
{
|
||||
"filename" : "index3",
|
||||
"name" : {
|
||||
"zh_tw" : "3. 行事曆加公告",
|
||||
"en" : "3. Calendar with announcement"
|
||||
},
|
||||
"thumbnail" : "thumb.png"
|
||||
}
|
||||
],
|
||||
"widgets" : [
|
||||
|
|
Loading…
Reference in New Issue