diff --git a/js/module.js b/js/module.js index a92ee22c..44c50099 100644 --- a/js/module.js +++ b/js/module.js @@ -110,6 +110,20 @@ var Module = Class.extend({ Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload); }, + /* suspend() + * This method is called when a module is hidden. + */ + suspend: function() { + Log.log(this.name + " is suspend."); + }, + + /* resume() + * This method is called when a module is shown. + */ + resume: function() { + Log.log(this.name + " is resumed."); + }, + /********************************************* * The methods below don"t need subclassing. * *********************************************/ @@ -291,7 +305,13 @@ var Module = Class.extend({ * argument callback function - Called when the animation is done. */ hide: function(speed, callback) { - MM.hideModule(this, speed, callback); + callback = callback || function() {}; + + var self = this; + MM.hideModule(self, speed, function() { + self.suspend(); + callback(); + }); }, /* showModule(module, speed, callback) @@ -301,6 +321,7 @@ var Module = Class.extend({ * argument callback function - Called when the animation is done. */ show: function(speed, callback) { + this.resume(); MM.showModule(this, speed, callback); } }); diff --git a/modules/README.md b/modules/README.md index e69ec337..43c694b3 100644 --- a/modules/README.md +++ b/modules/README.md @@ -208,6 +208,13 @@ socketNotificationReceived: function(notification, payload) { }, ```` +####`suspend()` +When a module is hidden (using the `module.hide()` method), the `suspend()` method will be called. By subclassing this method you can perform tasks like halting the update timers. + +####`resume()` +When a module will be shown after it was previously hidden (using the `module.show()` method), the `resume()` method will be called. By subclassing this method you can perform tasks restarting the update timers. + + ### Module instance methods Each module instance has some handy methods which can be helpfull building your module.