Giter VIP home page Giter VIP logo

jquery.addtocalendar's Introduction

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.

Supported calendar systems:

  • Google Calendar

  • Microsoft Live Calendar

  • Yahoo! Calendar

  • 30boxes

  • Any iCal-compatible desktop application

  • Any vCalendar-compatible desktop application

See the addtocal.htm demo file for an example of how to initialize and use the widget. You can find and use a live demo at tardate.com/addtocal/addtocal.htm

Using AddToCal is simply a matter of initializing the widget, and attaching it to any DOM element that will hold a calendarable event in your application.

You need to implement one method when initializing AddToCal: getEventDetails( element ). 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 structure, and whether you are using a standard markup such as the hCalendar microformat.

Widget Initialzation

Here’s an example of the minimal initialisation require. This example attaches the addtocal widget to all elements with the class ‘addtocal’.

<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='javascripts/rfc3339date.js'></script>
<script type='text/javascript' src='javascripts/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.
    // Disable these features if reqired (as a result the 30boxes, iCal and vCalendar menu links will not appear)
    icalEnabled:false,
    vcalEnabled:false,

    getEventDetails: function( element ) {

      ... [implement whatever is required to parse 'element' into the required event structure] ...

      // 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>

Required getEventDetails event structure

The structure returned from getEventDetails has the following members:

  • webcalurl: full url to webcal resource (if supported) e.g. webcal://mydomain/events/1.ics

  • icalurl: full url to iCal resource (if supported) e.g. mydomain/events/1.ics

  • vcalurl: full url to vCalendar resource (if supported) e.g. mydomain/events/1.vcs

  • start: start time of the event (javascript date object)

  • end: end time of the event (javascript date object)

  • title: event title text

  • details: event details text

  • location: event location text

  • url: full url to information about the event e.g. mydomain/events/1.html

Source

For more information and source files, see the project’s github repository. Feel free to fork and enhance!

Dependencies

Copyright © 2010 Paul GALLAGHER tardate.com

Dual licensed under the MIT or GPL Version 2 licenses.

Other References

jquery.addtocalendar's People

Contributors

tardate avatar

Watchers

James Cloos avatar Vijayamaharaj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.