Read the statement by Michael Teeuw here.
Add module reference to alerts
-
Hey guys,
I recently worked on
[card:fewieden/MMM-AlarmClock]
and stumbled on a problem. I want to support normal devices and touch screen devices. Non touch screen is working fine already,
but there’s a problem for the touch screen mode. I added a button but when I fire an alert from the default alert module, there will be an overlay, so my button will not be clickable. To get around this, I thought about adding a reference to an alert, so I can query the alert of my module and give it a click event.My thought was to change this https://github.com/MichMich/MagicMirror/blob/master/modules/default/alert/alert.js#L91 to
message += "<span data-sender='" + sender.name + "' class='thin' style='font-size:22px;line-height: 30px;'>" + params.message + "</span>";
What are your thoughts on this?
-
Paging @paviro since he is te writer of the alert module.
-
Can’t you just change the z-index of the button in your module’s CSS file?
-
@MichMich z-Index didn’t work for me, but with the following code I could achieve what I was trying to do.
MM.getModules().enumerate((module) => { if(module.name === 'alert'){ module.alerts["MMM-AlarmClock"].ntf.addEventListener("click", ()=>{this.resetAlarmClock();}); } });
-
So no more change to the core is required?
-
@MichMich In my oppinion it’s not a good idea to mess around with other modules variables. If someone has a better approach just let me now, but it would work without changes to the core at the moment.
-
Well feel free to change things in the alert module since it should be rewritten at some point anyway… :D