By default, timer has a timeout of 5 seconds, output format is 'H:MM:SS' and initial value is the representation of the initial timeout.
If you have cancelled the timer, you can resume it by starting it again.
When the timer is exhaused and you need to rerun it, reset it first. You can also reset the timer while it is running.
The source code for the example above is listed below. Take a look at timer's initialization at the line #10.
To specify timer's timeout value, pass an object with 'seconds' attribure to the initialization function:
See an example:
By default, timer's output format is 'h%:m%:s%', which results in displaying hours without leading zero, minutes and seconds with leading zero, all separated by colons.
If timer's timeout has days, then they will be converted to hours, e.g.
will result into:
If you want to display days explicitly, then you have to change output format. Days pluralization is up to you. Below you can see the initialization of the same timer as above, but with another output format for handling days. Hours will have leading zero now.
Actually, you may use any format and set placeholders for time intervals in any order:
Very probably, you will want to do some action, when your timer is exhausted. To make so, you can set 'on_exhausted' callback function during plugin's initialization:
Callback function accepts 'timer' argument, which is an instance of timer plugin. Its properties will be discussed later. Now note, that it can access 'target' property, which in this case is equal to calling $('#timer_6').
If you need to perform some action on each tick, while your timer is working, you can set a callback for that event as well.
This will change color of the timer's value each second. Give it a try:
As you may noticed, callback functions have 'timer' as an input argument. It is an instance of the plugin applied to your element, which was created during plugin's initialization. If you dir its attributes (e.g., via 'console.dir(timer)') you will see all the guts of the plugin:
Two of them you are familiar with. They are 'target' and 'seconds_left'. Former is an object the plugin is applied to. As you can see, it is a 'span' element with an ID of '#timer_6' and with style a class 'timer'. Latter is the current value of seconds, which are left before the timer is considered to be exhausted. 'timeout' is the ID of current timer, created by 'setTimeout()' method. 'settings' stores output format, initial amount of seconds to count and a couple of callbacks, which were discussed just in the last two examples. 'methods' objects containes all the public and private methods of the plugin.
So, here you are. At the end of the documentation for backward timer. From now, you may know everything about it. Thanks for reading and good luck with usage!