Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

classchanger-widget not correctly working for pagetab #199

Open
schmidHolger opened this issue Feb 13, 2017 · 0 comments
Open

classchanger-widget not correctly working for pagetab #199

schmidHolger opened this issue Feb 13, 2017 · 0 comments

Comments

@schmidHolger
Copy link

In my menu bar I would like to hide/show certain buttons based on the overall status of fhem. E.g. if a battery is low, I would like to see a red icon whereas for all batteries ok, a green check-icon would be desired.

I have setup my menu.html as follows:

<body>
   <header>MENU</header>
      <div class='row'>
      :
      <div class="cell" data-type='classchanger' data-device='status' data-get='overallStatus' data-get-on='notOk' data-get-off='ok' data-on-class='hide'>
         <div data-type="pagetab" data-url="status.html" data-icon="fa-check" data-on-color="green" data-off-color="green"></div>
      </div>
      <div class="cell" data-type='classchanger' data-device='status' data-get='overallStatus' data-get-on='ok' data-get-off='notOk' data-on-class='hide'>
         <div data-type="pagetab" data-url="status.html" data-icon="fa-times" data-on-color="red" data-off-color="red"></div>
      </div>
   </div>
</body>

However, this approach did not work, as only the classchanger-div gets the "hide" added as class attribute. I tried modifiying the children-attribues as well in widget-classchanger.js in function update() and this seems to work ok but I have not yet tested other cases.

if (value == elem.data('get-on')) {
	elem.removeClass(elem.data('off-class'));
	elem.addClass(elem.data('on-class'));
	// modify children as well
	elem.children().removeClass(elem.data('off-class'));
	elem.children().addClass(elem.data('on-class'));
} else {
	elem.removeClass(elem.data('on-class'));
	elem.addClass(elem.data('off-class'));
	// modify children as well
	elem.children().removeClass(elem.data('on-class'));
	elem.children().addClass(elem.data('off-class'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant