diff --git a/dist/jquery.qtip.basic.js b/dist/jquery.qtip.basic.js index 6922c954..49da6db3 100644 --- a/dist/jquery.qtip.basic.js +++ b/dist/jquery.qtip.basic.js @@ -9,7 +9,7 @@ * http://en.wikipedia.org/wiki/MIT_License * http://en.wikipedia.org/wiki/GNU_General_Public_License * -* Date: Thu Apr 14 20:23:41 2011 +0100 +* Date: Thu Apr 14 23:46:32 2011 +0100 */ "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ @@ -1055,11 +1055,11 @@ function QTip(target, options, id, attr) // Make sure this axis is enabled for reposition if (!readjust.horizontal) { return 0; } - var viewportScroll = (viewport.offset.left || 0) + viewport.scrollLeft, + var viewportScroll = viewport.scrollLeft, myWidth = my.x === 'left' ? elemWidth : my.x === 'right' ? -elemWidth : -elemWidth / 2, atWidth = at.x === 'left' ? targetWidth : at.x === 'right' ? -targetWidth : -targetWidth / 2, tipAdjust = tip && tip.precedance === 'x' ? options.style.tip.width : 0, - overflowLeft = viewportScroll - posLeft - tipAdjust, + overflowLeft = (viewport.offset.left || 0) + viewportScroll - posLeft - tipAdjust, overflowRight = posLeft + elemWidth - viewport.width - viewportScroll + tipAdjust, offset = myWidth - (my.precedance === 'x' || my.x === my.y ? atWidth : 0), isCenter = my.x === 'center'; @@ -1082,18 +1082,18 @@ function QTip(target, options, id, attr) } // Make sure we haven't made things worse with the adjustment and return the adjusted difference - if(position.left < 0 && -position.left > overflowRight) { position.left = posLeft; } + if(position.left < viewportScroll && -position.left > overflowRight) { position.left = posLeft; } return position.left - posLeft; }, top: function(posTop) { // Make sure this axis is enabled for reposition if (!readjust.vertical) { return 0; } - var viewportScroll = (viewport.offset.top || 0) + viewport.scrollTop, + var viewportScroll = viewport.scrollTop, myHeight = my.y === 'top' ? elemHeight : my.y === 'bottom' ? -elemHeight : -elemHeight / 2, atHeight = at.y === 'top' ? targetHeight : at.y === 'bottom' ? -targetHeight : -targetHeight / 2, tipAdjust = tip && tip.precedance === 'y' ? options.style.tip.height : 0, - overflowTop = viewportScroll - posTop - tipAdjust, + overflowTop = (viewport.offset.top || 0) + viewportScroll - posTop - tipAdjust, overflowBottom = posTop + elemHeight - viewport.height - viewportScroll + tipAdjust, offset = myHeight - (my.precedance === 'y' || my.x === my.y ? atHeight : 0), isCenter = my.y === 'center'; diff --git a/dist/jquery.qtip.css b/dist/jquery.qtip.css index d3362596..486fcee3 100644 --- a/dist/jquery.qtip.css +++ b/dist/jquery.qtip.css @@ -9,7 +9,7 @@ * http://en.wikipedia.org/wiki/MIT_License * http://en.wikipedia.org/wiki/GNU_General_Public_License * -* Date: Thu Apr 14 20:23:41 2011 +0100 +* Date: Thu Apr 14 23:46:32 2011 +0100 */ /* Fluid class for determining actual width in IE */ diff --git a/dist/jquery.qtip.js b/dist/jquery.qtip.js index 2c279d04..d8326154 100644 --- a/dist/jquery.qtip.js +++ b/dist/jquery.qtip.js @@ -9,7 +9,7 @@ * http://en.wikipedia.org/wiki/MIT_License * http://en.wikipedia.org/wiki/GNU_General_Public_License * -* Date: Thu Apr 14 20:23:41 2011 +0100 +* Date: Thu Apr 14 23:46:32 2011 +0100 */ "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ @@ -1055,11 +1055,11 @@ function QTip(target, options, id, attr) // Make sure this axis is enabled for reposition if (!readjust.horizontal) { return 0; } - var viewportScroll = (viewport.offset.left || 0) + viewport.scrollLeft, + var viewportScroll = viewport.scrollLeft, myWidth = my.x === 'left' ? elemWidth : my.x === 'right' ? -elemWidth : -elemWidth / 2, atWidth = at.x === 'left' ? targetWidth : at.x === 'right' ? -targetWidth : -targetWidth / 2, tipAdjust = tip && tip.precedance === 'x' ? options.style.tip.width : 0, - overflowLeft = viewportScroll - posLeft - tipAdjust, + overflowLeft = (viewport.offset.left || 0) + viewportScroll - posLeft - tipAdjust, overflowRight = posLeft + elemWidth - viewport.width - viewportScroll + tipAdjust, offset = myWidth - (my.precedance === 'x' || my.x === my.y ? atWidth : 0), isCenter = my.x === 'center'; @@ -1082,18 +1082,18 @@ function QTip(target, options, id, attr) } // Make sure we haven't made things worse with the adjustment and return the adjusted difference - if(position.left < 0 && -position.left > overflowRight) { position.left = posLeft; } + if(position.left < viewportScroll && -position.left > overflowRight) { position.left = posLeft; } return position.left - posLeft; }, top: function(posTop) { // Make sure this axis is enabled for reposition if (!readjust.vertical) { return 0; } - var viewportScroll = (viewport.offset.top || 0) + viewport.scrollTop, + var viewportScroll = viewport.scrollTop, myHeight = my.y === 'top' ? elemHeight : my.y === 'bottom' ? -elemHeight : -elemHeight / 2, atHeight = at.y === 'top' ? targetHeight : at.y === 'bottom' ? -targetHeight : -targetHeight / 2, tipAdjust = tip && tip.precedance === 'y' ? options.style.tip.height : 0, - overflowTop = viewportScroll - posTop - tipAdjust, + overflowTop = (viewport.offset.top || 0) + viewportScroll - posTop - tipAdjust, overflowBottom = posTop + elemHeight - viewport.height - viewportScroll + tipAdjust, offset = myHeight - (my.precedance === 'y' || my.x === my.y ? atHeight : 0), isCenter = my.y === 'center'; @@ -1956,7 +1956,7 @@ function Tip(qTip, command) var newCorner = $.extend({}, self.corner), adjusted = pos.adjusted, shift = qTip.options.position.adjust.method.substr(0, 5) === 'shift', - adjust = { left: 0, top: 0 }, + adjust = { left: 0, top: 0, shift: shift }, offset; // Make sure our tip position isn't fixed e.g. doesn't adjust with adjust.screen @@ -1976,7 +1976,7 @@ function Tip(qTip, command) } // No shifting took place if both offets are zero... - if(!adjust.left && !adjust.top) { shift = FALSE; } + if(!adjust.left && !adjust.top) { shift = adjust.shift = FALSE; } } // Adjustment type = Flip @@ -2002,16 +2002,11 @@ function Tip(qTip, command) offset.option = Math.max(0, opts.offset); // Adjust position to accomodate tip dimensions - if((shift && adjust.top && !adjust.left) || !shift || !offset) { - pos.left -= offset.left.charAt ? offset.option : (offset.right ? -1 : 1) * offset.left; - } - if((shift && adjust.left && !adjust.top) || !shift || !offset) { - pos.top -= offset.top.charAt ? offset.option : (offset.bottom ? -1 : 1) * offset.top; - } - - // Make sure we also adjust for tip offset in shift repositioning - if(shift && adjust.left && newCorner.precedance === 'y') { pos.left -= offset.option; } - else if(shift && adjust.top && newCorner.precedance === 'x') { pos.top -= offset.option; } + pos.left -= shift && adjust.left || offset.left.charAt ? offset.option : 0; + pos.left -= ((shift && adjust.top && !adjust.left) || !shift ? (offset.right ? -1 : 1) * offset.left : 0) || 0; + + pos.top -= shift && adjust.top || offset.top.charAt ? offset.option : 0; + pos.top -= ((shift && adjust.left && !adjust.top) || !shift ? (offset.bottom ? -1 : 1) * offset.top : 0) || 0; // Cache details cache.left = adjusted.left; cache.top = adjusted.top; @@ -2311,11 +2306,12 @@ function Tip(qTip, command) }, // Tip positioning method - position: function(corner, offsets, set) + position: function(corner, adjust, set) { var tip = elems.tip, position = {}, - precedance, dimensions,corners; + userOffset = Math.max(0, opts.offset), + offsets, precedance, dimensions, corners; // Return if tips are disabled or tip is not yet rendered if(opts.corner === FALSE || !tip) { return FALSE; } @@ -2329,15 +2325,12 @@ function Tip(qTip, command) // Setup corners and offset array corners = [ corner.x, corner.y ]; - offsets = [ - Math.max(0, opts.offset + (offsets ? offsets.left : 0)), - Math.max(0, opts.offset + (offsets ? offsets.top : 0)) - ]; + offsets = [ adjust ? adjust.left : 0, adjust ? adjust.top : 0 ]; if(precedance === 'x') { corners.reverse(); offsets.reverse(); } // Calculate tip position $.each(corners, function(i, side) { - var d, b, br; + var b, br; if(side === 'center') { b = precedance === 'y' ? 'left' : 'top'; @@ -2347,12 +2340,10 @@ function Tip(qTip, command) else { b = borderWidth(corner, side, TRUE); br = borderRadius(corner); - d = i && precedance === 'y' ? 'height' : 'width'; - position[ side ] = Math.min( - tooltip[d]() - size[d] - border, - i ? borderWidth(corner, side) + (!i ? br : 0) : offsets[i] + (br > b ? br : 0) - ); + position[ side ] = i ? borderWidth(corner, side) : adjust && adjust.shift ? + br > offsets[i] ? (br > b ? br : 0) : offsets[i] + userOffset : + offsets[i] + userOffset + (br > b ? br : 0); } }); diff --git a/dist/jquery.qtip.min.js b/dist/jquery.qtip.min.js index 16704700..5c059901 100644 --- a/dist/jquery.qtip.min.js +++ b/dist/jquery.qtip.min.js @@ -9,5 +9,5 @@ * http://en.wikipedia.org/wiki/MIT_License * http://en.wikipedia.org/wiki/GNU_General_Public_License * -* Date: Thu Apr 14 20:23:41 2011 +0100 -*/"use strict",function(a,b,c){function z(b){var c=this,d=b.elements,e=d.tooltip,f=".bgiframe-"+b.id;a.extend(c,{init:function(){d.bgiframe=a(''),d.bgiframe.appendTo(e),e.bind("tooltipmove"+f,c.adjust)},adjust:function(){var a=b.get("dimensions"),c=b.plugins.tip,f=d.tip,g,h;h=parseInt(e.css("border-left-width"),10)||0,h={left:-h,top:-h},c&&f&&(g=c.corner.precedance==="x"?["width","left"]:["height","top"],h[g[1]]-=f[g[0]]()),d.bgiframe.css(h).css(a)},destroy:function(){d.bgiframe.remove(),e.unbind(f)}}),c.init()}function y(c){var f=this,g=c.options.show.modal,h=c.elements,i=h.tooltip,j="#qtip-overlay",k=".qtipmodal",l;c.checks.modal={"^show.modal.(on|blur)$":function(){f.init(),h.overlay.toggle(i.is(":visible"))}},a.extend(f,{init:function(){if(!g.on)return f;i.unbind(k).unbind(k+c.id).bind("tooltipshow"+k+" tooltiphide"+k,function(b,c,d){var e=b.type.replace("tooltip","");a.isFunction(g[e])?g[e].call(h.overlay,d,c):f[e](d)}).bind("tooltipfocus",function(a,b,c){l.css("z-index",c-1)}),f.create(),h.overlay.css("cursor",g.blur?"pointer":""),g.blur===d&&h.overlay.bind("click"+k+c.id,function(){c.hide.call(c)});return f},create:function(){var c=a(j);if(c.length){h.overlay=c;return c}l=h.overlay=a("
",{id:j.substr(1),css:{position:"absolute",top:0,left:0,display:"none"},mousedown:function(){return e}}).appendTo(document.body),a(b).bind("resize"+k,function(){l.css({height:Math.max(a(b).height(),a(document).height()),width:Math.max(a(b).width(),a(document).width())})}).trigger("resize");return l},toggle:function(b){var g=c.options.show.modal.effect,h=b?"show":"hide",i;l||(l=f.create());if(!l.is(":animated")||b){l.stop(d,e),a.isFunction(g)?g.call(l,b):g===e?l[h]():l.fadeTo(90,b?.7:0,function(){b||a(this).hide()});return f}},show:function(){return f.toggle(d)},hide:function(){return f.toggle(e)},destroy:function(){var d=l;d&&(a(j).each(function(){var b=a(this).data("qtip");if(b&&b.id!==b.id&&b.options.show.modal)return d=e}),d?(h.overlay.remove(),a(b).unbind(k)):h.overlay.unbind(k+c.id));return i.unbind(k)}}),f.init()}function x(b,g){function v(a){var b=a.precedance==="y",c=n[b?"width":"height"],d=n[b?"height":"width"],e=a.string().indexOf("center")>-1,f=c*(e?.5:1),g=Math.pow,h=Math.round,i,j,k,l=Math.sqrt(g(f,2)+g(d,2)),m=[p/f*l,p/d*l];m[2]=Math.sqrt(g(m[0],2)-g(p,2)),m[3]=Math.sqrt(g(m[1],2)-g(p,2)),i=l+m[2]+m[3]+(e?0:m[0]),j=i/l,k=[h(j*d),h(j*c)];return{height:k[b?0:1],width:k[b?1:0]}}function u(b){var c=k.titlebar&&b.y==="top",d=c?k.titlebar:k.content,e=a.browser.mozilla,f=e?"-moz-":a.browser.webkit?"-webkit-":"",g=b.y+(e?"":"-")+b.x,h=f+(e?"border-radius-"+g:"border-"+g+"-radius");return parseInt(d.css(h),10)||parseInt(l.css(h),10)||0}function t(a,b,c){b=b?b:a[a.precedance];var d=k.titlebar&&a.y==="top",e=d?k.titlebar:k.content,f="border-"+b+"-width",g=parseInt(e.css(f),10);return(c?g||parseInt(l.css(f),10):g)||0}function s(f,g,h,l){if(k.tip){var n=a.extend({},i.corner),o=h.adjusted,p=b.options.position.adjust.method.substr(0,5)==="shift",q={left:0,top:0},r;i.corner.fixed!==d&&(p?(o.top&&(q.top=Math.abs(o.top)),o.left&&(q.left=Math.abs(o.left)),n.precedance==="y"&&o.top&&n.x!=="center"?n.precedance=n.precedance==="y"?"x":"y":n.precedance==="x"&&o.left&&n.y!=="center"&&(n.precedance=n.precedance==="x"?"y":"x"),!q.left&&!q.top&&(p=e)):(o.left&&(n.x=n.x==="center"?o.left>0?"left":"right":n.x==="left"?"right":"left"),o.top&&(n.y=n.y==="center"?o.top>0?"top":"bottom":n.y==="top"?"bottom":"top")),n.string()!==m.corner&&(m.top!==o.top||m.left!==o.left)&&(r=i.update(n,e))),r=i.position(n,q,1),r.right!==c&&(r.left=r.right),r.bottom!==c&&(r.top=r.bottom),r.option=Math.max(0,j.offset);if(p&&q.top&&!q.left||!p||!r)h.left-=r.left.charAt?r.option:(r.right?-1:1)*r.left;if(p&&q.left&&!q.top||!p||!r)h.top-=r.top.charAt?r.option:(r.bottom?-1:1)*r.top;p&&q.left&&n.precedance==="y"?h.left-=r.option:p&&q.top&&n.precedance==="x"&&(h.top-=r.option),m.left=o.left,m.top=o.top,m.corner=n.string()}}var i=this,j=b.options.style.tip,k=b.elements,l=k.tooltip,m={top:0,left:0,corner:""},n={width:j.width,height:j.height},o={},p=j.border||0,q=".qtip-tip",r=a("")[0].getContext;i.corner=f,i.mimic=f,b.checks.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){i.init()||i.destroy(),b.reposition()},"^style.tip.(height|width)$":function(){n={width:j.width,height:j.height},i.create(),i.update(),b.reposition()},"^content.title.text|style.(classes|widget)$":function(){k.tip&&i.update()}},a.extend(i,{init:function(){var b=i.detectCorner()&&(r||a.browser.msie);b&&(i.create(),i.update(),l.unbind(q).bind("tooltipmove"+q,s));return b},detectCorner:function(){var a=j.corner,c=b.options.position,f=c.at,g=c.my.string?c.my.string():c.my;if(a===e||g===e&&f===e)return e;a===d?i.corner=new h.Corner(g):a.string||(i.corner=new h.Corner(a),i.corner.fixed=d);return i.corner.string()!=="centercenter"},detectColours:function(){var c,d,e,f=k.tip.css({backgroundColor:"",border:""}),g=i.corner,h=g[g.precedance],m="border-"+h+"-color",p="border"+h.charAt(0)+h.substr(1)+"Color",q=/rgba?\(0, 0, 0(, 0)?\)|transparent/i,r="background-color",s="transparent",t="ui-tooltip-fluid",u=a(document.body).css("color"),v=b.elements.content.css("color"),w=k.titlebar&&(g.y==="top"||g.y==="center"&&f.position().top+n.height/2+j.offset