##// END OF EJS Templates
Optimized new tooltip, and fixed events on lazy loaded ones
marcink -
r2976:45a8e005 beta
parent child Browse files
Show More
@@ -327,6 +327,7 b' var show_changeset_tooltip = function(){'
327 327 var json = JSON.parse(o.responseText);
328 328 YUD.addClass(target,'tooltip')
329 329 YUD.setAttribute(target, 'title',json['message']);
330 YAHOO.yuitip.main.set_listeners(target);
330 331 YAHOO.yuitip.main.show_yuitip(e, target);
331 332 }
332 333 if(rid && !YUD.hasClass(target, 'tooltip')){
@@ -343,8 +344,6 b' var show_changeset_tooltip = function(){'
343 344 YAHOO.namespace('yuitip');
344 345 YAHOO.yuitip.main = {
345 346
346 YE: YAHOO.util.Event,
347 Dom: YAHOO.util.Dom,
348 347 $: YAHOO.util.Dom.get,
349 348
350 349 bgColor: '#000',
@@ -352,8 +351,15 b' YAHOO.yuitip.main = {'
352 351 opacity: 0.9,
353 352 offset: [15,15],
354 353 useAnim: false,
355 maxWidth: 200,
354 maxWidth: 300,
356 355 add_links: false,
356 yuitips: [],
357
358 set_listeners: function(tt){
359 YUE.on(tt, 'mouseover', yt.show_yuitip, tt);
360 YUE.on(tt, 'mousemove', yt.move_yuitip, tt);
361 YUE.on(tt, 'mouseout', yt.close_yuitip, tt);
362 },
357 363
358 364 init: function(){
359 365 yt._tooltip = '';
@@ -364,13 +370,13 b' YAHOO.yuitip.main = {'
364 370 yt.tipBox.id = 'tip-box';
365 371 }
366 372
367 yt.Dom.setStyle(yt.tipBox, 'display', 'none');
368 yt.Dom.setStyle(yt.tipBox, 'position', 'absolute');
373 YUD.setStyle(yt.tipBox, 'display', 'none');
374 YUD.setStyle(yt.tipBox, 'position', 'absolute');
369 375 if(yt.maxWidth !== null){
370 yt.Dom.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px');
376 YUD.setStyle(yt.tipBox, 'max-width', yt.maxWidth+'px');
371 377 }
372 378
373 var yuitips = yt.Dom.getElementsByClassName('tooltip');
379 var yuitips = YUD.getElementsByClassName('tooltip');
374 380
375 381 if(yt.add_links === true){
376 382 var links = document.getElementsByTagName('a');
@@ -383,37 +389,28 b' YAHOO.yuitip.main = {'
383 389 var yuiLen = yuitips.length;
384 390
385 391 for(i=0;i<yuiLen;i++){
386 yt.YE.on(yuitips[i], 'mouseover', yt.show_yuitip, yuitips[i]);
387 yt.YE.on(yuitips[i], 'mousemove', yt.move_yuitip, yuitips[i]);
388 yt.YE.on(yuitips[i], 'mouseout', yt.close_yuitip, yuitips[i]);
392 yt.set_listeners(yuitips[i]);
389 393 }
390 394 },
391 395
392 396 show_yuitip: function(e, el){
393 yt.YE.stopEvent(e);
397 YUE.stopEvent(e);
394 398 if(el.tagName.toLowerCase() === 'img'){
395 399 yt.tipText = el.alt ? el.alt : '';
396 400 } else {
397 401 yt.tipText = el.title ? el.title : '';
398 402 }
399 403
400
401 404 if(yt.tipText !== ''){
402 405 // save org title
403 406 yt._tooltip = yt.tipText;
404 407 // reset title to not show org tooltips
405 408 YUD.setAttribute(el, 'title', '');
406 409
407 var newTipText = yt.tipText.split(' - ');
408 var tipLen = newTipText.length;
409 yt.tipText = '';
410 for(var i=0;i<tipLen;i++){
411 yt.tipText+= newTipText[i]+"<br/>";
412 }
413 410 yt.tipBox.innerHTML = yt.tipText;
414 yt.Dom.setStyle(yt.tipBox, 'display', 'block');
411 YUD.setStyle(yt.tipBox, 'display', 'block');
415 412 if(yt.useAnim === true){
416 yt.Dom.setStyle(yt.tipBox, 'opacity', '0');
413 YUD.setStyle(yt.tipBox, 'opacity', '0');
417 414 var newAnim = new YAHOO.util.Anim(yt.tipBox,
418 415 {
419 416 opacity: { to: yt.opacity }
@@ -425,14 +422,14 b' YAHOO.yuitip.main = {'
425 422 },
426 423
427 424 move_yuitip: function(e, el){
428 yt.YE.stopEvent(e);
429 var movePos = yt.YE.getXY(e);
430 yt.Dom.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px');
431 yt.Dom.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px');
425 YUE.stopEvent(e);
426 var movePos = YUE.getXY(e);
427 YUD.setStyle(yt.tipBox, 'top', (movePos[1] + yt.offset[1]) + 'px');
428 YUD.setStyle(yt.tipBox, 'left', (movePos[0] + yt.offset[0]) + 'px');
432 429 },
433 430
434 431 close_yuitip: function(e, el){
435 yt.YE.stopEvent(e);
432 YUE.stopEvent(e);
436 433
437 434 if(yt.useAnim === true){
438 435 var newAnim = new YAHOO.util.Anim(yt.tipBox,
@@ -442,7 +439,7 b' YAHOO.yuitip.main = {'
442 439 );
443 440 newAnim.animate();
444 441 } else {
445 yt.Dom.setStyle(yt.tipBox, 'display', 'none');
442 YUD.setStyle(yt.tipBox, 'display', 'none');
446 443 }
447 444 YUD.setAttribute(el,'title', yt._tooltip);
448 445 }
General Comments 0
You need to be logged in to leave comments. Login now