/** * @class YAHOO.ext.QuickTips * @singleton */ YAHOO.ext.QuickTips = function(){ var el, tipBody, tipTitle, tm, cfg, close, tagEls = {}, reader, esc, anim, removeCls = null; var ce, bd, xy; var visible = false, disabled = true, inited = false; var showProc = hideProc = dismissProc = 1, locks = []; var E = YAHOO.util.Event, dd; var onOver = function(e){ if(disabled){ return; } var t = E.getTarget(e); if(!t){ return; } if(ce && t == ce.el){ clearTimeout(hideProc); return; } if(t && tagEls[t.id]){ tagEls[t.id].el = t; showProc = show.defer(tm.showDelay, tm, [tagEls[t.id]]); return; } var ttp = reader.getAttribute(t, cfg.attribute); if(!ttp && tm.interceptTitles && t.title){ ttp = t.title; t.title = ''; if(reader.useNS){ t.setAttributeNS('y', 'qtip', ttp); }else{ t.setAttribute('qtip', ttp); } } if(ttp){ xy = E.getXY(e); xy[0] += 12; xy[1] += 20; showProc = show.defer(tm.showDelay, tm, [{ el: t, text: ttp, width: reader.getAttribute(t, cfg.width), autoHide: reader.getAttribute(t, cfg.hide) != 'user', title: reader.getAttribute(t, cfg.title), cls: reader.getAttribute(t, cfg.cls) }]); } }; var onOut = function(e){ clearTimeout(showProc); var t = E.getTarget(e); if(t && ce && ce.el == t && (tm.autoHide && ce.autoHide !== false)){ hideProc = setTimeout(hide, tm.hideDelay); } }; var onMove = function(e){ if(disabled){ return; } xy = E.getXY(e); xy[0] += 12; xy[1] += 20; if(tm.trackMouse && ce){ el.setXY(xy); } }; var onDown = function(e){ clearTimeout(showProc); clearTimeout(hideProc); if(!e.within(el)){ if(tm.hideOnClick && ce && ce.autoHide !== false){ hide(); tm.disable(); } } }; var onUp = function(e){ tm.enable(); } var show = function(o){ if(disabled){ return; } clearTimeout(dismissProc); stopAnim(); ce = o; if(removeCls){ // in case manually hidden el.removeClass(removeCls); removeCls = null; } if(ce.cls){ el.addClass(ce.cls); removeCls = ce.cls; } if(ce.title){ tipTitleText.update(ce.title); tipTitle.show(); }else{ tipTitle.hide(); } tipBody.update(o.text); if(!ce.width){ if(tipBody.dom.style.width){ tipBody.dom.style.width = ''; } if(tipBody.dom.offsetWidth > tm.maxWidth){ tipBody.setWidth(tm.maxWidth); } }else{ tipBody.setWidth(ce.width); } if(!ce.autoHide){ close.setDisplayed(true); if(dd){ dd.unlock(); } }else{ close.setDisplayed(false); if(dd){ dd.lock(); } } if(xy){ el.setXY(xy); } if(tm.animate){ anim.attributes = {opacity:{to:1}}; el.setOpacity(.1); el.setStyle('visibility', 'visible'); anim.animateX(afterShow); }else{ afterShow(); } }; var afterShow = function(){ if(ce){ el.show(); esc.enable(); if(tm.autoDismiss && ce.autoHide !== false){ dismissProc = setTimeout(hide, tm.autoDismissDelay); } } } var hide = function(noanim){ clearTimeout(dismissProc); clearTimeout(hideProc); ce = null; if(el.isVisible()){ esc.disable(); stopAnim(); if(noanim !== true && tm.animate){ anim.attributes = {opacity:{to:.1}}; el.beforeAction(); anim.animateX(afterHide); }else{ afterHide(); } } }; var afterHide = function(){ el.hide(); if(removeCls){ el.removeClass(removeCls); removeCls = null; } } var stopAnim = function(){ if(anim && anim.isAnimated()){ anim.stop(); } } return { init : function(){ if(YAHOO.ext.util.Browser.isIE && !YAHOO.ext.util.Browser.isIE7){ return; } tm = YAHOO.ext.QuickTips; cfg = tm.tagConfig; reader = new YAHOO.ext.CustomTagReader(cfg.namespace); if(!inited){ el = new YAHOO.ext.Layer({cls:'ytip', shadow:true, useDisplay: false}); el.update('