Skip to content

Commit

Permalink
Update to version 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rendro committed May 6, 2016
1 parent b52c528 commit 9f79971
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 28 deletions.
8 changes: 8 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,18 @@ You can pass a set of these options to set a custom behaviour and look for the p
<td><strong>start</strong>(<em>[refreshRate]</em>)</td>
<td>Start the refresh loop. If you set a refresh rate in the options you can overwrite it with the argument <code>refreshRate</code>. If you don't pass an argument, the old value or the default value of 1 sec will be used.</td>
</tr>
<tr>
<td><strong>restart</strong>(<em>options</em>)</td>
<td>Update the options and restart the countdown</td>
</tr>
</table>

## Changelog

### Version 2.2.0 - <small>May 6, 2016</small>
* added restart countdown api method (Thanks @scazzy)
* Fixed bower dependencies and main field

### Version 2.1.0 - <small>Oct 13, 2014</small>
* Added time offset option to fix time differences between server and client time (#8)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "countdown",
"version": "2.1.0",
"version": "2.2.0",
"description": "Simple, lightweight and easy to use countdown plugin",
"licenses": [
{
Expand Down
43 changes: 31 additions & 12 deletions dest/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,28 @@ var Countdown = function(el, options) {
this.interval = false;

// merge default options and options into this.options
for (var i in defaultOptions) {
if (defaultOptions.hasOwnProperty(i)) {
this.options[i] = typeof options[i] !== 'undefined' ? options[i] : defaultOptions[i];

if (i === 'date' && typeof this.options.date !== 'object') {
this.options.date = new Date(this.options.date);
}

// bind context for functions
if (typeof this.options[i] === 'function') {
this.options[i] = this.options[i].bind(this);
this.mergeOptions = function(options) {
for (var i in defaultOptions) {
if (defaultOptions.hasOwnProperty(i)) {
this.options[i] = typeof options[i] !== 'undefined' ? options[i] : defaultOptions[i];

if (i === 'date' && typeof this.options.date !== 'object') {
this.options.date = new Date(this.options.date);
}

// bind context for functions
if (typeof this.options[i] === 'function') {
this.options[i] = this.options[i].bind(this);
}
}
}
}
if (typeof this.options.date !== 'object') {
this.options.date = new Date(this.options.date);
}
}.bind(this);

this.mergeOptions(options);


/**
* Get the difference between now and the end date
Expand Down Expand Up @@ -185,6 +193,17 @@ var Countdown = function(el, options) {
}.bind(this);


/**
* Restart the countdown and update options
*/
this.restart = function (options) {
this.mergeOptions(options);
this.interval = false;
this.start();
return this;
}.bind(this);


// initial start of the countdown or initial render
this.start();
};
Expand Down
2 changes: 1 addition & 1 deletion dest/countdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 31 additions & 12 deletions dest/jquery.countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,28 @@ var Countdown = function(el, options) {
this.interval = false;

// merge default options and options into this.options
for (var i in defaultOptions) {
if (defaultOptions.hasOwnProperty(i)) {
this.options[i] = typeof options[i] !== 'undefined' ? options[i] : defaultOptions[i];

if (i === 'date' && typeof this.options.date !== 'object') {
this.options.date = new Date(this.options.date);
}

// bind context for functions
if (typeof this.options[i] === 'function') {
this.options[i] = this.options[i].bind(this);
this.mergeOptions = function(options) {
for (var i in defaultOptions) {
if (defaultOptions.hasOwnProperty(i)) {
this.options[i] = typeof options[i] !== 'undefined' ? options[i] : defaultOptions[i];

if (i === 'date' && typeof this.options.date !== 'object') {
this.options.date = new Date(this.options.date);
}

// bind context for functions
if (typeof this.options[i] === 'function') {
this.options[i] = this.options[i].bind(this);
}
}
}
}
if (typeof this.options.date !== 'object') {
this.options.date = new Date(this.options.date);
}
}.bind(this);

this.mergeOptions(options);


/**
* Get the difference between now and the end date
Expand Down Expand Up @@ -185,6 +193,17 @@ var Countdown = function(el, options) {
}.bind(this);


/**
* Restart the countdown and update options
*/
this.restart = function (options) {
this.mergeOptions(options);
this.interval = false;
this.start();
return this;
}.bind(this);


// initial start of the countdown or initial render
this.start();
};
Expand Down
2 changes: 1 addition & 1 deletion dest/jquery.countdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easy-countdown",
"version": "2.1.0",
"version": "2.2.0",
"description": "Simple, lightweight and easy to use countdown plugin",
"main": "src/countdown.js",
"scripts": {
Expand Down

0 comments on commit 9f79971

Please sign in to comment.