renamed excludes config to fixed, added legacy handling code.

This commit is contained in:
Edward Shen 2019-02-13 00:15:20 -05:00
parent 9f255cf04d
commit d2323aa116
Signed by: edward
GPG key ID: 19182661E818369F
2 changed files with 17 additions and 9 deletions

View file

@ -10,7 +10,8 @@ Module.register('MMM-pages', {
*/
defaults: {
modules: [],
excludes: ['MMM-page-indicator'],
excludes: [], // Keep for compatibility
fixed: ['MMM-page-indicator'],
animationTime: 1000,
rotationTime: 0,
rotationDelay: 10000
@ -40,6 +41,12 @@ Module.register('MMM-pages', {
*/
start: function() {
this.curPage = 0;
// Compatibility
if (this.config.excludes.length) {
Log.warn(`[Pages]: The config option "excludes" is deprecated. Please use "fixed" instead.`);
this.config.fixed = this.config.excludes;
}
// Disable rotation if an invalid input is given
this.config.rotationTime = Math.max(this.config.rotationTime, 0);
@ -140,7 +147,7 @@ Module.register('MMM-pages', {
// Hides all modules not on the current page. This hides any module not
// meant to be shown.
MM.getModules()
.exceptWithClass(this.config.excludes)
.exceptWithClass(this.config.fixed)
.exceptWithClass(this.config.modules[this.curPage])
.enumerate(module => module.hide(
self.config.animationTime / 2,

View file

@ -42,7 +42,7 @@ modules: [
modules:
[[ "weatherforecast", "newsfeed"],
[ "calendar", "compliments" ]],
excludes: ["clock", "currentweather", "MMM-page-indicator"],
fixed: ["clock", "currentweather", "MMM-page-indicator"],
}
}
]
@ -50,12 +50,13 @@ modules: [
## Configuration options
| Option | Type | Default Value | Description |
| --------------- | ------------------ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Notethat all entries must take their class name (e.g. this module's class name is `MMM-pages`, while the default modules may just have `newsfeed`, without the `MMM-` prefix. |
| `excludes` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. |
| `animationTime` | `int` | `1000` | Fading animation time. Set to `0` for instant change. Value is in milliseconds (1 second = 1000 milliseconds). |
| `rotationTime` | `int` | `0` | Time, in milliseconds, between automatic page changes. |
| Option | Type | Default Value | Description |
| --------------- | ------------------ | ------------------------ | --------- |
| `modules` | `[[String...]...]` | `[]` | A 2D String array of what each module should be on which page. Notethat all entries must take their class name (e.g. this module's class name is `MMM-pages`, while the default modules may just have `newsfeed`, without the `MMM-` prefix. |
| `excludes` | *None* | *None* | **Deprecated** Use `fixed` instead. |
| `fixed` | `[String...]` | `["MMM-page-indicator"]` | Which modules should show up all the time. |
| `animationTime` | `int` | `1000` | Fading animation time. Set to `0` for instant change. Value is in milliseconds (1 second = 1000 milliseconds). |
| `rotationTime` | `int` | `0` | Time, in milliseconds, between automatic page changes. |
| `delayTime` | `int` | `0` | Time, in milliseconds, of how long should a manual page change linger before returning to automatic page changing. In other words, how long should the timer wait for after you manually change a page. This does include the animation time, so you may wish to increase it by a few seconds or so to account for the animation time. |
For the `module` configuration option, the first element of the outer array