event bug fixed

This commit is contained in:
Harry Bomrah 2012-09-17 13:28:11 +08:00
parent 221ffc08dd
commit c5743a50bb
2 changed files with 21 additions and 13 deletions

View File

@ -114,19 +114,28 @@ var calendarAPI = function(){
var getEvents = function(month,year){
$.getJSON("cals/getEvents",{"type":"monthview","month":month,"year":year},function(events){
var $eventrow = $("<tr></tr>");
var currow = 1;
var curpos = 1;
var nos = new Array();
nos.push(0);
$.each(events,function(i,evnt){
var daydom = $("#calendar_month td[date="+evnt.start_date+"]");
var curparent = daydom.parent().parent().parent();
var thisrow = curparent.attr("row");
var pos = daydom.attr("position");
if(thisrow != currow){
$eventrow = null;
$eventrow = $("<tr></tr>");
}else if(pos == curpos){
$eventrow = null;
$eventrow = $("<tr></tr>");
var thisno = daydom.attr("no");
var index = "new";
for(x in nos){
if(thisno < nos[x]){
$eventrow = null;
$eventrow = $("<tr></tr>");
index = x;
break;
}
}
if(index!="new"){
nos[index] = (thisno + evnt.total_days) - 1;
}else{
nos.push((thisno + evnt.total_days) - 1);
}
if(pos == 1){
$eventrow.html('<td colspan="'+evnt.total_days+'"><div class="event" style="background-color: '+evnt.color+';">'+evnt.title+'</div></td>');
@ -136,8 +145,7 @@ var calendarAPI = function(){
}
$eventrow.append('<td colspan="'+evnt.total_days+'"><div class="event" style="background-color: '+evnt.color+';">'+evnt.title+'</div></td>');
}
currow = thisrow;
curpos = pos;
curparent.append($eventrow);
})
})

View File

@ -41,11 +41,11 @@
<% x = 0 %>
<% while x < 7 %>
<% if day_count_for_title < @pre_disabled_days %>
<td class="day_title disable"><%= @dateset[day_count_for_title] %></td>
<td class="day_title disable" no="<%= day_count_for_title+1 %>"><%= @dateset[day_count_for_title] %></td>
<% elsif day_count_for_title >= @post_disabled_days %>
<td class="day_title disable"><%= @dateset[day_count_for_title] %></td>
<td class="day_title disable" no="<%= day_count_for_title+1 %>"><%= @dateset[day_count_for_title] %></td>
<% else %>
<td class="day_title click_event" ref="day-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @dateset[day_count_for_title] %>" position="<%= x+1 %>"><%= @dateset[day_count_for_title] %></td>
<td class="day_title click_event" ref="day-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @dateset[day_count_for_title] %>" position="<%= x+1 %>" no="<%= day_count_for_title+1 %>"><%= @dateset[day_count_for_title] %></td>
<% end %>
<% day_count_for_title += 1 %>
<% x += 1 %>