From 598fc92c2ddea3eafe8338d7e1ae96c9ba8580ec Mon Sep 17 00:00:00 2001 From: Stefan Hasenstab Date: Tue, 8 Jul 2014 15:56:33 +0200 Subject: [PATCH 1/2] sanitize hex colors by prefixing missing # if necessary --- public/js/lib/models/arrow.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/public/js/lib/models/arrow.js b/public/js/lib/models/arrow.js index aced0c3..4ba0d95 100644 --- a/public/js/lib/models/arrow.js +++ b/public/js/lib/models/arrow.js @@ -69,10 +69,15 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {}; hasBorder = borderWidth > 0, css = '.arrow_box {\n'; + color = this._sanitizeHexColors(color); + css += '\tposition: relative;\n'; css += '\tbackground: ' + color + ';\n'; - if (hasBorder) css += '\tborder: ' + borderWidth + 'px solid ' + borderColor + ';\n'; + if (hasBorder) { + borderColor = this._sanitizeHexColors(borderColor); + css += '\tborder: ' + borderWidth + 'px solid ' + borderColor + ';\n'; + } css += '}\n'; css += '.arrow_box:after'; @@ -111,6 +116,7 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {}; @protected **/ _arrowCSS: function (color, size, layer) { + color = this._sanitizeHexColors(color); var pos = this.get('position'), iPos = this.invertedPosition(), rgbColor = this.hexToRGB(color), @@ -204,6 +210,16 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {}; this._attributes = attributes; }, + /** + @method _sanitizeHexColors + @description prefix hexcolors with # if necessary + @returns {String} h + @protected + **/ + _sanitizeHexColors: function(h) { + return (h.charAt(0)==='#')?h:'#' + h; + }, + /** @method getAttrs @description returns all the attributes From a77d696e923b44040675498fbbb542fe3a73e974 Mon Sep 17 00:00:00 2001 From: Stefan Hasenstab Date: Mon, 14 Jul 2014 10:16:11 +0200 Subject: [PATCH 2/2] changed code indention to 2 spaces --- public/js/lib/models/arrow.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/lib/models/arrow.js b/public/js/lib/models/arrow.js index 4ba0d95..a23af2c 100644 --- a/public/js/lib/models/arrow.js +++ b/public/js/lib/models/arrow.js @@ -75,8 +75,8 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {}; css += '\tbackground: ' + color + ';\n'; if (hasBorder) { - borderColor = this._sanitizeHexColors(borderColor); - css += '\tborder: ' + borderWidth + 'px solid ' + borderColor + ';\n'; + borderColor = this._sanitizeHexColors(borderColor); + css += '\tborder: ' + borderWidth + 'px solid ' + borderColor + ';\n'; } css += '}\n'; @@ -217,7 +217,7 @@ if (!('CSSArrowPlease' in window)) window.CSSArrowPlease = {}; @protected **/ _sanitizeHexColors: function(h) { - return (h.charAt(0)==='#')?h:'#' + h; + return (h.charAt(0)==='#')?h:'#' + h; }, /**