@@ -187,6 +187,34 @@ $(function() {
187187 }
188188 } ;
189189
190+ self . getDefaultBackground = function ( ) {
191+ // have to add to the document in order to use getComputedStyle
192+ var div = document . createElement ( "div" ) ;
193+ document . head . appendChild ( div ) ;
194+ var bg = window . getComputedStyle ( div ) . backgroundColor ;
195+ document . head . removeChild ( div ) ;
196+ return bg ;
197+ } ;
198+
199+ self . getInheritedBackgroundColor = function ( el ) {
200+ // get default style for current browser
201+ if ( ! self . defaultStyle ) {
202+ self . defaultStyle = self . getDefaultBackground ( ) ; // typically "rgba(0, 0, 0, 0)"
203+ }
204+
205+ // get computed color for el
206+ var backgroundColor = window . getComputedStyle ( el ) . backgroundColor ;
207+
208+ // if we got a real value, return it
209+ if ( backgroundColor !== self . defaultStyle ) return backgroundColor ;
210+
211+ // if we've reached the top parent el without getting an explicit color, return default
212+ if ( ! el . parentElement ) return self . defaultStyle ;
213+
214+ // otherwise, recurse and try again on parent element
215+ return self . getInheritedBackgroundColor ( el . parentElement ) ;
216+ } ;
217+
190218 self . plotEnergyData = function ( ) {
191219 $ . ajax ( {
192220 url : API_BASEURL + "plugin/tasmota" ,
@@ -232,7 +260,7 @@ $(function() {
232260 }
233261 }
234262
235- var background_color = ( $ ( '.tab-content' ) . css ( 'background-color' ) == 'rgba(0, 0, 0, 0)' ) ? '#FFFFFF' : $ ( '.tab-content' ) . css ( 'background-color' ) ;
263+ var background_color = ( self . getInheritedBackgroundColor ( document . getElementById ( 'tab_plugin_tasmota' ) ) == 'rgba(0, 0, 0, 0)' ) ? '#FFFFFF' : self . getInheritedBackgroundColor ( document . getElementById ( 'tab_plugin_tasmota' ) ) ;
236264 var foreground_color = ( $ ( '.tab-content' ) . css ( 'color' ) == 'rgba(0, 0, 0, 0)' ) ? '#FFFFFF' : $ ( '#tabs_content' ) . css ( 'color' ) ;
237265
238266 var layout = {
0 commit comments