root / trunk / web / dojo / dijit / Tooltip.js @ 12
History | View | Annotate | Download (4.85 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dijit.Tooltip"]){ |
||
9 | dojo._hasResource["dijit.Tooltip"]=true; |
||
10 | dojo.provide("dijit.Tooltip");
|
||
11 | dojo.require("dijit._Widget");
|
||
12 | dojo.require("dijit._Templated");
|
||
13 | dojo.declare("dijit._MasterTooltip",[dijit._Widget,dijit._Templated],{duration:dijit.defaultDuration,templateString:dojo.cache("dijit","templates/Tooltip.html","<div class=\"dijitTooltip dijitTooltipLeft\" id=\"dojoTooltip\">\n\t<div class=\"dijitTooltipContainer dijitTooltipContents\" dojoAttachPoint=\"containerNode\" waiRole='alert'></div>\n\t<div class=\"dijitTooltipConnector\"></div>\n</div>\n"),postCreate:function(){ |
||
14 | dojo.body().appendChild(this.domNode);
|
||
15 | this.bgIframe=new dijit.BackgroundIframe(this.domNode); |
||
16 | this.fadeIn=dojo.fadeIn({node:this.domNode,duration:this.duration,onEnd:dojo.hitch(this,"_onShow")}); |
||
17 | this.fadeOut=dojo.fadeOut({node:this.domNode,duration:this.duration,onEnd:dojo.hitch(this,"_onHide")}); |
||
18 | },show:function(_1,_2,_3,_4){ |
||
19 | if(this.aroundNode&&this.aroundNode===_2){ |
||
20 | return;
|
||
21 | } |
||
22 | if(this.fadeOut.status()=="playing"){ |
||
23 | this._onDeck=arguments; |
||
24 | return;
|
||
25 | } |
||
26 | this.containerNode.innerHTML=_1;
|
||
27 | var _5=dijit.placeOnScreenAroundElement(this.domNode,_2,dijit.getPopupAroundAlignment((_3&&_3.length)?_3:dijit.Tooltip.defaultPosition,!_4),dojo.hitch(this,"orient")); |
||
28 | dojo.style(this.domNode,"opacity",0); |
||
29 | this.fadeIn.play();
|
||
30 | this.isShowingNow=true; |
||
31 | this.aroundNode=_2;
|
||
32 | },orient:function(_6,_7,_8){ |
||
33 | _6.className="dijitTooltip "+{"BL-TL":"dijitTooltipBelow dijitTooltipABLeft","TL-BL":"dijitTooltipAbove dijitTooltipABLeft","BR-TR":"dijitTooltipBelow dijitTooltipABRight","TR-BR":"dijitTooltipAbove dijitTooltipABRight","BR-BL":"dijitTooltipRight","BL-BR":"dijitTooltipLeft"}[_7+"-"+_8]; |
||
34 | },_onShow:function(){ |
||
35 | if(dojo.isIE){
|
||
36 | this.domNode.style.filter=""; |
||
37 | } |
||
38 | },hide:function(_9){ |
||
39 | if(this._onDeck&&this._onDeck[1]==_9){ |
||
40 | this._onDeck=null; |
||
41 | }else{
|
||
42 | if(this.aroundNode===_9){ |
||
43 | this.fadeIn.stop();
|
||
44 | this.isShowingNow=false; |
||
45 | this.aroundNode=null; |
||
46 | this.fadeOut.play();
|
||
47 | }else{
|
||
48 | } |
||
49 | } |
||
50 | },_onHide:function(){ |
||
51 | this.domNode.style.cssText=""; |
||
52 | this.containerNode.innerHTML=""; |
||
53 | if(this._onDeck){ |
||
54 | this.show.apply(this,this._onDeck); |
||
55 | this._onDeck=null; |
||
56 | } |
||
57 | }}); |
||
58 | dijit.showTooltip=function(_a,_b,_c,_d){ |
||
59 | if(!dijit._masterTT){
|
||
60 | dijit._masterTT=new dijit._MasterTooltip();
|
||
61 | } |
||
62 | return dijit._masterTT.show(_a,_b,_c,_d);
|
||
63 | }; |
||
64 | dijit.hideTooltip=function(_e){ |
||
65 | if(!dijit._masterTT){
|
||
66 | dijit._masterTT=new dijit._MasterTooltip();
|
||
67 | } |
||
68 | return dijit._masterTT.hide(_e);
|
||
69 | }; |
||
70 | dojo.declare("dijit.Tooltip",dijit._Widget,{label:"",showDelay:400,connectId:[],position:[],constructor:function(){ |
||
71 | this._nodeConnectionsById={};
|
||
72 | },_setConnectIdAttr:function(_f){ |
||
73 | for(var _10 in this._nodeConnectionsById){ |
||
74 | this.removeTarget(_10);
|
||
75 | } |
||
76 | dojo.forEach(dojo.isArrayLike(_f)?_f:[_f],this.addTarget,this); |
||
77 | },_getConnectIdAttr:function(){ |
||
78 | var ary=[];
|
||
79 | for(var id in this._nodeConnectionsById){ |
||
80 | ary.push(id); |
||
81 | } |
||
82 | return ary;
|
||
83 | },addTarget:function(id){ |
||
84 | var _11=dojo.byId(id);
|
||
85 | if(!_11){
|
||
86 | return;
|
||
87 | } |
||
88 | if(_11.id in this._nodeConnectionsById){ |
||
89 | return;
|
||
90 | } |
||
91 | this._nodeConnectionsById[_11.id]=[this.connect(_11,"onmouseenter","_onTargetMouseEnter"),this.connect(_11,"onmouseleave","_onTargetMouseLeave"),this.connect(_11,"onfocus","_onTargetFocus"),this.connect(_11,"onblur","_onTargetBlur")]; |
||
92 | },removeTarget:function(_12){ |
||
93 | var id=_12.id||_12;
|
||
94 | if(id in this._nodeConnectionsById){ |
||
95 | dojo.forEach(this._nodeConnectionsById[id],this.disconnect,this); |
||
96 | delete this._nodeConnectionsById[id]; |
||
97 | } |
||
98 | },postCreate:function(){ |
||
99 | dojo.addClass(this.domNode,"dijitTooltipData"); |
||
100 | },startup:function(){ |
||
101 | this.inherited(arguments); |
||
102 | var ids=this.connectId; |
||
103 | dojo.forEach(dojo.isArrayLike(ids)?ids:[ids],this.addTarget,this); |
||
104 | },_onTargetMouseEnter:function(e){ |
||
105 | this._onHover(e);
|
||
106 | },_onTargetMouseLeave:function(e){ |
||
107 | this._onUnHover(e);
|
||
108 | },_onTargetFocus:function(e){ |
||
109 | this._focus=true; |
||
110 | this._onHover(e);
|
||
111 | },_onTargetBlur:function(e){ |
||
112 | this._focus=false; |
||
113 | this._onUnHover(e);
|
||
114 | },_onHover:function(e){ |
||
115 | if(!this._showTimer){ |
||
116 | var _13=e.target;
|
||
117 | this._showTimer=setTimeout(dojo.hitch(this,function(){ |
||
118 | this.open(_13);
|
||
119 | }),this.showDelay);
|
||
120 | } |
||
121 | },_onUnHover:function(e){ |
||
122 | if(this._focus){ |
||
123 | return;
|
||
124 | } |
||
125 | if(this._showTimer){ |
||
126 | clearTimeout(this._showTimer);
|
||
127 | delete this._showTimer; |
||
128 | } |
||
129 | this.close();
|
||
130 | },open:function(_14){ |
||
131 | if(this._showTimer){ |
||
132 | clearTimeout(this._showTimer);
|
||
133 | delete this._showTimer; |
||
134 | } |
||
135 | dijit.showTooltip(this.label||this.domNode.innerHTML,_14,this.position,!this.isLeftToRight()); |
||
136 | this._connectNode=_14;
|
||
137 | this.onShow(_14,this.position); |
||
138 | },close:function(){ |
||
139 | if(this._connectNode){ |
||
140 | dijit.hideTooltip(this._connectNode);
|
||
141 | delete this._connectNode; |
||
142 | this.onHide();
|
||
143 | } |
||
144 | if(this._showTimer){ |
||
145 | clearTimeout(this._showTimer);
|
||
146 | delete this._showTimer; |
||
147 | } |
||
148 | },onShow:function(_15,_16){ |
||
149 | },onHide:function(){ |
||
150 | },uninitialize:function(){ |
||
151 | this.close();
|
||
152 | this.inherited(arguments); |
||
153 | }}); |
||
154 | dijit.Tooltip.defaultPosition=["after","before"]; |
||
155 | } |