AngularJs Calendar | Directive for the Arshaw JQuery fullcalendar

While working on our latest project a need for a calendar implementation was needed. Since rolling a custom calendar would be very time consuming other options were taken for the immediate solution. Searching the web for calendar implementations will return many different open source calendars. Most are inadequate for current web standards. The best implantation that we came across was Arshaws’ Fullcalendar jQuery implementation. We decided to write an angular directive wrapping this calendar to accentuate its features in an AngularJs environment.

The Angular UI framework is the most well tested open source companion suite for Angular JS on the market and is trusted by many developers that are harnessing the power of Angular in their apps. The approach taken to create directives is focused on utilizing the uiConfig object, which is just an empty json object that is filled with the users options at compile time. These options are fed into the directive to render dom elements accordingly. This is the approach that was taken to wrap the fullcalendar.

The bones of the directive are modeled after the already in place angular-ui directives. This made the process simpler and more efficient. First the ui-config is inserted into the directive, to give the user the ability to enter native fullcalendar options.

angular.module('ui.directives').directive('uiCalendar',['ui.config', '$parse', function (uiConfig,$parse) {
    uiConfig.uiCalendar = uiConfig.uiCalendar || {};

The ng-model tag is required for the calendar the render correctly. The idea to use ng-model instead of events was proposed by ProLoser. The original creator of the Angular-UI repository. The logic being that most people are familiar with the ng-model syntax and would understand it more coming from a noob experience level. The ultimate goal of ng-model in this specific case is to take in either an array of events or and events object that contains information about a data source. These event items are documented splendidly on Arshaw's website.

    return {
        require: 'ngModel',
        restrict: 'A',
        scope: {
          events: "=ngModel"
        },

There are multiple points of interest in the link function that will be explained. The first is how the options and expressions are configured and passed into the fullcalendar method. The default options are related to the navigation for the calendar. These are used to page through different views of the calendar. They were set to show the month, week, and day view. The expression variable is used to pull the attributes out of the ui.config element to allow for more options to be entered from the directive's html interface. There can be as many different options entered into the calendar as needed. This opens up a wide variety of implementations that are available.

The only native method that was wrapped for the calendar was eventMouseOver. This was because the other methods, such as event drag and drop have many different implementations that should be left up to the end user for their desired functionality. However true this may be the fact has recently come up that the event methods should be tied to the directive at least to show the date or time changing by dragging and dropping the events. This means that in the near future the methods will be added to the calendar and wired up to the scope.

</pre>
link: function(scope, elm, $attrs) {
 var ngModel = $parse($attrs.ngModel);
 //update method that is called on load and whenever the events array is changed.
 function update() {
 //Default View Options
 var expression,
 options = {
 header: {
 left: 'prev,next today',
 center: 'title',
 right: 'month,agendaWeek,agendaDay'
 },
 // add event name to title attribute on mouseover. Would be nice if this was an angular tooltip.
 eventMouseover: function(event, jsEvent, view) {
 if (view.name !== 'agendaDay') {
 $(jsEvent.target).attr('title', event.title);
 }
 },

//extend the options to suite the custom directive.
angular.extend(options, uiConfig.uiCalendar, expression);

This was the most monumental part of the calendar implementation for me. Once I had the ability to add in live events from the scope and insert them directly into the calendar I felt a sense of great accomplishment. This meant that the sky was the limit and we were just taking off.

</pre>
// Calling the events from the scope through the ng-model binding attribute.
 events: scope.events
 };

Everything that was explained before is all encompassed in the directive's update method. The update method is called on the initial load and whenever the length of the scope.events array changes. This is because it is much more efficient to watch just the length of the array, rather than the entire array itself. This watch method is credited to Andy Joslin. There was a request while the calendar was on the PR list for Angular-UI, that the events should update automatically if the scope changes. Since this is part of the beauty of AngularJS it was a must that this worked.

 //call fullCalendar from an empty html tag, to keep angular happy.
 elm.html('').fullCalendar(options);
 }
 //on load update call.
 update();
 //watching the length of the array to create a more effifient update process.
 scope.$watch( 'events.length', function( newVal, oldVal )
 {
 //update the calendar on every change to the length of the events array
 update();
 }, true );
 }
 };
 }]);
 

ui-calendar has a few dependencies, which must be included in the app to be able to work properly. Jquery is always required, as well as the fullcalendar.min.js file. The current implementation that we are showing on this post is a version that pulls in a live google feed to display the events. To do this the gcal.js file is required. If drag and drop is required, then the jquery-ui file is required.

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"></script><script type="text/javascript" src="https://raw.github.com/arshaw/fullcalendar/master/lib/jquery-ui-1.8.23.custom.min.js"></script>
<script type="text/javascript" src="http://www.dillingermediaonline.com/wp-content/themes/enterprise/js/fullcalendar.js"></script><script type="text/javascript" src="http://arshaw.com/js/fullcalendar-1.5.3/fullcalendar/gcal.js"></script>

The markup for the calendar is very simple now thanks to Angular.

</pre>
While working on our latest project a need for a calendar implantation was needed. Since rolling a custom calendar would be very time consuming other options were taken for the immediate solution. Searching the web for calendar implementations will return many different open source calendars. Most are inadequate for current web standards. The best implantation that we came across was <a title="Fullcalendar" href="http://arshaw.com/fullcalendar/" target="_blank">Arshaws' Fullcalendar</a> jQuery implementation. We decided to write an angular directive wrapping this calendar to accentuate its features in an AngularJs environment.

The <a href="http://angular-ui.github.com/" target="_blank">Angular UI</a> framework is the most well tested open source companion suite for Angular JS on the market and is trusted by many developers that are harnessing the power of Angular in their apps. The approach taken to create directives is focused on utilizing the uiConfig object, which is just an empty json object that is filled with the users options at compile time. These options are fed into the directive to render dom elements accordingly. This is the approach that was taken to wrap the fullcalendar.

The bones of the directive are modeled after the already in place angular-ui directives. This made the process simpler and more efficient. First the ui-config is inserted into the directive, to give the user the ability to enter native fullcalendar options.

1
angular.module('ui.directives').directive('uiCalendar',['ui.config', '$parse', function (uiConfig,$parse) {
    uiConfig.uiCalendar = uiConfig.uiCalendar || {};

The ng-model tag is required for the calendar the render correctly. The idea to use ng-model instead of events was proposed by ProLoser. The original creater of the Angular-UI repository. The logic being that most people are familiar with the ng-model syntax and would understand it more coming from a noob experience level. The ultimate goal of ng-model in this specific case is to take in either an array of events or and events object that contains information about a data source. These event items are documented splendidly on Arshaw's website.

    return {
        require: 'ngModel',
        restrict: 'A',
        scope: {
          events: &quot;=ngModel&quot;
        },

There are multiple points of interest in the link function that will be explained. The first is how the options and expressions are configured and passed into the fullcalendar method. The default options are related to the navigation for the calendar. These are used to page through different views of the calendar. They were set to show the month, week, and day view. The expression variable is used to pull the attributes out of the ui.config element to allow for more options to be entered from the directive's html interface. There can be as many different options entered into the calendar as needed. This opens up a wide variety of implementations that are available.

The only native method that was wrapped for the calendar was eventMouseOver. This was because the other methods, such as event drag and drop have many different implementations that should be left up to the end user for their desired functionality. However true this may be the fact has recently come up that the event methods should be tied to the directive at least to show the date or time changing by dragging and dropping the events. This means that in the near future the methods will be added to the calendar and wired up to the scope.

</pre>
link: function(scope, elm, $attrs) {
 var ngModel = $parse($attrs.ngModel);
 //update method that is called on load and whenever the events array is changed.
 function update() {
 //Default View Options
 var expression,
 options = {
 header: {
 left: 'prev,next today',
 center: 'title',
 right: 'month,agendaWeek,agendaDay'
 },
 // add event name to title attribute on mouseover. Would be nice if this was an angular tooltip.
 eventMouseover: function(event, jsEvent, view) {
 if (view.name !== 'agendaDay') {
 $(jsEvent.target).attr('title', event.title);
 }
 },

//extend the options to suite the custom directive.
angular.extend(options, uiConfig.uiCalendar, expression);

This was the most monumental part of the calendar implementation for me. Once I had the ability to add in live events from the scope and insert them directly into the calendar I felt a sense of great accomplishment. This meant that the sky was the limit and we were just taking off.

</pre>
// Calling the events from the scope through the ng-model binding attribute.
 events: scope.events
 };

Everything that was explained before is all encumbused in the directive's update method. The update method is called on the initial load and whenever the length of the scope.events array changes. This is because it is much more efficient to watch just the length of the array, rather than the entire array itself. This watch method is credited to Andy Joslin. There was a request while the calendar was on the PR list for Angular-UI, that the events should update automatically if the scope changes. Since this is part of the beauty of AngularJS it was a must that this worked.

 //call fullCalendar from an empty html tag, to keep angular happy.
 elm.html('').fullCalendar(options);
 }
 //on load update call.
 update();
 //watching the length of the array to create a more effifient update process.
 scope.$watch( 'events.length', function( newVal, oldVal )
 {
 //update the calendar on every change to the length of the events array
 update();
 }, true );
 }
 };
 }]);
 

ui-calendar has a few dependencies, which must be included in the app to be able to work properly. Jquery is always required, as well as the fullcalendar.min.js file. The current implementation that we are showing on this post is a version that pulls in a live google feed to display the events. To do this the gcal.js file is required. If drag and drop is required, then the jquery-ui file is required.

<script src="http://code.jquery.com/jquery-1.7.1.js"></script>
<script src="https://raw.github.com/arshaw/fullcalendar/master/lib/jquery-ui-1.8.23.custom.min.js"></script>
<script src="http://www.dillingermediaonline.com/wp-content/themes/enterprise/js/fullcalendar.js"></script>
<script src="http://arshaw.com/js/fullcalendar-1.5.3/fullcalendar/gcal.js"></script>

The markup for the calendar is very simple now thanks to Angular.

<div ng-controller="MainCtrl">
  <div ui-calendar="{height: 800,editable: true}" ng-model='eventSource'></div>
</div>

{{alertMessage}}

The full code base on git hub is located here ui-calendar

Article Directory List for 2012 with High PR DoFollow Linking

Great list of high PR Article Directories to use for SEO in 2012.

PR7 Directories:

http://www.squidoo.com

PR6 Directories:

http://www.ezinearticles.com

http://www.selfgrowth.com

http://www.brighthub.com

http://www.hubpages.com

http://www.suite101.com

PR5 Directories:

http://www.goarticles.com

http://www.isnare.com

http://www.articlecity.com

http://www.site-reference.com

http://www.articlecircle.com

http://www.articlesbus.com

http://www.theallineed.com

PR4 Directories:

http://www.readezarchive.com

http://www.articlesfactory.com

http://www.articlerich.com

http://www.ideamarketers.com

http://www.amazines.com

http://www.articlebiz.com

http://www.articleslash.com

http://www.ezinemark.com

http://www.mycontentbuilder.com

http://www.biz-whiz.com

Favicons in Gmail? Why Isn’t This in Widespread Use?

My typical daily ritual, like most people that work on a computer begins with the grueling chore of getting those pesky emails read. Today was slightly different. When I opened my Gmail I saw a favicon being utilized in a marketing email. This tiny 16×16 favicon immediately grabbed my attention like a homing beacon. Normally I am very good at filtering out these marketing emails, but this time I had a very difficult time trying to ignore it.

email favicon

These favicons appeared in three places as seen in the three photos. First within my inbox next to my name in the subject line, and as seen below, it was next to my name in the subject line within the actual email.

 

Finally and most important, it appeared next to the Gmail favicon in my open Gmail Tab.

Email Favicon next to gmail favicon in browser

Naturally this got me very excited. At the time I was thinking that Google had just implemented a new feature in Gmail that I somehow missed. A feature that will allow better branding in email marketing blasts. I felt like a little kid on Christmas as I began my usual Google searches for favicons in Gmail/Email, and hoping to find a way to implement this ourselves. The very first post I saw searching for favicons in gmail was a post from Techcrunch titled, “Gmail, Now With Favicons“.

The article I found was rather disappointing to say the least. At first I thought it was only a month old, but after closer inspection I realized we were in the same month, but 3 years off. The article was dated Saturday, October 3rd, 2009. The author referenced Netflix using favicons in their email, but here we are 3 years later, and I had never seen nor heard of an example of this. I spent more time digging for a more up-to-date article, but I couldn’t find any articles discussing favicons in email after searching for roughly 15-20 minutes.

This could simply be some kind of a symbol that looks like a favicon, but if the idea was proposed for Netflix in 2009, then my question would be: What happened?favicons appearing in gmail

The idea seems to be more dead today than it was 3 years go. Also, why aren’t there more articles out there talking about this? I would think that this is an idea that would many of us would pounce on, but for some reason it never seemed to catch on. Either that or the idea was cancelled for some reason, Google was quiet about it, and the idea slowly drifted away into obscurity. In the meantime I will keep looking for an answer, and if anybody can shed some light on this situation it would be greatly appreciated!