-
Notifications
You must be signed in to change notification settings - Fork 35
/
addtocal.htm
127 lines (112 loc) · 4.49 KB
/
addtocal.htm
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>jquery.AddToCal Demo</title>
<link rel='stylesheet' type='text/css' href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/south-street/jquery-ui.css' />
<link rel='stylesheet' type='text/css' href='jquery.addtocal.css' />
<!-- hcalendar is only included for an hCalendar event markup example. It is NOT required for jquery.addtocal -->
<link rel="profile" href="http://microformats.org/profile/hcalendar">
<style type='text/css'>
/* styles here are purely for the purpose of the demo and are not essential for addtocal functionality */
body {
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
font-size: 12px;
margin: 0 50px;
}
h1 {
}
p.description {
}
.addtocal {
background-color:#CCCCCC;
display: inline-block;
margin:0 1em 0 0;
padding:10px;
text-align:center;
width: 220px;
}
.addtocal:hover {
background-color:#DDDDDD;
}
.addtocal .summary {
font-size: 14px;
font-weight:bold;
}
.addtocal .date {
font-weight:bold;
}
.addtocal .description {
}
</style>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js'></script>
<script type='text/javascript' src='libs/rfc3339date.js'></script>
<script type='text/javascript' src='jquery.addtocal.js'></script>
<script type='text/javascript'>
$(document).ready(function() {
$('.addtocal').AddToCal({
/* ical and vcal require an ics or vcs file to be served.
* Since we don't have a server for this demo, these features are disabled.
* As a result the 30boxes, iCal and vCalendar menu links will not appear
*/
icalEnabled:false,
vcalEnabled:false,
/* getEventDetails is the most critical function to provide.
* It is called when a user selects a calendar to add an event to.
* The element parameter is the jQuery object for the event invoked.
* You must return an object packed with the relevant event details.
* How you determine the event attributes will depend on your page.
* The example below illustrates how to handle two formats of event markup.
*/
getEventDetails: function( element ) {
var
dtstart_element = element.find('.dtstart'), start,
dtend_element = element.find('.dtend'), end,
title_element = element.find('.summary'), title,
details_element = element.find('.description'), details;
// in this demo, we attempt to get hCalendar attributes or otherwise just dummy the values
start = dtstart_element.length ? dtstart_element.attr('title') : new Date();
if(dtend_element.length) {
end = dtend_element.attr('title');
} else {
end = new Date();
end.setTime(end.getTime() + 60 * 60 * 1000);
}
title = title_element.length ? title_element.html() : element.attr('id');
details = details_element.length ? details_element.html() : element.html();
// return the required event structure
return {
webcalurl: null,
icalurl: null,
vcalurl: null,
start: start,
end: end,
title: title,
details: details,
location: null,
url: null
};
},
});
});
</script>
</head>
<body>
<h1>jQuery UI AddToCal Widget Demo</h1>
<p class="description">This demonstrates the basic add-to-calendar function.
For more information and source files, see the project's <a href="http://github.com/tardate/jquery.addtocalendar">github repository</a>.</p>
<div class="calendar-examples">
<div id='event-1' class='addtocal'>Basic event holder (click me)</div>
<div id='event-2' class='addtocal vevent'>
<div class="summary">hCalendar annotated event</div>
<span class="dtstart date" title="20100908T070000Z">8th Aug 2010</span>
<span class="dtend date" title="20100908T080000Z">7-8am UTC</span>
<div class="description">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed quam sem, tincidunt sit amet blandit vitae, vehicula sit amet sem.
Quisque aliquam commodo lorem vel facilisis. (click me)
</div>
</div>
</div>
</body>
</html>