custom.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. jQuery(document).ready(function ($) {
  2. var themeVersion = '2.4';
  3. // Check für JS-Installation entfernen
  4. $('#hdr').addClass('js-installed');
  5. // Add version to logo
  6. $('#logo').append(
  7. $('<span class="theme-version">' + themeVersion + '</span>')
  8. );
  9. // Clear spaces
  10. $('#content .devType, #menu .room a').each(function() {
  11. $(this).html($(this).html().replace(/&nbsp;/g, ''));
  12. });
  13. $('#content > br').remove();
  14. $('.makeSelect').parent().find('br').remove();
  15. // Add missing classes for elements
  16. $('.SVGplot').prevAll('a').addClass('plot-nav');
  17. $('.SVGplot').parents('tr.odd').addClass('no-background').parents('.block').addClass('no-background');
  18. $('.SVGplot').parents('tr.even').addClass('no-background').parents('.block').addClass('no-background');
  19. // Icon selection
  20. $('button.dist').wrapAll('<div class="icons"/>');
  21. $('button.dist').css({width: '50px', height: '50px', margin: '5px', padding: '0'});
  22. $('button.dist > *').css({maxWidth: '40px', maxHeight: '40px', display: 'block', margin: '0px auto'});
  23. $('input[type=text][name=icon-filter]').keyup(function() {
  24. var val = $(this).val().toLowerCase();
  25. if (val.length === 0) {
  26. jQuery('button.dist').show();
  27. } else {
  28. jQuery('button.dist').hide().filter(function() {
  29. return $(this).attr('title').toLowerCase().indexOf(val) > -1;
  30. }).show();
  31. }
  32. });
  33. // Links in der Navigation hinzufügen
  34. var $navElement = jQuery('#menu .room').last().find('tbody');
  35. $navElement.append(
  36. $('<tr><td><div><a class="custom-menu-entry" href="https://github.com/klein0r/fhem-style-haus-automatisierung/issues/">Theme-Fehler melden (v' + themeVersion + ')</a></div></td></tr>')
  37. );
  38. // Automatische Breite für HDR Input
  39. $('#hdr input.maininput').css({width: $('#content').width() + 'px'});
  40. $(window).resize(function() {
  41. $('#hdr input.maininput').css({width: $('#content').width() + 'px'});
  42. });
  43. // Klick auf Error-Message blendet diese aus
  44. $('body').on('click', '#errmsg', function() {
  45. $(this).hide();
  46. });
  47. });