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

Commit

Permalink
Added new style.tip.border = true option that auto detects the border…
Browse files Browse the repository at this point in the history
… width for you each time the tip is updated (Screen positioning etc)
  • Loading branch information
Craga89 committed Dec 30, 2010
1 parent 6fd026e commit b77c99a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 93 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: Thu Dec 30 17:40:19 2010 +0000
* Date: Thu Dec 30 18:01:42 2010 +0000
*/

.ui-tooltip-accessible{
Expand Down
33 changes: 19 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: Thu Dec 30 17:40:19 2010 +0000
* Date: Thu Dec 30 18:01:42 2010 +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 @@ -1671,9 +1671,6 @@ function Tip(qTip, command)
self.mimic = NULL;
self.checks = {
'^position.my|style.tip.(corner|mimic|method|border)': function() {
// Re-determine tip type and update
border = opts.border;

// Make sure a tip can be drawn
if(!self.init()) {
self.destroy();
Expand Down Expand Up @@ -1741,6 +1738,15 @@ function Tip(qTip, command)
cache.corner = newCorner.string();
}

/* border width calculator */
function borderWidth(corner, side) {
var isTitleTop = elems.titlebar && corner.y === 'top',
elem = isTitleTop ? elems.titlebar : elems.content;
side = !side ? corner[corner.precedance] : side;

return parseInt(elem.css('border-' + side + '-width'), 10) || 0;
}

$.extend(self, {
init: function()
{
Expand All @@ -1756,6 +1762,9 @@ function Tip(qTip, command)
// Create a new tip
self.create();
self.detectColours();

// Detect initial border width if auto-detect is on and draw the tip
border = opts.border === TRUE ? borderWidth(self.corner) : opts.border;
self.update();

// Bind update events
Expand Down Expand Up @@ -1872,8 +1881,8 @@ function Tip(qTip, command)
height = size.height,
regular = 'px solid ',
transparent = 'px dashed transparent', // Dashed IE6 border-transparency hack. Awesome!
i = border > 0 ? 0 : 1,
mimic = opts.mimic,

context, coords, center, translate, round;

// Re-determine tip if not already set
Expand All @@ -1893,6 +1902,10 @@ function Tip(qTip, command)
mimic[ corner.precedance ] = corner[ corner.precedance ];
}
}

// Detect border width
border = opts.border === TRUE ? borderWidth(corner) : opts.border;
i = border > 0 ? 0 : 1;

// Determine if tip is a "center" based one
center = mimic.string().indexOf('center') > -1;
Expand Down Expand Up @@ -2018,14 +2031,6 @@ function Tip(qTip, command)
// Determine which tip dimension to use for adjustment
dimension = size[ precedance === 'x' ? 'width' : 'height' ];

/* border width calculator */
function borderWidth(corner, side) {
var isTitleTop = elems.titlebar && corner.y === 'top',
elem = isTitleTop ? elems.titlebar : elems.content;

return parseInt(elem.css('border-' + side + '-width'), 10) || 0;
}

/* Calculate tip position */
$.each(
precedance === 'y' ? [ corner.x, corner.y ] : [ corner.y, corner.x ],
Expand Down Expand Up @@ -2082,7 +2087,7 @@ $.fn.qtip.plugins.tip.sanitize = function(options)
if(!(/canvas|polygon/i).test(opts.method)){ opts.method = TRUE; }
if(typeof opts.width !== 'number'){ delete opts.width; }
if(typeof opts.height !== 'number'){ delete opts.height; }
if(typeof opts.border !== 'number'){ delete opts.border; }
if(typeof opts.border !== 'number' && opts.border !== TRUE){ delete opts.border; }
if(typeof opts.offset !== 'number'){ delete opts.offset; }
}
};
Expand Down

0 comments on commit b77c99a

Please sign in to comment.