-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent-list.js
75 lines (67 loc) · 2.19 KB
/
event-list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
jQuery(function ($) {
//date lister
if($("#jcal").length > 0)
{
function displayEventsForDate(e)
{
//clicked on a non date
if(typeof($(this).attr('date')) == "undefined"){ return; }
var ele = $(this);
var hasEvents = $(this).hasClass('has-events');
var noEvent = "<li class='title'><h2>"+$(this).attr('date')+"</h2></li><li>No events on this day</li>";
$('.active').removeClass('active');
$(this).addClass('active');
$("#event-list li").each(function(){
var delay = $("#event-list li").index($(this)) * 30;
$(this).delay(delay).animate({left:'-80px',opacity:0},'fast');
});
$("#event-list").delay(300).fadeOut('fast',function(){
$(this).children('ul').html('');
if(!hasEvents)
{
$(this).children('ul').html(noEvent);
}
var id = -1;
//loop through until we get the next element
while(id == -1)
{
id = $("#jcal td ul").index(ele.find('ul'));
var current = $("#jcal td").index(ele);
ele = $("#jcal td").eq(current+1);
//we've reached the end of the month
if(current > 30){break;}
}
if(id != -1)
{
var uls = $("#jcal td ul");
for(var x = id; x<= id+4; x++)
{
$("#event-list ul").append(uls.eq(x).html());
}
}
$(this).find('li').css({left:"-80px",opacity:0});
$(this).show().find('li').each(function(){
var delay = $("#event-list li").index($(this)) * 30;
$(this).delay(delay).animate({left:'0px',opacity:1},'fast');
});
});
}
$("#jcal td").live('click',displayEventsForDate);
$("#jcal th.next,#jcal th.previous").live('click',function(){
var self = $(this).children('a');
$("#jcal th.full").html('Loading...');
$.post('/wp-content/plugins/jCalendar/get-month.php',{"c":self.attr('href')}, function(data) {
$('#jcal-wrap').children().fadeOut('fast',function(){
$('#jcal-wrap').html(data).children().fadeIn();
$("#jcal td.today").eq(0).trigger('click');
});
});
return false;
});
$("#jcal td.today").eq(0).trigger('click');
$("#event-list .expands").live('click',function(){
$(this).removeClass('expands').children('span').show();
$(this).text($(this).text().replace('&hellp;'));
});
}
});