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

Commit

Permalink
Rename BGIFrame plugin to generic IE6 plugin, and move redraw() into …
Browse files Browse the repository at this point in the history
…it, as everything ie7+ supports max/min width.
  • Loading branch information
Craga89 committed Nov 1, 2012
1 parent c1ac7a3 commit 5b4b786
Show file tree
Hide file tree
Showing 13 changed files with 345 additions and 450 deletions.
2 changes: 1 addition & 1 deletion dist/basic/jquery.qtip.css
@@ -1,4 +1,4 @@
/*! qTip2 - Pretty powerful tooltips - v2.0.0 - 2012-10-25
/*! qTip2 - Pretty powerful tooltips - v2.0.0 - 2012-11-01
* http://craigsworks.com/projects/qtip2/
* Copyright (c) 2012 Craig Michael Thompson; Licensed MIT, GPL */

Expand Down
148 changes: 39 additions & 109 deletions dist/basic/jquery.qtip.js
@@ -1,4 +1,4 @@
/*! qTip2 - Pretty powerful tooltips - v2.0.0 - 2012-10-25
/*! qTip2 - Pretty powerful tooltips - v2.0.0 - 2012-11-01
* http://craigsworks.com/projects/qtip2/
* Copyright (c) 2012 Craig Michael Thompson; Licensed MIT, GPL */

Expand Down Expand Up @@ -52,16 +52,7 @@
hoverClass = uitooltip + '-hover',
replaceSuffix = '_replacedByqTip',
oldtitle = 'oldtitle',
trackingBound,
redrawContainer;

/*
* redraw() container for width/height calculations
*/
redrawContainer = $('<div/>', { id: 'qtip-rcontainer' });
$(function() { redrawContainer.appendTo(document.body); });


trackingBound;

// Option object sanitizer
function sanitizeOptions(opts)
Expand Down Expand Up @@ -170,13 +161,6 @@ function QTip(target, options, id, attr)
return [obj || options, levels.pop()];
}

function triggerEvent(type, args, event) {
var callback = $.Event('tooltip'+type);
callback.originalEvent = (event ? $.extend({}, event) : NULL) || cache.event || NULL;
tooltip.trigger(callback, [self].concat(args || []));

return !callback.isDefaultPrevented();
}

function setWidget()
{
Expand Down Expand Up @@ -240,9 +224,6 @@ function QTip(target, options, id, attr)
if(!tooltip.hasClass(disabled)) { self.hide(event); }
return FALSE;
});

// Redraw the tooltip when we're done
self.redraw();
}

function createTitle()
Expand Down Expand Up @@ -275,9 +256,6 @@ function QTip(target, options, id, attr)

// Create button if enabled
if(options.content.title.button) { createButton(); }

// Redraw the tooltip dimensions if it's rendered
else if(self.rendered){ self.redraw(); }
}

function updateButton(button)
Expand Down Expand Up @@ -322,8 +300,7 @@ function QTip(target, options, id, attr)
// Content is a regular string, insert the new content
else { elem.html(content); }

// Redraw and reposition
self.redraw();
// Reposition if rnedered
if(reposition !== FALSE && self.rendered && tooltip[0].offsetWidth > 0) {
self.reposition(cache.event);
}
Expand Down Expand Up @@ -363,7 +340,6 @@ function QTip(target, options, id, attr)

// If queue is empty after image removal, update tooltip and continue the queue
if($.isEmptyObject(srcs)) {
self.redraw();
if(reposition !== FALSE) {
self.reposition(cache.event);
}
Expand Down Expand Up @@ -710,6 +686,9 @@ function QTip(target, options, id, attr)
'^style.classes$': function(obj, o, v) {
tooltip.attr('class', uitooltip + ' qtip ' + v);
},
'^style.width|height': function(obj, o, v) {
tooltip.css(o, v);
},
'^style.widget|content.title': setWidget,

// Events check
Expand All @@ -729,10 +708,22 @@ function QTip(target, options, id, attr)
}
};

/*
* Public API methods
*/
$.extend(self, {
/*
* Psuedo-private API methods
*/
_triggerEvent: function(type, args, event)
{
var callback = $.Event('tooltip'+type);
callback.originalEvent = (event ? $.extend({}, event) : NULL) || cache.event || NULL;
tooltip.trigger(callback, [self].concat(args || []));

return !callback.isDefaultPrevented();
},

/*
* Public API methods
*/
render: function(show)
{
if(self.rendered) { return self; } // If tooltip has already been rendered, exit
Expand Down Expand Up @@ -771,9 +762,9 @@ function QTip(target, options, id, attr)
})
);

// Set rendered flag and prevent redundant redraw/reposition calls for now
// Set rendered flag and prevent redundant reposition calls for now
self.rendered = -1;
isDrawing = 1; isPositioning = 1;
isPositioning = 1;

// Create title...
if(title) {
Expand Down Expand Up @@ -812,13 +803,10 @@ function QTip(target, options, id, attr)
*/
tooltip.queue('fx', function(next) {
// tooltiprender event
triggerEvent('render');
self._triggerEvent('render');

// Reset flags
isDrawing = 0; isPositioning = 0;

// Redraw the tooltip manually now we're fully rendered
self.redraw();
isPositioning = 0;

// Show tooltip if needed
if(options.show.ready || show) {
Expand All @@ -839,7 +827,8 @@ function QTip(target, options, id, attr)
{
case 'dimensions':
result = {
height: tooltip.outerHeight(FALSE), width: tooltip.outerWidth(FALSE)
height: tooltip.outerHeight(FALSE),
width: tooltip.outerWidth(FALSE)
};
break;

Expand All @@ -862,7 +851,6 @@ function QTip(target, options, id, attr)
var rmove = /^position\.(my|at|adjust|target|container)|style|content|show\.ready/i,
rdraw = /^content\.(title|attr)|style/i,
reposition = FALSE,
redraw = FALSE,
checks = self.checks,
name;

Expand Down Expand Up @@ -896,27 +884,22 @@ function QTip(target, options, id, attr)
// Set the new params for the callback
option[notation] = [obj[0], obj[1], value, previous];

// Also check if we need to reposition / redraw
// Also check if we need to reposition
reposition = rmove.test(notation) || reposition;
redraw = rdraw.test(notation) || redraw;
});

// Re-sanitize options
sanitizeOptions(options);

/*
* Execute any valid callbacks for the set options
* Also set isPositioning/isDrawing so we don't get loads of redundant repositioning
* and redraw calls.
* Also set isPositioning/isDrawing so we don't get loads of redundant repositioning calls.
*/
isPositioning = isDrawing = 1; $.each(option, callback); isPositioning = isDrawing = 0;
isPositioning = 1; $.each(option, callback); isPositioning = 0;

// Update position / redraw if needed
if(self.rendered && tooltip[0].offsetWidth > 0) {
if(reposition) {
self.reposition( options.position.target === 'mouse' ? NULL : cache.event );
}
if(redraw) { self.redraw(); }
// Update position if needed
if(self.rendered && tooltip[0].offsetWidth > 0 && reposition) {
self.reposition( options.position.target === 'mouse' ? NULL : cache.event );
}

return self;
Expand Down Expand Up @@ -956,7 +939,7 @@ function QTip(target, options, id, attr)
if(!tooltip.is(':animated') && visible === state && sameTarget) { return self; }

// tooltipshow/tooltiphide events
if(!triggerEvent(type, [90])) { return self; }
if(!self._triggerEvent(type, [90])) { return self; }

// Set ARIA hidden status attribute
$.attr(tooltip[0], 'aria-hidden', !!!state);
Expand Down Expand Up @@ -1035,7 +1018,7 @@ function QTip(target, options, id, attr)
}

// tooltipvisible/tooltiphidden events
triggerEvent(state ? 'visible' : 'hidden');
self._triggerEvent(state ? 'visible' : 'hidden');
}

// If no effect type is supplied, use a simple toggle
Expand Down Expand Up @@ -1078,7 +1061,7 @@ function QTip(target, options, id, attr)
if(!tooltip.hasClass(focusClass))
{
// tooltipfocus event
if(triggerEvent('focus', [newIndex], cachedEvent)) {
if(self._triggerEvent('focus', [newIndex], cachedEvent)) {
// Only update z-index's if they've changed
if(curIndex !== newIndex) {
// Reduce our z-index's and keep them properly ordered
Expand All @@ -1105,7 +1088,7 @@ function QTip(target, options, id, attr)
tooltip.removeClass(focusClass);

// tooltipblur event
triggerEvent('blur', [tooltip.css('zIndex')], event);
self._triggerEvent('blur', [tooltip.css('zIndex')], event);

return self;
},
Expand Down Expand Up @@ -1242,7 +1225,7 @@ function QTip(target, options, id, attr)
else { position.adjusted = { left: 0, top: 0 }; }

// tooltipmove event
if(!triggerEvent('move', [position, viewport.elem || viewport], event)) { return self; }
if(!self._triggerEvent('move', [position, viewport.elem || viewport], event)) { return self; }
delete position.adjusted;

// If effect is disabled, target it mouse, no animation is defined or positioning gives NaN out, set CSS directly
Expand All @@ -1262,65 +1245,12 @@ function QTip(target, options, id, attr)
});
}

// Set positioning flag
// Set positioning flagwtf
isPositioning = 0;

return self;
},

// Max/min width simulator function for all browsers.. yeaaah!
redraw: function()
{
if(self.rendered < 1 || isDrawing) { return self; }

var style = options.style,
container = options.position.container,
perc, width, max, min;

// Set drawing flag
isDrawing = 1;

// tooltipredraw event
triggerEvent('redraw');

// If tooltip has a set height/width, just set it... like a boss!
if(style.height) { tooltip.css(HEIGHT, style.height); }
if(style.width) { tooltip.css(WIDTH, style.width); }

// Simulate max/min width if not set width present...
else {
// Reset width and add fluid class
tooltip.css(WIDTH, '').appendTo(redrawContainer);

// Grab our tooltip width (add 1 if odd so we don't get wrapping problems.. huzzah!)
width = tooltip.width();
if(width % 2 < 1) { width += 1; }

// Grab our max/min properties
max = tooltip.css('max-width') || '';
min = tooltip.css('min-width') || '';

// Parse into proper pixel values
perc = (max + min).indexOf('%') > -1 ? container.width() / 100 : 0;
max = ((max.indexOf('%') > -1 ? perc : 1) * parseInt(max, 10)) || width;
min = ((min.indexOf('%') > -1 ? perc : 1) * parseInt(min, 10)) || 0;

// Determine new dimension size based on max/min/current values
width = max + min ? Math.min(Math.max(width, min), max) : width;

// Set the newly calculated width and remvoe fluid class
tooltip.css(WIDTH, Math.round(width)).appendTo(container);
}

// tooltipredrawn event
triggerEvent('redrawn');

// Set drawing flag
isDrawing = 0;

return self;
},

disable: function(state)
{
if('boolean' !== typeof state) {
Expand Down
2 changes: 1 addition & 1 deletion dist/basic/jquery.qtip.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jquery.qtip.css
@@ -1,4 +1,4 @@
/*! qTip2 - Pretty powerful tooltips - v2.0.0 - 2012-10-25
/*! qTip2 - Pretty powerful tooltips - v2.0.0 - 2012-11-01
* http://craigsworks.com/projects/qtip2/
* Copyright (c) 2012 Craig Michael Thompson; Licensed MIT, GPL */

Expand Down

0 comments on commit 5b4b786

Please sign in to comment.