diff --git a/dist/jquery.qtip.basic.js b/dist/jquery.qtip.basic.js index 8e9c0300..cbd20526 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: Fri Apr 8 19:32:29 2011 +0100 +* Date: Fri Apr 8 19:33:04 2011 +0100 */ "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ @@ -335,12 +335,12 @@ function QTip(target, options, id, attr) function detectImages(next) { var images; - function imageLoad(event, i) { + function imageLoad(event) { // If queue is empty after image removal, update tooltip and continue the queue if((images = images.not(this)).length === 0) { self.redraw(); self.reposition(cache.event); - + next(); } } @@ -348,15 +348,17 @@ function QTip(target, options, id, attr) // Find all content images without dimensions, and if no images were found, continue if((images = elem.find('img:not([height]):not([width])')).length === 0) { return imageLoad.call(images); } - // Apply the callback to img events to ensure queue continues no matter what! - images.one(['abort','error','load','unload',''].join('.qtip-image '), imageLoad) - - // Apply a recursive method that polls the image for dimensions every 20ms - .each(function(i, elem) { + // Apply timer to each iamge to poll for dimensions + images.each(function(i, elem) { (function timer(){ + var timers = self.timers.img; + // When the dimensions are found, remove the image from the queue and stop timer - if(elem.height && elem.width) { return imageLoad.call(elem, NULL); } - self.timers.img[i] = setTimeout(timer, 20); + if(elem.height && elem.width) { + clearTimeout(timers[i]); + return imageLoad.call(elem); + } + timer = setTimeout(timers[i], 20); }()); }); } @@ -786,7 +788,9 @@ function QTip(target, options, id, attr) set: function(option, value) { 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; @@ -817,9 +821,12 @@ function QTip(target, options, id, attr) previous = obj[0][ obj[1] ]; obj[0][ obj[1] ] = 'object' === typeof value && value.nodeType ? $(value) : value; - // Set the new params for the callback and test it against reposition + // Set the new params for the callback option[notation] = [obj[0], obj[1], value, previous]; + + // Also check if we need to reposition / redraw reposition = rmove.test(notation) || reposition; + redraw = rdraw.test(notation) || redraw; }); // Re-sanitize options @@ -828,12 +835,15 @@ function QTip(target, options, id, attr) /* * Execute any valid callbacks for the set options * Also set isPositioning/isDrawing so we don't get loads of redundant repositioning - * and redraw calls + * and redraw calls. */ isPositioning = isDrawing = 1; $.each(option, callback); isPositioning = isDrawing = 0; - // Update position on ANY style/position/content change if shown and rendered - if(reposition && tooltip.is(':visible') && self.rendered) { self.reposition(); } + // Update position / redraw if needed + if(tooltip.is(':visible') && self.rendered) { + if(reposition) { self.reposition(); } + if(redraw) { self.redraw(); } + } return self; }, diff --git a/dist/jquery.qtip.css b/dist/jquery.qtip.css index 2e8d653b..b16c7879 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: Fri Apr 8 19:32:29 2011 +0100 +* Date: Fri Apr 8 19:33:04 2011 +0100 */ /* Fluid class for determining actual width in IE */ diff --git a/dist/jquery.qtip.js b/dist/jquery.qtip.js index 99aacd1a..b0dc90be 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: Fri Apr 8 19:32:29 2011 +0100 +* Date: Fri Apr 8 19:33:04 2011 +0100 */ "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ @@ -335,12 +335,12 @@ function QTip(target, options, id, attr) function detectImages(next) { var images; - function imageLoad(event, i) { + function imageLoad(event) { // If queue is empty after image removal, update tooltip and continue the queue if((images = images.not(this)).length === 0) { self.redraw(); self.reposition(cache.event); - + next(); } } @@ -348,15 +348,17 @@ function QTip(target, options, id, attr) // Find all content images without dimensions, and if no images were found, continue if((images = elem.find('img:not([height]):not([width])')).length === 0) { return imageLoad.call(images); } - // Apply the callback to img events to ensure queue continues no matter what! - images.one(['abort','error','load','unload',''].join('.qtip-image '), imageLoad) - - // Apply a recursive method that polls the image for dimensions every 20ms - .each(function(i, elem) { + // Apply timer to each iamge to poll for dimensions + images.each(function(i, elem) { (function timer(){ + var timers = self.timers.img; + // When the dimensions are found, remove the image from the queue and stop timer - if(elem.height && elem.width) { return imageLoad.call(elem, NULL); } - self.timers.img[i] = setTimeout(timer, 20); + if(elem.height && elem.width) { + clearTimeout(timers[i]); + return imageLoad.call(elem); + } + timer = setTimeout(timers[i], 20); }()); }); } @@ -786,7 +788,9 @@ function QTip(target, options, id, attr) set: function(option, value) { 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; @@ -817,9 +821,12 @@ function QTip(target, options, id, attr) previous = obj[0][ obj[1] ]; obj[0][ obj[1] ] = 'object' === typeof value && value.nodeType ? $(value) : value; - // Set the new params for the callback and test it against reposition + // Set the new params for the callback option[notation] = [obj[0], obj[1], value, previous]; + + // Also check if we need to reposition / redraw reposition = rmove.test(notation) || reposition; + redraw = rdraw.test(notation) || redraw; }); // Re-sanitize options @@ -828,12 +835,15 @@ function QTip(target, options, id, attr) /* * Execute any valid callbacks for the set options * Also set isPositioning/isDrawing so we don't get loads of redundant repositioning - * and redraw calls + * and redraw calls. */ isPositioning = isDrawing = 1; $.each(option, callback); isPositioning = isDrawing = 0; - // Update position on ANY style/position/content change if shown and rendered - if(reposition && tooltip.is(':visible') && self.rendered) { self.reposition(); } + // Update position / redraw if needed + if(tooltip.is(':visible') && self.rendered) { + if(reposition) { self.reposition(); } + if(redraw) { self.redraw(); } + } return self; }, @@ -1761,7 +1771,7 @@ QTIP.defaults = { } // Define success handler - function successHandler(content) { + function successHandler(content) { if(selector) { // Create a dummy div to hold the results and grab the selector element content = $('
') diff --git a/dist/jquery.qtip.min.js b/dist/jquery.qtip.min.js index a03e0501..45f3a01f 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: Fri Apr 8 19:32:29 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,h=c.options.show.modal,i=c.elements,j=i.tooltip,k="#qtip-overlay",l=".qtipmodal",m="tooltipshow"+l+" tooltiphide"+l;c.checks.modal={"^show.modal.(on|blur)$":function(){f.init(),i.overlay.toggle(j.is(":visible"))}},a.extend(f,{init:function(){h.on&&(j.unbind(l).bind(m,function(b,c,d){var e=b.type.replace("tooltip","");a.isFunction(h[e])?h[e].call(i.overlay,d,c):f[e](d)}),f.create(),h.blur===d&&i.overlay.unbind(l+c.id).bind("click"+l+c.id,function(){c.hide.call(c)}),i.overlay.css("cursor",h.blur?"pointer":""))},create:function(){var c=a(k),d;if(c.length){i.overlay=c;return c}d=i.overlay=a("",{id:k.substr(1),css:{position:"absolute",top:0,left:0,display:"none"},mousedown:function(){return e}}).appendTo(document.body),a(b).bind("resize"+l,function(){d.css({height:Math.max(a(b).height(),a(document).height()),width:Math.max(a(b).width(),a(document).width())})}).trigger("resize");return d},toggle:function(b){var h=i.overlay,k=c.options.show.modal.effect,l=b?"show":"hide",m;h||(h=f.create());if(!h.is(":animated")||b)h.stop(d,e),b&&(m=parseInt(a.css(j[0],"z-index"),10),h.css("z-index",(m||g.zindex)-1)),a.isFunction(k)?k.call(h,b):k===e?h[l]():h.fadeTo(90,b?.7:0,function(){b||a(this).hide()})},show:function(){f.toggle(d)},hide:function(){f.toggle(e)},destroy:function(){var d=i.overlay;d&&(a(k).each(function(){var b=a(this).data("qtip");if(b&&b.id!==b.id&&b.options.show.modal)return d=e}),d?(i.overlay.remove(),a(b).unbind(l)):i.overlay.unbind(l+c.id)),j.unbind(m)}}),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(b,e,f,g){if(k.tip){var h=a.extend({},i.corner),l=f.adjusted,n;i.corner.fixed!==d&&(l.left&&(h.x=h.x==="center"?l.left>0?"left":"right":h.x==="left"?"right":"left"),l.top&&(h.y=h.y==="center"?l.top>0?"top":"bottom":h.y==="top"?"bottom":"top"),h.string()!==m.corner&&(m.top!==l.top||m.left!==l.left)&&(n=i.update(h))),n||(n=i.position(h,0)),n.right!==c&&(n.left=n.right),n.bottom!==c&&(n.top=n.bottom),n.option=Math.max(0,j.offset),f.left-=n.left.charAt?n.option:(n.right?-1:1)*n.left,f.top-=n.top.charAt?n.option:(n.bottom?-1:1)*n.top,m.left=l.left,m.top=l.top,m.corner=h.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