There are many needs for a calendar on any website. The problem with many calendar programs is reusability. They often only work with one Content Management System (CMS). When you need to move to another one, they don’t work.
If you are creating your own site with static files or your own CMS, then you usually have to develop your own calendar. That was my dilemma with the goPress CMS that I wrote. Then I found Jalendar 2 on CodeCanyon.
The first thing you need to do is to buy Jalendar 2 from CodeCanyon.
Once you have the Jalendar 2 zip file downloaded, unpack it into your working directory. The zip file should contain these files:
~/D/R/r/J/codecanyon-12662442-jalendar-2-calendar-pack-event-range-and-more ➜ tree . . ├── jalendar-event-demo.html ├── jalendar-linker-demo.html ├── jalendar-range-demo.html ├── jalendar-selector-demo.html ├── js │ ├── jalendar.js │ ├── jalendar.min.js │ ├── jalendar.min.js.map │ └── jquery-1.11.3.min.js └── style ├── jalendar.css ├── jalendar.css.map └── jalendar.less 2 directories, 12 files
The top directory has two folders (js and style) and example HTML files. The js directory contains the JavaScript for the Jalendar 2 program. It also contains the version of jQuery that it uses.
You will be using the jalendar.min.js
in your project. This gives the fastest load time for your website. The author says that you can use any version of jQuery version 1.11.3 or newer. But when I tried jQuery 3.1.1, I lost some functionality. So I’m just using the copy of jQuery that comes with the download.
The style directory contains the CSS files for Jalendar 2. In the style directory, there is the jalendar.less
file. This file creates the jalendar.css
and jalendar.css.map
file when processed by Less. Less is a CSS preprocessor for creating CSS files more easily. You will only need to use the Less files for making major changes to the styling of the calendars. Since you can change the colors with preferences, changing the Less files isn’t necessary.
In your working directory for this project, create the js directory. Then place a copy of the jalendar.min.js
and the jquery-1.11.3.min.js
files in it. Then create the css directory and place the jalendar.css
file in it.
At the top of the directory, create a file called Basic.html and place this code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!–Jalendar 2 Files–> <link rel="stylesheet" href="css/jalendar.css" type="text/css" /> <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="js/jalendar.min.js"></script> <title>Jalendar 2 Demo</title> </head> <body> <div id="calendar" class="jalendar"> </div> <script> $('#calendar').jalendar(); </script> </body> </html>
This is the minimal installation for Jalendar 2. It is a basic HTML boilerplate with the lines needed to create a calendar. Lines 8 and 10 load in the files for Jalendar 2. Line 9 loads in the jQuery. Line 15 is the HTML for the div
that will contain the calendar. The id
of the div
can be anything you want. The class has to have the jalendar
class. Otherwise, it doesn’t get the proper styling.
Lines 17 through 19 contain the least JavaScript code to display a calendar. It uses jQuery to locate the id of the div and execute the jalendar()
function on it.
When you load this file in your browser, you will see a calendar in a nice blue color. You can use the arrows at the top to move to the previous or next month. It is a nice-looking calendar for any website!
Showing events on the calendar is easy too. Create a series of event div
s inside the calendar div
. The format for an event div
is:
<div class="added-event" data-link="<link to event details" data-date="<date of event>" data-title="<title of the event>"> </div>
The <link to event details>
is a link to the page on your site, or another site, for details about that event. The <date of event>
is the text date of the event. The default date structure is dd-mm-yyyy
. The <title of the event>
is the text shown at the bottom of the calendar when the user selects the date of the event. Add the following to the HTML file inside the calendar’s div
:
<div class="added-event" data-date="25-12-2016" data-title="Christmas Day"></div>
Now, reload the page and you will see the event.
Selecting the day of the event will show the text you gave it at the bottom of the calendar. You can close the event list with the Close button at the bottom.
So far, I’ve only used the basic features for Jalendar 2. You can customize it with 17 different properties. You can see the full list on the Jalendar 2 website.
The first thing I need to do is make the calendar match my website. My website uses a tan color for the basic theme. I love the default blue, but it doesn’t quite match. Change the script code to:
$('#calendar').jalendar({ customDay: '12-23-2016', color: '#f2ce95', color2: '#f7edde', titleColor: "black", weekColor: "black", todayColor: "black", dateType: "mm-dd-yyyy" });
This code sets a custom day to show using the customDay
property. I’m setting the custom day so that when you test it on your system you will get the same results.
The colorization is set with the color
and color2
properties. The color properties set the topmost color. With the color2
property set, it creates a smooth gradient from the top color to the bottom color. The titleColor
, weekColor
, and todayColor
properties set the colorization for the title, week names, and the today number in the calendar.
The dateType
format sets the format to use for the event dates and for the customDay
property.
With these settings, I’m close to the look I want. But I like the corners more rounded. There isn’t a property for that, but I can see how to tweak it using the inspector.
In the inspector, I can tweak the CSS setting and figure out what needs to be changed to get the result I want. The .jalendar .jalendar-container .jalendar-pages
CSS path handles the rounding of the corners. When I set the border-radius
property to 20px
, I get the look that I like.
This gets it close, but there still is a problem. The bottom close button shows a slight black on the bottom corners. The inspector shows that the style .jalendar .jalendar-container .jalendar-pages .add-event .close-button
is responsible. So you will need to add the two styling rules to the HTML:
<style> .jalendar .jalendar-container .jalendar-pages { border-radius: 20px; } .jalendar .jalendar-container .jalendar-pages .add-event .close-button { border-radius: 0 0 20px 20px; } </style>
It’s easy to edit select CSS properties this way. Hacking the original CSS source code is sometimes harder. It also allows for keeping your edits separate from what you get from the author. When you update to a newer version, you can see what edits you made without losing them.
Now that I have the look that I want, I can add it to my website. The download for this tutorial has a copy of my goPress Server that I use with the theme for my website. Please refer to the goPress Server tutorial on how to build the server.
I added the following code to the site/parts/sidebar.html
file:
<h2 class="sidebarTitle">Events</h2> <div id="EventCalendar"> <div id="calendar" class="jalendar"> <div class="added-event" data-date="12-25-2016" data-title="Christmas Day"></div> <div class="added-event" data-date="12-24-2016" data-title="Christmas Eve"></div> <div class="added-event" data-date="12-31-2016" data-title="New Years Eve"></div> <div class="added-event" data-date="01-01-2017" data-title="New Years Day"></div> </div> </div> <style> .jalendar .jalendar-container .jalendar-pages { border-radius: 20px; } .jalendar .jalendar-container .jalendar-pages .add-event .close-button { border-radius: 0 0 20px 20px; } .jalendar { width: 300px; } </style> <hr>
Then you will need to add the jalendar.css
to the site/css
directory. The jquery-1.11.3.min.js
and the jalendar.min.js
files go in the site/js
directory. Since JavaScript files are load order dependent, add a 00-
to the jQuery file and a 01-
to the Jalendar 2 file. I set the width for the .jalendar
div to center the calendar. The jalendar.css
file already had the margins for the calendar set to auto
. The problem is that the browser doesn’t center it unless you assign the width.
Now, you need to set the code for processing the calendar set in the site/js/02-site.js
file. Open that file and add this code:
jQuery(document).ready(function () { SyntaxHighlighter.all(); $('#calendar').jalendar({ customDay: '12-23-2016', color: '#f2ce95', color2: '#C7AB82', titleColor: "black", weekColor: "black", todayColor: "black", dateType: "mm-dd-yyyy" }); });
The SyntaxHighlighter.all()
code is for setting up any code highlighting for the page. The rest is what I copied from the last test file running the Jalendar 2 code from the last section.
When you run the goPress server, you should see the above web page. The centered calendar is the sidebar with the proper theme matching colors.
At times, you will need a date picker inside your web page. Jalendar 2 works great for this as well. In the site/main.html
file, add these lines:
<h3>Testing Jalendar 2</h3> <h4>Date Picker</h4> <div class="jalendar-input"> <input type="text" readonly /> <div id="dateInputCal" class="jalendar"></div> </div>
Then add this code to the site/js/02-site.js
file:
$('#dateInputCal').jalendar({ type: 'selector', selectingBeforeToday: false, selectingAfterToday: true, color: '#f2ce95', color2: '#C7AB82', titleColor: "black", weekColor: "black", todayColor: "black" });
This code is just after the code for initializing the sidebar calendar. The type
property is set to selector
to create a date selector. The selectingBeforeToday
property is set to false. This insures that the user can’t select a date before the current date. The selectingAfterToday
property is set to true. This insures that the user can select dates after the current date.
The resulting date picker looks just like the one in the sidebar. There are two main differences. It shows the current date, and the user can only select dates after the current date. When you select a date, it gets placed in the text box above the calendar.
With the right tools, adding items to your website is easy. The Jalendar 2 calendar is easy to integrate with any website and looks good. Now, you need to add it to your website. There are more items on CodeCanyon that you can add to your site as well.
The Best Small Business Web Designs by DesignRush
/Create Modern Vue Apps Using Create-Vue and Vite
/Pros and Cons of Using WordPress
/How to Fix the “There Has Been a Critical Error in Your Website” Error in WordPress
/How To Fix The “There Has Been A Critical Error in Your Website” Error in WordPress
/How to Create a Privacy Policy Page in WordPress
/How Long Does It Take to Learn JavaScript?
/The Best Way to Deep Copy an Object in JavaScript
/Adding and Removing Elements From Arrays in JavaScript
/Create a JavaScript AJAX Post Request: With and Without jQuery
/5 Real-Life Uses for the JavaScript reduce() Method
/How to Enable or Disable a Button With JavaScript: jQuery vs. Vanilla
/How to Enable or Disable a Button With JavaScript: jQuery vs Vanilla
/Confirm Yes or No With JavaScript
/How to Change the URL in JavaScript: Redirecting
/15+ Best WordPress Twitter Widgets
/27 Best Tab and Accordion Widget Plugins for WordPress (Free & Premium)
/21 Best Tab and Accordion Widget Plugins for WordPress (Free & Premium)
/30 HTML Best Practices for Beginners
/31 Best WordPress Calendar Plugins and Widgets (With 5 Free Plugins)
/25 Ridiculously Impressive HTML5 Canvas Experiments
/How to Implement Email Verification for New Members
/How to Create a Simple Web-Based Chat Application
/30 Popular WordPress User Interface Elements
/Top 18 Best Practices for Writing Super Readable Code
/Best Affiliate WooCommerce Plugins Compared
/18 Best WordPress Star Rating Plugins
/10+ Best WordPress Twitter Widgets
/20+ Best WordPress Booking and Reservation Plugins
/Working With Tables in React: Part Two
/Best CSS Animations and Effects on CodeCanyon
/30 CSS Best Practices for Beginners
/How to Create a Custom WordPress Plugin From Scratch
/10 Best Responsive HTML5 Sliders for Images and Text… and 3 Free Options
/16 Best Tab and Accordion Widget Plugins for WordPress
/18 Best WordPress Membership Plugins and 5 Free Plugins
/25 Best WooCommerce Plugins for Products, Pricing, Payments and More
/10 Best WordPress Twitter Widgets
1 /12 Best Contact Form PHP Scripts for 2020
/20 Popular WordPress User Interface Elements
/10 Best WordPress Star Rating Plugins
/12 Best CSS Animations on CodeCanyon
/12 Best WordPress Booking and Reservation Plugins
/12 Elegant CSS Pricing Tables for Your Latest Web Project
/24 Best WordPress Form Plugins for 2020
/14 Best PHP Event Calendar and Booking Scripts
/Create a Blog for Each Category or Department in Your WooCommerce Store
/8 Best WordPress Booking and Reservation Plugins
/Best Exit Popups for WordPress Compared
/Best Exit Popups for WordPress Compared
/11 Best Tab & Accordion WordPress Widgets & Plugins
/12 Best Tab & Accordion WordPress Widgets & Plugins
1 /New Course: Practical React Fundamentals
/Preview Our New Course on Angular Material
/Build Your Own CAPTCHA and Contact Form in PHP
/Object-Oriented PHP With Classes and Objects
/Best Practices for ARIA Implementation
/Accessible Apps: Barriers to Access and Getting Started With Accessibility
/Dramatically Speed Up Your React Front-End App Using Lazy Loading
/15 Best Modern JavaScript Admin Templates for React, Angular, and Vue.js
/15 Best Modern JavaScript Admin Templates for React, Angular and Vue.js
/19 Best JavaScript Admin Templates for React, Angular, and Vue.js
/New Course: Build an App With JavaScript and the MEAN Stack
/Hands-on With ARIA: Accessibility Recipes for Web Apps
/10 Best WordPress Facebook Widgets
13 /Hands-on With ARIA: Accessibility for eCommerce
/New eBooks Available for Subscribers
/Hands-on With ARIA: Homepage Elements and Standard Navigation
/Site Accessibility: Getting Started With ARIA
/How Secure Are Your JavaScript Open-Source Dependencies?
/New Course: Secure Your WordPress Site With SSL
/Testing Components in React Using Jest and Enzyme
/Testing Components in React Using Jest: The Basics
/15 Best PHP Event Calendar and Booking Scripts
/Create Interactive Gradient Animations Using Granim.js
/How to Build Complex, Large-Scale Vue.js Apps With Vuex
1 /Examples of Dependency Injection in PHP With Symfony Components
/Set Up Routing in PHP Applications Using the Symfony Routing Component
1 /A Beginner’s Guide to Regular Expressions in JavaScript
/Introduction to Popmotion: Custom Animation Scrubber
/Introduction to Popmotion: Pointers and Physics
/New Course: Connect to a Database With Laravel’s Eloquent ORM
/How to Create a Custom Settings Panel in WooCommerce
/Building the DOM faster: speculative parsing, async, defer and preload
1 /20 Useful PHP Scripts Available on CodeCanyon
3 /How to Find and Fix Poor Page Load Times With Raygun
/Introduction to the Stimulus Framework
/Single-Page React Applications With the React-Router and React-Transition-Group Modules
12 Best Contact Form PHP Scripts
1 /Getting Started With the Mojs Animation Library: The ShapeSwirl and Stagger Modules
/Getting Started With the Mojs Animation Library: The Shape Module
/Getting Started With the Mojs Animation Library: The HTML Module
/Project Management Considerations for Your WordPress Project
/8 Things That Make Jest the Best React Testing Framework
/Creating an Image Editor Using CamanJS: Layers, Blend Modes, and Events
/New Short Course: Code a Front-End App With GraphQL and React
/Creating an Image Editor Using CamanJS: Applying Basic Filters
/Creating an Image Editor Using CamanJS: Creating Custom Filters and Blend Modes
/Modern Web Scraping With BeautifulSoup and Selenium
/Challenge: Create a To-Do List in React
1 /Deploy PHP Web Applications Using Laravel Forge
/Getting Started With the Mojs Animation Library: The Burst Module
/10 Things Men Can Do to Support Women in Tech
/A Gentle Introduction to Higher-Order Components in React: Best Practices
/Challenge: Build a React Component
/A Gentle Introduction to HOC in React: Learn by Example
/A Gentle Introduction to Higher-Order Components in React
/Creating Pretty Popup Messages Using SweetAlert2
/Creating Stylish and Responsive Progress Bars Using ProgressBar.js
/18 Best Contact Form PHP Scripts for 2022
/How to Make a Real-Time Sports Application Using Node.js
/Creating a Blogging App Using Angular & MongoDB: Delete Post
/Set Up an OAuth2 Server Using Passport in Laravel
/Creating a Blogging App Using Angular & MongoDB: Edit Post
/Creating a Blogging App Using Angular & MongoDB: Add Post
/Introduction to Mocking in Python
/Creating a Blogging App Using Angular & MongoDB: Show Post
/Creating a Blogging App Using Angular & MongoDB: Home
/Creating a Blogging App Using Angular & MongoDB: Login
/Creating Your First Angular App: Implement Routing
/Persisted WordPress Admin Notices: Part 4
/Creating Your First Angular App: Components, Part 2
/Persisted WordPress Admin Notices: Part 3
/Creating Your First Angular App: Components, Part 1
/How Laravel Broadcasting Works
/Persisted WordPress Admin Notices: Part 2
/Create Your First Angular App: Storing and Accessing Data
/Persisted WordPress Admin Notices: Part 1
/Error and Performance Monitoring for Web & Mobile Apps Using Raygun
/Using Luxon for Date and Time in JavaScript
7 /How to Create an Audio Oscillator With the Web Audio API
/How to Cache Using Redis in Django Applications
/20 Essential WordPress Utilities to Manage Your Site
/Introduction to API Calls With React and Axios
/Beginner’s Guide to Angular 4: HTTP
/Rapid Web Deployment for Laravel With GitHub, Linode, and RunCloud.io
/Beginners Guide to Angular 4: Routing
/Beginner’s Guide to Angular 4: Services
/Beginner’s Guide to Angular 4: Components
/Creating a Drop-Down Menu for Mobile Pages
/Introduction to Forms in Angular 4: Writing Custom Form Validators
/10 Best WordPress Booking & Reservation Plugins
/Getting Started With Redux: Connecting Redux With React
/Getting Started With Redux: Learn by Example
/Getting Started With Redux: Why Redux?
/Understanding Recursion With JavaScript
/How to Auto Update WordPress Salts
/How to Download Files in Python
/Eloquent Mutators and Accessors in Laravel
1 /10 Best HTML5 Sliders for Images and Text
/Site Authentication in Node.js: User Signup
/Creating a Task Manager App Using Ionic: Part 2
/Creating a Task Manager App Using Ionic: Part 1
/Introduction to Forms in Angular 4: Reactive Forms
/Introduction to Forms in Angular 4: Template-Driven Forms
/24 Essential WordPress Utilities to Manage Your Site
/25 Essential WordPress Utilities to Manage Your Site
/Get Rid of Bugs Quickly Using BugReplay
1 /Manipulating HTML5 Canvas Using Konva: Part 1, Getting Started
/10 Must-See Easy Digital Downloads Extensions for Your WordPress Site
/22 Best WordPress Booking and Reservation Plugins
/Understanding ExpressJS Routing
/15 Best WordPress Star Rating Plugins
/Creating Your First Angular App: Basics
/Inheritance and Extending Objects With JavaScript
/Introduction to the CSS Grid Layout With Examples
1Performant Animations Using KUTE.js: Part 5, Easing Functions and Attributes
Performant Animations Using KUTE.js: Part 4, Animating Text
/Performant Animations Using KUTE.js: Part 3, Animating SVG
/New Course: Code a Quiz App With Vue.js
/Performant Animations Using KUTE.js: Part 2, Animating CSS Properties
Performant Animations Using KUTE.js: Part 1, Getting Started
/10 Best Responsive HTML5 Sliders for Images and Text (Plus 3 Free Options)
/Single-Page Applications With ngRoute and ngAnimate in AngularJS
/Deferring Tasks in Laravel Using Queues
/Site Authentication in Node.js: User Signup and Login
/Working With Tables in React, Part Two
/Working With Tables in React, Part One
/How to Set Up a Scalable, E-Commerce-Ready WordPress Site Using ClusterCS
/New Course on WordPress Conditional Tags
/TypeScript for Beginners, Part 5: Generics
/Building With Vue.js 2 and Firebase
6 /Best Unique Bootstrap JavaScript Plugins
/Essential JavaScript Libraries and Frameworks You Should Know About
/Vue.js Crash Course: Create a Simple Blog Using Vue.js
/Build a React App With a Laravel RESTful Back End: Part 1, Laravel 5.5 API
/API Authentication With Node.js
/Beginner’s Guide to Angular: Routing
/Beginners Guide to Angular: Routing
/Beginner’s Guide to Angular: Services
/Beginner’s Guide to Angular: Components
/How to Create a Custom Authentication Guard in Laravel
/Learn Computer Science With JavaScript: Part 3, Loops
/Build Web Applications Using Node.js
/Learn Computer Science With JavaScript: Part 4, Functions
/Learn Computer Science With JavaScript: Part 2, Conditionals
/Create Interactive Charts Using Plotly.js, Part 5: Pie and Gauge Charts
/Create Interactive Charts Using Plotly.js, Part 4: Bubble and Dot Charts
Create Interactive Charts Using Plotly.js, Part 3: Bar Charts
/Awesome JavaScript Libraries and Frameworks You Should Know About
/Create Interactive Charts Using Plotly.js, Part 2: Line Charts
/Bulk Import a CSV File Into MongoDB Using Mongoose With Node.js
/Build a To-Do API With Node, Express, and MongoDB
/Getting Started With End-to-End Testing in Angular Using Protractor
/TypeScript for Beginners, Part 4: Classes
/Object-Oriented Programming With JavaScript
/10 Best Affiliate WooCommerce Plugins Compared
/Stateful vs. Stateless Functional Components in React
/Make Your JavaScript Code Robust With Flow
/Build a To-Do API With Node and Restify
/Testing Components in Angular Using Jasmine: Part 2, Services
/Testing Components in Angular Using Jasmine: Part 1
/Creating a Blogging App Using React, Part 6: Tags
/React Crash Course for Beginners, Part 3
/React Crash Course for Beginners, Part 2
/React Crash Course for Beginners, Part 1
/Set Up a React Environment, Part 4
1 /Set Up a React Environment, Part 3
/New Course: Get Started With Phoenix
/Set Up a React Environment, Part 2
/Set Up a React Environment, Part 1
/Command Line Basics and Useful Tricks With the Terminal
/How to Create a Real-Time Feed Using Phoenix and React
/Build a React App With a Laravel Back End: Part 2, React
/Build a React App With a Laravel RESTful Back End: Part 1, Laravel 9 API
/Creating a Blogging App Using React, Part 5: Profile Page
/Pagination in CodeIgniter: The Complete Guide
/JavaScript-Based Animations Using Anime.js, Part 4: Callbacks, Easings, and SVG
/JavaScript-Based Animations Using Anime.js, Part 3: Values, Timeline, and Playback
/Learn to Code With JavaScript: Part 1, The Basics
/10 Elegant CSS Pricing Tables for Your Latest Web Project
/Getting Started With the Flux Architecture in React
/Getting Started With Matter.js: The Composites and Composite Modules
Getting Started With Matter.js: The Engine and World Modules
/10 More Popular HTML5 Projects for You to Use and Study
/Understand the Basics of Laravel Middleware
/Iterating Fast With Django & Heroku
/Creating a Blogging App Using React, Part 4: Update & Delete Posts
/Creating a jQuery Plugin for Long Shadow Design
/How to Register & Use Laravel Service Providers
2 /Unit Testing in React: Shallow vs. Static Testing
/Creating a Blogging App Using React, Part 3: Add & Display Post
/Creating a Blogging App Using React, Part 2: User Sign-Up
20 /Creating a Blogging App Using React, Part 1: User Sign-In
/Creating a Grocery List Manager Using Angular, Part 2: Managing Items
/9 Elegant CSS Pricing Tables for Your Latest Web Project
/Dynamic Page Templates in WordPress, Part 3
/Angular vs. React: 7 Key Features Compared
/Creating a Grocery List Manager Using Angular, Part 1: Add & Display Items
New eBooks Available for Subscribers in June 2017
/Create Interactive Charts Using Plotly.js, Part 1: Getting Started
/The 5 Best IDEs for WordPress Development (And Why)
/33 Popular WordPress User Interface Elements
/New Course: How to Hack Your Own App
/How to Install Yii on Windows or a Mac
/What Is a JavaScript Operator?
/How to Register and Use Laravel Service Providers
/
waly Good blog post. I absolutely love this…