# HG changeset patch # User Marcin Kuzminski # Date 1351626964 -3600 # Node ID 45a8e0051280bb4cd3ce2f91b47c2b7f30454677 # Parent e0da2c0ecee1737be68552c63b88f64139812e70 Optimized new tooltip, and fixed events on lazy loaded ones diff -r e0da2c0ecee1 -r 45a8e0051280 rhodecode/public/js/rhodecode.js --- a/rhodecode/public/js/rhodecode.js Mon Oct 29 22:26:44 2012 +0100 +++ b/rhodecode/public/js/rhodecode.js Tue Oct 30 20:56:04 2012 +0100 @@ -327,6 +327,7 @@ var json = JSON.parse(o.responseText); YUD.addClass(target,'tooltip') YUD.setAttribute(target, 'title',json['message']); + YAHOO.yuitip.main.set_listeners(target); YAHOO.yuitip.main.show_yuitip(e, target); } if(rid && !YUD.hasClass(target, 'tooltip')){ @@ -343,8 +344,6 @@ YAHOO.namespace('yuitip'); YAHOO.yuitip.main = { - YE: YAHOO.util.Event, - Dom: YAHOO.util.Dom, $: YAHOO.util.Dom.get, bgColor: '#000', @@ -352,8 +351,15 @@ opacity: 0.9, offset: [15,15], useAnim: false, - maxWidth: 200, + maxWidth: 300, add_links: false, + yuitips: [], + + set_listeners: function(tt){ + YUE.on(tt, 'mouseover', yt.show_yuitip, tt); + YUE.on(tt, 'mousemove', yt.move_yuitip, tt); + YUE.on(tt, 'mouseout', yt.close_yuitip, tt); + }, init: function(){ yt._tooltip = ''; @@ -364,13 +370,13 @@ yt.tipBox.id = 'tip-box'; } - yt.Dom.setStyle(yt.tipBox, 'display', 'none'); - yt.Dom.setStyle(yt.tipBox, 'position', 'absolute'); + YUD.setStyle(yt.tipBox, 'display', 'none'); + YUD.setStyle(yt.tipBox, 'position', 'absolute'); if(yt.maxWidth !== null){ - yt.Dom.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px'); + YUD.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px'); } - var yuitips = yt.Dom.getElementsByClassName('tooltip'); + var yuitips = YUD.getElementsByClassName('tooltip'); if(yt.add_links === true){ var links = document.getElementsByTagName('a'); @@ -383,37 +389,28 @@ var yuiLen = yuitips.length; for(i=0;i"; - } yt.tipBox.innerHTML = yt.tipText; - yt.Dom.setStyle(yt.tipBox, 'display', 'block'); + YUD.setStyle(yt.tipBox, 'display', 'block'); if(yt.useAnim === true){ - yt.Dom.setStyle(yt.tipBox, 'opacity', '0'); + YUD.setStyle(yt.tipBox, 'opacity', '0'); var newAnim = new YAHOO.util.Anim(yt.tipBox, { opacity: { to: yt.opacity } @@ -425,14 +422,14 @@ }, move_yuitip: function(e, el){ - yt.YE.stopEvent(e); - var movePos = yt.YE.getXY(e); - yt.Dom.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px'); - yt.Dom.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px'); + YUE.stopEvent(e); + var movePos = YUE.getXY(e); + YUD.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px'); + YUD.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px'); }, close_yuitip: function(e, el){ - yt.YE.stopEvent(e); + YUE.stopEvent(e); if(yt.useAnim === true){ var newAnim = new YAHOO.util.Anim(yt.tipBox, @@ -442,7 +439,7 @@ ); newAnim.animate(); } else { - yt.Dom.setStyle(yt.tipBox, 'display', 'none'); + YUD.setStyle(yt.tipBox, 'display', 'none'); } YUD.setAttribute(el,'title', yt._tooltip); }