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.width attribute that allows you to override the .redr…
Browse files Browse the repository at this point in the history
…aw() functionality and provide a set width for the tooltip
  • Loading branch information
Craga89 committed Apr 13, 2011
1 parent a794aea commit d9af3a9
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 77 deletions.
41 changes: 18 additions & 23 deletions dist/jquery.qtip.basic.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 Apr 13 11:43:08 2011 +0100
* Date: Wed Apr 13 11:48:47 2011 +0100
*/

"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 @@ -687,11 +687,11 @@ function QTip(target, options, id, attr)
$.attr(target[0], 'aria-describedby', tooltipID);

// Create tooltip element
tooltip = elements.tooltip = $('<div/>')
.attr({
tooltip = elements.tooltip = $('<div/>', {
'id': tooltipID,
'class': uitooltip + ' qtip ui-helper-reset ' + options.style.classes,

'width': options.style.width || '',

/* ARIA specific attributes */
'role': 'alert',
'aria-live': 'polite',
Expand Down Expand Up @@ -1245,32 +1245,26 @@ function QTip(target, options, id, attr)
// IMax/min width simulator function for all browsers.. yeaaah!
redraw: function()
{
if(self.rendered < 1 || isDrawing) { return self; }
if(self.rendered < 1 || options.style.width || isDrawing) { return self; }

var fluid = uitooltip + '-fluid', width, max, min;
isDrawing = 1; // Set drawing flag

// Reset the width in style attribute
tooltip.css('width', '');
// Reset width and add fluid class
tooltip.css('width', '').addClass(fluid);

// Makesure do pre-defined width is set
if(tooltip.css('width') === 'auto') {
// Add fluid class
tooltip.addClass(fluid);
// Grab our tooltip width (add 1 so we don't get wrapping problems in Gecko)
width = tooltip.width() + ($.browser.mozilla ? 1 : 0);

// Grab our tooltip width (add 1 so we don't get wrapping problems in Gecko)
width = tooltip.width() + ($.browser.mozilla ? 1 : 0);
// Parse our max/min properties
max = parseInt(tooltip.css('max-width'), 10) || 0;
min = parseInt(tooltip.css('min-width'), 10) || 0;

// Parse our max/min properties
max = parseInt(tooltip.css('max-width'), 10) || 0;
min = parseInt(tooltip.css('min-width'), 10) || 0;
// Determine new dimension size based on max/min/current values
width = max + min ? Math.min(Math.max(width, min), max) : width;

// 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', width).removeClass(fluid);
}
// Set the newly calculated width and remvoe fluid class
tooltip.css('width', width).removeClass(fluid);

// Set drawing flag
isDrawing = 0;
Expand Down Expand Up @@ -1738,7 +1732,8 @@ QTIP.defaults = {
},
style: {
classes: '',
widget: FALSE
widget: FALSE,
width: FALSE
},
events: {
render: NULL,
Expand Down
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 Apr 13 11:43:08 2011 +0100
* Date: Wed Apr 13 11:48:47 2011 +0100
*/

/* Fluid class for determining actual width in IE */
Expand Down
45 changes: 20 additions & 25 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 Apr 13 11:43:08 2011 +0100
* Date: Wed Apr 13 11:48:47 2011 +0100
*/

"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 @@ -687,11 +687,11 @@ function QTip(target, options, id, attr)
$.attr(target[0], 'aria-describedby', tooltipID);

// Create tooltip element
tooltip = elements.tooltip = $('<div/>')
.attr({
tooltip = elements.tooltip = $('<div/>', {
'id': tooltipID,
'class': uitooltip + ' qtip ui-helper-reset ' + options.style.classes,

'width': options.style.width || '',

/* ARIA specific attributes */
'role': 'alert',
'aria-live': 'polite',
Expand Down Expand Up @@ -1245,32 +1245,26 @@ function QTip(target, options, id, attr)
// IMax/min width simulator function for all browsers.. yeaaah!
redraw: function()
{
if(self.rendered < 1 || isDrawing) { return self; }
if(self.rendered < 1 || options.style.width || isDrawing) { return self; }

var fluid = uitooltip + '-fluid', width, max, min;
isDrawing = 1; // Set drawing flag

// Reset the width in style attribute
tooltip.css('width', '');
// Reset width and add fluid class
tooltip.css('width', '').addClass(fluid);

// Makesure do pre-defined width is set
if(tooltip.css('width') === 'auto') {
// Add fluid class
tooltip.addClass(fluid);
// Grab our tooltip width (add 1 so we don't get wrapping problems in Gecko)
width = tooltip.width() + ($.browser.mozilla ? 1 : 0);

// Grab our tooltip width (add 1 so we don't get wrapping problems in Gecko)
width = tooltip.width() + ($.browser.mozilla ? 1 : 0);
// Parse our max/min properties
max = parseInt(tooltip.css('max-width'), 10) || 0;
min = parseInt(tooltip.css('min-width'), 10) || 0;

// Parse our max/min properties
max = parseInt(tooltip.css('max-width'), 10) || 0;
min = parseInt(tooltip.css('min-width'), 10) || 0;
// Determine new dimension size based on max/min/current values
width = max + min ? Math.min(Math.max(width, min), max) : width;

// 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', width).removeClass(fluid);
}
// Set the newly calculated width and remvoe fluid class
tooltip.css('width', width).removeClass(fluid);

// Set drawing flag
isDrawing = 0;
Expand Down Expand Up @@ -1738,7 +1732,8 @@ QTIP.defaults = {
},
style: {
classes: '',
widget: FALSE
widget: FALSE,
width: FALSE
},
events: {
render: NULL,
Expand Down Expand Up @@ -1969,10 +1964,10 @@ function Tip(qTip, command)
if(adjusted.left) { adjust.left = Math.abs(adjusted.left); }

// Switch precedance based on adjusted properties
if(newCorner.precedance === 'y' && adjusted.top) {
if(newCorner.precedance === 'y' && adjusted.top && newCorner.x !== 'center') {
newCorner.precedance = newCorner.precedance === 'y' ? 'x' : 'y';
}
else if(newCorner.precedance === 'x' && adjusted.left){
else if(newCorner.precedance === 'x' && adjusted.left && newCorner.y !== 'center'){
newCorner.precedance = newCorner.precedance === 'x' ? 'y' : 'x';
}

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.

39 changes: 17 additions & 22 deletions src/core.js
Expand Up @@ -645,11 +645,11 @@ function QTip(target, options, id, attr)
$.attr(target[0], 'aria-describedby', tooltipID);

// Create tooltip element
tooltip = elements.tooltip = $('<div/>')
.attr({
tooltip = elements.tooltip = $('<div/>', {
'id': tooltipID,
'class': uitooltip + ' qtip ui-helper-reset ' + options.style.classes,

'width': options.style.width || '',

/* ARIA specific attributes */
'role': 'alert',
'aria-live': 'polite',
Expand Down Expand Up @@ -1203,32 +1203,26 @@ function QTip(target, options, id, attr)
// IMax/min width simulator function for all browsers.. yeaaah!
redraw: function()
{
if(self.rendered < 1 || isDrawing) { return self; }
if(self.rendered < 1 || options.style.width || isDrawing) { return self; }

var fluid = uitooltip + '-fluid', width, max, min;
isDrawing = 1; // Set drawing flag

// Reset the width in style attribute
tooltip.css('width', '');
// Reset width and add fluid class
tooltip.css('width', '').addClass(fluid);

// Makesure do pre-defined width is set
if(tooltip.css('width') === 'auto') {
// Add fluid class
tooltip.addClass(fluid);
// Grab our tooltip width (add 1 so we don't get wrapping problems in Gecko)
width = tooltip.width() + ($.browser.mozilla ? 1 : 0);

// Grab our tooltip width (add 1 so we don't get wrapping problems in Gecko)
width = tooltip.width() + ($.browser.mozilla ? 1 : 0);
// Parse our max/min properties
max = parseInt(tooltip.css('max-width'), 10) || 0;
min = parseInt(tooltip.css('min-width'), 10) || 0;

// Parse our max/min properties
max = parseInt(tooltip.css('max-width'), 10) || 0;
min = parseInt(tooltip.css('min-width'), 10) || 0;
// Determine new dimension size based on max/min/current values
width = max + min ? Math.min(Math.max(width, min), max) : width;

// 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', width).removeClass(fluid);
}
// Set the newly calculated width and remvoe fluid class
tooltip.css('width', width).removeClass(fluid);

// Set drawing flag
isDrawing = 0;
Expand Down Expand Up @@ -1696,7 +1690,8 @@ QTIP.defaults = {
},
style: {
classes: '',
widget: FALSE
widget: FALSE,
width: FALSE
},
events: {
render: NULL,
Expand Down
4 changes: 2 additions & 2 deletions src/tips.js
Expand Up @@ -94,10 +94,10 @@ function Tip(qTip, command)
if(adjusted.left) { adjust.left = Math.abs(adjusted.left); }

// Switch precedance based on adjusted properties
if(newCorner.precedance === 'y' && adjusted.top) {
if(newCorner.precedance === 'y' && adjusted.top && newCorner.x !== 'center') {
newCorner.precedance = newCorner.precedance === 'y' ? 'x' : 'y';
}
else if(newCorner.precedance === 'x' && adjusted.left){
else if(newCorner.precedance === 'x' && adjusted.left && newCorner.y !== 'center'){
newCorner.precedance = newCorner.precedance === 'x' ? 'y' : 'x';
}

Expand Down

0 comments on commit d9af3a9

Please sign in to comment.