diff --git a/js/app/directives/use-theme.js b/js/app/directives/use-theme.js index 8544cfadc..92e8d3ec3 100644 --- a/js/app/directives/use-theme.js +++ b/js/app/directives/use-theme.js @@ -42,6 +42,16 @@ return color; } + function whenRgbToHex(input) { + var re = /rgb\((\d+),\s*(\d+),\s*(\d+)\)/i; + var match = input.match(re); + if (match) { + var color = match[1] | (match[2] << 8) | (match[3] << 16); + return '#' + (0x1000000 + color).toString(16).slice(1); + } + return input; + } + return { restrict: 'A', scope: { @@ -50,7 +60,8 @@ negative: '=' }, link: function (scope, el) { - var _color = jQuery('#header').css('background-color'); + var _color = whenRgbToHex( + jQuery('#header').css('background-color')); var _bg = _color; if (scope.negative) { _bg = invertColor(_bg); @@ -66,4 +77,4 @@ } }; }]); -}()); \ No newline at end of file +}());