Change portlet header text color to contrast with selected color

This commit is contained in:
Nathan Gray 2016-04-11 16:42:50 +00:00
parent fd5ccdbf63
commit d5225a8338

View File

@ -162,6 +162,10 @@ var et2_portlet = (function(){ "use strict"; return et2_valueWidget.extend(
this._super.apply(this, arguments); this._super.apply(this, arguments);
}, },
doLoadingFinished: function() {
this.set_color(this.options.color);
},
/** /**
* If anyone asks, return the content node, so content goes inside * If anyone asks, return the content node, so content goes inside
*/ */
@ -364,7 +368,9 @@ var et2_portlet = (function(){ "use strict"; return et2_valueWidget.extend(
*/ */
set_color: function(color) set_color: function(color)
{ {
this.options.color = color;
this.header.css("backgroundColor", color); this.header.css("backgroundColor", color);
this.header.css('color', jQuery.Color(this.header.css("backgroundColor")).lightness() > 0.5 ? 'black':'white');
this.content.css("backgroundColor", color); this.content.css("backgroundColor", color);
}, },