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

Commit

Permalink
adjust.screen now transofmred into adjust.viewport, which accepts an …
Browse files Browse the repository at this point in the history
…jQuery element. The element will be used as the viewport for the adjustment of the tooltip position.
  • Loading branch information
Craga89 committed Dec 30, 2010
1 parent b4582ce commit b652911
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 113 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: Wed Dec 29 20:02:46 2010 +0000
* Date: Wed Dec 29 20:05:20 2010 +0000
*/

.ui-tooltip-accessible{
Expand Down
32 changes: 9 additions & 23 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: Wed Dec 29 20:02:46 2010 +0000
* Date: Wed Dec 29 20:05:20 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 @@ -62,23 +62,9 @@ function sanitizeOptions(opts)
at: opts.position
};
}

if('object' !== typeof opts.position.adjust) {
opts.position.adjust = {};
}

if('undefined' !== typeof opts.position.adjust.screen) {
opts.position.adjust.screen = !!opts.position.adjust.screen;
}
}

if('show' in opts) {
if('object' !== typeof opts.show) {
opts.show = {
event: opts.show
};
}

if('object' !== typeof opts.show) {
if(opts.show.jquery) {
opts.show = { target: opts.show };
Expand Down Expand Up @@ -552,13 +538,13 @@ function QTip(target, options, id)
// Apply document events
if(doc) {
// Adjust positions of the tooltip on window resize if enabled
if(posOptions.adjust.resize || posOptions.adjust.screen) {
$($.event.special.resize ? targets.container : window).bind('resize'+namespace, repositionMethod);
if(posOptions.adjust.resize || posOptions.adjust.viewport) {
$($.event.special.resize ? posOptions.adjust.viewport : window).bind('resize'+namespace, repositionMethod);
}

// Adjust tooltip position on scroll if screen adjustment is enabled
if(posOptions.adjust.screen || (IE6 && targets.tooltip.css('position') === 'fixed')) {
$(targets.container).bind('scroll'+namespace, repositionMethod);
if(posOptions.adjust.viewport || (IE6 && targets.tooltip.css('position') === 'fixed')) {
$(posOptions.adjust.viewport).bind('scroll'+namespace, repositionMethod);
}

// Hide tooltip on document mousedown if unfocus events are enabled
Expand Down Expand Up @@ -985,7 +971,7 @@ function QTip(target, options, id)
targetHeight = 0,
callback = $.Event('tooltipmove'),
fixed = tooltip.css('position') === 'fixed',
viewport = posOptions.container[0] !== document.body ? posOptions.container : $(window),
viewport = adjust.viewport.jquery ? adjust.viewport : FALSE,
position = { left: 0, top: 0 },
readjust = {
left: function(posLeft) {
Expand Down Expand Up @@ -1029,7 +1015,7 @@ function QTip(target, options, id)
};

// Cache our viewport details
viewport = {
viewport = !viewport ? FALSE : {
elem: viewport,
height: viewport[ (viewport[0] === window ? 'h' : 'outerH') + 'eight' ](),
width: viewport[ (viewport[0] === window ? 'w' : 'outerW') + 'idth' ](),
Expand Down Expand Up @@ -1102,7 +1088,7 @@ function QTip(target, options, id)
position.top += adjust.y + (my.y === 'bottom' ? -elemHeight : my.y === 'center' ? -elemHeight / 2 : 0);

// Calculate collision offset values
if(adjust.screen && target[0] !== window && target[0] !== document.body) {
if(viewport && target[0] !== window && target[0] !== document.body) {
position.adjusted = { left: readjust.left(position.left), top: readjust.top(position.top) };
}
else {
Expand Down Expand Up @@ -1517,7 +1503,7 @@ $.fn.qtip.defaults = {
adjust: {
x: 0, y: 0,
mouse: TRUE,
screen: FALSE,
viewport: FALSE,
resize: TRUE
},
effect: TRUE
Expand Down

0 comments on commit b652911

Please sign in to comment.