[hg] galaxy 3389: new tipsy works with jQuery 1.4
details: http://www.bx.psu.edu/hg/galaxy/rev/c6fe590de8d7 changeset: 3389:c6fe590de8d7 user: Kanwei Li <kanwei@gmail.com> date: Sun Feb 14 16:03:54 2010 -0500 description: new tipsy works with jQuery 1.4 diffstat: static/scripts/jquery.tipsy.js | 60 ++++------------------------------ static/scripts/packed/jquery.tipsy.js | 2 +- 2 files changed, 9 insertions(+), 53 deletions(-) diffs (104 lines): diff -r aae17e597791 -r c6fe590de8d7 static/scripts/jquery.tipsy.js --- a/static/scripts/jquery.tipsy.js Sat Feb 13 19:13:54 2010 -0500 +++ b/static/scripts/jquery.tipsy.js Sun Feb 14 16:03:54 2010 -0500 @@ -38,72 +38,27 @@ tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback); - var pos = $.extend({}, $(self).offset(), {width: self.offsetWidth, height: self.offsetHeight}); tip.get(0).className = 'tipsy'; // reset classname in case of dynamic gravity tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body); - - tip.css( { width: tip.width() + 1, height: tip.height() } ); - var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight; var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(self) : opts.gravity; - var top, left; - switch (gravity.charAt(0)) { + switch (gravity.charAt(0)) { case 'n': - top = pos.top + pos.height; - left = pos.left + pos.width / 2 - actualWidth / 2; - tip.addClass('tipsy-north'); + tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north'); break; case 's': - top = pos.top - actualHeight; - left = pos.left + pos.width / 2 - actualWidth / 2; - tip.addClass('tipsy-south'); + tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south'); break; case 'e': - top = pos.top + pos.height / 2 - actualHeight / 2; - left = pos.left - actualWidth; - tip.addClass('tipsy-east'); + tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east'); break; case 'w': - top = pos.top + pos.height / 2 - actualHeight / 2; - left = pos.left + pos.width; - tip.addClass('tipsy-west'); + tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west'); break; } - // Shift if off screen - var window = $(window); - - top = Math.max( top, window.scrollTop() ); - top = Math.min( top, window.scrollTop() + window.height() - tip.outerHeight() ); - - var left_shift = 0; - if ( left < window.scrollLeft() ) { - left_shift = left - window.scrollLeft(); - } - var t = window.scrollLeft() + window.width() - tip.outerWidth(); - if ( left > t ) { - left_shift = left - t; - } - - left -= left_shift; - - tip.css( { left: left, top: top } ); - - // Shift background to center over element (not implemented for east/west) - switch (gravity.charAt(0)) { - case 'n': - tip.css( 'background-position', - ( 250 - tip.outerWidth() / 2 ) + left_shift + "px top" ); - break; - case 's': - tip.css( 'background-position', - ( 250 - tip.outerWidth() / 2 ) + left_shift + "px bottom" ); - break; - case 'e': - break; - case 'w': - break; - } - + if (opts.fade) { tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: opts.opacity}); } else { @@ -116,7 +71,7 @@ var self = this; clearTimeout(timeout); setTimeout(function() { - if ($.data(this, 'cancel.tipsy')) { return; } + if ($.data(this, 'cancel.tipsy')) return; var tip = $.data(self, 'active.tipsy'); if (opts.fade) { tip.stop().fadeOut(function() { $(this).remove(); }); @@ -159,3 +114,4 @@ }; })(jQuery); + diff -r aae17e597791 -r c6fe590de8d7 static/scripts/packed/jquery.tipsy.js --- a/static/scripts/packed/jquery.tipsy.js Sat Feb 13 19:13:54 2010 -0500 +++ b/static/scripts/packed/jquery.tipsy.js Sun Feb 14 16:03:54 2010 -0500 @@ -1,1 +1,1 @@ -(function(b){function a(c){if(c.attr("title")||typeof(c.attr("original-title"))!="string"){c.attr("original-title",c.attr("title")||"").removeAttr("title")}}b.fn.tipsy=function(c){c=b.extend({},b.fn.tipsy.defaults,c);return this.each(function(){a(b(this));var d=b.fn.tipsy.elementOptions(this,c);var e=null;b(this).hover(function(){var f=this;e=setTimeout(function(){b.data(f,"cancel.tipsy",true);var o=b.data(f,"active.tipsy");if(!o){o=b('<div class="tipsy"><div class="tipsy-inner"/></div>');o.css({position:"absolute",zIndex:100000});b.data(f,"active.tipsy",o)}a(b(f));var n;if(typeof d.title=="string"){n=b(f).attr(d.title=="title"?"original-title":d.title)}else{if(typeof d.title=="function"){n=d.title.call(f)}}o.find(".tipsy-inner")[d.html?"html":"text"](n||d.fallback);var l=b.extend({},b(f).offset(),{width:f.offsetWidth,height:f.offsetHeight});o.get(0).className="tipsy";o.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).appendTo(document.body);o.css({width:o.wi dth()+1,height:o.height()});var h=o[0].offsetWidth,j=o[0].offsetHeight;var q=(typeof d.gravity=="function")?d.gravity.call(f):d.gravity;var m,i;switch(q.charAt(0)){case"n":m=l.top+l.height;i=l.left+l.width/2-h/2;o.addClass("tipsy-north");break;case"s":m=l.top-j;i=l.left+l.width/2-h/2;o.addClass("tipsy-south");break;case"e":m=l.top+l.height/2-j/2;i=l.left-h;o.addClass("tipsy-east");break;case"w":m=l.top+l.height/2-j/2;i=l.left+l.width;o.addClass("tipsy-west");break}var k=b(k);m=Math.max(m,k.scrollTop());m=Math.min(m,k.scrollTop()+k.height()-o.outerHeight());var g=0;if(i<k.scrollLeft()){g=i-k.scrollLeft()}var p=k.scrollLeft()+k.width()-o.outerWidth();if(i>p){g=i-p}i-=g;o.css({left:i,top:m});switch(q.charAt(0)){case"n":o.css("background-position",-(250-o.outerWidth()/2)+g+"px top");break;case"s":o.css("background-position",-(250-o.outerWidth()/2)+g+"px bottom");break;case"e":break;case"w":break}if(d.fade){o.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({o pacity:d.opacity})}else{o.css({visibility:"visible",opacity:d.opacity})}},d.delayIn)},function(){b.data(this,"cancel.tipsy",false);var f=this;clearTimeout(e);setTimeout(function(){if(b.data(this,"cancel.tipsy")){return}var g=b.data(f,"active.tipsy");if(d.fade){g.stop().fadeOut(function(){b(this).remove()})}else{if(g){g.remove()}}},d.delayOut)})})};b.fn.tipsy.elementOptions=function(d,c){return b.metadata?b.extend({},c,b(d).metadata()):c};b.fn.tipsy.defaults={delayIn:0,delayOut:100,fade:false,fallback:"",gravity:"n",html:false,opacity:0.8,title:"title"};b.fn.tipsy.autoNS=function(){return b(this).offset().top>(b(document).scrollTop()+b(window).height()/2)?"s":"n"};b.fn.tipsy.autoWE=function(){return b(this).offset().left>(b(document).scrollLeft()+b(window).width()/2)?"e":"w"}})(jQuery); \ No newline at end of file +(function(b){function a(c){if(c.attr("title")||typeof(c.attr("original-title"))!="string"){c.attr("original-title",c.attr("title")||"").removeAttr("title")}}b.fn.tipsy=function(c){c=b.extend({},b.fn.tipsy.defaults,c);return this.each(function(){a(b(this));var d=b.fn.tipsy.elementOptions(this,c);var e=null;b(this).hover(function(){var f=this;e=setTimeout(function(){b.data(f,"cancel.tipsy",true);var g=b.data(f,"active.tipsy");if(!g){g=b('<div class="tipsy"><div class="tipsy-inner"/></div>');g.css({position:"absolute",zIndex:100000});b.data(f,"active.tipsy",g)}a(b(f));var i;if(typeof d.title=="string"){i=b(f).attr(d.title=="title"?"original-title":d.title)}else{if(typeof d.title=="function"){i=d.title.call(f)}}g.find(".tipsy-inner")[d.html?"html":"text"](i||d.fallback);var l=b.extend({},b(f).offset(),{width:f.offsetWidth,height:f.offsetHeight});g.get(0).className="tipsy";g.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).appendTo(document.body);var h=g[0].offset Width,k=g[0].offsetHeight;var j=(typeof d.gravity=="function")?d.gravity.call(f):d.gravity;switch(j.charAt(0)){case"n":g.css({top:l.top+l.height,left:l.left+l.width/2-h/2}).addClass("tipsy-north");break;case"s":g.css({top:l.top-k,left:l.left+l.width/2-h/2}).addClass("tipsy-south");break;case"e":g.css({top:l.top+l.height/2-k/2,left:l.left-h}).addClass("tipsy-east");break;case"w":g.css({top:l.top+l.height/2-k/2,left:l.left+l.width}).addClass("tipsy-west");break}if(d.fade){g.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:d.opacity})}else{g.css({visibility:"visible",opacity:d.opacity})}},d.delayIn)},function(){b.data(this,"cancel.tipsy",false);var f=this;clearTimeout(e);setTimeout(function(){if(b.data(this,"cancel.tipsy")){return}var g=b.data(f,"active.tipsy");if(d.fade){g.stop().fadeOut(function(){b(this).remove()})}else{if(g){g.remove()}}},d.delayOut)})})};b.fn.tipsy.elementOptions=function(d,c){return b.metadata?b.extend({},c,b(d).metadata()):c} ;b.fn.tipsy.defaults={delayIn:0,delayOut:100,fade:false,fallback:"",gravity:"n",html:false,opacity:0.8,title:"title"};b.fn.tipsy.autoNS=function(){return b(this).offset().top>(b(document).scrollTop()+b(window).height()/2)?"s":"n"};b.fn.tipsy.autoWE=function(){return b(this).offset().left>(b(document).scrollLeft()+b(window).width()/2)?"e":"w"}})(jQuery); \ No newline at end of file
participants (1)
-
Greg Von Kuster