Permalink
Browse files

add parameter testing for cal generation

  • Loading branch information...
1 parent 89e0214 commit 30d2527378f18189c303041a14254cc4f7c8127c @tardate committed Jul 29, 2010
Showing with 48 additions and 47 deletions.
  1. +36 −39 addtocal.htm
  2. +12 −8 jquery.addtocal.js
View
@@ -1,46 +1,39 @@
<!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' />
-<style type='text/css'>
-
- body {
- font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
- margin: 0 30px;
- }
-
- h1 {
- margin: 0 0 1em;
- padding: 0.5em;
- }
-
- p.description {
- font-size: 0.8em;
- padding: 1em;
- position: absolute;
- top: 3.2em;
- margin-right: 400px;
- }
-
- #message {
- font-size: 0.7em;
- position: absolute;
- top: 1em;
- right: 1em;
- width: 350px;
- display: none;
- padding: 1em;
- background: #ffc;
- border: 1px solid #dda;
- }
-
- div.addtocal {
- display: inline-block;
- width: 220px;
- }
-
-</style>
+ <style type='text/css'>
+
+ body {
+ font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
+ margin: 0 30px;
+ }
+
+ h1 {
+ margin: 0 0 1em;
+ padding: 0.5em;
+ }
+
+ p.description {
+ font-size: 0.8em;
+ padding: 1em;
+ position: absolute;
+ top: 3.2em;
+ margin-right: 400px;
+ }
+
+ div.addtocal {
+ background-color:#EFEFEF;
+ display: inline-block;
+ margin:0 1em;
+ padding:10px;
+ text-align:center;
+ width: 220px;
+ }
+
+ </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>
@@ -52,10 +45,14 @@
$(document).ready(function() {
$('.addtocal').addtocal({
+ webcalProvided:false,
getEventDetails: function( element ) {
+ var start = new Date();
+ var end = new Date();
+ end.setTime(end.getTime() + 60 * 60 * 1000);
return {
webcalurl: 'webcal://',
- start: new Date(), end: new Date(),
+ start: start, end: end,
title: element.attr('id'), details: element.html(),
location: null, url: null};
},
View
@@ -21,6 +21,7 @@
collision: "none"
},
selectedCalendarTarget: null,
+ webcalProvided: true,
getEventDetails: function( element ) {
return {
webcalurl: 'webcal://',
@@ -33,6 +34,10 @@
var eventDetails = ui.getEventDetails($(this));
var
title = ( eventDetails.title ? encodeURIComponent( eventDetails.title ) : '' ),
+ start = ( typeof eventDetails.start.toRFC3339UTCString == 'function' ?
+ eventDetails.start.toRFC3339UTCString(true,true) : ''),
+ end = ( typeof eventDetails.end.toRFC3339UTCString == 'function' ?
+ eventDetails.end.toRFC3339UTCString(true,true) : ''),
location = ( eventDetails.location ? encodeURIComponent( eventDetails.location ) : '' ),
details = ( eventDetails.details ? encodeURIComponent( eventDetails.details ) : '' ),
url = ( eventDetails.url ? encodeURIComponent( eventDetails.url ) : '' );
@@ -41,8 +46,8 @@
case 1: //google
link = "http://www.google.com/calendar/event?action=TEMPLATE&trp=false" +
"&text=" + title +
- "&dates=" + eventDetails.start.toRFC3339UTCString(true,true) +
- "/" + eventDetails.end.toRFC3339UTCString(true,true) +
+ "&dates=" + start +
+ "/" + end +
"&location=" + location +
"&details=" + details +
"&sprop=" + url;
@@ -51,15 +56,15 @@
link="http://calendar.yahoo.com/?v=60" +
"&DUR=0400" +
"&TITLE=" + title +
- "&ST=" + eventDetails.start.toRFC3339UTCString(true,true) +
+ "&ST=" + start +
"&in_loc=" + location +
"&DESC=" + details +
"&URL=" + url;
break;
case 3:// live
link="http://calendar.live.com/calendar/calendar.aspx?rru=addevent" +
- "&dtstart=" + eventDetails.start.toRFC3339UTCString(true,true) +
- "&dtend=" + eventDetails.end.toRFC3339UTCString(true,true) +
+ "&dtstart=" + start +
+ "&dtend=" + end +
"&summary=" + title +
"&location=" + location;
break;
@@ -134,9 +139,8 @@
this.source = [
{value: 1, label:"Add to Google Calendar"},
{value: 2, label:"Add to Live Calendar"},
- {value: 3, label:"Add to Yahoo! Calendar"},
- {value: 4, label:"Add to 30boxes"},
- {value: 5, label:"iCal" } ];
+ {value: 3, label:"Add to Yahoo! Calendar"} ]
+ if(this.options.webcalProvided) this.source.push( {value: 4, label:"Add to 30boxes"}, {value: 5, label:"iCal" } );
},
toggleMenu: function( event ) {

0 comments on commit 30d2527

Please sign in to comment.