/* * Ext JS Library 1.0.1 * Copyright(c) 2006-2007, Ext JS, LLC. * licensing@extjs.com * * http://www.extjs.com/license */ /** * @class Ext.QuickTips * Provides attractive and customizable tooltips for any element. * @singleton */ Ext.QuickTips = function(){ var el, tipBody, tipBodyText, tipTitle, tm, cfg, close, tagEls = {}, esc, removeCls = null, bdLeft, bdRight; var ce, bd, xy, dd; var visible = false, disabled = true, inited = false; var showProc = 1, hideProc = 1, dismissProc = 1, locks = []; var onOver = function(e){ if(disabled){ return; } var t = e.getTarget(); if(!t || t.nodeType !== 1 || t == document || t == document.body){ 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, et = Ext.fly(t); var ns = cfg.namespace; if(tm.interceptTitles && t.title){ ttp = t.title; t.qtip = ttp; t.removeAttribute("title"); e.preventDefault(); }else{ ttp = t.qtip || et.getAttributeNS(ns, cfg.attribute); } if(ttp){ showProc = show.defer(tm.showDelay, tm, [{ el: t, text: ttp, width: et.getAttributeNS(ns, cfg.width), autoHide: et.getAttributeNS(ns, cfg.hide) != "user", title: et.getAttributeNS(ns, cfg.title), cls: et.getAttributeNS(ns, cfg.cls) }]); } }; var onOut = function(e){ clearTimeout(showProc); var t = e.getTarget(); 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(); xy[1] += 18; if(tm.trackMouse && ce){ el.setXY(xy); } }; var onDown = function(e){ clearTimeout(showProc); clearTimeout(hideProc); if(!e.within(el)){ if(tm.hideOnClick){ hide(); tm.disable(); } } }; var onUp = function(e){ tm.enable(); }; var getPad = function(){ return bdLeft.getPadding('l')+bdRight.getPadding('r'); }; var show = function(o){ if(disabled){ return; } clearTimeout(dismissProc); 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){ tipTitle.update(ce.title); tipTitle.show(); }else{ tipTitle.update(''); tipTitle.hide(); } el.dom.style.width = tm.maxWidth+'px'; //tipBody.dom.style.width = ''; tipBodyText.update(o.text); var p = getPad(), w = ce.width; if(!w){ var td = tipBodyText.dom; var aw = Math.max(td.offsetWidth, td.clientWidth, td.scrollWidth); if(aw > tm.maxWidth){ w = tm.maxWidth; }else if(aw < tm.minWidth){ w = tm.minWidth; }else{ w = aw; } } //tipBody.setWidth(w); el.setWidth(parseInt(w, 10) + p); if(!ce.autoHide){ close.setDisplayed(true); if(dd){ dd.unlock(); } }else{ close.setDisplayed(false); if(dd){ dd.lock(); } } if(xy){ el.avoidY = xy[1]-18; el.setXY(xy); } if(tm.animate){ el.setOpacity(.1); el.setStyle("visibility", "visible"); el.fadeIn({callback: 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(); if(noanim !== true && tm.animate){ el.fadeOut({callback: afterHide}); }else{ afterHide(); } } }; var afterHide = function(){ el.hide(); if(removeCls){ el.removeClass(removeCls); removeCls = null; } }; return { /** * @cfg {Number} minWidth * The minimum width of the quick tip (defaults to 40) */ minWidth : 40, /** * @cfg {Number} maxWidth * The maximum width of the quick tip (defaults to 300) */ maxWidth : 300, /** * @cfg {Boolean} interceptTitles * True to automatically use the element's DOM title value if available (defaults to false) */ interceptTitles : false, /** * @cfg {Boolean} trackMouse * True to have the quick tip follow the mouse as it moves over the target element (defaults to false) */ trackMouse : false, /** * @cfg {Boolean} hideOnClick * True to hide the quick tip if the user clicks anywhere in the document (defaults to true) */ hideOnClick : true, /** * @cfg {Number} showDelay * Delay in milliseconds before the quick tip displays after the mouse enters the target element (defaults to 500) */ showDelay : 500, /** * @cfg {Number} hideDelay * Delay in milliseconds before the quick tip hides when autoHide = true (defaults to 200) */ hideDelay : 200, /** * @cfg {Boolean} autoHide * True to automatically hide the quick tip after the mouse exits the target element (defaults to true). * Used in conjunction with hideDelay. */ autoHide : true, /** * @cfg {Boolean} * True to automatically hide the quick tip after a set period of time, regardless of the user's actions * (defaults to true). Used in conjunction with autoDismissDelay. */ autoDismiss : true, /** * @cfg {Number} * Delay in milliseconds before the quick tip hides when autoDismiss = true (defaults to 5000) */ autoDismissDelay : 5000, /** * @cfg {Boolean} animate * True to turn on fade animation. Defaults to false (ClearType/scrollbar flicker issues in IE7). */ animate : false, // private init : function(){ tm = Ext.QuickTips; cfg = tm.tagConfig; if(!inited){ el = new Ext.Layer({cls:"x-tip", shadow:"drop", shim: true, constrain:true, shadowOffset:3}); el.fxDefaults = {stopFx: true}; // maximum custom styling el.update('