Author: ygrego Date: 2015-04-10 12:51:17 +0000 (Fri, 10 Apr 2015) New Revision: 1145 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1145 Log: Moving "if" block from method "createTimer" to method "clearTimer" and call "clearTimer" in "createTimer". Modified: oipf/js/utils/TimerManager.js Modified: oipf/js/utils/TimerManager.js =================================================================== --- oipf/js/utils/TimerManager.js 2015-04-10 10:15:18 UTC (rev 1144) +++ oipf/js/utils/TimerManager.js 2015-04-10 12:51:17 UTC (rev 1145) @@ -5,21 +5,21 @@ */ var TimerManager = Class.extend({ - timer: null, - - createTimer: function(time) { - if (this.timer) { - this.timer.cancel(); - console.log("cancelTimer", this.timer.timerId); - } - this.timer = new Timeout(time); - console.log("createTimer", this.timer.timerId); - return this.timer; - }, - - clearTimer: function() { - this.timer.cancel(); - } + timer: null, + + createTimer: function(time) { + this.clearTimer(); + this.timer = new Timeout(time); + console.log("createTimer", this.timer.timerId); + return this.timer; + }, + + clearTimer: function() { + if (this.timer) { + this.timer.cancel(); + console.log("cancelTimer", this.timer.timerId); + } + } });