Weekend Project: jQuery CountUp Plugin

W

This is my first jQuery plugin and also second weekend projectCountUp plugin is simply calculates time different between two dates and also iterates second by second.

One of the dates should be from past and second date will be setted automatically present. Then plugin gonna find how many time passed until now in three different format. These formats are full date (by year, month, day etc.), just days&more and lastly only seconds.

Version History
v1.1: Supports multiple instance (special thanks Gabriel Murphy)
v1.0: Just launched plugin.

Note: Lastest version is on github.

Example:

[code lang=”js”] $(document).ready(function(){

$(‘#jq_count’).countUp({‘format’:’full’, ‘sinceDate’: ’01/01/2011-00:00:00′});

});
[/code]

This snippet gives us 0 year, 9 month, 18 day, 20 hour, 51 minute, 32 seconds (which also shows the time that i wrote this post). You can change the output format by editing ‘format’ field.

Plugin is already available with 4 languages: English, Turkish, Spanish and Deutsch. Another example for Spanish:

[code lang=”js”]

$(document).ready(function(){

$(‘#jq_count’).countUp({‘lang’: ‘es’ ,’format’:’full’, ‘sinceDate’: ’01/01/2011-00:00:00′});

});
[/code]

Last but not least, you may want to hide “0” outputs, “write_zero” field does it.

Some other notes:

  • Date format: ‘dd/mm/yy-hh:mm:ss’
  • Only call with ID not class.
  • Suitable for jQuery 1.4+ and also jquery.min

Here is a small demo and codes are on github.

Please do not hesitate for bugs and suggestions.

11 Yorum

Oğulcan

Arşivler

Kategoriler