Simple calendar jquery plugin

Overview

Simple Calendar

preview

A simple and easy plugin to create a calendar and add events to it.

Usage

Including files

You need to include :

  • A recent version of JQuery
  • The javascript file jquery.simple-calendar.js
  • The stylesheet simple-calendar.css
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.simple-calendar.js"></script>
<link rel="stylesheet" type="text/css" href="simple-calendar.css" />

Simple usage

Inside a $(document).ready(); function you need to call the plugin on a container jquery element :

$(document).ready(function(){
    $("#container").simpleCalendar();
});

This initialize the calendar with its default settings.

Usage with options

To customize its settings simply overwrite them like below :

$(document).ready(function(){
    $("#container").simpleCalendar({
        //Defaults options below
        //string of months starting from january
        months: ['january','february','march','april','may','june','july','august','september','october','november','december'],
        days: ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'],
        displayYear: true,              // Display year in header
        fixedStartDay: true,            // Week begin always by monday or by day set by number 0 = sunday, 7 = saturday, false = month always begin by first day of the month
        displayEvent: true,             // Display existing event
        disableEventDetails: false, // disable showing event details
        disableEmptyDetails: false, // disable showing empty date details
        events: [],                     // List of events
        onInit: function (calendar) {}, // Callback after first initialization
        onMonthChange: function (month, year) {}, // Callback on month change
        onDateSelect: function (date, events) {}, // Callback on date selection
        onEventSelect: function() {}, // Callback on event selection - use $(this).data('event') to access the event
        onEventCreate: function( $el ) {},          // Callback fired when an HTML event is created - see $(this).data('event')
        onDayCreate:   function( $el, d, m, y ) {}  // Callback fired when an HTML day is created   - see $(this).data('today'), .data('todayEvents')
    });
});

Calendar events

Events are json object that contains startDate, endDate, and summary

var events = [{
    startDate: Date|timestamp|ISOstring,
    endDate: Date|timestamp|ISOstring,
    summary: string
}]

Methods

To use methods, first get the plugin instance from the data properties and then use the following methods.

var container = $("#container").simpleCalendar({ ...code });
let $calendar = container.data('plugin_simpleCalendar')

Add event

var newEvent = {
  startDate: new Date(new Date().setHours(new Date().getHours() + 48)).toISOString(),
  endDate: new Date(new Date().setHours(new Date().getHours() + 49)).getTime(),
  summary: 'New event'
}

$calendar.addEvent(newEvent)

Set events

var events = [{
  startDate: new Date(new Date().setHours(new Date().getHours() + 48)).toISOString(),
  endDate: new Date(new Date().setHours(new Date().getHours() + 49)).getTime(),
  summary: 'New event'
},
{
  startDate: new Date(new Date().setHours(new Date().getHours() - 24)).toISOString(),
  endDate: new Date(new Date().setHours(new Date().getHours() - 23)).getTime(),
  summary: 'New event 2'
}]

$calendar.setEvents(events)
Comments
  • Question: Ability to add Events?

    Question: Ability to add Events?

    Hello!

    Just a question. Is it possible to update Events after initialization?

    I tried calling again $calendar.simpleCalendar( { events: myEvents } ) but without much success, but maybe I'm doing something wrong.

    Thank you :)

    opened by valerio-bozzolan 6
  • Events Are Not Visible In Mac/iPhone (Safari)

    Events Are Not Visible In Mac/iPhone (Safari)

    The plugin is perfectly working on ( Chrome / Opera / Firefox ) - But when I open it on Safari the calender is perfectly visible but inside it the events and notable event dates are not visible.

    jQuery(document).on('click', '#showEventsTab', function(e){ e.preventDefault();

    var event_calender = '<div class="events-calender-wrapper"><div id="eventCalender"></div></div>';
    	
    jQuery('.events-intro-title > a').removeClass('tab-active');
    jQuery(this).addClass('tab-active');
    jQuery('.custom-paging-row').hide();
    jQuery('#signupEventContent').html(event_calender);
    var calContainer = jQuery(document).find('#eventCalender').simpleCalendar();
    let CalenderInstance = calContainer.data('plugin_simpleCalendar');
    
    jQuery.each(cs_object.event_object, function(index, val) {
    	var newEvent = {
    		startDate: new Date(val.ev_date).toISOString(),
    		endDate: new Date(val.ev_date).toISOString(),
    		summary: '<a href="'+val.ev_link+'">'+val.ev_title+'</a>'
    	}
    	CalenderInstance.addEvent(newEvent);
    });
    

    });

    opened by zohaibalimemonx 5
  • Is there provision for times zones?

    Is there provision for times zones?

    Eg, if someone is viewing events in the US, there will be at a certain time. but those same events need to appear at different times for someone viewing them in the UK.

    Does Simple Cal support this?

    Also - is there demo page somewhere to see how the various options work?

    Thanks!

    opened by coda-apps 4
  • Merge monsterbrain work

    Merge monsterbrain work

    Hi @monsterbrain ,

    I wish to merge your awesome work on displaying events and the demo page but their is to many changes and some unwanted changes. What I would want is :

    • Displaying events (cf screenshot and code)
    • Demo page with examples
    • Select callback
    • Standalone (no added librairies)

    I think I could cherry pick some of your work to new branches and create new PRs from that branches.

    What do you think ?

    Events : Events are an array of event (based on iCal standard if possible, even if we don't support the whole thing)

    events: [
      {
        summary: string
        dateStart: timestamp
        dateEnd: timestamp
      },
      ...
    ]
    

    image

    opened by brospars 4
  • Fixed start day does not work as expected

    Fixed start day does not work as expected

    fixedStartDay = 3 but still the calendar month starts with monday.

    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="utf-8">
    	<title></title>
    	<link rel="stylesheet" type="text/css" href="simple-calendar.css" />
    </head>
    <body>
    	<div id="container"></div>
    	<script src="jquery.js"></script>
    	<script type="text/javascript" src="simple-calendar.js"></script>
    		<script type="text/javascript">
    			jQuery( document ).ready( function() {
    				jQuery("#container").simpleCalendar( {
    					months: ['january','february','march','april','may','june','july','august','september','october','november','december'],
    					days: ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'],
    					displayYear: true,
    					fixedStartDay: 3,
    					displayEvent: true,
    					disableEventDetails: false,
    					disableEmptyDetails: false,
    					events: [],
    					onInit: function (calendar) {},
    					onMonthChange: function (month, year) {},
    					onDateSelect: function (date, events) {},
    					onEventSelect: function() {},
    					onEventCreate: function( jqueryel ) {},
    					onDayCreate:   function( jqueryel, d, m, y ) {}
    				} );
    			} );
    	</script>
    </body>
    </html>
    

    image

    opened by pokhiii 3
  • reset calendar

    reset calendar

    great plugin! is it possible to reset the calendar event data ? i tried using this calendar.empty().simpleCalendar({}) but it simply disappears and doesnt load again.

    opened by buzi 3
  • Missing month navigation

    Missing month navigation

    Hi, it looks like month navigation is missing in the current version of the code. At least, this part is suspicious:

    var calendar = $('<div class="calendar"></div>'); var header = $('<header>' + '<h2 class="month"></h2>' + '<a class="simple-calendar-btn btn-prev" href="#"></a>' + '<a class="simple-calendar-btn btn-next" href="#"></a>' + '</header>');

    There seems to be missing "<" and ">" .. as it was in some previous version. Or maybe it's solved now differently, but when I download the current version and open index.html, month navigation buttons are missing.

    Thank you Martin

    opened by marfig2005 3
  • Is this library still relevant today ?

    Is this library still relevant today ?

    I made this library some years ago and never updated it. I don't use it often but I could work on it if someone is interested...

    Todo :

    • [ ] Implementing events
    • [ ] Add options and api to customize usage and controls
    • [ ] Better docs and use cases
    • [ ] Refactor
    opened by brospars 3
  • (#15, #28) Fix to incorrect next month display on very first click when today's date is greater than next month days

    (#15, #28) Fix to incorrect next month display on very first click when today's date is greater than next month days

    Fix: #15 & #28 @brospars I dug out the issue and found that whenever the today date is greater than the total days on the next month, the next button behavior on the first time is not correct, it is skipping the next month. In my case, today is 2020-August-31 and on clicking the first time on the next arrow to change the calendar to next month, it skipped the September and displayed me October but after the first click on every click it displays the correct result. While researching around I got to bug on the line: https://github.com/brospars/simple-calendar/blob/a2357a392a1f9b3010f7869f0764f9478e574915/src/jquery.simple-calendar.js#L154 and after doing some research I found this solution https://stackoverflow.com/a/14680430/10119231 which worked for me. @brospars Not sure but changing this.currentDate.setMonth(this.currentDate.getMonth() + value); to this.currentDate.setMonth(this.currentDate.getMonth() + value, 1); might fix the problem, as in my case it's working fine. Here, is the PR, you can have a look. And if want me to explain the issue further then please let me know, I can try with the screenshots of my case in any of the reported issue.

    opened by Gauravbhatt19 2
  • date format

    date format

    heres my event, is't correct format? events: [   { startDate: 2020-08-05, endDate: 2020-08-10, summary: 'lorem ipsum 1' } , { startDate: 2020-08-07, endDate: 2020-08-10, summary: 'lorem ipsum 2' } , { startDate: 2020-08-09, endDate: 2020-08-09, summary: 'lorem ipsum 3' } ],

    opened by antonhilman 2
  • Add option to disable dates

    Add option to disable dates

    The plugin is still useful on today's era,who wants simple integration,can we have option to add disabled dates? as I see a relevant class is added - .wrong-month Requirement is simple,I would like to show all dates of a month disabled unless it's not in the event list array unlike now showing enabled all the dates.

    $("#event-cal-container").simpleCalendar({ //disabled : true,//this feature we are looking for events: ['2019-03-04', '2019-03-08', '2019-03-12', '2019-03-15'], eventsInfo: ['John\'s Birthday', 'Janet\'s Marriage','Graduation Day', 'Final Exams !'], selectCallback: function(date){ console.log('date selected '+date); }, insertCallback: function(date){ //console.log('date selected '+date); } });

    Originally posted by @findela in https://github.com/brospars/simple-calendar/issues/4#issuecomment-578636377

    opened by brospars 2
  • Bump decode-uri-component from 0.2.0 to 0.2.2

    Bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Property ignored?

    Property ignored?

    I think these two properties are ignored

    disableEventDetails: false, // disable showing event details
    disableEmptyDetails: false, // disable showing empty date details
    
    opened by GabrieleCicconetti 1
Owner
Benoit Rospars
I'm Benoit Rospars a software engineer based in Grenoble.
Benoit Rospars
jQuery plugin for showing a calendar yearview with blocks (github contributions style)

calendar-yearview-blocks jQuery plugin for showing a calendar yearview with blocks (github contributions style) Code adopted from https://github.com/b

Opbod 2 Feb 28, 2021
A simple Calendar Heatmap for jQuery

Calendar Heat Map This jQuery plugin allows to conveniently display data like contributions on a day by day basis, indicating the count by colors. Ins

Sebastian 38 Jul 5, 2022
A Tempermonky / Greasemonkey plugin which can help you export your class schedule to the calendar on your phone / pad / PC / Mac.

WHU Class Schedule Export as iCS Languages: English | 簡體中文 | 繁體中文 Changelog v0.90.1 - Sep 18, 2022 Fix bugs: Fix an error when a class have multiple s

Ostrich_B 6 Sep 7, 2022
Simple modern-looking event calendar 📅💜

evo-calendar Simple Modern-looking Event Calendar ?? Demo: https://edlynvillegas.github.io/evo-calendar/ ?? Features: Flexible and fully customizable

Edlyn Villegas 144 Jan 6, 2023
ES6 - Simple pure JavaScript calendar

rolyart-calendar Simple Pure JS Calendar. Demo Install Add rolyart-calendar.js Add style.css Add calendar container <div id="myCalendar"></div> Init c

Roland Maruntalu 3 Sep 28, 2022
This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Rajan Karmaker 1 Aug 22, 2022
🍞📅A JavaScript calendar that has everything you need.

A JavaScript schedule calendar that is full featured. Now your service just got the customizable calendar. ?? Table of Contents Collect statistics on

NHN 10.4k Jan 5, 2023
Quick access to view the current time and date in Ethiopian calendar.

Ethiopian-Current-time-chrome-extension Quick access to view the current time and date in Ethiopian calendar. steps to follow:- Extract the zip folder

null 10 Aug 26, 2022
🏳️‍🌈 event calendar

alman-akka :rainbow-flag: event calendar Frontend The frontend of this app uses NextJS and Node 16 together with Yarn 1.x as a package manager. Develo

null 3 Mar 10, 2022
A block calendar for Logseq.

Logseq Block Calendar A plugin to render a calendar in block, so you can put it onto right side bar. Features Click date to jump to journal page. Swit

Richard Yu 17 Dec 27, 2022
📅 Calendar link generator for popular services

?? Calendar Link Status Build Health Community JavaScript library to generate an event link for Google Calendar, Yahoo! Calendar, Microsoft Outlook, e

Anand Chowdhary 246 Dec 18, 2022
Basic styling to create calendar icons with pure HTML and CSS

Calendar Icon Basic styling to create calendar icons with pure HTML and CSS Usage Embed the CSS, and markup your date: <link type="text/css" rel="styl

null 1 Aug 23, 2022
Bulma's extension to display a calendar

bulma-calendar Bulma's extension to display a calendar. It can be used on page as large calendar with apointments or in modal/popup for datepicker. Ex

null 275 Jan 4, 2023
Script to synchronize between a Notion database and Google Calendar both ways. Uses Google App Script.

Yet Another Two Way Notion-Google Calendar Sync Script A script to sync events between Google calendar and a Notion database. Features! Google App Scr

kat 41 Jan 7, 2023
Memento mori (Latin for 'remember that you [have to] die'). Self-filling calendar.

Memento mori Latin for 'Remember your death', Memento Mori is a powerful concept that's been used for centuries to help people focus on what truly mat

Roni Laukkarinen 6 Nov 8, 2022
JQuery charCounter - jQuery Character Counter Plugin

jQuery Character Counter A jQuery based character counter for <input> and <textarea> HTML tags. What is this? This simple plugin allows you to add a c

mmmm_lemon 1 Aug 10, 2022
jQuery quick notification plugin. jQuery плагин быстрых уведомлений

Note: English translation by Google Translate Notific About Description: this is a jQuery plugin that helps you display notifications on your site. Li

Webarion 2 Nov 7, 2021
jquery-input-mask-phone-number.js - A simple, easy jquery format phone number mask library

jquery-input-mask-phone-number A jQuery Plugin to make masks on input field to US phone format. Quick start 1. Add latest jQuery and jquery-input-mask

Raja Rama Mohan Thavalam 12 Aug 25, 2022
A variety of jQuery plugin patterns for jump starting your plugin development

jQuery Plugin Patterns So, you've tried out jQuery Boilerplate or written a few of your own plugins before. They work to a degree and are readable, bu

jQuery Boilerplate 1.6k Dec 31, 2022