mirror of
https://github.com/edward-shen/MMM-pages.git
synced 2025-04-19 03:38:19 -07:00
Added mechanism for paging the same module with different configurations
This commit is contained in:
parent
b554ee86b1
commit
c17ad64b96
1 changed files with 35 additions and 6 deletions
41
MMM-pages.js
41
MMM-pages.js
|
@ -15,7 +15,8 @@ Module.register('MMM-pages', {
|
||||||
animationTime: 1000,
|
animationTime: 1000,
|
||||||
rotationTime: 0,
|
rotationTime: 0,
|
||||||
rotationFirstPage: 0,
|
rotationFirstPage: 0,
|
||||||
rotationDelay: 10000
|
rotationDelay: 10000,
|
||||||
|
subclassBy: "header"
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,23 +174,51 @@ Module.register('MMM-pages', {
|
||||||
|
|
||||||
// Hides all modules not on the current page. This hides any module not
|
// Hides all modules not on the current page. This hides any module not
|
||||||
// meant to be shown.
|
// meant to be shown.
|
||||||
|
|
||||||
|
var subclassBy = this.config.subclassBy;
|
||||||
|
var majorModules = this.config.modules[this.curPage].map(function(a){ return a.split('.')[0]});
|
||||||
|
var minorModules = this.config.modules[this.curPage].map(function(a){ var b = a.split('.')
|
||||||
|
if (b.length>1){return {major:b[0], minor: b[1]}} else {return {major:a}};
|
||||||
|
});
|
||||||
|
|
||||||
MM.getModules()
|
MM.getModules()
|
||||||
.exceptWithClass(this.config.fixed)
|
.exceptWithClass(this.config.fixed)
|
||||||
.exceptWithClass(this.config.modules[this.curPage])
|
.exceptWithClass(majorModules)
|
||||||
.enumerate(module => module.hide(
|
.enumerate(module => module.hide(
|
||||||
self.config.animationTime / 2,
|
self.config.animationTime / 2,
|
||||||
{ lockString: self.identifier }
|
{ lockString: self.identifier }
|
||||||
));
|
));
|
||||||
|
|
||||||
|
var shortlist = MM.getModules()
|
||||||
|
.withClass(majorModules);
|
||||||
|
|
||||||
|
shortlist.enumerate((module) => {
|
||||||
|
var mdata = module.data;
|
||||||
|
if (minorModules.find( function(el) {
|
||||||
|
return (mdata.name === el.major) && (!el.minor || (mdata[subclassBy] === el.minor))}
|
||||||
|
)) {
|
||||||
|
|
||||||
|
console.log("should not hide this");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
module.hide(
|
||||||
|
self.config.animationTime / 2,
|
||||||
|
{ lockString: self.identifier }
|
||||||
|
)} ;
|
||||||
|
});
|
||||||
|
|
||||||
// Shows all modules meant to be on the current page, after a small delay.
|
// Shows all modules meant to be on the current page, after a small delay.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
MM.getModules()
|
shortlist.enumerate((module) => {
|
||||||
.withClass(self.config.modules[self.curPage])
|
var mdata = module.data;
|
||||||
.enumerate((module) => {
|
if (minorModules.find( function(el) {
|
||||||
|
return (mdata.name === el.major) && (!el.minor || (mdata[subclassBy] === el.minor))}
|
||||||
|
)) {
|
||||||
|
|
||||||
module.show(
|
module.show(
|
||||||
self.config.animationTime / 2,
|
self.config.animationTime / 2,
|
||||||
{ lockString: self.identifier }
|
{ lockString: self.identifier }
|
||||||
);
|
) }
|
||||||
});
|
});
|
||||||
}, this.config.animationTime / 2);
|
}, this.config.animationTime / 2);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue