Permalink
Browse files

update to 0.1.2

* includes some whitespace cleanup
  • Loading branch information...
1 parent 57f2c6e commit 9bcfd03cd3f2e58ddfcbd4bf297711eba6c9b3b5 @tardate committed Jan 7, 2013
Showing with 59 additions and 55 deletions.
  1. +4 −0 CHANGELOG.rdoc
  2. +1 −1 README.rdoc
  3. +26 −26 addtocal.htm
  4. +28 −28 jquery.addtocal.js
View
@@ -1,3 +1,7 @@
+== 0.1.2 released 2013-01-08
+
+* Truncate details to avoid 414 error on Google Calendar site (thanks to woodchuck)
+
== 0.1.1 released 2011-03-20
* Patch for javascript compatibility in older IE (thanks to nfarina)
View
@@ -1,4 +1,4 @@
-= jQuery UI AddToCal widget v0.1.0
+= jQuery UI AddToCal widget v0.1.2
AddToCal is a jQuery UI widget that provides "Add to Calendar" functionality for any website.
Given event details, it allows users to add the event to any supported calendar system.
View
@@ -7,7 +7,7 @@
<!-- 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;
@@ -38,7 +38,7 @@
}
.addtocal .description {
}
-
+
</style>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
@@ -49,29 +49,29 @@
<script type='text/javascript'>
$(document).ready(function() {
-
+
$('.addtocal').AddToCal({
- /* ical and vcal require an ics or vcs file to be served.
+ /* 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.
+
+ /* 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.
+ * 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.
+ * The example below illustrates how to handle two formats of event markup.
*/
getEventDetails: function( element ) {
- var
+ 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) {
@@ -82,46 +82,46 @@
}
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 {
+ return {
webcalurl: null,
icalurl: null,
- vcalurl: null,
- start: start,
- end: end,
- title: title,
- details: details,
- location: 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.
+ <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.
+ 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>
View
@@ -1,5 +1,5 @@
/*
- * jQuery.addtocal v0.1.1
+ * jQuery.addtocal v0.1.2
* http://github.com/tardate/jquery.addtocalendar
*
* Copyright (c) 2010 Paul GALLAGHER http://tardate.com
@@ -9,11 +9,11 @@
*/
(function($) {
-
+
$.widget("tardate.AddToCal",
{
options: {
-
+
/*
* calendars is a collection of all the supported calendars and the method for formating
* the calendar link in each case. If you want to use a calendar system not supported here, you can
@@ -71,12 +71,12 @@
return ( eventDetails.vcalurl ? eventDetails.vcalurl : null );
} }
],
-
+
/* icalEnabled: set if iCal links are to be supported (requires you to provide an iCal format resource) */
icalEnabled: true,
/* vcalEnabled: set if vCalendar links are to be supported (requires you to provide an vCalendar format resource) */
vcalEnabled: true,
-
+
/* 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.
@@ -94,8 +94,8 @@
title: null, details: null,
location: null, url: null};
},
-
-
+
+
/*
* sanitizeEventDetails cleans up and normalises the event details provided by getEventDetails
*/
@@ -117,7 +117,7 @@
eventDetails.url = ( eventDetails.url ? encodeURIComponent( eventDetails.url ) : '' );
return eventDetails;
},
-
+
/* records the currently selected calendar service */
selectedCalendarTarget: null,
/* positioning of the addtocal widget */
@@ -127,7 +127,7 @@
at: "left bottom",
collision: "none"
},
-
+
/* main method called on selection of calendar service */
select: function(event, ui) {
var eventDetails = ui.sanitizeEventDetails( ui.getEventDetails($(this)) );
@@ -138,9 +138,9 @@
if(link) window.open(link);
}
},
-
+
source:[],
-
+
_create: function() {
var self = this,
doc = this.element[ 0 ].ownerDocument;
@@ -160,15 +160,15 @@
selected: function( event, ui ) {
var item = ui.item.data( "item.addtocal" ),
previous = self.previous;
-
+
// only trigger when focus was lost (click on menu)
if ( self.element[0] !== doc.activeElement ) {
self.element.focus();
self.previous = previous;
}
self.options.selectedCalendarTarget = item.value;
self._trigger( "select", event, self.options );
-
+
self.close( event );
self.selectedItem = item;
}
@@ -177,38 +177,38 @@
.css({ top: 0, left: 0 })
.hide()
.data( "menu" );
-
+
if ( $.fn.bgiframe ) {
this.menu.element.bgiframe();
}
-
+
//Close the popup if click elsewhere in the window
$(document).bind("click", function(event, ui) { self.close( event ); });
-
+
},
-
+
destroy: function() {
this.element
.removeClass( "ui-addtocal" );
this.menu.element.remove();
$.Widget.prototype.destroy.call( this );
},
-
+
_setOption: function( key, value ) {
$.Widget.prototype._setOption.apply( this, arguments );
if ( key === "appendTo" ) {
this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
}
},
-
+
_initSource: function() {
var self = this;
self.source=[];
$.each( this.options.calendars, function(index, value) {
if(value.enabled(self)) self.source.push( {value: value.value, label: value.label } );
});
},
-
+
toggleMenu: function( event ) {
var content = this.source;
if ( content.length && ! ( this.menu.element.is(":visible") ) ) {
@@ -220,7 +220,7 @@
this.close();
}
},
-
+
close: function( event ) {
clearTimeout( this.closing );
if ( this.menu.element.is(":visible") ) {
@@ -229,7 +229,7 @@
this.menu.deactivate();
}
},
-
+
_normalize: function( items ) {
// assume all items have the right format when the first item is complete
if ( items.length && items[0].label && items[0].value ) {
@@ -248,7 +248,7 @@
}, item );
});
},
-
+
_suggest: function( items ) {
var ul = this.menu.element
.empty()
@@ -262,30 +262,30 @@
this.menu.element.show().position( $.extend({
of: this.element
}, this.options.position ));
-
+
menuWidth = ul.width( "" ).outerWidth();
textWidth = this.element.outerWidth();
ul.outerWidth( Math.max( menuWidth, textWidth ) );
},
-
+
_renderMenu: function( ul, items ) {
var self = this;
$.each( items, function( index, item ) {
self._renderItem( ul, item );
});
},
-
+
_renderItem: function( ul, item) {
return $( "<li></li>" )
.data( "item.addtocal", item )
.append( $( "<a></a>" ).text( item.label ) )
.appendTo( ul );
},
-
+
widget: function() {
return this.menu.element;
}
-
+
});
}(jQuery));

0 comments on commit 9bcfd03

Please sign in to comment.