Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Fixed tip colour detection bug when using #000 as border colour
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Mar 8, 2011
1 parent 1035bbb commit 4cc07ce
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion dist/jquery.qtip.css
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Sun Mar 6 23:40:54 2011 +0000
* Date: Tue Mar 8 21:18:55 2011 +0000
*/

/* Fluid class for determining actual width in IE */
Expand Down
31 changes: 17 additions & 14 deletions dist/jquery.qtip.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Sun Mar 6 23:40:54 2011 +0000
* Date: Tue Mar 8 21:18:55 2011 +0000
*/

"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
Expand Down Expand Up @@ -2012,7 +2012,8 @@ function Tip(qTip, command)
},

detectColours: function() {
var tip = elems.tip.css({ backgroundColor: '', border: '' }),
var i,
tip = elems.tip.css({ backgroundColor: '', border: '' }),
corner = self.corner,
precedance = corner[ corner.precedance ],

Expand All @@ -2023,26 +2024,28 @@ function Tip(qTip, command)
backgroundColor = 'background-color',
transparent = 'transparent',

useTitle = elems.titlebar &&
(corner.y === 'top' || (corner.y === 'center' && tip.position().top + (size.height / 2) + opts.offset < elems.titlebar.outerHeight(1))),
colorElem = useTitle ? elems.titlebar : elems.content;

bodyBorder = $(document.body).css('color'),
contentColour = qTip.elements.content.css('color'),

useTitle = elems.titlebar && (corner.y === 'top' || (corner.y === 'center' && tip.position().top + (size.height / 2) + opts.offset < elems.titlebar.outerHeight(1))),
colorElem = useTitle ? elems.titlebar : elems.content,

// Detect tip colours from CSS styles
color.fill = tip.css(backgroundColor) || transparent;
color.border = tip[0].style[ borderSideCamel ];
fill = tip.css(backgroundColor) || transparent,
border = tip[0].style[ borderSideCamel ];

// Make sure colours are valid
if(!color.fill || invalid.test(color.fill)) {
if(!fill || invalid.test(fill)) {
color.fill = colorElem.css(backgroundColor);
if(invalid.test(color.fill)) {
color.fill = tooltip.css(backgroundColor);
color.fill = tooltip.css(backgroundColor) || fill;
}
}
if(!color.border || invalid.test(color.border)) {
if(!border || invalid.test(border)) {
color.border = tooltip.css(borderSide);
if(invalid.test(color.border) || color.border === $(document.body).css('color')) {
color.border = (colorElem.css(borderSide) !== $(qTip.elements.content).css('color') ?
colorElem.css(borderSide) : transparent);
if(invalid.test(color.border) || color.border === bodyBorder) {
color.border = colorElem.css(borderSide);
if(color.border === contentColour) { color.border = border; }
}
}

Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.qtip.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/jquery.qtip.pack.js

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions src/tips.js
Expand Up @@ -204,7 +204,8 @@ function Tip(qTip, command)
},

detectColours: function() {
var tip = elems.tip.css({ backgroundColor: '', border: '' }),
var i,
tip = elems.tip.css({ backgroundColor: '', border: '' }),
corner = self.corner,
precedance = corner[ corner.precedance ],

Expand All @@ -215,26 +216,28 @@ function Tip(qTip, command)
backgroundColor = 'background-color',
transparent = 'transparent',

useTitle = elems.titlebar &&
(corner.y === 'top' || (corner.y === 'center' && tip.position().top + (size.height / 2) + opts.offset < elems.titlebar.outerHeight(1))),
colorElem = useTitle ? elems.titlebar : elems.content;

bodyBorder = $(document.body).css('color'),
contentColour = qTip.elements.content.css('color'),

useTitle = elems.titlebar && (corner.y === 'top' || (corner.y === 'center' && tip.position().top + (size.height / 2) + opts.offset < elems.titlebar.outerHeight(1))),
colorElem = useTitle ? elems.titlebar : elems.content,

// Detect tip colours from CSS styles
color.fill = tip.css(backgroundColor) || transparent;
color.border = tip[0].style[ borderSideCamel ];
fill = tip.css(backgroundColor) || transparent,
border = tip[0].style[ borderSideCamel ];

// Make sure colours are valid
if(!color.fill || invalid.test(color.fill)) {
if(!fill || invalid.test(fill)) {
color.fill = colorElem.css(backgroundColor);
if(invalid.test(color.fill)) {
color.fill = tooltip.css(backgroundColor);
color.fill = tooltip.css(backgroundColor) || fill;
}
}
if(!color.border || invalid.test(color.border)) {
if(!border || invalid.test(border)) {
color.border = tooltip.css(borderSide);
if(invalid.test(color.border) || color.border === $(document.body).css('color')) {
color.border = (colorElem.css(borderSide) !== $(qTip.elements.content).css('color') ?
colorElem.css(borderSide) : transparent);
if(invalid.test(color.border) || color.border === bodyBorder) {
color.border = colorElem.css(borderSide);
if(color.border === contentColour) { color.border = border; }
}
}

Expand Down

0 comments on commit 4cc07ce

Please sign in to comment.