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

Commit

Permalink
Fixed typo in previous commits in core.js and tips.js causing errors.…
Browse files Browse the repository at this point in the history
… Also optimized ipts plugin further.
  • Loading branch information
Craga89 committed Jul 22, 2010
1 parent 67c398a commit a0f4fec
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 53 deletions.
2 changes: 1 addition & 1 deletion src/bgiframe.js
Expand Up @@ -3,7 +3,7 @@ function BGIFrame(qTip)
{
var self = this,
tooltip = qTip.elements.tooltip,
ns = '.bgiframe-' + qTip.id,
namespace = '.bgiframe-' + qTip.id,
events = 'tooltipmove'+namespace+' tooltipshow'+namespace;

self.frame = NULL;
Expand Down
50 changes: 20 additions & 30 deletions src/core.js
Expand Up @@ -182,6 +182,17 @@ function QTip(target, options, id)
tooltip.width(newWidth);
}

function removeTitle()
{
var elems = self.elements;

if(elems.title) {
elems.titlebar.remove();
elems.titlebar = elems.title = elems.button = NULL;
elems.tooltip.removeAttr('aria-labelledby');
}
}

function createTitle()
{
var elems = self.elements,
Expand All @@ -191,14 +202,14 @@ function QTip(target, options, id)
if(elems.titlebar) { removeTitle(); }

// Create title bar and title elements
elem.titlebar = $('<div />', {
classes: 'ui-tooltip-wrapper' + (options.style.widget ? 'ui-widget-header' : ''),
elems.titlebar = $('<div />', {
'class': 'ui-tooltip-titlebar ' + (options.style.widget ? 'ui-widget-header' : '')
})
.append(
elems.title = $('<div />', {
id: 'ui-tooltip-'+id+'-title',
classes: 'ui-tooltip-title',
html: options.content.title.text
'id': 'ui-tooltip-'+id+'-title',
'class': 'ui-tooltip-title',
'html': options.content.title.text
})
)
.prependTo(elems.wrapper);
Expand All @@ -210,14 +221,14 @@ function QTip(target, options, id)
elems.button = button;
}
else if('string' === typeof button) {
elems.button = $('<a />', { html: button });
elems.button = $('<a />', { 'html': button });
}
else {
elems.button = $('<a />', {
classes: 'ui-state-default'
'class': 'ui-state-default'
})
.append(
$('<span />', { classes: 'ui-icon ui-icon-close' })
$('<span />', { 'class': 'ui-icon ui-icon-close' })
);
}

Expand All @@ -228,7 +239,7 @@ function QTip(target, options, id)
.addClass('ui-tooltip-' + (button === TRUE ? 'close' : 'button'))
.hover(function(event){ $(this).toggleClass('ui-state-hover', event.type === 'mouseenter'); })
.click(function() {
!elems.tooltip.hasClass('ui-state-disabled') && self.hide();
if(!elems.tooltip.hasClass('ui-state-disabled')) { self.hide(); }
return FALSE;
})
.bind('mousedown keydown mouseup keyup mouseout', function(event) {
Expand All @@ -237,17 +248,6 @@ function QTip(target, options, id)
}
}

function removeTitle()
{
var elems = self.elements;

if(elems.title) {
elems.titlebar.remove();
elems.titlebar = elems.title = elems.button = NULL;
elems.tooltip.removeAttr('aria-labelledby');
}
}

function updateTitle(content)
{
// Make sure tooltip is rendered and if not, return
Expand Down Expand Up @@ -440,16 +440,6 @@ function QTip(target, options, id)
if(options.position.adjust.screen || (IE6 && targets.tooltip.css('position') === 'fixed')) {
$(document).bind('scroll'+namespace, repositionMethod);
}

// Apply automatic position: fixed override
if() {
// Set positioning to absolute
tooltip.css({ position: 'absolute' });

// Reposition tooltip when window is scrolled
$(window).bind('scroll'+self.ns, self.scroll);
}


// Hide tooltip on document mousedown if unfocus events are enabled
if((/unfocus/i).test(options.hide.event)) {
Expand Down
49 changes: 27 additions & 22 deletions src/tips.js
Expand Up @@ -23,22 +23,25 @@ function calculateTip(corner, width, height)
}

function Tip(qTip, command)

{
var self = this,
opts = qTip.options.style.tip,
tooltip = qTip.elements.tooltip,
wrapper = qTip.elements.wrapper,
tip = qTip.elements.tip = $(),
cache = {
top: 0,
left: 0,
corner: { string: function(){} }
},
size = {
width: qTip.options.style.tip.width,
height: qTip.options.style.tip.height
width: opts.width,
height: opts.height
},
color = { },
border = qTip.options.style.tip.border || 0,
adjust = qTip.options.style.tip.adjust || 0,
method = qTip.options.style.tip.method || FALSE;
border = opts.border || 0,
adjust = opts.adjust || 0,
method = opts.method || FALSE;

self.corner = NULL;
self.mimic = NULL;
Expand All @@ -51,7 +54,7 @@ function Tip(qTip, command)
},
'^style.tip.(corner|mimic|method|border)': function() {
// Re-determine tip type and update
border = qTip.options.style.tip.border;
border = opts.border;
self.detectCorner();
self.update();

Expand All @@ -63,8 +66,8 @@ function Tip(qTip, command)
'^style.tip.(height|width)': function() {
// Re-set dimensions and redraw the tip
size = {
width: qTip.options.style.tip.width,
height: qTip.options.style.tip.height
width: opts.width,
height: opts.height
};
self.create();
self.update();
Expand All @@ -81,7 +84,7 @@ function Tip(qTip, command)
function position(corner)
{
// Return if tips are disabled or tip is not yet rendered
if(qTip.options.style.tip.corner === FALSE || !tip) { return FALSE; }
if(opts.corner === FALSE || !tip) { return FALSE; }

// Inherit corner if not provided
corner = corner || self.corner;
Expand Down Expand Up @@ -123,8 +126,8 @@ function Tip(qTip, command)

// Determine adjustments
offset = size[ (corner.precedance === 'x') ? 'width' : 'height' ];
if(qTip.options.style.tip.border) {
offset -= parseInt(qTip.elements.wrapper.css('border-' + corner[ corner.precedance ] + '-width'), 10);
if(border) {
offset -= parseInt(wrapper.css('border-' + corner[ corner.precedance ] + '-width'), 10);
}

// Adjust secondary corners
Expand All @@ -136,7 +139,7 @@ function Tip(qTip, command)
}
}

function adjust(event, api, position) {
function reposition(event, api, position) {
// Only continue if tip adjustments are enabled
if(!self.corner.adjust) {
return FALSE;
Expand All @@ -146,7 +149,7 @@ function Tip(qTip, command)
newType = self.mimic.adjust ? $.extend({}, self.mimic) : null,
precedance = newCorner.precedance === 'y' ? ['y', 'top', 'left', 'height'] : ['x', 'left', 'top', 'width'],
adjusted = position.adjusted,
offset = parseInt(qTip.elements.wrapper.css('border-' + newCorner[ precedance[0] ] + '-width'), 10),
offset = parseInt(wrapper.css('border-' + newCorner[ precedance[0] ] + '-width'), 10),
walk = [newCorner, newType];

// Adjust tip corners
Expand Down Expand Up @@ -183,8 +186,8 @@ function Tip(qTip, command)
color.border = tip.get(0).style ? tip.get(0).style['border' + precedance.charAt(0) + precedance.substr(1) + 'Color'] : tip.css(borderSide) || 'transparent';

// Make sure colours are valid and reset background and border properties
if((/rgba?\(0, 0, 0(, 0)?\)|transparent/i).test(color.fill)) { color.fill = qTip.elements.wrapper.css(border ? 'background-color' : borderSide); }
if(!color.border || (/rgba?\(0, 0, 0(, 0)?\)|transparent/i).test(color.border)) { color.border = qTip.elements.wrapper.css(borderSide) || color.fill; }
if((/rgba?\(0, 0, 0(, 0)?\)|transparent/i).test(color.fill)) { color.fill = wrapper.css(border ? 'background-color' : borderSide); }
if(!color.border || (/rgba?\(0, 0, 0(, 0)?\)|transparent/i).test(color.border)) { color.border = wrapper.css(borderSide) || color.fill; }

$('*', tip).add(tip).css('background-color', 'transparent').css('border', 0);
}
Expand All @@ -197,7 +200,7 @@ function Tip(qTip, command)
if(properties === FALSE){ return FALSE; }

// Bind update events
qTip.elements.tooltip.bind('tooltipmove.tip', adjust);
tooltip.bind('tooltipmove.tip', reposition);

// Check if rendering method is possible and if not fall back
if(method === TRUE) {
Expand All @@ -222,8 +225,8 @@ function Tip(qTip, command)

detectCorner: function()
{
var corner = qTip.options.style.tip.corner,
mimic = qTip.options.style.tip.mimic || corner,
var corner = opts.corner,
mimic = opts.mimic || corner,
at = qTip.options.position.at,
my = qTip.options.position.my;
if(my.string) { my = my.string(); }
Expand Down Expand Up @@ -261,7 +264,7 @@ function Tip(qTip, command)

// Create tip element and prepend to the tooltip if needed
if(tip){ tip.remove(); }
tip = $('<div class="ui-tooltip-tip ui-widget-content"></div>').css(size).prependTo(qTip.elements.tooltip);
tip = $('<div class="ui-tooltip-tip ui-widget-content"></div>').css(size).prependTo(tooltip);

// Create tip element
switch(method)
Expand Down Expand Up @@ -291,7 +294,9 @@ function Tip(qTip, command)

update: function(corner, mimic)
{
var regular = 'px solid ',
var width = size.width,
height = size.height,
regular = 'px solid ',
transparent = 'px dashed transparent', // Dashed IE6 border-transparency hack. Awesome!
i = border > 0 ? 0 : 1,
translate = Math.ceil(border / 2 + 0.5),
Expand Down Expand Up @@ -435,7 +440,7 @@ function Tip(qTip, command)
}

// Remove bound events
qTip.elements.tooltip.unbind('tooltipmove.tip');
tooltip.unbind('tooltipmove.tip');
}
});
}
Expand Down

0 comments on commit a0f4fec

Please sign in to comment.