Commit 8abde1193d1373b6d1adb97182d980e5dc999604
1 parent
7c46aa05
Exists in
master
and in
7 other branches
--no commit message
Showing
21 changed files
with
3215 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,258 @@ |
1 | +<html> | |
2 | +<head> | |
3 | + <title>Balloon Tooltips</title> | |
4 | + <script type="text/javascript" src="js/balloon.config.js"></script> | |
5 | + <script type="text/javascript" src="js/balloon.js"></script> | |
6 | + <script type="text/javascript" src="js/box.js"></script> | |
7 | + <script type="text/javascript" src="js/yahoo-dom-event.js"></script> | |
8 | + <!-- Note: This CSS is specific to this page -- it is not required for balloon tooltips to work --> | |
9 | + <style> | |
10 | + .tt { | |
11 | + background-color:lightsteelblue; | |
12 | + color:blue; | |
13 | + text-decoration:none; | |
14 | + cursor:pointer; | |
15 | + } | |
16 | + .hidden { | |
17 | + display:none; | |
18 | + } | |
19 | + pre { | |
20 | + background-color:gainsboro; | |
21 | + padding:10px; | |
22 | + margin-left:20px; | |
23 | + margin-right:20px; | |
24 | + font-family:courier; | |
25 | + font-size:90%; | |
26 | + } | |
27 | + b.y { background-color:yellow } | |
28 | + </style> | |
29 | + | |
30 | + <script type="text/javascript"> | |
31 | + // white balloon with default configuration | |
32 | + var balloon = new Balloon; | |
33 | + BalloonConfig(balloon,'GBubble'); | |
34 | + | |
35 | + // plain balloon tooltip | |
36 | + var tooltip = new Balloon; | |
37 | + BalloonConfig(tooltip,'GPlain'); | |
38 | + | |
39 | + // fading balloon | |
40 | + var fader = new Balloon; | |
41 | + BalloonConfig(fader,'GFade'); | |
42 | + | |
43 | + // a plainer popup box | |
44 | + var box = new Box; | |
45 | + BalloonConfig(box,'GBox'); | |
46 | + | |
47 | + // a box that fades in/out | |
48 | + var fadeBox = new Box; | |
49 | + BalloonConfig(fadeBox,'GBox'); | |
50 | + fadeBox.bgColor = 'black'; | |
51 | + fadeBox.fontColor = 'white'; | |
52 | + fadeBox.borderStyle = 'none'; | |
53 | + fadeBox.delayTime = 200; | |
54 | + fadeBox.allowFade = true; | |
55 | + fadeBox.fadeIn = 750; | |
56 | + fadeBox.fadeOut = 200; | |
57 | + | |
58 | + </script> | |
59 | +</head> | |
60 | +<body> | |
61 | +<div style="border:1px solid blue;background:ivory;padding:10px;font-family:arial, sans-serif"> | |
62 | +<img style="float:right" src="images/sample.png" width=300> | |
63 | +</span> | |
64 | +<span id="sheldon" style="display:none"> | |
65 | +<center> | |
66 | +<img src="images/sheldon.jpg"> | |
67 | +<br>mckays@cshl.edu | |
68 | +</center> | |
69 | +</span> | |
70 | +<br> | |
71 | +<ul> | |
72 | +<li>This page is a demonstration of <a href="http://www.gmod.org/wiki/index.php/Popup_Balloons">balloon.js</a>.</li> | |
73 | +<li>Contact <a href="mailto:mckays@cshl.edu">the author</a> for help.</li> | |
74 | +</ul> | |
75 | +<p> | |
76 | +The balloon.js package is written in object-oriented JavaScript and allows you to add configurable balloon tooltips | |
77 | +(AKA popup balloons, bubbles, rollover tooltips etc., etc.) to your website. It is generic and is portable to most web sites. | |
78 | +<p> | |
79 | +The balloons are dynamically sized in both the vertical and horizontal dimensions and the left/right/up/down orientation | |
80 | +is calculated automatically based on the position of the cursor. Balloon contents can be provided locally in your own HTML or remotely via AJAX. | |
81 | +This package is open source and free to all as long as the copyright notice is retained. See below for demonstrations and documentation. | |
82 | +</p> | |
83 | + | |
84 | + | |
85 | +<hr> | |
86 | +<h1 style="align:left">Demo:</h1> | |
87 | +<div style="border:1px solid black;width:90%;margin:auto"> | |
88 | +<table cellpadding=3 style="width:100%"> | |
89 | +<tr> | |
90 | +<th width=10% align=left rowspan=2>Demonstration:</th> | |
91 | +<th width=30% class="tt" style="border:1px solid black" | |
92 | + onmouseover="balloon.showTooltip(event,'This is a balloon tooltip. \ | |
93 | + It will vanish if you leave this box',0,250)">mouse over this box</th> | |
94 | +<th width=30% class="tt"> | |
95 | +<span onmouseover="balloon.showTooltip(event,'Your are hovering, I said click me!')" | |
96 | + onclick="balloon.showTooltip(event,'Your sticky message goes here.',1)">click me</span> | |
97 | +</th> | |
98 | +<th width=30% class="tt"><span onmouseover="tooltip.showTooltip(event,'This is a plain balloon.<br>Your message goes here!')">plainer balloon</span></th> | |
99 | +</tr> | |
100 | +<tr> | |
101 | +<th class="tt"><span onmouseover="fader.showTooltip(event,'Your message goes here!')">fading balloon</span></th> | |
102 | +<th class="tt"><span onmouseover="fadeBox.showTooltip(event,'Your message goes here!')">fading box</span></th> | |
103 | +<th class="tt"><span onmouseover="box.showTooltip(event,'Your sticky message goes here!<br><a href=\'http://www.google.com\'>Your link goes here...</span>',1,275)"> | |
104 | +sticky box</span></th> | |
105 | +</tr> | |
106 | +<tr> | |
107 | +<th align=left>Documentation:</th> | |
108 | +<th colspan=3 align=left class=tt> | |
109 | +<a class=tt href="http://gmod.org/wiki/Popup_Balloons" | |
110 | + onmouseover="balloon.showTooltip(event,'Click this link to go to documentation on the GMOD Wiki')" | |
111 | + onmouseout="alert('Read the docs, when you get a chance...')"> | |
112 | +http://gmod.org/wiki/Popup_Balloons | |
113 | +</th> | |
114 | +</tr> | |
115 | +<tr> | |
116 | +<th align=left>Download:</th> | |
117 | +<th class=tt colspan=3 align=left> | |
118 | +<a class=tt href="http://mckay.cshl.edu/downloads/balloons.tar.gz" | |
119 | + onmouseover="box.showTooltip(event,'Click to download the whole package, with all required scripts, images, etc',0,300)"> | |
120 | +balloons.tar.gz</a> | |
121 | +<font color="black"> | |
122 | +or for windows users... | |
123 | +</font> | |
124 | +<a class=tt href="http://mckay.cshl.edu/downloads/balloons.zip" | |
125 | + onmouseover="box.showTooltip(event,'Click to download the whole package. Try this if your unzip program complains that the tar.gz file is corrupted')"> | |
126 | +balloons.zip | |
127 | +</a> | |
128 | + | |
129 | +</th> | |
130 | +</tr> | |
131 | +</table> | |
132 | +</div> | |
133 | +</div> | |
134 | +<br> | |
135 | + | |
136 | +<!-- These hidden elements contain balloon contents --> | |
137 | +<div id="lorem1" class="hidden"> | |
138 | +Lorem ipsum dolor sit amet, <b><i>consectetuer adipiscing elit</b></i>. Vestibulum iaculis, | |
139 | +ligula quis fringilla volutpat, metus mi molestie lorem, <span style="color:red">quis accumsan pede | |
140 | +turpis nec metus.</span> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.' | |
141 | +</div> | |
142 | + | |
143 | +<div id="lorem2" class="hidden"> | |
144 | +<a href="http://www.lipsum.com" target="_new" style="color:blue">What is <i>Lorem ipsum...</i>?</a> | |
145 | +Lorem ipsum dolor sit amet, <b><i>consectetuer adipiscing elit</b></i>. Vestibulum iaculis | |
146 | +, ligula quis fringilla volutpat, metus mi molestie lorem, quis accumsan pede | |
147 | +turpis nec metus. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. | |
148 | +</div> | |
149 | + | |
150 | +<p> | |
151 | +This is an example of a simple balloon <span class=tt onmouseover="balloon.showTooltip(event,'I am a simple message...')">message</span> | |
152 | + | |
153 | +<pre> | |
154 | + <span onmouseover="<b class=y>balloon</b>.showTooltip(event,'I am a simple message...')">message</span> | |
155 | +</pre> | |
156 | + | |
157 | +This is an example of the same message with a different balloon <span class=tt | |
158 | +onmouseover="tooltip.showTooltip(event,'I am a simple message...')">style</span> | |
159 | + | |
160 | +<pre> | |
161 | + onmouseover="<b class=y>tooltip</b>.showTooltip(event,'I am a simple message...')">message</span> | |
162 | +</pre> | |
163 | + | |
164 | +This is an example of the same message with a box <span class=tt | |
165 | +onmouseover="box.showTooltip(event,'I am a simple message...')">style</span> | |
166 | + | |
167 | +<pre> | |
168 | + onmouseover="<b class=y>box</b>.showTooltip(event,'I am a simple message...')">message</span> | |
169 | +</pre> | |
170 | + | |
171 | +</p> | |
172 | + | |
173 | +<p> | |
174 | +Roll over <span class=tt onmouseover="balloon.showTooltip(event,'load:lorem1')"> | |
175 | +this text</span> for an example of HTML-formatted text loaded from a hidden <div> element. | |
176 | +<pre> | |
177 | + onmouseover="balloon.showTooltip(event,<b class=y>'load:lorem1'</b>)" | |
178 | + ... | |
179 | + <div id="lorem1" style="display:none"> | |
180 | + Lorem ipsum dolor sit amet, <b><i>consectetuer adipiscing elit</b></i>. Vestibulum iaculis, | |
181 | + ligula quis fringilla volutpat, metus mi molestie lorem, <span style="color:red">quis accumsan pede | |
182 | + turpis nec metus.</span> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.' | |
183 | + </div> | |
184 | + | |
185 | +</pre> | |
186 | + | |
187 | +<span id=sticky> | |
188 | +Adding a third argument makes the tooltip <span class=tt | |
189 | +onmouseover="balloon.showTooltip(event,'load:lorem2',1)">sticky</span>.</span> | |
190 | +<pre> | |
191 | + onmouseover="balloon.showTooltip(event,'load:lorem2',<b class=y>1</b>)" | |
192 | +</pre> | |
193 | + | |
194 | +A fourth argument will set the width (Example:<span class=tt | |
195 | +onmouseover="balloon.showTooltip(event,'load:lorem2',1,300)"> | |
196 | +300px sticky balloon</span>) | |
197 | + Try a <span class=tt | |
198 | +onmouseover="tooltip.showTooltip(event,'load:lorem2',1,300)">plain version</span> | |
199 | + | |
200 | +<pre> | |
201 | + onmouseover="balloon.showTooltip(event,'load:lorem2',1,<b class=y>300</b>)" | |
202 | +</pre> | |
203 | + | |
204 | +Now let's try that with a <span class=tt | |
205 | +onmouseover="box.showTooltip(event,'load:lorem2',1,300)"> | |
206 | +sticky box</span>. | |
207 | + | |
208 | +<pre> | |
209 | + onmouseover="box.showTooltip(event,'load:lorem2',1,<b class=y>300</b>)" | |
210 | +</pre> | |
211 | + | |
212 | +The height can also be specified with a fifth argument (Example:<span class=tt | |
213 | +onmouseover="balloon.showTooltip(event,'load:lorem2',1,250,250)"> | |
214 | +250px x 250px sticky balloon</span>) | |
215 | + | |
216 | +<pre> | |
217 | + onmouseover="balloon.showTooltip(event,'load:lorem2',1,<b class=y>250</b>,<b class=y>250</b>)" | |
218 | +</pre> | |
219 | + | |
220 | + | |
221 | +If the balloon contents are too large for the specified dimensions, you will <span class=tt | |
222 | +onmouseover="balloon.showTooltip(event,'load:lorem2',1,150,150)">scrollbars for sticky balloons</span> | |
223 | +and <span class=tt onmouseover="balloon.showTooltip(event,'load:lorem2',0,150,150)">clipping for non-sticky balloons</span>. | |
224 | + | |
225 | +<pre> | |
226 | + onmouseover="balloon.showTooltip(event,'load:lorem2',1,<b class=y>150</b>,<b class=y>150</b>)" | |
227 | +</pre> | |
228 | + | |
229 | +</p> | |
230 | + | |
231 | +<p> | |
232 | +Here is an example of a tooltip balloon that is populated by an | |
233 | +<span class=tt | |
234 | +onmouseover="balloon.showTooltip(event,'<img height=150 src=\'images/balloons.png\' />')"> | |
235 | +image</span>. | |
236 | +<pre> | |
237 | + onmouseover="balloon.showTooltip(event,'<img height=150 src=\'images/balloons.png\' />')" | |
238 | +</pre> | |
239 | +</p> | |
240 | + | |
241 | +<img src="images/balloons.png" onmouseover="balloon.showTooltip(event,'my message')" /> | |
242 | + | |
243 | +<p> | |
244 | +This creates a sticky balloon whose contents are from an external website. | |
245 | +<span class=tt | |
246 | +onmouseover="balloon.showTooltip(event,'<iframe style=\'width:300;height:290\' frameborder=0 src=\'http://m.nypost.com\'></iframe>',1)"> | |
247 | +What's new at the NY Post?</span><br> | |
248 | + | |
249 | +<b>Note: </b> This requires an embedded iframe because it is an external website. | |
250 | +<pre> | |
251 | +<span onmouseover="balloon.showTooltip(event,'<iframe style=\'width:300;height:290\' frameborder=0 src=\'http://m.nypost.com\'></iframe>',1)"> | |
252 | +What's new at the NY Post?</span> | |
253 | +</pre> | |
254 | +<br> | |
255 | +Ajax methods are <a href="http://gmod.org/wiki/Popup_Balloons#Using_AJAX_to_get_balloon_contents">also available</a>. | |
256 | +</p> | |
257 | +</body> | |
258 | +</html> | ... | ... |
10.1 KB
13.5 KB
333 Bytes
582 Bytes
578 Bytes
584 Bytes
588 Bytes
5.12 KB
333 Bytes
151 Bytes
149 Bytes
153 Bytes
153 Bytes
14.5 KB
... | ... | @@ -0,0 +1,100 @@ |
1 | +/* | |
2 | + | |
3 | +This file contains the default configuration options for balloon tooltips. | |
4 | +Default options can be edited in this file or changed after the Balloon object is | |
5 | +initiliazed as follows: | |
6 | + | |
7 | + var balloon = new Balloon; | |
8 | + balloon.fontColor = 'black'; | |
9 | + balloon.fontFamily = 'Arial, sans-serif'; | |
10 | + balloon.fontSize = '12pt'; | |
11 | + etc... | |
12 | + | |
13 | +*/ | |
14 | + | |
15 | +// This function adds the default configuration and also custom | |
16 | +// configuration sets, specified in 'case' stanzas | |
17 | +BalloonConfig = function(balloon, set) { | |
18 | + set = set || ''; | |
19 | + | |
20 | + //////////////////////////////////////////////////////////////// | |
21 | + // The default "base" config applied to all balloon objects. // | |
22 | + // See http://gmod.org/wiki/Popup_Balloons#Customization for // | |
23 | + // details about config options // | |
24 | + // // | |
25 | + // values can be overriden in custom config cases (see below) // | |
26 | + //////////////////////////////////////////////////////////////// | |
27 | + if (!balloon.configured || set == 'GBubble' || set == 'GBox') { // | |
28 | + balloon.fontColor = 'black'; // | |
29 | + balloon.fontFamily = 'Arial, sans-serif'; // | |
30 | + balloon.fontSize = '12pt'; // | |
31 | + balloon.minWidth = 100; // | |
32 | + balloon.maxWidth = 400; // | |
33 | + balloon.delayTime = 750; // | |
34 | + balloon.vOffset = 10; // | |
35 | + balloon.hOffset = 10; // | |
36 | + balloon.stem = true; // | |
37 | + balloon.images = i3GEO.configura.locaplic+'/pacotes/balloon-tooltips/htdocs/images/GBubble'; // | |
38 | + balloon.ieImage = 'balloon_ie.png'; // | |
39 | + balloon.balloonImage = 'balloon.png'; // | |
40 | + balloon.upLeftStem = 'up_left.png'; // | |
41 | + balloon.downLeftStem = 'down_left.png'; // | |
42 | + balloon.upRightStem = 'up_right.png'; // | |
43 | + balloon.downRightStem = 'down_right.png'; // | |
44 | + balloon.closeButton = 'close.png'; // | |
45 | + balloon.closeButtonWidth = 16; // | |
46 | + balloon.allowAJAX = false; // | |
47 | + balloon.allowIframes = false; // | |
48 | + balloon.trackCursor = true; // | |
49 | + balloon.shadow = 20; // | |
50 | + balloon.padding = 10; // | |
51 | + balloon.stemHeight = 32; // | |
52 | + balloon.stemOverlap = 3; // | |
53 | + balloon.vOffset = 1; // | |
54 | + balloon.hOffset = 1; // | |
55 | + balloon.opacity = 0.9; // | |
56 | + balloon.configured = set || true; // | |
57 | + } // | |
58 | + //////////////////////////////////////////////////////////////// | |
59 | + | |
60 | + | |
61 | + //////////////////////////////////////////////////////////////// | |
62 | + // Custom configuration options -- Add a case below for your // | |
63 | + // config set (default sets: GBox, GPlain, and GFade) // | |
64 | + //////////////////////////////////////////////////////////////// | |
65 | + switch(set) { | |
66 | + | |
67 | + // A formatted box (no background image) | |
68 | + case('GBoxxxx') : | |
69 | + balloon.bgColor = 'whitesmoke'; | |
70 | + balloon.borderStyle = '2px solid gray'; | |
71 | + //balloon.images = i3GEO.configura.locaplic+'/pacotes/balloon-tooltips/htdocs/images/GPlain'; | |
72 | + balloon.padding = 5; | |
73 | + balloon.shadow = 0; | |
74 | + balloon.stem = true; //original é false edmar | |
75 | + balloon.opacity = 0.8; | |
76 | + balloon.hOffset = 1; | |
77 | + balloon.vOffset = 1; | |
78 | + balloon.allowFade = false; | |
79 | + break; | |
80 | + | |
81 | + // A simpler balloon | |
82 | + case('GPlain') : | |
83 | + balloon.padding = 5; | |
84 | + balloon.images = i3GEO.configura.locaplic+'/pacotes/balloon-tooltips/htdocs/images/GPlain'; | |
85 | + balloon.ieImage = null; | |
86 | + balloon.shadow = 0; | |
87 | + balloon.stemHeight = 15; | |
88 | + balloon.stemOverlap = 1; | |
89 | + balloon.opacity = 0.85; | |
90 | + break; | |
91 | + | |
92 | + // The default cartoon bubble with a fade-in effect | |
93 | + case('GFade') : | |
94 | + balloon.allowFade = true; | |
95 | + balloon.fadeIn = 1000; | |
96 | + balloon.faedOut = 200; | |
97 | + break; | |
98 | + } | |
99 | +} | |
100 | + | ... | ... |
... | ... | @@ -0,0 +1,100 @@ |
1 | +/* | |
2 | + | |
3 | +This file contains the default configuration options for balloon tooltips. | |
4 | +Default options can be edited in this file or changed after the Balloon object is | |
5 | +initiliazed as follows: | |
6 | + | |
7 | + var balloon = new Balloon; | |
8 | + balloon.fontColor = 'black'; | |
9 | + balloon.fontFamily = 'Arial, sans-serif'; | |
10 | + balloon.fontSize = '12pt'; | |
11 | + etc... | |
12 | + | |
13 | +*/ | |
14 | + | |
15 | +// This function adds the default configuration and also custom | |
16 | +// configuration sets, specified in 'case' stanzas | |
17 | +BalloonConfig = function(balloon, set) { | |
18 | + set = set || ''; | |
19 | + | |
20 | + //////////////////////////////////////////////////////////////// | |
21 | + // The default "base" config applied to all balloon objects. // | |
22 | + // See http://gmod.org/wiki/Popup_Balloons#Customization for // | |
23 | + // details about config options // | |
24 | + // // | |
25 | + // values can be overriden in custom config cases (see below) // | |
26 | + //////////////////////////////////////////////////////////////// | |
27 | + if (!balloon.configured || set == 'GBubble' || set == 'GBox') { // | |
28 | + balloon.fontColor = 'black'; // | |
29 | + balloon.fontFamily = 'Arial, sans-serif'; // | |
30 | + balloon.fontSize = '12pt'; // | |
31 | + balloon.minWidth = 100; // | |
32 | + balloon.maxWidth = 400; // | |
33 | + balloon.delayTime = 750; // | |
34 | + balloon.vOffset = 10; // | |
35 | + balloon.hOffset = 10; // | |
36 | + balloon.stem = true; // | |
37 | + balloon.images = i3GEO.configura.locaplic+'/pacotes/balloon-tooltips/htdocs/images/GBubble'; // | |
38 | + balloon.ieImage = 'balloon_ie.png'; // | |
39 | + balloon.balloonImage = 'balloon.png'; // | |
40 | + balloon.upLeftStem = 'up_left.png'; // | |
41 | + balloon.downLeftStem = 'down_left.png'; // | |
42 | + balloon.upRightStem = 'up_right.png'; // | |
43 | + balloon.downRightStem = 'down_right.png'; // | |
44 | + balloon.closeButton = 'close.png'; // | |
45 | + balloon.closeButtonWidth = 16; // | |
46 | + balloon.allowAJAX = false; // | |
47 | + balloon.allowIframes = false; // | |
48 | + balloon.trackCursor = false; // | |
49 | + balloon.shadow = 20; // | |
50 | + balloon.padding = 10; // | |
51 | + balloon.stemHeight = 32; // | |
52 | + balloon.stemOverlap = 3; // | |
53 | + balloon.vOffset = 1; // | |
54 | + balloon.hOffset = 1; // | |
55 | + balloon.opacity = 0.9; // | |
56 | + balloon.configured = set || true; // | |
57 | + } // | |
58 | + //////////////////////////////////////////////////////////////// | |
59 | + | |
60 | + | |
61 | + //////////////////////////////////////////////////////////////// | |
62 | + // Custom configuration options -- Add a case below for your // | |
63 | + // config set (default sets: GBox, GPlain, and GFade) // | |
64 | + //////////////////////////////////////////////////////////////// | |
65 | + switch(set) { | |
66 | + | |
67 | + // A formatted box (no background image) | |
68 | + case('GBoxxxx') : | |
69 | + balloon.bgColor = 'whitesmoke'; | |
70 | + balloon.borderStyle = '2px solid gray'; | |
71 | + //balloon.images = i3GEO.configura.locaplic+'/pacotes/balloon-tooltips/htdocs/images/GPlain'; | |
72 | + balloon.padding = 5; | |
73 | + balloon.shadow = 0; | |
74 | + balloon.stem = true; //original é false edmar | |
75 | + balloon.opacity = 0.8; | |
76 | + balloon.hOffset = 1; | |
77 | + balloon.vOffset = 1; | |
78 | + balloon.allowFade = false; | |
79 | + break; | |
80 | + | |
81 | + // A simpler balloon | |
82 | + case('GPlain') : | |
83 | + balloon.padding = 5; | |
84 | + balloon.images = i3GEO.configura.locaplic+'/pacotes/balloon-tooltips/htdocs/images/GPlain'; | |
85 | + balloon.ieImage = null; | |
86 | + balloon.shadow = 0; | |
87 | + balloon.stemHeight = 15; | |
88 | + balloon.stemOverlap = 1; | |
89 | + balloon.opacity = 0.85; | |
90 | + break; | |
91 | + | |
92 | + // The default cartoon bubble with a fade-in effect | |
93 | + case('GFade') : | |
94 | + balloon.allowFade = true; | |
95 | + balloon.fadeIn = 1000; | |
96 | + balloon.faedOut = 200; | |
97 | + break; | |
98 | + } | |
99 | +} | |
100 | + | ... | ... |
... | ... | @@ -0,0 +1,1166 @@ |
1 | +/* | |
2 | + * balloon.js -- a DHTML library for balloon tooltips | |
3 | + * | |
4 | + * $Id: balloon.js 22300 2009-12-01 09:40:39Z sheldon_mckay $ | |
5 | + * | |
6 | + * See http://www.gmod.org/wiki/index.php/Popup_Balloons | |
7 | + * for documentation. | |
8 | + * | |
9 | + * Copyright (c) 2007-2009 Sheldon McKay, Cold Spring Harbor Laboratory | |
10 | + * | |
11 | + * This balloon tooltip package and associated files not otherwise copyrighted are | |
12 | + * distributed under the MIT-style license: | |
13 | + * | |
14 | + * http://opensource.org/licenses/mit-license.php | |
15 | + * | |
16 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
17 | + * of this software and associated documentation files (the "Software"), to deal | |
18 | + * in the Software without restriction, including without limitation the rights | |
19 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
20 | + * copies of the Software, and to permit persons to whom the Software is | |
21 | + * furnished to do so, subject to the following conditions: | |
22 | + * | |
23 | + * The above copyright notice and this permission notice shall be included in | |
24 | + * all copies or substantial portions of the Software. | |
25 | + * | |
26 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
27 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
28 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
29 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
30 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
31 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
32 | + * THE SOFTWARE. | |
33 | + * | |
34 | + */ | |
35 | + | |
36 | +// These global variables are necessary to avoid losing scope when | |
37 | +// setting the balloon timeout and for inter-object communication | |
38 | +var currentBalloonClass; | |
39 | +var balloonIsVisible; | |
40 | +var balloonIsSticky; | |
41 | +var balloonInvisibleSelects; | |
42 | +var balloonIsSuppressed; | |
43 | +var tooltipIsSuppressed; | |
44 | + | |
45 | + | |
46 | +////////////////////////////////////////////////////////////////////////// | |
47 | +// This is constructor that is called to initialize the Balloon object // | |
48 | +////////////////////////////////////////////////////////////////////////// | |
49 | +var Balloon = function () { | |
50 | + // Cursor tracking enabled by default | |
51 | + this.trackCursor = true; | |
52 | + | |
53 | + // Track the cursor every time the mouse moves | |
54 | + document.onmousemove = this.setActiveCoordinates; | |
55 | + | |
56 | + // scrolling aborts visible balloons | |
57 | + var myObject = this.isIE() ? window : document; | |
58 | + myObject.onscroll = function(){Balloon.prototype.nukeTooltip()}; | |
59 | + | |
60 | + // make balloons go away if the page is unloading or waiting | |
61 | + // to unload. | |
62 | + window.onbeforeunload = function(){ | |
63 | + Balloon.prototype.nukeTooltip(); | |
64 | + balloonIsSuppressed = true; | |
65 | + }; | |
66 | + | |
67 | + // for IE, the balloons can't start until the page is finished loading | |
68 | + // set a flag that will get toggled when loading is finished | |
69 | + if (this.isIE()) { | |
70 | + this.suppress = true; | |
71 | + } | |
72 | + | |
73 | + return this; | |
74 | +} | |
75 | + | |
76 | +////////////////////////////////////////////////////////////////////////// | |
77 | +// This is the method that is called on mouseover. It has a built-in // | |
78 | +// delay time to avoid balloons popping up on rapid mouseover events // | |
79 | +////////////////////////////////////////////////////////////////////////// | |
80 | +Balloon.prototype.showTooltip = function(evt,caption,sticky,width,height) { | |
81 | + // If the objext is not configured by now, fall back to default | |
82 | + if (!this.configured) { | |
83 | + BalloonConfig(this,'GBubble'); | |
84 | + } | |
85 | + | |
86 | + // Cursor tracking halts after one of these vertical | |
87 | + // or horizontal thresholds are reached | |
88 | + this.stopTrackingX = this.trackCursor ? 100 : 10; | |
89 | + this.stopTrackingY = this.trackCursor ? 50 : 10; | |
90 | + | |
91 | + // Awful IE bug, page load aborts if the balloon is fired | |
92 | + // before the page is fully loaded. | |
93 | + if (this.isIE() && document.readyState.match(/complete/i)) { | |
94 | + this.suppress = false; | |
95 | + } | |
96 | + | |
97 | + // All balloons have been suppressed, go no further | |
98 | + if (this.suppress || balloonIsSuppressed) { | |
99 | + return false; | |
100 | + } | |
101 | + | |
102 | + // Non-sticky balloons suppressed | |
103 | + if (tooltipIsSuppressed && !sticky) { | |
104 | + return false; | |
105 | + } | |
106 | + | |
107 | + // We use 1-100 scale for opacity internally | |
108 | + if (this.opacity && this.opacity < 1) { | |
109 | + this.opacity = parseInt(parseFloat(this.opacity) * 100); | |
110 | + } | |
111 | + else if (this.opacity && this.opacity == 1) { | |
112 | + this.opacity = 100; | |
113 | + } | |
114 | + else if (!this.opacity) { | |
115 | + this.opacity == 100; | |
116 | + } | |
117 | + | |
118 | + // Sorry Konqueror, no fade-in or translucency for you! | |
119 | + if (this.isKonqueror()) { | |
120 | + this.allowFade = false; | |
121 | + this.opacity = 100; | |
122 | + } | |
123 | + | |
124 | + // With IE, fading and translucency are not very compatible | |
125 | + // use opaque balloons if fadein is enabled | |
126 | + if (this.isIE() && this.allowFade) { | |
127 | + this.opacity = 100; | |
128 | + } | |
129 | + | |
130 | + // Check for mouseover (vs. mousedown or click) | |
131 | + var mouseOver = true; | |
132 | + try{ | |
133 | + var mouseOver = evt.type.match('mouseover','i'); | |
134 | + }catch(e){} | |
135 | + | |
136 | + // if the firing event is a click, fade-in and a non-sticky balloon make no sense | |
137 | + if (!mouseOver) { | |
138 | + sticky = true; | |
139 | + this.fadeOK = false; | |
140 | + // case where hover and click events both trigger balloons | |
141 | + if (balloonIsVisible) { | |
142 | + this.hideTooltip(); | |
143 | + } | |
144 | + } | |
145 | + else { | |
146 | + this.fadeOK = this.allowFade; | |
147 | + } | |
148 | + | |
149 | + // Don't fire on mouseover if a non-sticky balloon is visible | |
150 | + if (balloonIsVisible && !balloonIsSticky && mouseOver) { | |
151 | + return false; | |
152 | + } | |
153 | + | |
154 | + // Don't start a non-sticky balloon if a sticky one is visible | |
155 | + if (balloonIsVisible && balloonIsSticky && !sticky) { | |
156 | + return false; | |
157 | + } | |
158 | + | |
159 | + // Ignore repeated firing of mouseover->mouseout events on | |
160 | + // the same element (Safari) | |
161 | + | |
162 | + try{ | |
163 | + var el = this.getEventTarget(evt); | |
164 | + }catch(e){var el = evt;} | |
165 | + | |
166 | + if (sticky && mouseOver && this.isSameElement(el,this.currentElement)) { | |
167 | + return false; | |
168 | + } | |
169 | + this.currentElement = el; | |
170 | + | |
171 | + // remember the coordinates of the element | |
172 | + this.elCoords = this.getLoc(el,'region'); | |
173 | + | |
174 | + // attach a mouseout event handler to the target element | |
175 | + if (!sticky) { | |
176 | + var mouseoutFunc = el.onmouseout; | |
177 | + var closeBalloon = function() { | |
178 | + Balloon.prototype.hideTooltip(); | |
179 | + // fall through to any onmouseout event specified elsewhere | |
180 | + if (mouseoutFunc) { | |
181 | + mouseoutFunc(); | |
182 | + } | |
183 | + } | |
184 | + if (!mouseOver) { | |
185 | + el.onmouseup = function() {return false}; | |
186 | + } | |
187 | + //el.onmouseout = closeBalloon; | |
188 | + } | |
189 | + | |
190 | + balloonIsSticky = sticky; | |
191 | + | |
192 | + this.hideTooltip(); | |
193 | + | |
194 | + // request the contents synchronously (ie wait for result) | |
195 | + this.currentHelpText = this.getAndCheckContents(caption); | |
196 | + | |
197 | + // no contents? abort. | |
198 | + if (!this.currentHelpText) { | |
199 | + return false; | |
200 | + } | |
201 | + | |
202 | + this.width = width; | |
203 | + this.height = height; | |
204 | + this.actualWidth = null; | |
205 | + | |
206 | + // make sure old balloons are removed | |
207 | + this.hideTooltip(); | |
208 | + | |
209 | + // Put the balloon contents and images into a visible (but offscreen) | |
210 | + // element so they will be preloaded and have a layout to | |
211 | + // calculate the balloon dimensions | |
212 | + this.container = document.createElement('div'); | |
213 | + this.container.id = 'balloonPreloadContainer'; | |
214 | + document.body.appendChild(this.container); | |
215 | + this.setStyle(this.container,'position','absolute'); | |
216 | + this.setStyle(this.container,'top',-8888); | |
217 | + this.setStyle(this.container,'font-family',this.fontFamily); | |
218 | + this.setStyle(this.container,'font-size',this.fontSize); | |
219 | + | |
220 | + // protect escaped '&' | |
221 | + this.currentHelpText = this.currentHelpText.replace(/\&/g, '&amp'); | |
222 | + this.container.innerHTML = unescape(this.currentHelpText); | |
223 | + | |
224 | + // make sure balloon image path is complete | |
225 | + if (this.images) { | |
226 | + | |
227 | + // main background image | |
228 | + this.balloonImage = this.balloonImage ? this.images +'/'+ this.balloonImage : false; | |
229 | + this.ieImage = this.ieImage ? this.images +'/'+ this.ieImage : false; | |
230 | + | |
231 | + // optional stems | |
232 | + this.upLeftStem = this.upLeftStem ? this.images +'/'+ this.upLeftStem : false; | |
233 | + this.upRightStem = this.upRightStem ? this.images +'/'+ this.upRightStem : false; | |
234 | + this.downLeftStem = this.downLeftStem ? this.images +'/'+ this.downLeftStem : false; | |
235 | + this.downRightStem = this.downRightStem ? this.images +'/'+ this.downRightStem : false; | |
236 | + | |
237 | + this.closeButton = this.closeButton ? this.images +'/'+ this.closeButton : false; | |
238 | + | |
239 | + this.images = false; | |
240 | + } | |
241 | + | |
242 | + // The PNG alpha channels (shadow transparency) are not | |
243 | + // handled properly by IE < 6. Also, if opacity is set to | |
244 | + // < 1 (translucent balloons), any version of IE does not | |
245 | + // handle the image properly. | |
246 | + // Google chrome is a bit dodgey too | |
247 | + // If there is an IE image provided, use that instead. | |
248 | + if (this.ieImage && (this.isIE() || this.isChrome())) { | |
249 | + if (this.isOldIE() || this.opacity || this.allowFade) { | |
250 | + this.balloonImage = this.ieImage; | |
251 | + } | |
252 | + } | |
253 | + | |
254 | + // preload balloon images | |
255 | + if (!this.preloadedImages) { | |
256 | + var images = new Array(this.balloonImage, this.closeButton); | |
257 | + if (this.ieImage) { | |
258 | + images.push(this.ieImage); | |
259 | + } | |
260 | + if (this.stem) { | |
261 | + images.push(this.upLeftStem,this.upRightStem,this.downLeftStem,this.downRightStem); | |
262 | + } | |
263 | + var len = images.length; | |
264 | + for (var i=0;i<len;i++) { | |
265 | + if ( images[i] ) { | |
266 | + this.preload(images[i]); | |
267 | + } | |
268 | + } | |
269 | + this.preloadedImages = true; | |
270 | + } | |
271 | + | |
272 | + currentBalloonClass = this; | |
273 | + | |
274 | + // Capture coordinates for mousedown or click | |
275 | + //if (!mouseOver) {this.setActiveCoordinates(evt);} | |
276 | + if (!mouseOver) el.onmouseup = function() {return false;}; | |
277 | + // Remember which event started this | |
278 | + this.currentEvent = evt; | |
279 | + | |
280 | + // prevent interaction with gbrowse drag and drop | |
281 | + evt.cancelBubble = true; | |
282 | + | |
283 | + // Make delay time short for onmousedown | |
284 | + //var delay = mouseOver ? this.delayTime : 1; | |
285 | + //this.timeoutTooltip = window.setTimeout(this.doShowTooltip,delay); | |
286 | + this.doShowTooltip(); | |
287 | + this.pending = true; | |
288 | +} | |
289 | + | |
290 | +// Preload the balloon background images | |
291 | +Balloon.prototype.preload = function(src) { | |
292 | + var i = new Image; | |
293 | + i.src = src; | |
294 | + | |
295 | + // append to the DOM tree so the images have a layout, | |
296 | + // then remove. | |
297 | + this.setStyle(i,'position','absolute'); | |
298 | + this.setStyle(i,'top',-8000); | |
299 | + document.body.appendChild(i); | |
300 | + document.body.removeChild(i); | |
301 | +} | |
302 | + | |
303 | + | |
304 | +///////////////////////////////////////////////////////////////////// | |
305 | +// Tooltip rendering function | |
306 | +///////////////////////////////////////////////////////////////////// | |
307 | +Balloon.prototype.doShowTooltip = function() { | |
308 | + var self = currentBalloonClass; | |
309 | + | |
310 | + // Stop firing if a balloon is already being displayed | |
311 | + if (balloonIsVisible) { | |
312 | + return false; | |
313 | + } | |
314 | + if (!self.parent) { | |
315 | + if (self.parentID) { | |
316 | + self.parent = document.getElementById(self.parentID); | |
317 | + } | |
318 | + else { | |
319 | + self.parent = document.body; | |
320 | + } | |
321 | + self.xOffset = self.getLoc(self.parent, 'x1'); | |
322 | + self.yOffset = self.getLoc(self.parent, 'y1'); | |
323 | + } | |
324 | + | |
325 | + // a short delay time might cause some intereference | |
326 | + // with fading | |
327 | + window.clearTimeout(self.timeoutFade); | |
328 | + if (!balloonIsSticky) { | |
329 | + self.setStyle('visibleBalloonElement','display','none'); | |
330 | + } | |
331 | + | |
332 | + // make sure user-configured numbers are not strings | |
333 | + self.parseIntAll(); | |
334 | + | |
335 | + // create the balloon object | |
336 | + var balloon = self.makeBalloon(); | |
337 | + | |
338 | + // window dimensions | |
339 | + var pageWidth = YAHOO.util.Dom.getViewportWidth(); | |
340 | + var pageCen = Math.round(pageWidth/2); | |
341 | + var pageHeight = YAHOO.util.Dom.getViewportHeight(); | |
342 | + var pageLeft = YAHOO.util.Dom.getDocumentScrollLeft(); | |
343 | + var pageTop = YAHOO.util.Dom.getDocumentScrollTop(); | |
344 | + var pageMid = pageTop + Math.round(pageHeight/2); | |
345 | + self.pageBottom = pageTop + pageHeight; | |
346 | + self.pageTop = pageTop; | |
347 | + self.pageLeft = pageLeft; | |
348 | + self.pageRight = pageLeft + pageWidth; | |
349 | + | |
350 | + // balloon orientation | |
351 | + var vOrient = self.activeTop > pageMid ? 'up' : 'down'; | |
352 | + var hOrient = self.activeRight > pageCen ? 'left' : 'right'; | |
353 | + | |
354 | + // get the preloaded balloon contents | |
355 | + var helpText = self.container.innerHTML; | |
356 | + self.actualWidth = self.getLoc(self.container,'width'); | |
357 | + if (!isNaN(self.actualWidth)) { | |
358 | + self.actualWidth += 10; | |
359 | + } | |
360 | + self.parent.removeChild(self.container); | |
361 | + var wrapper = document.createElement('div'); | |
362 | + wrapper.id = 'contentWrapper'; | |
363 | + self.contents.appendChild(wrapper); | |
364 | + wrapper.innerHTML = helpText; | |
365 | + | |
366 | + // how and where to draw the balloon | |
367 | + self.setBalloonStyle(vOrient,hOrient,pageWidth,pageLeft); | |
368 | + | |
369 | + // close control for balloon or box | |
370 | + if (balloonIsSticky) { | |
371 | + self.addCloseButton(); | |
372 | + } | |
373 | + | |
374 | + balloonIsVisible = true; | |
375 | + self.pending = false; | |
376 | + | |
377 | + // in IE < 7, hide <select> elements | |
378 | + self.showHide(); | |
379 | + | |
380 | + self.startX = self.activeLeft; | |
381 | + self.startY = self.activeTop; | |
382 | + self.fade(0,self.opacity,self.fadeIn); | |
383 | +} | |
384 | + | |
385 | +Balloon.prototype.addCloseButton = function () { | |
386 | + var self = currentBalloonClass; | |
387 | + var margin = Math.round(self.padding/2); | |
388 | + var closeWidth = self.closeButtonWidth || 16; | |
389 | + var balloonTop = self.getLoc('visibleBalloonElement','y1') + margin + self.shadow; | |
390 | + var BalloonLeft = self.getLoc('topRight','x2') - self.closeButtonWidth - self.shadow - margin; | |
391 | + var closeButton = document.getElementById('closeButton'); | |
392 | + | |
393 | + if (!closeButton) { | |
394 | + closeButton = new Image; | |
395 | + closeButton.setAttribute('id','closeButton'); | |
396 | + closeButton.setAttribute('src',self.closeButton); | |
397 | + closeButton.onclick = function() { | |
398 | + Balloon.prototype.nukeTooltip(); | |
399 | + }; | |
400 | + self.setStyle(closeButton,'position','absolute'); | |
401 | + document.body.appendChild(closeButton); | |
402 | + } | |
403 | + | |
404 | + // I have no idea why | |
405 | + if (self.isIE()) { | |
406 | + BalloonLeft = BalloonLeft - 5; | |
407 | + } | |
408 | + | |
409 | + self.setStyle(closeButton,'top',balloonTop); | |
410 | + self.setStyle(closeButton,'left',BalloonLeft); | |
411 | + self.setStyle(closeButton,'display','inline'); | |
412 | + self.setStyle(closeButton,'cursor','pointer'); | |
413 | + self.setStyle(closeButton,'z-index',999999999); | |
414 | +} | |
415 | + | |
416 | +// use a fresh object every time to make sure style | |
417 | +// is not polluted | |
418 | +Balloon.prototype.makeBalloon = function() { | |
419 | + var self = currentBalloonClass; | |
420 | + | |
421 | + var balloon = document.getElementById('visibleBalloonElement'); | |
422 | + if (balloon) { | |
423 | + self.hideTooltip(); | |
424 | + } | |
425 | + | |
426 | + balloon = document.createElement('div'); | |
427 | + balloon.setAttribute('id','visibleBalloonElement'); | |
428 | + self.parent.appendChild(balloon); | |
429 | + self.activeBalloon = balloon; | |
430 | + | |
431 | + self.parts = new Array(); | |
432 | + var parts = new Array('contents','topRight','bottomRight','bottomLeft'); | |
433 | + for (var i=0;i<parts.length;i++) { | |
434 | + var child = document.createElement('div'); | |
435 | + child.setAttribute('id',parts[i]); | |
436 | + balloon.appendChild(child); | |
437 | + if (parts[i] == 'contents') self.contents = child; | |
438 | + self.parts.push(child); | |
439 | + } | |
440 | + //self.parts.push(balloon); | |
441 | + | |
442 | + if (self.displayTime) { | |
443 | + self.timeoutAutoClose = window.setTimeout(this.hideTooltip,self.displayTime); | |
444 | + } | |
445 | + return balloon; | |
446 | +} | |
447 | + | |
448 | +Balloon.prototype.setBalloonStyle = function(vOrient,hOrient,pageWidth,pageLeft) { | |
449 | + var self = currentBalloonClass; | |
450 | + var balloon = self.activeBalloon; | |
451 | + | |
452 | + if (typeof(self.shadow) != 'number') self.shadow = 0; | |
453 | + if (!self.stem) self.stemHeight = 0; | |
454 | + | |
455 | + var fullPadding = self.padding + self.shadow; | |
456 | + var insidePadding = self.padding; | |
457 | + var outerWidth = self.actualWidth + fullPadding; | |
458 | + var innerWidth = self.actualWidth; | |
459 | + | |
460 | + self.setStyle(balloon,'position','absolute'); | |
461 | + self.setStyle(balloon,'top',-9999); | |
462 | + self.setStyle(balloon,'z-index',1000000); | |
463 | + | |
464 | + if (self.height) { | |
465 | + self.setStyle('contentWrapper','height',self.height-fullPadding); | |
466 | + } | |
467 | + | |
468 | + if (self.width) { | |
469 | + self.setStyle(balloon,'width',self.width); | |
470 | + innerWidth = self.width - fullPadding; | |
471 | + if (balloonIsSticky) { | |
472 | + innerWidth -= self.closeButtonWidth; | |
473 | + } | |
474 | + self.setStyle('contentWrapper','width',innerWidth); | |
475 | + } | |
476 | + else { | |
477 | + self.setStyle(balloon,'width',outerWidth); | |
478 | + self.setStyle('contentWrapper','width',innerWidth); | |
479 | + } | |
480 | + | |
481 | + // not too big... | |
482 | + if (!self.width && self.maxWidth && outerWidth > self.maxWidth) { | |
483 | + self.setStyle(balloon,'width',self.maxWidth); | |
484 | + self.setStyle('contentWrapper','width',self.maxWidth-fullPadding); | |
485 | + } | |
486 | + // not too small... | |
487 | + if (!self.width && self.minWidth && outerWidth < self.minWidth) { | |
488 | + self.setStyle(balloon,'width',self.minWidth); | |
489 | + self.setStyle('contentWrapper','width',self.minWidth-fullPadding); | |
490 | + } | |
491 | + | |
492 | + self.setStyle('contents','z-index',2); | |
493 | + self.setStyle('contents','color',self.fontColor); | |
494 | + self.setStyle('contents','font-family',self.fontFamily); | |
495 | + self.setStyle('contents','font-size',self.fontSize); | |
496 | + self.setStyle('contents','background','url('+self.balloonImage+') top left no-repeat'); | |
497 | + self.setStyle('contents','padding-top',fullPadding); | |
498 | + self.setStyle('contents','padding-left',fullPadding); | |
499 | + | |
500 | + self.setStyle('bottomRight','background','url('+self.balloonImage+') bottom right no-repeat'); | |
501 | + self.setStyle('bottomRight','position','absolute'); | |
502 | + self.setStyle('bottomRight','right',0-fullPadding); | |
503 | + self.setStyle('bottomRight','bottom',0-fullPadding); | |
504 | + self.setStyle('bottomRight','height',fullPadding); | |
505 | + self.setStyle('bottomRight','width',fullPadding); | |
506 | + self.setStyle('bottomRight','z-index',-1); | |
507 | + | |
508 | + self.setStyle('topRight','background','url('+self.balloonImage+') top right no-repeat'); | |
509 | + self.setStyle('topRight','position','absolute'); | |
510 | + self.setStyle('topRight','right',0-fullPadding); | |
511 | + self.setStyle('topRight','top',0); | |
512 | + self.setStyle('topRight','width',fullPadding); | |
513 | + | |
514 | + self.setStyle('bottomLeft','background','url('+self.balloonImage+') bottom left no-repeat'); | |
515 | + self.setStyle('bottomLeft','position','absolute'); | |
516 | + self.setStyle('bottomLeft','left',0); | |
517 | + self.setStyle('bottomLeft','bottom',0-fullPadding); | |
518 | + self.setStyle('bottomLeft','height',fullPadding); | |
519 | + self.setStyle('bottomLeft','z-index',-1); | |
520 | + | |
521 | + if (this.stem) { | |
522 | + var stem = document.createElement('img'); | |
523 | + self.setStyle(stem,'position','absolute'); | |
524 | + balloon.appendChild(stem); | |
525 | + | |
526 | + if (vOrient == 'up' && hOrient == 'left') { | |
527 | + stem.src = self.upLeftStem; | |
528 | + var height = self.stemHeight + insidePadding - self.stemOverlap; | |
529 | + self.setStyle(stem,'bottom',0-height); | |
530 | + self.setStyle(stem,'right',0); | |
531 | + } | |
532 | + else if (vOrient == 'down' && hOrient == 'left') { | |
533 | + stem.src = self.downLeftStem; | |
534 | + var height = self.stemHeight - (self.shadow + self.stemOverlap); | |
535 | + self.setStyle(stem,'top',0-height); | |
536 | + self.setStyle(stem,'right',0); | |
537 | + } | |
538 | + else if (vOrient == 'up' && hOrient == 'right') { | |
539 | + stem.src = self.upRightStem; | |
540 | + var height = self.stemHeight + insidePadding - self.stemOverlap; | |
541 | + self.setStyle(stem,'bottom',0-height); | |
542 | + self.setStyle(stem,'left',self.shadow); | |
543 | + } | |
544 | + else if (vOrient == 'down' && hOrient == 'right') { | |
545 | + stem.src = self.downRightStem; | |
546 | + var height = self.stemHeight - (self.shadow + self.stemOverlap); | |
547 | + self.setStyle(stem,'top',0-height); | |
548 | + self.setStyle(stem,'left',self.shadow); | |
549 | + } | |
550 | + if (self.fadeOK && self.isIE()) { | |
551 | + self.parts.push(stem); | |
552 | + } | |
553 | + } | |
554 | + | |
555 | + if (self.allowFade) { | |
556 | + self.setOpacity(1); | |
557 | + } | |
558 | + else if (self.opacity) { | |
559 | + self.setOpacity(self.opacity); | |
560 | + } | |
561 | + | |
562 | + // flip left or right, as required | |
563 | + if (hOrient == 'left') { | |
564 | + var pageWidth = self.pageRight - self.pageLeft; | |
565 | + var activeRight = pageWidth - self.activeLeft; | |
566 | + self.setStyle(balloon,'right',activeRight); | |
567 | + } | |
568 | + else { | |
569 | + var activeLeft = self.activeRight - self.xOffset; | |
570 | + self.setStyle(balloon,'left',activeLeft); | |
571 | + } | |
572 | + | |
573 | + // oversized contents? Scrollbars for sticky balloons, clipped for non-sticky | |
574 | + var overflow = balloonIsSticky ? 'auto' : 'hidden'; | |
575 | + self.setStyle('contentWrapper','overflow',overflow); | |
576 | + | |
577 | + // a bit of room for the closebutton | |
578 | + if (balloonIsSticky) { | |
579 | + self.setStyle('contentWrapper','margin-right',self.closeButtonWidth); | |
580 | + } | |
581 | + | |
582 | + // Make sure the balloon is not offscreen horizontally. | |
583 | + // We handle vertical sanity checking later, after the final | |
584 | + // layout is set. | |
585 | + var balloonLeft = self.getLoc(balloon,'x1'); | |
586 | + var balloonRight = self.getLoc(balloon,'x2'); | |
587 | + var scrollBar = 20; | |
588 | + | |
589 | + if (hOrient == 'right' && balloonRight > (self.pageRight - fullPadding)) { | |
590 | + var width = (self.pageRight - balloonLeft) - fullPadding - scrollBar; | |
591 | + self.setStyle(balloon,'width',width); | |
592 | + self.setStyle('contentWrapper','width',width-fullPadding); | |
593 | + } | |
594 | + else if (hOrient == 'left' && balloonLeft < (self.pageLeft + fullPadding)) { | |
595 | + var width = (balloonRight - self.pageLeft) - fullPadding; | |
596 | + self.setStyle(balloon,'width',width); | |
597 | + self.setStyle('contentWrapper','width',width-fullPadding); | |
598 | + } | |
599 | + | |
600 | + // Get the width/height for the right and bottom outlines | |
601 | + var balloonWidth = self.getLoc(balloon,'width'); | |
602 | + var balloonHeight = self.getLoc(balloon,'height'); | |
603 | + | |
604 | + // IE7 quirk -- look for unwanted overlap cause by an off by 1px error | |
605 | + var vOverlap = self.isOverlap('topRight','bottomRight'); | |
606 | + var hOverlap = self.isOverlap('bottomLeft','bottomRight'); | |
607 | + if (vOverlap) { | |
608 | + self.setStyle('topRight','height',balloonHeight-vOverlap[1]); | |
609 | + } | |
610 | + if (hOverlap) { | |
611 | + self.setStyle('bottomLeft','width',balloonWidth-hOverlap[0]); | |
612 | + } | |
613 | + | |
614 | + // vertical position of the balloon | |
615 | + if (vOrient == 'up') { | |
616 | + var activeTop = self.activeTop - balloonHeight; | |
617 | + self.setStyle(balloon,'top',activeTop); | |
618 | + } | |
619 | + else { | |
620 | + var activeTop = self.activeBottom; | |
621 | + self.setStyle(balloon,'top',activeTop); | |
622 | + } | |
623 | + | |
624 | + // Make sure the balloon is vertically contained in the window | |
625 | + var balloonTop = self.getLoc(balloon,'y1'); | |
626 | + var balloonBottom = self.height ? balloonTop + self.height : self.getLoc(balloon,'y2'); | |
627 | + var deltaTop = balloonTop < self.pageTop ? self.pageTop - balloonTop : 0; | |
628 | + var deltaBottom = balloonBottom > self.pageBottom ? balloonBottom - self.pageBottom : 0; | |
629 | + | |
630 | + if (vOrient == 'up' && deltaTop) { | |
631 | + var newHeight = balloonHeight - deltaTop; | |
632 | + if (newHeight > (self.padding*2)) { | |
633 | + self.setStyle('contentWrapper','height',newHeight-fullPadding); | |
634 | + self.setStyle(balloon,'top',self.pageTop+self.padding); | |
635 | + self.setStyle(balloon,'height',newHeight); | |
636 | + } | |
637 | + } | |
638 | + if (vOrient == 'down' && deltaBottom) { | |
639 | + var newHeight = balloonHeight - deltaBottom - scrollBar; | |
640 | + if (newHeight > (self.padding*2) + scrollBar) { | |
641 | + self.setStyle('contentWrapper','height',newHeight-fullPadding); | |
642 | + self.setStyle(balloon,'height',newHeight); | |
643 | + } | |
644 | + } | |
645 | + | |
646 | + // If we have an iframe, make sure it fits properly | |
647 | + var iframe = balloon.getElementsByTagName('iframe'); | |
648 | + if (iframe[0]) { | |
649 | + iframe = iframe[0]; | |
650 | + var w = self.getLoc('contentWrapper','width'); | |
651 | + if (balloonIsSticky && !this.isIE()) { | |
652 | + w -= self.closeButtonWidth; | |
653 | + } | |
654 | + var h = self.getLoc('contentWrapper','height'); | |
655 | + self.setStyle(iframe,'width',w); | |
656 | + self.setStyle(iframe,'height',h); | |
657 | + self.setStyle('contentWrapper','overflow','hidden'); | |
658 | + } | |
659 | + | |
660 | + // Make edges match the main balloon body | |
661 | + self.setStyle('topRight','height', self.getLoc(balloon,'height')); | |
662 | + self.setStyle('bottomLeft','width', self.getLoc(balloon,'width')); | |
663 | + | |
664 | + self.hOrient = hOrient; | |
665 | + self.vOrient = vOrient; | |
666 | +} | |
667 | + | |
668 | + | |
669 | +// Fade method adapted from an example on | |
670 | +// http://brainerror.net/scripts/javascript/blendtrans/ | |
671 | +Balloon.prototype.fade = function(opacStart, opacEnd, millisec) { | |
672 | + var self = currentBalloonClass || new Balloon; | |
673 | + if (!millisec || !self.allowFade) { | |
674 | + return false; | |
675 | + } | |
676 | + | |
677 | + opacEnd = opacEnd || 100; | |
678 | + | |
679 | + //speed for each frame | |
680 | + var speed = Math.round(millisec / 100); | |
681 | + var timer = 0; | |
682 | + for(o = opacStart; o <= opacEnd; o++) { | |
683 | + self.timeoutFade = setTimeout('Balloon.prototype.setOpacity('+o+')',(timer*speed)); | |
684 | + timer++; | |
685 | + } | |
686 | +} | |
687 | + | |
688 | +Balloon.prototype.setOpacity = function(opc) { | |
689 | + var self = currentBalloonClass; | |
690 | + if (!self || !opc) return false; | |
691 | + | |
692 | + var o = parseFloat(opc/100); | |
693 | + | |
694 | + // opacity handled differently for IE | |
695 | + var parts = self.isIE() ? self.parts : [self.activeBalloon]; | |
696 | + | |
697 | + var len = parts.length; | |
698 | + for (var i=0;i<len;i++) { | |
699 | + self.doOpacity(o,opc,parts[i]); | |
700 | + } | |
701 | +} | |
702 | + | |
703 | +Balloon.prototype.doOpacity = function(op,opc,el) { | |
704 | + var self = currentBalloonClass; | |
705 | + if (!el) return false; | |
706 | + | |
707 | + // CSS standards-compliant browsers! | |
708 | + self.setStyle(el,'opacity',op); | |
709 | + | |
710 | + // old IE | |
711 | + self.setStyle(el,'filter','alpha(opacity='+opc+')'); | |
712 | + | |
713 | + // old Mozilla/NN | |
714 | + self.setStyle(el,'MozOpacity',op); | |
715 | + | |
716 | + // old Safari | |
717 | + self.setStyle(el,'KhtmlOpacity',op); | |
718 | +} | |
719 | + | |
720 | +Balloon.prototype.nukeTooltip = function() { | |
721 | + this.hideTooltip(1); | |
722 | +} | |
723 | + | |
724 | +Balloon.prototype.hideTooltip = function(override) { | |
725 | + // some browsers pass the event object == we don't want it | |
726 | + if (override && typeof override == 'object') override = false; | |
727 | + if (balloonIsSticky && !override) return false; | |
728 | + var self = currentBalloonClass; | |
729 | + Balloon.prototype.showHide(1); | |
730 | + Balloon.prototype.cleanup(); | |
731 | + | |
732 | + if (self) { | |
733 | + window.clearTimeout(self.timeoutTooltip); | |
734 | + window.clearTimeout(self.timeoutFade); | |
735 | + window.clearTimeout(self.timeoutAutoClose); | |
736 | + if (balloonIsSticky) { | |
737 | + self.currentElement = null; | |
738 | + } | |
739 | + self.startX = 0; | |
740 | + self.startY = 0; | |
741 | + } | |
742 | + | |
743 | + balloonIsVisible = false; | |
744 | + balloonIsSticky = false; | |
745 | +} | |
746 | + | |
747 | +// Garbage collection | |
748 | +Balloon.prototype.cleanup = function() { | |
749 | + var self = currentBalloonClass; | |
750 | + var body; | |
751 | + if (self) { | |
752 | + body = self.parent ? self.parent | |
753 | + : self.parentID ? document.getElementById(self.parentID) || document.body | |
754 | + : document.body; | |
755 | + } | |
756 | + else { | |
757 | + body = document.body; | |
758 | + } | |
759 | + | |
760 | + var bubble = document.getElementById('visibleBalloonElement'); | |
761 | + var close = document.getElementById('closeButton'); | |
762 | + var cont = document.getElementById('balloonPreloadContainer'); | |
763 | + if (bubble) { body.removeChild(bubble) } | |
764 | + if (close) { body.removeChild(close) } | |
765 | + if (cont) { body.removeChild(cont) } | |
766 | +} | |
767 | + | |
768 | + | |
769 | +// this function is meant to be called externally to clear | |
770 | +// any open balloons | |
771 | +hideAllTooltips = function() { | |
772 | + var self = currentBalloonClass; | |
773 | + if (!self) return; | |
774 | + window.clearTimeout(self.timeoutTooltip); | |
775 | + if (self.activeBalloon) self.setStyle(self.activeBalloon,'display','none'); | |
776 | + balloonIsVisible = false; | |
777 | + balloonIsSticky = false; | |
778 | + currentBalloonClass = null; | |
779 | +} | |
780 | + | |
781 | + | |
782 | +// Track the active mouseover coordinates | |
783 | +Balloon.prototype.setActiveCoordinates = function(evt) { | |
784 | + var self = currentBalloonClass; | |
785 | + if (!self) { | |
786 | + return true; | |
787 | + } | |
788 | + var evt = evt || window.event || self.currentEvent; | |
789 | + if (!evt) { | |
790 | + return true; | |
791 | + } | |
792 | + // | |
793 | + //modificado por edmar | |
794 | + // | |
795 | + | |
796 | + self.currentEvent = {}; | |
797 | + for (var i in evt) { | |
798 | + self.currentEvent[i] = evt[i]; | |
799 | + } | |
800 | + | |
801 | + // avoid silent NaN errors | |
802 | + self.hOffset = self.hOffset || 1; | |
803 | + self.vOffset = self.vOffset || 1; | |
804 | + self.stemHeight = self.stem && self.stemHeight ? (self.stemHeight|| 0) : 0; | |
805 | + | |
806 | + var scrollTop = 0; | |
807 | + var scrollLeft = 0; | |
808 | + | |
809 | + var XY = self.eventXY(evt); | |
810 | + adjustment = self.hOffset < 20 ? 10 : 0; | |
811 | + self.activeTop = scrollTop + XY[1] - adjustment - self.vOffset - self.stemHeight; | |
812 | + self.activeLeft = scrollLeft + XY[0] - adjustment - self.hOffset; | |
813 | + self.activeRight = scrollLeft + XY[0]; | |
814 | + self.activeBottom = scrollTop + XY[1] + self.vOffset + 2*adjustment; | |
815 | + | |
816 | + // dynamic positioning but only if the balloon is not sticky | |
817 | + // and cursor tracking is enabled | |
818 | + if (balloonIsVisible && !balloonIsSticky) { | |
819 | + var deltaX = Math.abs(self.activeLeft - self.startX); | |
820 | + var deltaY = Math.abs(self.activeTop - self.startY); | |
821 | + | |
822 | + // Close the balloon if the cursor has left the firing element | |
823 | + if ( XY[0] < self.elCoords.left || XY[0] > self.elCoords.right | |
824 | + || XY[1] < self.elCoords.top || XY[1] > self.elCoords.bottom ) { | |
825 | + //self.hideTooltip(); | |
826 | + } | |
827 | + | |
828 | + // In some cases , such as <area> elements in image maps or big elements, | |
829 | + // we need to kill the balloon if the mouse has strayed too far. | |
830 | + if (deltaX > self.stopTrackingX || deltaY > self.stopTrackingY) { | |
831 | + //self.hideTooltip(); | |
832 | + } | |
833 | + else if (self.trackCursor) { | |
834 | + var b = self.activeBalloon; | |
835 | + var bwidth = self.getLoc(b,'width'); | |
836 | + var bheight = self.getLoc(b,'height'); | |
837 | + var btop = self.getLoc(b,'y1'); | |
838 | + var bleft = self.getLoc(b,'x1'); | |
839 | + | |
840 | + if (self.hOrient == 'right') { | |
841 | + self.setStyle(b,'left',self.activeRight); | |
842 | + } | |
843 | + else if (self.hOrient == 'left') { | |
844 | + self.setStyle(b,'right',null); | |
845 | + var newLeft = self.activeLeft - bwidth; | |
846 | + self.setStyle(b,'left',newLeft); | |
847 | + } | |
848 | + | |
849 | + if (self.vOrient == 'up') { | |
850 | + self.setStyle(b,'top',self.activeTop - bheight); | |
851 | + } | |
852 | + else if (self.vOrient == 'down') { | |
853 | + self.setStyle(b,'top',self.activeBottom); | |
854 | + } | |
855 | + } | |
856 | + } | |
857 | + | |
858 | + return true; | |
859 | +} | |
860 | + | |
861 | +//// | |
862 | +// event XY and getEventTarget Functions based on examples by Peter-Paul | |
863 | +// Koch http://www.quirksmode.org/js/events_properties.html | |
864 | +Balloon.prototype.eventXY = function(event) { | |
865 | + var XY = new Array(2); | |
866 | + var e = event || window.event; | |
867 | + if (!e) { | |
868 | + return false; | |
869 | + } | |
870 | + if (e.pageX || e.pageY) { | |
871 | + XY[0] = e.pageX; | |
872 | + XY[1] = e.pageY; | |
873 | + return XY; | |
874 | + } | |
875 | + else if ( e.clientX || e.clientY ) { | |
876 | + XY[0] = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; | |
877 | + XY[1] = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; | |
878 | + return XY; | |
879 | + } | |
880 | +} | |
881 | + | |
882 | +Balloon.prototype.getEventTarget = function(event) { | |
883 | + var targ; | |
884 | + var e = event || window.event; | |
885 | + if (e.target) targ = e.target; | |
886 | + else if (e.srcElement) targ = e.srcElement; | |
887 | + if (targ.nodeType == 3) targ = targ.parentNode; // Safari | |
888 | + return targ; | |
889 | +} | |
890 | +//// | |
891 | + | |
892 | + | |
893 | +Balloon.prototype.setStyle = function(el,att,val) { | |
894 | + if (!el) { | |
895 | + return false; | |
896 | + } | |
897 | + if (typeof(el) != 'object') { | |
898 | + el = document.getElementById(el); | |
899 | + } | |
900 | + if (!el) { | |
901 | + return false; | |
902 | + } | |
903 | + | |
904 | + var v = val; | |
905 | + | |
906 | + if (val && att.match(/left|top|bottom|right|width|height|padding|margin/)) { | |
907 | + val = new String(val); | |
908 | + if (!val.match(/auto/)) { | |
909 | + val += 'px'; | |
910 | + } | |
911 | + } | |
912 | + | |
913 | + | |
914 | + // z-index does not work as expected | |
915 | + if (att == 'z-index') { | |
916 | + if (el.style) { | |
917 | + el.style.zIndex = parseInt(val); | |
918 | + } | |
919 | + } | |
920 | + else { | |
921 | + // Oh just shut up, IE | |
922 | + if (this.isIE() && att.match(/^left|right|top|bottom$/) && !parseInt(val) && val != 0) { | |
923 | + val = null; | |
924 | + } | |
925 | + | |
926 | + YAHOO.util.Dom.setStyle(el,att,val); | |
927 | + } | |
928 | +} | |
929 | + | |
930 | +// Uses YAHOO's region class for element coordinates | |
931 | +Balloon.prototype.getLoc = function(el,request) { | |
932 | + var region = YAHOO.util.Dom.getRegion(el); | |
933 | + | |
934 | + switch(request) { | |
935 | + case ('y1') : return parseInt(region.top); | |
936 | + case ('y2') : return parseInt(region.bottom); | |
937 | + case ('x1') : return parseInt(region.left); | |
938 | + case ('x2') : return parseInt(region.right); | |
939 | + case ('width') : return (parseInt(region.right) - parseInt(region.left)); | |
940 | + case ('height') : return (parseInt(region.bottom) - parseInt(region.top)); | |
941 | + case ('region') : return region; | |
942 | + } | |
943 | + | |
944 | + return region; | |
945 | +} | |
946 | + | |
947 | +// We don't know if numbers are overridden with strings | |
948 | +// so play it safe | |
949 | +Balloon.prototype.parseIntAll = function() { | |
950 | + this.padding = parseInt(this.padding); | |
951 | + this.shadow = parseInt(this.shadow); | |
952 | + this.stemHeight = parseInt(this.stemHeight); | |
953 | + this.stemOverlap = parseInt(this.stemOverlap); | |
954 | + this.vOffset = parseInt(this.vOffset); | |
955 | + this.delayTime = parseInt(this.delayTime); | |
956 | + this.width = parseInt(this.width); | |
957 | + this.maxWidth = parseInt(this.maxWidth); | |
958 | + this.minWidth = parseInt(this.minWidth); | |
959 | + this.fadeIn = parseInt(this.fadeIn) || 1000; | |
960 | +} | |
961 | + | |
962 | + | |
963 | +// show/hide select elements in older IE | |
964 | +// plus user-defined elements | |
965 | +Balloon.prototype.showHide = function(visible) { | |
966 | + var self = currentBalloonClass || new Balloon; | |
967 | + | |
968 | + // IE z-index bug fix (courtesy of Lincoln Stein) | |
969 | + if (self.isOldIE()) { | |
970 | + var balloonContents = document.getElementById('contentWrapper'); | |
971 | + if (!visible && balloonContents) { | |
972 | + var balloonSelects = balloonContents.getElementsByTagName('select'); | |
973 | + var myHash = new Object(); | |
974 | + for (var i=0; i<balloonSelects.length; i++) { | |
975 | + var id = balloonSelects[i].id || balloonSelects[i].name; | |
976 | + myHash[id] = 1; | |
977 | + } | |
978 | + balloonInvisibleSelects = new Array(); | |
979 | + var allSelects = document.getElementsByTagName('select'); | |
980 | + for (var i=0; i<allSelects.length; i++) { | |
981 | + var id = allSelects[i].id || allSelects[i].name; | |
982 | + if (self.isOverlap(allSelects[i],self.activeBalloon) && !myHash[id]) { | |
983 | + balloonInvisibleSelects.push(allSelects[i]); | |
984 | + self.setStyle(allSelects[i],'visibility','hidden'); | |
985 | + } | |
986 | + } | |
987 | + } | |
988 | + else if (balloonInvisibleSelects) { | |
989 | + for (var i=0; i < balloonInvisibleSelects.length; i++) { | |
990 | + var id = balloonInvisibleSelects[i].id || balloonInvisibleSelects[i].name; | |
991 | + self.setStyle(balloonInvisibleSelects[i],'visibility','visible'); | |
992 | + } | |
993 | + balloonInvisibleSelects = null; | |
994 | + } | |
995 | + } | |
996 | + | |
997 | + // show/hide any user-specified elements that overlap the balloon | |
998 | + if (self.hide) { | |
999 | + var display = visible ? 'inline' : 'none'; | |
1000 | + for (var n=0;n<self.hide.length;n++) { | |
1001 | + if (self.isOverlap(self.activeBalloon,self.hide[n])) { | |
1002 | + self.setStyle(self.hide[n],'display',display); | |
1003 | + } | |
1004 | + } | |
1005 | + } | |
1006 | +} | |
1007 | + | |
1008 | +// Try to find overlap | |
1009 | +Balloon.prototype.isOverlap = function(el1,el2) { | |
1010 | + if (!el1 || !el2) return false; | |
1011 | + var R1 = this.getLoc(el1,'region'); | |
1012 | + var R2 = this.getLoc(el2,'region'); | |
1013 | + if (!R1 || !R2) return false; | |
1014 | + var intersect = R1.intersect(R2); | |
1015 | + if (intersect) { | |
1016 | + // extent of overlap; | |
1017 | + intersect = new Array((intersect.right - intersect.left),(intersect.bottom - intersect.top)); | |
1018 | + } | |
1019 | + return intersect; | |
1020 | +} | |
1021 | + | |
1022 | +// Coordinate-based test for the same element | |
1023 | +Balloon.prototype.isSameElement = function(el1,el2) { | |
1024 | + if (!el1 || !el2) return false; | |
1025 | + var R1 = this.getLoc(el1,'region'); | |
1026 | + var R2 = this.getLoc(el2,'region'); | |
1027 | + var same = R1.contains(R2) && R2.contains(R1); | |
1028 | + return same ? true : false; | |
1029 | +} | |
1030 | + | |
1031 | + | |
1032 | +/////////////////////////////////////////////////////// | |
1033 | +// Security -- get the balloon contents while checking | |
1034 | +// for disallowed elements. | |
1035 | +////////////////////////////////////////////////////// | |
1036 | +Balloon.prototype.getAndCheckContents = function(caption) { | |
1037 | + var originalCaption = caption; | |
1038 | + var notAllowed = 'are not allowed in popup balloons in this web site. \ | |
1039 | + Please contact the site administrator for assistance.'; | |
1040 | + var notSupported = 'AJAX is not supported for popup balloons in this web site. \ | |
1041 | + Please contact the site administrator for assistance.'; | |
1042 | + | |
1043 | + // no Help Url without AJAX | |
1044 | + if (this.helpUrl && !this.allowAJAX) { | |
1045 | + alert('Sorry, you have specified help URL '+this.helpUrl+' but '+notSupported); | |
1046 | + return null; | |
1047 | + } | |
1048 | + | |
1049 | + // look for a url in the balloon contents | |
1050 | + if (caption.match(/^url:/)) { | |
1051 | + this.activeUrl = caption.replace(/^url:/,''); | |
1052 | + caption = ''; | |
1053 | + } | |
1054 | + // or if the text is a bare hyperlink | |
1055 | + else if (caption.match(/^(https?:|\/|ftp:)\S+$/i)) { | |
1056 | + this.activeUrl = caption; | |
1057 | + caption = ''; | |
1058 | + } | |
1059 | + | |
1060 | + // Make sure AJAX is allowed | |
1061 | + if (this.activeUrl && !this.allowAJAX) { | |
1062 | + alert('Sorry, you asked for '+originalCaption+' but '+notSupported); | |
1063 | + return null; | |
1064 | + } | |
1065 | + | |
1066 | + // check if the contents are to be retrieved from an element | |
1067 | + if (caption.match(/^load:/)) { | |
1068 | + var load = caption.split(':'); | |
1069 | + if (!document.getElementById(load[1])) alert ('problem locating element '+load[1]); | |
1070 | + caption = document.getElementById(load[1]).innerHTML; | |
1071 | + this.loadedFromElement = true; | |
1072 | + } | |
1073 | + | |
1074 | + // check if iframes are allowed | |
1075 | + if (caption.match(/\<\s*iframe/i) && !this.allowIframes) { | |
1076 | + alert('Sorry: iframe elements '+notAllowed); | |
1077 | + return null; | |
1078 | + } | |
1079 | + | |
1080 | + // check if event handlers are allowed | |
1081 | + if (caption.match(/\bon(load|mouse|click|unload|before)[^=]*=/i) && !this.allowEventHandlers) { | |
1082 | + alert('Sorry: JavaScript event handlers '+notAllowed); | |
1083 | + return null; | |
1084 | + } | |
1085 | + | |
1086 | + // check for script elements | |
1087 | + if (caption.match(/\<\s*script/i) && !this.allowScripts) { | |
1088 | + alert('Sorry: <script> elements '+notAllowed); | |
1089 | + return null; | |
1090 | + } | |
1091 | + | |
1092 | + // request the contents | |
1093 | + this.currentHelpText = this.getContents(caption); | |
1094 | + this.loadedFromElement = false; | |
1095 | + | |
1096 | + return this.currentHelpText;; | |
1097 | +} | |
1098 | + | |
1099 | + | |
1100 | +/////////////////////////////////////////////////////// | |
1101 | +// AJAX widget to fill the balloons | |
1102 | +// requires prototype.js | |
1103 | +/////////////////////////////////////////////////////// | |
1104 | +Balloon.prototype.getContents = function(section) { | |
1105 | + | |
1106 | + // just pass it back if no AJAX handler is required. | |
1107 | + if (!this.helpUrl && !this.activeUrl) return section; | |
1108 | + | |
1109 | + // or if the contents are already loaded from another element | |
1110 | + if (this.loadedFromElement) return section; | |
1111 | + | |
1112 | + // inline URL takes precedence | |
1113 | + var url = this.activeUrl || this.helpUrl; | |
1114 | + url += this.activeUrl ? '' : '?section='+section; | |
1115 | + | |
1116 | + // activeUrl is meant to be single-use only | |
1117 | + this.activeUrl = null; | |
1118 | + | |
1119 | + var ajax; | |
1120 | + if (window.XMLHttpRequest) { | |
1121 | + ajax = new XMLHttpRequest(); | |
1122 | + } else { | |
1123 | + ajax = new ActiveXObject("Microsoft.XMLHTTP"); | |
1124 | + } | |
1125 | + | |
1126 | + if (ajax) { | |
1127 | + ajax.open("GET", url, false); | |
1128 | + ajax.onreadystatechange=function() { | |
1129 | + //alert(ajax.readyState); | |
1130 | + }; | |
1131 | + try { | |
1132 | + ajax.send(null); | |
1133 | + } | |
1134 | + catch (e) { | |
1135 | + // alert(e); | |
1136 | + } | |
1137 | + var txt = this.escapeHTML ? escape(ajax.responseText) : ajax.responseText; | |
1138 | + return txt || section; | |
1139 | + } | |
1140 | + else { | |
1141 | + return section; | |
1142 | + } | |
1143 | +} | |
1144 | + | |
1145 | + | |
1146 | +// test for internet explorer | |
1147 | +Balloon.prototype.isIE = function() { | |
1148 | + return document.all && !window.opera; | |
1149 | +} | |
1150 | + | |
1151 | +// test for internet explorer (but not IE7) | |
1152 | +Balloon.prototype.isOldIE = function() { | |
1153 | + if (navigator.appVersion.indexOf("MSIE") == -1) return false; | |
1154 | + var temp=navigator.appVersion.split("MSIE"); | |
1155 | + return parseFloat(temp[1]) < 7; | |
1156 | +} | |
1157 | + | |
1158 | +// test for Konqueror | |
1159 | +Balloon.prototype.isKonqueror = function() { | |
1160 | + return navigator.userAgent.toLowerCase().indexOf( 'konqueror' ) != -1; | |
1161 | +} | |
1162 | + | |
1163 | +// and Google chrome | |
1164 | +Balloon.prototype.isChrome = function() { | |
1165 | + return navigator.userAgent.toLowerCase().indexOf('chrome') > -1; | |
1166 | +} | |
0 | 1167 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,1177 @@ |
1 | +/* | |
2 | + * balloon.js -- a DHTML library for balloon tooltips | |
3 | + * | |
4 | + * $Id: balloon.js 22300 2009-12-01 09:40:39Z sheldon_mckay $ | |
5 | + * | |
6 | + * See http://www.gmod.org/wiki/index.php/Popup_Balloons | |
7 | + * for documentation. | |
8 | + * | |
9 | + * Copyright (c) 2007-2009 Sheldon McKay, Cold Spring Harbor Laboratory | |
10 | + * | |
11 | + * This balloon tooltip package and associated files not otherwise copyrighted are | |
12 | + * distributed under the MIT-style license: | |
13 | + * | |
14 | + * http://opensource.org/licenses/mit-license.php | |
15 | + * | |
16 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
17 | + * of this software and associated documentation files (the "Software"), to deal | |
18 | + * in the Software without restriction, including without limitation the rights | |
19 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
20 | + * copies of the Software, and to permit persons to whom the Software is | |
21 | + * furnished to do so, subject to the following conditions: | |
22 | + * | |
23 | + * The above copyright notice and this permission notice shall be included in | |
24 | + * all copies or substantial portions of the Software. | |
25 | + * | |
26 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
27 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
28 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
29 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
30 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
31 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
32 | + * THE SOFTWARE. | |
33 | + * | |
34 | + */ | |
35 | + | |
36 | +// These global variables are necessary to avoid losing scope when | |
37 | +// setting the balloon timeout and for inter-object communication | |
38 | +var currentBalloonClass; | |
39 | +var balloonIsVisible; | |
40 | +var balloonIsSticky; | |
41 | +var balloonInvisibleSelects; | |
42 | +var balloonIsSuppressed; | |
43 | +var tooltipIsSuppressed; | |
44 | + | |
45 | + | |
46 | +////////////////////////////////////////////////////////////////////////// | |
47 | +// This is constructor that is called to initialize the Balloon object // | |
48 | +////////////////////////////////////////////////////////////////////////// | |
49 | +var Balloon = function () { | |
50 | + // Cursor tracking enabled by default | |
51 | + this.trackCursor = true; | |
52 | + | |
53 | + // Track the cursor every time the mouse moves | |
54 | + document.onmousemove = this.setActiveCoordinates; | |
55 | + | |
56 | + // scrolling aborts visible balloons | |
57 | + var myObject = this.isIE() ? window : document; | |
58 | + myObject.onscroll = function(){Balloon.prototype.nukeTooltip()}; | |
59 | + | |
60 | + // make balloons go away if the page is unloading or waiting | |
61 | + // to unload. | |
62 | + window.onbeforeunload = function(){ | |
63 | + Balloon.prototype.nukeTooltip(); | |
64 | + balloonIsSuppressed = true; | |
65 | + }; | |
66 | + | |
67 | + // for IE, the balloons can't start until the page is finished loading | |
68 | + // set a flag that will get toggled when loading is finished | |
69 | + if (this.isIE()) { | |
70 | + this.suppress = true; | |
71 | + } | |
72 | + | |
73 | + return this; | |
74 | +} | |
75 | + | |
76 | +////////////////////////////////////////////////////////////////////////// | |
77 | +// This is the method that is called on mouseover. It has a built-in // | |
78 | +// delay time to avoid balloons popping up on rapid mouseover events // | |
79 | +////////////////////////////////////////////////////////////////////////// | |
80 | +Balloon.prototype.showTooltip = function(evt,caption,sticky,width,height) { | |
81 | + // If the objext is not configured by now, fall back to default | |
82 | + if (!this.configured) { | |
83 | + BalloonConfig(this,'GBubble'); | |
84 | + } | |
85 | + | |
86 | + // Cursor tracking halts after one of these vertical | |
87 | + // or horizontal thresholds are reached | |
88 | + this.stopTrackingX = this.trackCursor ? 100 : 10; | |
89 | + this.stopTrackingY = this.trackCursor ? 50 : 10; | |
90 | + | |
91 | + // Awful IE bug, page load aborts if the balloon is fired | |
92 | + // before the page is fully loaded. | |
93 | + if (this.isIE() && document.readyState.match(/complete/i)) { | |
94 | + this.suppress = false; | |
95 | + } | |
96 | + | |
97 | + // All balloons have been suppressed, go no further | |
98 | + if (this.suppress || balloonIsSuppressed) { | |
99 | + return false; | |
100 | + } | |
101 | + | |
102 | + // Non-sticky balloons suppressed | |
103 | + if (tooltipIsSuppressed && !sticky) { | |
104 | + return false; | |
105 | + } | |
106 | + | |
107 | + // We use 1-100 scale for opacity internally | |
108 | + if (this.opacity && this.opacity < 1) { | |
109 | + this.opacity = parseInt(parseFloat(this.opacity) * 100); | |
110 | + } | |
111 | + else if (this.opacity && this.opacity == 1) { | |
112 | + this.opacity = 100; | |
113 | + } | |
114 | + else if (!this.opacity) { | |
115 | + this.opacity == 100; | |
116 | + } | |
117 | + | |
118 | + // Sorry Konqueror, no fade-in or translucency for you! | |
119 | + if (this.isKonqueror()) { | |
120 | + this.allowFade = false; | |
121 | + this.opacity = 100; | |
122 | + } | |
123 | + | |
124 | + // With IE, fading and translucency are not very compatible | |
125 | + // use opaque balloons if fadein is enabled | |
126 | + if (this.isIE() && this.allowFade) { | |
127 | + this.opacity = 100; | |
128 | + } | |
129 | + | |
130 | + // Check for mouseover (vs. mousedown or click) | |
131 | + var mouseOver = true; | |
132 | + try{ | |
133 | + var mouseOver = evt.type.match('mouseover','i'); | |
134 | + }catch(e){} | |
135 | + | |
136 | + // if the firing event is a click, fade-in and a non-sticky balloon make no sense | |
137 | + if (!mouseOver) { | |
138 | + sticky = true; | |
139 | + this.fadeOK = false; | |
140 | + // case where hover and click events both trigger balloons | |
141 | + if (balloonIsVisible) { | |
142 | + this.hideTooltip(); | |
143 | + } | |
144 | + } | |
145 | + else { | |
146 | + this.fadeOK = this.allowFade; | |
147 | + } | |
148 | + | |
149 | + // Don't fire on mouseover if a non-sticky balloon is visible | |
150 | + if (balloonIsVisible && !balloonIsSticky && mouseOver) { | |
151 | + return false; | |
152 | + } | |
153 | + | |
154 | + // Don't start a non-sticky balloon if a sticky one is visible | |
155 | + if (balloonIsVisible && balloonIsSticky && !sticky) { | |
156 | + return false; | |
157 | + } | |
158 | + | |
159 | + // Ignore repeated firing of mouseover->mouseout events on | |
160 | + // the same element (Safari) | |
161 | + | |
162 | + try{ | |
163 | + var el = this.getEventTarget(evt); | |
164 | + }catch(e){var el = evt;} | |
165 | + | |
166 | + if (sticky && mouseOver && this.isSameElement(el,this.currentElement)) { | |
167 | + return false; | |
168 | + } | |
169 | + this.currentElement = el; | |
170 | + | |
171 | + // remember the coordinates of the element | |
172 | + this.elCoords = this.getLoc(el,'region'); | |
173 | + | |
174 | + // attach a mouseout event handler to the target element | |
175 | + if (!sticky) { | |
176 | + var mouseoutFunc = el.onmouseout; | |
177 | + var closeBalloon = function() { | |
178 | + Balloon.prototype.hideTooltip(); | |
179 | + // fall through to any onmouseout event specified elsewhere | |
180 | + if (mouseoutFunc) { | |
181 | + mouseoutFunc(); | |
182 | + } | |
183 | + } | |
184 | + if (!mouseOver) { | |
185 | + el.onmouseup = function() {return false}; | |
186 | + } | |
187 | + //el.onmouseout = closeBalloon; | |
188 | + } | |
189 | + | |
190 | + balloonIsSticky = sticky; | |
191 | + | |
192 | + this.hideTooltip(); | |
193 | + | |
194 | + // request the contents synchronously (ie wait for result) | |
195 | + this.currentHelpText = this.getAndCheckContents(caption); | |
196 | + | |
197 | + // no contents? abort. | |
198 | + if (!this.currentHelpText) { | |
199 | + return false; | |
200 | + } | |
201 | + | |
202 | + this.width = width; | |
203 | + this.height = height; | |
204 | + this.actualWidth = null; | |
205 | + | |
206 | + // make sure old balloons are removed | |
207 | + this.hideTooltip(); | |
208 | + | |
209 | + // Put the balloon contents and images into a visible (but offscreen) | |
210 | + // element so they will be preloaded and have a layout to | |
211 | + // calculate the balloon dimensions | |
212 | + this.container = document.createElement('div'); | |
213 | + this.container.id = 'balloonPreloadContainer'; | |
214 | + document.body.appendChild(this.container); | |
215 | + this.setStyle(this.container,'position','absolute'); | |
216 | + this.setStyle(this.container,'top',-8888); | |
217 | + this.setStyle(this.container,'font-family',this.fontFamily); | |
218 | + this.setStyle(this.container,'font-size',this.fontSize); | |
219 | + | |
220 | + // protect escaped '&' | |
221 | + this.currentHelpText = this.currentHelpText.replace(/\&/g, '&amp'); | |
222 | + this.container.innerHTML = unescape(this.currentHelpText); | |
223 | + | |
224 | + // make sure balloon image path is complete | |
225 | + if (this.images) { | |
226 | + | |
227 | + // main background image | |
228 | + this.balloonImage = this.balloonImage ? this.images +'/'+ this.balloonImage : false; | |
229 | + this.ieImage = this.ieImage ? this.images +'/'+ this.ieImage : false; | |
230 | + | |
231 | + // optional stems | |
232 | + this.upLeftStem = this.upLeftStem ? this.images +'/'+ this.upLeftStem : false; | |
233 | + this.upRightStem = this.upRightStem ? this.images +'/'+ this.upRightStem : false; | |
234 | + this.downLeftStem = this.downLeftStem ? this.images +'/'+ this.downLeftStem : false; | |
235 | + this.downRightStem = this.downRightStem ? this.images +'/'+ this.downRightStem : false; | |
236 | + | |
237 | + this.closeButton = this.closeButton ? this.images +'/'+ this.closeButton : false; | |
238 | + | |
239 | + this.images = false; | |
240 | + } | |
241 | + | |
242 | + // The PNG alpha channels (shadow transparency) are not | |
243 | + // handled properly by IE < 6. Also, if opacity is set to | |
244 | + // < 1 (translucent balloons), any version of IE does not | |
245 | + // handle the image properly. | |
246 | + // Google chrome is a bit dodgey too | |
247 | + // If there is an IE image provided, use that instead. | |
248 | + if (this.ieImage && (this.isIE() || this.isChrome())) { | |
249 | + if (this.isOldIE() || this.opacity || this.allowFade) { | |
250 | + this.balloonImage = this.ieImage; | |
251 | + } | |
252 | + } | |
253 | + | |
254 | + // preload balloon images | |
255 | + if (!this.preloadedImages) { | |
256 | + var images = new Array(this.balloonImage, this.closeButton); | |
257 | + if (this.ieImage) { | |
258 | + images.push(this.ieImage); | |
259 | + } | |
260 | + if (this.stem) { | |
261 | + images.push(this.upLeftStem,this.upRightStem,this.downLeftStem,this.downRightStem); | |
262 | + } | |
263 | + var len = images.length; | |
264 | + for (var i=0;i<len;i++) { | |
265 | + if ( images[i] ) { | |
266 | + this.preload(images[i]); | |
267 | + } | |
268 | + } | |
269 | + this.preloadedImages = true; | |
270 | + } | |
271 | + | |
272 | + currentBalloonClass = this; | |
273 | + | |
274 | + // Capture coordinates for mousedown or click | |
275 | + //if (!mouseOver) {this.setActiveCoordinates(evt);} | |
276 | + if (!mouseOver) el.onmouseup = function() {return false;}; | |
277 | + // Remember which event started this | |
278 | + this.currentEvent = evt; | |
279 | + | |
280 | + // prevent interaction with gbrowse drag and drop | |
281 | + evt.cancelBubble = true; | |
282 | + | |
283 | + // Make delay time short for onmousedown | |
284 | + //var delay = mouseOver ? this.delayTime : 1; | |
285 | + //this.timeoutTooltip = window.setTimeout(this.doShowTooltip,delay); | |
286 | + this.doShowTooltip(); | |
287 | + this.pending = true; | |
288 | +} | |
289 | + | |
290 | +// Preload the balloon background images | |
291 | +Balloon.prototype.preload = function(src) { | |
292 | + var i = new Image; | |
293 | + i.src = src; | |
294 | + | |
295 | + // append to the DOM tree so the images have a layout, | |
296 | + // then remove. | |
297 | + this.setStyle(i,'position','absolute'); | |
298 | + this.setStyle(i,'top',-8000); | |
299 | + document.body.appendChild(i); | |
300 | + document.body.removeChild(i); | |
301 | +} | |
302 | + | |
303 | + | |
304 | +///////////////////////////////////////////////////////////////////// | |
305 | +// Tooltip rendering function | |
306 | +///////////////////////////////////////////////////////////////////// | |
307 | +Balloon.prototype.doShowTooltip = function() { | |
308 | + var self = currentBalloonClass; | |
309 | + | |
310 | + // Stop firing if a balloon is already being displayed | |
311 | + if (balloonIsVisible) { | |
312 | + return false; | |
313 | + } | |
314 | + if (!self.parent) { | |
315 | + if (self.parentID) { | |
316 | + self.parent = document.getElementById(self.parentID); | |
317 | + } | |
318 | + else { | |
319 | + self.parent = document.body; | |
320 | + } | |
321 | + self.xOffset = self.getLoc(self.parent, 'x1'); | |
322 | + self.yOffset = self.getLoc(self.parent, 'y1'); | |
323 | + } | |
324 | + | |
325 | + // a short delay time might cause some intereference | |
326 | + // with fading | |
327 | + window.clearTimeout(self.timeoutFade); | |
328 | + if (!balloonIsSticky) { | |
329 | + self.setStyle('visibleBalloonElement','display','none'); | |
330 | + } | |
331 | + | |
332 | + // make sure user-configured numbers are not strings | |
333 | + self.parseIntAll(); | |
334 | + | |
335 | + // create the balloon object | |
336 | + var balloon = self.makeBalloon(); | |
337 | + | |
338 | + // window dimensions | |
339 | + var pageWidth = YAHOO.util.Dom.getViewportWidth(); | |
340 | + var pageCen = Math.round(pageWidth/2); | |
341 | + var pageHeight = YAHOO.util.Dom.getViewportHeight(); | |
342 | + var pageLeft = YAHOO.util.Dom.getDocumentScrollLeft(); | |
343 | + var pageTop = YAHOO.util.Dom.getDocumentScrollTop(); | |
344 | + var pageMid = pageTop + Math.round(pageHeight/2); | |
345 | + self.pageBottom = pageTop + pageHeight; | |
346 | + self.pageTop = pageTop; | |
347 | + self.pageLeft = pageLeft; | |
348 | + self.pageRight = pageLeft + pageWidth; | |
349 | + | |
350 | + // balloon orientation | |
351 | + var vOrient = self.activeTop > pageMid ? 'up' : 'down'; | |
352 | + var hOrient = self.activeRight > pageCen ? 'left' : 'right'; | |
353 | + | |
354 | + // get the preloaded balloon contents | |
355 | + var helpText = self.container.innerHTML; | |
356 | + self.actualWidth = self.getLoc(self.container,'width'); | |
357 | + if (!isNaN(self.actualWidth)) { | |
358 | + self.actualWidth += 10; | |
359 | + } | |
360 | + self.parent.removeChild(self.container); | |
361 | + var wrapper = document.createElement('div'); | |
362 | + wrapper.id = 'contentWrapper'; | |
363 | + self.contents.appendChild(wrapper); | |
364 | + wrapper.innerHTML = helpText; | |
365 | + | |
366 | + // how and where to draw the balloon | |
367 | + self.setBalloonStyle(vOrient,hOrient,pageWidth,pageLeft); | |
368 | + | |
369 | + // close control for balloon or box | |
370 | + if (balloonIsSticky) { | |
371 | + self.addCloseButton(); | |
372 | + } | |
373 | + | |
374 | + balloonIsVisible = true; | |
375 | + self.pending = false; | |
376 | + | |
377 | + // in IE < 7, hide <select> elements | |
378 | + self.showHide(); | |
379 | + | |
380 | + self.startX = self.activeLeft; | |
381 | + self.startY = self.activeTop; | |
382 | + self.fade(0,self.opacity,self.fadeIn); | |
383 | +} | |
384 | + | |
385 | +Balloon.prototype.addCloseButton = function () { | |
386 | + var self = currentBalloonClass; | |
387 | + var margin = Math.round(self.padding/2); | |
388 | + var closeWidth = self.closeButtonWidth || 16; | |
389 | + var balloonTop = self.getLoc('visibleBalloonElement','y1') + margin + self.shadow; | |
390 | + var BalloonLeft = self.getLoc('topRight','x2') - self.closeButtonWidth - self.shadow - margin; | |
391 | + var closeButton = document.getElementById('closeButton'); | |
392 | + | |
393 | + if (!closeButton) { | |
394 | + closeButton = new Image; | |
395 | + closeButton.setAttribute('id','closeButton'); | |
396 | + closeButton.setAttribute('src',self.closeButton); | |
397 | + closeButton.onclick = function() { | |
398 | + Balloon.prototype.nukeTooltip(); | |
399 | + }; | |
400 | + self.setStyle(closeButton,'position','absolute'); | |
401 | + document.body.appendChild(closeButton); | |
402 | + } | |
403 | + | |
404 | + // I have no idea why | |
405 | + if (self.isIE()) { | |
406 | + BalloonLeft = BalloonLeft - 5; | |
407 | + } | |
408 | + | |
409 | + self.setStyle(closeButton,'top',balloonTop); | |
410 | + self.setStyle(closeButton,'left',BalloonLeft); | |
411 | + self.setStyle(closeButton,'display','inline'); | |
412 | + self.setStyle(closeButton,'cursor','pointer'); | |
413 | + self.setStyle(closeButton,'z-index',999999999); | |
414 | +} | |
415 | + | |
416 | +// use a fresh object every time to make sure style | |
417 | +// is not polluted | |
418 | +Balloon.prototype.makeBalloon = function() { | |
419 | + var self = currentBalloonClass; | |
420 | + | |
421 | + var balloon = document.getElementById('visibleBalloonElement'); | |
422 | + if (balloon) { | |
423 | + self.hideTooltip(); | |
424 | + } | |
425 | + | |
426 | + balloon = document.createElement('div'); | |
427 | + balloon.setAttribute('id','visibleBalloonElement'); | |
428 | + self.parent.appendChild(balloon); | |
429 | + self.activeBalloon = balloon; | |
430 | + | |
431 | + self.parts = new Array(); | |
432 | + var parts = new Array('contents','topRight','bottomRight','bottomLeft'); | |
433 | + for (var i=0;i<parts.length;i++) { | |
434 | + var child = document.createElement('div'); | |
435 | + child.setAttribute('id',parts[i]); | |
436 | + balloon.appendChild(child); | |
437 | + if (parts[i] == 'contents') self.contents = child; | |
438 | + self.parts.push(child); | |
439 | + } | |
440 | + //self.parts.push(balloon); | |
441 | + | |
442 | + if (self.displayTime) { | |
443 | + self.timeoutAutoClose = window.setTimeout(this.hideTooltip,self.displayTime); | |
444 | + } | |
445 | + return balloon; | |
446 | +} | |
447 | + | |
448 | +Balloon.prototype.setBalloonStyle = function(vOrient,hOrient,pageWidth,pageLeft) { | |
449 | + var self = currentBalloonClass; | |
450 | + var balloon = self.activeBalloon; | |
451 | + | |
452 | + if (typeof(self.shadow) != 'number') self.shadow = 0; | |
453 | + if (!self.stem) self.stemHeight = 0; | |
454 | + | |
455 | + var fullPadding = self.padding + self.shadow; | |
456 | + var insidePadding = self.padding; | |
457 | + var outerWidth = self.actualWidth + fullPadding; | |
458 | + var innerWidth = self.actualWidth; | |
459 | + | |
460 | + self.setStyle(balloon,'position','absolute'); | |
461 | + self.setStyle(balloon,'top',-9999); | |
462 | + self.setStyle(balloon,'z-index',1000000); | |
463 | + | |
464 | + if (self.height) { | |
465 | + self.setStyle('contentWrapper','height',self.height-fullPadding); | |
466 | + } | |
467 | + | |
468 | + if (self.width) { | |
469 | + self.setStyle(balloon,'width',self.width); | |
470 | + innerWidth = self.width - fullPadding; | |
471 | + if (balloonIsSticky) { | |
472 | + innerWidth -= self.closeButtonWidth; | |
473 | + } | |
474 | + self.setStyle('contentWrapper','width',innerWidth); | |
475 | + } | |
476 | + else { | |
477 | + self.setStyle(balloon,'width',outerWidth); | |
478 | + self.setStyle('contentWrapper','width',innerWidth); | |
479 | + } | |
480 | + | |
481 | + // not too big... | |
482 | + if (!self.width && self.maxWidth && outerWidth > self.maxWidth) { | |
483 | + self.setStyle(balloon,'width',self.maxWidth); | |
484 | + self.setStyle('contentWrapper','width',self.maxWidth-fullPadding); | |
485 | + } | |
486 | + // not too small... | |
487 | + if (!self.width && self.minWidth && outerWidth < self.minWidth) { | |
488 | + self.setStyle(balloon,'width',self.minWidth); | |
489 | + self.setStyle('contentWrapper','width',self.minWidth-fullPadding); | |
490 | + } | |
491 | + | |
492 | + self.setStyle('contents','z-index',2); | |
493 | + self.setStyle('contents','color',self.fontColor); | |
494 | + self.setStyle('contents','font-family',self.fontFamily); | |
495 | + self.setStyle('contents','font-size',self.fontSize); | |
496 | + self.setStyle('contents','background','url('+self.balloonImage+') top left no-repeat'); | |
497 | + self.setStyle('contents','padding-top',fullPadding); | |
498 | + self.setStyle('contents','padding-left',fullPadding); | |
499 | + | |
500 | + self.setStyle('bottomRight','background','url('+self.balloonImage+') bottom right no-repeat'); | |
501 | + self.setStyle('bottomRight','position','absolute'); | |
502 | + self.setStyle('bottomRight','right',0-fullPadding); | |
503 | + self.setStyle('bottomRight','bottom',0-fullPadding); | |
504 | + self.setStyle('bottomRight','height',fullPadding); | |
505 | + self.setStyle('bottomRight','width',fullPadding); | |
506 | + self.setStyle('bottomRight','z-index',-1); | |
507 | + | |
508 | + self.setStyle('topRight','background','url('+self.balloonImage+') top right no-repeat'); | |
509 | + self.setStyle('topRight','position','absolute'); | |
510 | + self.setStyle('topRight','right',0-fullPadding); | |
511 | + self.setStyle('topRight','top',0); | |
512 | + self.setStyle('topRight','width',fullPadding); | |
513 | + | |
514 | + self.setStyle('bottomLeft','background','url('+self.balloonImage+') bottom left no-repeat'); | |
515 | + self.setStyle('bottomLeft','position','absolute'); | |
516 | + self.setStyle('bottomLeft','left',0); | |
517 | + self.setStyle('bottomLeft','bottom',0-fullPadding); | |
518 | + self.setStyle('bottomLeft','height',fullPadding); | |
519 | + self.setStyle('bottomLeft','z-index',-1); | |
520 | + | |
521 | + if (this.stem) { | |
522 | + var stem = document.createElement('img'); | |
523 | + self.setStyle(stem,'position','absolute'); | |
524 | + balloon.appendChild(stem); | |
525 | + | |
526 | + if (vOrient == 'up' && hOrient == 'left') { | |
527 | + stem.src = self.upLeftStem; | |
528 | + var height = self.stemHeight + insidePadding - self.stemOverlap; | |
529 | + self.setStyle(stem,'bottom',0-height); | |
530 | + self.setStyle(stem,'right',0); | |
531 | + } | |
532 | + else if (vOrient == 'down' && hOrient == 'left') { | |
533 | + stem.src = self.downLeftStem; | |
534 | + var height = self.stemHeight - (self.shadow + self.stemOverlap); | |
535 | + self.setStyle(stem,'top',0-height); | |
536 | + self.setStyle(stem,'right',0); | |
537 | + } | |
538 | + else if (vOrient == 'up' && hOrient == 'right') { | |
539 | + stem.src = self.upRightStem; | |
540 | + var height = self.stemHeight + insidePadding - self.stemOverlap; | |
541 | + self.setStyle(stem,'bottom',0-height); | |
542 | + self.setStyle(stem,'left',self.shadow); | |
543 | + } | |
544 | + else if (vOrient == 'down' && hOrient == 'right') { | |
545 | + stem.src = self.downRightStem; | |
546 | + var height = self.stemHeight - (self.shadow + self.stemOverlap); | |
547 | + self.setStyle(stem,'top',0-height); | |
548 | + self.setStyle(stem,'left',self.shadow); | |
549 | + } | |
550 | + if (self.fadeOK && self.isIE()) { | |
551 | + self.parts.push(stem); | |
552 | + } | |
553 | + } | |
554 | + | |
555 | + if (self.allowFade) { | |
556 | + self.setOpacity(1); | |
557 | + } | |
558 | + else if (self.opacity) { | |
559 | + self.setOpacity(self.opacity); | |
560 | + } | |
561 | + | |
562 | + // flip left or right, as required | |
563 | + if (hOrient == 'left') { | |
564 | + var pageWidth = self.pageRight - self.pageLeft; | |
565 | + var activeRight = pageWidth - self.activeLeft; | |
566 | + self.setStyle(balloon,'right',activeRight); | |
567 | + } | |
568 | + else { | |
569 | + var activeLeft = self.activeRight - self.xOffset; | |
570 | + self.setStyle(balloon,'left',activeLeft); | |
571 | + } | |
572 | + | |
573 | + // oversized contents? Scrollbars for sticky balloons, clipped for non-sticky | |
574 | + var overflow = balloonIsSticky ? 'auto' : 'hidden'; | |
575 | + self.setStyle('contentWrapper','overflow',overflow); | |
576 | + | |
577 | + // a bit of room for the closebutton | |
578 | + if (balloonIsSticky) { | |
579 | + self.setStyle('contentWrapper','margin-right',self.closeButtonWidth); | |
580 | + } | |
581 | + | |
582 | + // Make sure the balloon is not offscreen horizontally. | |
583 | + // We handle vertical sanity checking later, after the final | |
584 | + // layout is set. | |
585 | + var balloonLeft = self.getLoc(balloon,'x1'); | |
586 | + var balloonRight = self.getLoc(balloon,'x2'); | |
587 | + var scrollBar = 20; | |
588 | + | |
589 | + if (hOrient == 'right' && balloonRight > (self.pageRight - fullPadding)) { | |
590 | + var width = (self.pageRight - balloonLeft) - fullPadding - scrollBar; | |
591 | + self.setStyle(balloon,'width',width); | |
592 | + self.setStyle('contentWrapper','width',width-fullPadding); | |
593 | + } | |
594 | + else if (hOrient == 'left' && balloonLeft < (self.pageLeft + fullPadding)) { | |
595 | + var width = (balloonRight - self.pageLeft) - fullPadding; | |
596 | + self.setStyle(balloon,'width',width); | |
597 | + self.setStyle('contentWrapper','width',width-fullPadding); | |
598 | + } | |
599 | + | |
600 | + // Get the width/height for the right and bottom outlines | |
601 | + var balloonWidth = self.getLoc(balloon,'width'); | |
602 | + var balloonHeight = self.getLoc(balloon,'height'); | |
603 | + | |
604 | + // IE7 quirk -- look for unwanted overlap cause by an off by 1px error | |
605 | + var vOverlap = self.isOverlap('topRight','bottomRight'); | |
606 | + var hOverlap = self.isOverlap('bottomLeft','bottomRight'); | |
607 | + if (vOverlap) { | |
608 | + self.setStyle('topRight','height',balloonHeight-vOverlap[1]); | |
609 | + } | |
610 | + if (hOverlap) { | |
611 | + self.setStyle('bottomLeft','width',balloonWidth-hOverlap[0]); | |
612 | + } | |
613 | + | |
614 | + // vertical position of the balloon | |
615 | + if (vOrient == 'up') { | |
616 | + var activeTop = self.activeTop - balloonHeight; | |
617 | + self.setStyle(balloon,'top',activeTop); | |
618 | + } | |
619 | + else { | |
620 | + var activeTop = self.activeBottom; | |
621 | + self.setStyle(balloon,'top',activeTop); | |
622 | + } | |
623 | + | |
624 | + // Make sure the balloon is vertically contained in the window | |
625 | + var balloonTop = self.getLoc(balloon,'y1'); | |
626 | + var balloonBottom = self.height ? balloonTop + self.height : self.getLoc(balloon,'y2'); | |
627 | + var deltaTop = balloonTop < self.pageTop ? self.pageTop - balloonTop : 0; | |
628 | + var deltaBottom = balloonBottom > self.pageBottom ? balloonBottom - self.pageBottom : 0; | |
629 | + | |
630 | + if (vOrient == 'up' && deltaTop) { | |
631 | + var newHeight = balloonHeight - deltaTop; | |
632 | + if (newHeight > (self.padding*2)) { | |
633 | + self.setStyle('contentWrapper','height',newHeight-fullPadding); | |
634 | + self.setStyle(balloon,'top',self.pageTop+self.padding); | |
635 | + self.setStyle(balloon,'height',newHeight); | |
636 | + } | |
637 | + } | |
638 | + if (vOrient == 'down' && deltaBottom) { | |
639 | + var newHeight = balloonHeight - deltaBottom - scrollBar; | |
640 | + if (newHeight > (self.padding*2) + scrollBar) { | |
641 | + self.setStyle('contentWrapper','height',newHeight-fullPadding); | |
642 | + self.setStyle(balloon,'height',newHeight); | |
643 | + } | |
644 | + } | |
645 | + | |
646 | + // If we have an iframe, make sure it fits properly | |
647 | + var iframe = balloon.getElementsByTagName('iframe'); | |
648 | + if (iframe[0]) { | |
649 | + iframe = iframe[0]; | |
650 | + var w = self.getLoc('contentWrapper','width'); | |
651 | + if (balloonIsSticky && !this.isIE()) { | |
652 | + w -= self.closeButtonWidth; | |
653 | + } | |
654 | + var h = self.getLoc('contentWrapper','height'); | |
655 | + self.setStyle(iframe,'width',w); | |
656 | + self.setStyle(iframe,'height',h); | |
657 | + self.setStyle('contentWrapper','overflow','hidden'); | |
658 | + } | |
659 | + | |
660 | + // Make edges match the main balloon body | |
661 | + self.setStyle('topRight','height', self.getLoc(balloon,'height')); | |
662 | + self.setStyle('bottomLeft','width', self.getLoc(balloon,'width')); | |
663 | + | |
664 | + self.hOrient = hOrient; | |
665 | + self.vOrient = vOrient; | |
666 | +} | |
667 | + | |
668 | + | |
669 | +// Fade method adapted from an example on | |
670 | +// http://brainerror.net/scripts/javascript/blendtrans/ | |
671 | +Balloon.prototype.fade = function(opacStart, opacEnd, millisec) { | |
672 | + var self = currentBalloonClass || new Balloon; | |
673 | + if (!millisec || !self.allowFade) { | |
674 | + return false; | |
675 | + } | |
676 | + | |
677 | + opacEnd = opacEnd || 100; | |
678 | + | |
679 | + //speed for each frame | |
680 | + var speed = Math.round(millisec / 100); | |
681 | + var timer = 0; | |
682 | + for(o = opacStart; o <= opacEnd; o++) { | |
683 | + self.timeoutFade = setTimeout('Balloon.prototype.setOpacity('+o+')',(timer*speed)); | |
684 | + timer++; | |
685 | + } | |
686 | +} | |
687 | + | |
688 | +Balloon.prototype.setOpacity = function(opc) { | |
689 | + var self = currentBalloonClass; | |
690 | + if (!self || !opc) return false; | |
691 | + | |
692 | + var o = parseFloat(opc/100); | |
693 | + | |
694 | + // opacity handled differently for IE | |
695 | + var parts = self.isIE() ? self.parts : [self.activeBalloon]; | |
696 | + | |
697 | + var len = parts.length; | |
698 | + for (var i=0;i<len;i++) { | |
699 | + self.doOpacity(o,opc,parts[i]); | |
700 | + } | |
701 | +} | |
702 | + | |
703 | +Balloon.prototype.doOpacity = function(op,opc,el) { | |
704 | + var self = currentBalloonClass; | |
705 | + if (!el) return false; | |
706 | + | |
707 | + // CSS standards-compliant browsers! | |
708 | + self.setStyle(el,'opacity',op); | |
709 | + | |
710 | + // old IE | |
711 | + self.setStyle(el,'filter','alpha(opacity='+opc+')'); | |
712 | + | |
713 | + // old Mozilla/NN | |
714 | + self.setStyle(el,'MozOpacity',op); | |
715 | + | |
716 | + // old Safari | |
717 | + self.setStyle(el,'KhtmlOpacity',op); | |
718 | +} | |
719 | + | |
720 | +Balloon.prototype.nukeTooltip = function() { | |
721 | + this.hideTooltip(1); | |
722 | +} | |
723 | + | |
724 | +Balloon.prototype.hideTooltip = function(override) { | |
725 | + // some browsers pass the event object == we don't want it | |
726 | + if (override && typeof override == 'object') override = false; | |
727 | + if (balloonIsSticky && !override) return false; | |
728 | + var self = currentBalloonClass; | |
729 | + Balloon.prototype.showHide(1); | |
730 | + Balloon.prototype.cleanup(); | |
731 | + | |
732 | + if (self) { | |
733 | + window.clearTimeout(self.timeoutTooltip); | |
734 | + window.clearTimeout(self.timeoutFade); | |
735 | + window.clearTimeout(self.timeoutAutoClose); | |
736 | + if (balloonIsSticky) { | |
737 | + self.currentElement = null; | |
738 | + } | |
739 | + self.startX = 0; | |
740 | + self.startY = 0; | |
741 | + } | |
742 | + | |
743 | + balloonIsVisible = false; | |
744 | + balloonIsSticky = false; | |
745 | +} | |
746 | + | |
747 | +// Garbage collection | |
748 | +Balloon.prototype.cleanup = function() { | |
749 | + var self = currentBalloonClass; | |
750 | + var body; | |
751 | + if (self) { | |
752 | + body = self.parent ? self.parent | |
753 | + : self.parentID ? document.getElementById(self.parentID) || document.body | |
754 | + : document.body; | |
755 | + } | |
756 | + else { | |
757 | + body = document.body; | |
758 | + } | |
759 | + | |
760 | + var bubble = document.getElementById('visibleBalloonElement'); | |
761 | + var close = document.getElementById('closeButton'); | |
762 | + var cont = document.getElementById('balloonPreloadContainer'); | |
763 | + if (bubble) { body.removeChild(bubble) } | |
764 | + if (close) { body.removeChild(close) } | |
765 | + if (cont) { body.removeChild(cont) } | |
766 | +} | |
767 | + | |
768 | + | |
769 | +// this function is meant to be called externally to clear | |
770 | +// any open balloons | |
771 | +hideAllTooltips = function() { | |
772 | + var self = currentBalloonClass; | |
773 | + if (!self) return; | |
774 | + window.clearTimeout(self.timeoutTooltip); | |
775 | + if (self.activeBalloon) self.setStyle(self.activeBalloon,'display','none'); | |
776 | + balloonIsVisible = false; | |
777 | + balloonIsSticky = false; | |
778 | + currentBalloonClass = null; | |
779 | +} | |
780 | + | |
781 | + | |
782 | +// Track the active mouseover coordinates | |
783 | +Balloon.prototype.setActiveCoordinates = function(evt) { | |
784 | + var self = currentBalloonClass; | |
785 | + if (!self) { | |
786 | + return true; | |
787 | + } | |
788 | + var evt = evt || window.event || self.currentEvent; | |
789 | + if (!evt) { | |
790 | + return true; | |
791 | + } | |
792 | + // | |
793 | + //modificado por edmar | |
794 | + // | |
795 | + alert(evt.id) | |
796 | + try{ | |
797 | + if(typeof(evt.id) == "string") | |
798 | + { | |
799 | + var pos = i3GEO.util.pegaPosicaoObjeto(event); | |
800 | + self.activeTop = pos[1] - 10; | |
801 | + self.activeLeft = pos[0] - 10; | |
802 | + self.activeRight = self.activeLeft + 20; | |
803 | + self.activeBottom = self.activeTop + 20; | |
804 | + return true; | |
805 | + } | |
806 | + }catch(e){} | |
807 | + self.currentEvent = {}; | |
808 | + for (var i in evt) { | |
809 | + self.currentEvent[i] = evt[i]; | |
810 | + } | |
811 | + | |
812 | + // avoid silent NaN errors | |
813 | + self.hOffset = self.hOffset || 1; | |
814 | + self.vOffset = self.vOffset || 1; | |
815 | + self.stemHeight = self.stem && self.stemHeight ? (self.stemHeight|| 0) : 0; | |
816 | + | |
817 | + var scrollTop = 0; | |
818 | + var scrollLeft = 0; | |
819 | + | |
820 | + var XY = self.eventXY(evt); | |
821 | + adjustment = self.hOffset < 20 ? 10 : 0; | |
822 | + self.activeTop = scrollTop + XY[1] - adjustment - self.vOffset - self.stemHeight; | |
823 | + self.activeLeft = scrollLeft + XY[0] - adjustment - self.hOffset; | |
824 | + self.activeRight = scrollLeft + XY[0]; | |
825 | + self.activeBottom = scrollTop + XY[1] + self.vOffset + 2*adjustment; | |
826 | + | |
827 | + // dynamic positioning but only if the balloon is not sticky | |
828 | + // and cursor tracking is enabled | |
829 | + if (balloonIsVisible && !balloonIsSticky) { | |
830 | + var deltaX = Math.abs(self.activeLeft - self.startX); | |
831 | + var deltaY = Math.abs(self.activeTop - self.startY); | |
832 | + | |
833 | + // Close the balloon if the cursor has left the firing element | |
834 | + if ( XY[0] < self.elCoords.left || XY[0] > self.elCoords.right | |
835 | + || XY[1] < self.elCoords.top || XY[1] > self.elCoords.bottom ) { | |
836 | + //self.hideTooltip(); | |
837 | + } | |
838 | + | |
839 | + // In some cases , such as <area> elements in image maps or big elements, | |
840 | + // we need to kill the balloon if the mouse has strayed too far. | |
841 | + if (deltaX > self.stopTrackingX || deltaY > self.stopTrackingY) { | |
842 | + //self.hideTooltip(); | |
843 | + } | |
844 | + else if (self.trackCursor) { | |
845 | + var b = self.activeBalloon; | |
846 | + var bwidth = self.getLoc(b,'width'); | |
847 | + var bheight = self.getLoc(b,'height'); | |
848 | + var btop = self.getLoc(b,'y1'); | |
849 | + var bleft = self.getLoc(b,'x1'); | |
850 | + | |
851 | + if (self.hOrient == 'right') { | |
852 | + self.setStyle(b,'left',self.activeRight); | |
853 | + } | |
854 | + else if (self.hOrient == 'left') { | |
855 | + self.setStyle(b,'right',null); | |
856 | + var newLeft = self.activeLeft - bwidth; | |
857 | + self.setStyle(b,'left',newLeft); | |
858 | + } | |
859 | + | |
860 | + if (self.vOrient == 'up') { | |
861 | + self.setStyle(b,'top',self.activeTop - bheight); | |
862 | + } | |
863 | + else if (self.vOrient == 'down') { | |
864 | + self.setStyle(b,'top',self.activeBottom); | |
865 | + } | |
866 | + } | |
867 | + } | |
868 | + | |
869 | + return true; | |
870 | +} | |
871 | + | |
872 | +//// | |
873 | +// event XY and getEventTarget Functions based on examples by Peter-Paul | |
874 | +// Koch http://www.quirksmode.org/js/events_properties.html | |
875 | +Balloon.prototype.eventXY = function(event) { | |
876 | + var XY = new Array(2); | |
877 | + var e = event || window.event; | |
878 | + if (!e) { | |
879 | + return false; | |
880 | + } | |
881 | + if (e.pageX || e.pageY) { | |
882 | + XY[0] = e.pageX; | |
883 | + XY[1] = e.pageY; | |
884 | + return XY; | |
885 | + } | |
886 | + else if ( e.clientX || e.clientY ) { | |
887 | + XY[0] = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; | |
888 | + XY[1] = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; | |
889 | + return XY; | |
890 | + } | |
891 | +} | |
892 | + | |
893 | +Balloon.prototype.getEventTarget = function(event) { | |
894 | + var targ; | |
895 | + var e = event || window.event; | |
896 | + if (e.target) targ = e.target; | |
897 | + else if (e.srcElement) targ = e.srcElement; | |
898 | + if (targ.nodeType == 3) targ = targ.parentNode; // Safari | |
899 | + return targ; | |
900 | +} | |
901 | +//// | |
902 | + | |
903 | + | |
904 | +Balloon.prototype.setStyle = function(el,att,val) { | |
905 | + if (!el) { | |
906 | + return false; | |
907 | + } | |
908 | + if (typeof(el) != 'object') { | |
909 | + el = document.getElementById(el); | |
910 | + } | |
911 | + if (!el) { | |
912 | + return false; | |
913 | + } | |
914 | + | |
915 | + var v = val; | |
916 | + | |
917 | + if (val && att.match(/left|top|bottom|right|width|height|padding|margin/)) { | |
918 | + val = new String(val); | |
919 | + if (!val.match(/auto/)) { | |
920 | + val += 'px'; | |
921 | + } | |
922 | + } | |
923 | + | |
924 | + | |
925 | + // z-index does not work as expected | |
926 | + if (att == 'z-index') { | |
927 | + if (el.style) { | |
928 | + el.style.zIndex = parseInt(val); | |
929 | + } | |
930 | + } | |
931 | + else { | |
932 | + // Oh just shut up, IE | |
933 | + if (this.isIE() && att.match(/^left|right|top|bottom$/) && !parseInt(val) && val != 0) { | |
934 | + val = null; | |
935 | + } | |
936 | + | |
937 | + YAHOO.util.Dom.setStyle(el,att,val); | |
938 | + } | |
939 | +} | |
940 | + | |
941 | +// Uses YAHOO's region class for element coordinates | |
942 | +Balloon.prototype.getLoc = function(el,request) { | |
943 | + var region = YAHOO.util.Dom.getRegion(el); | |
944 | + | |
945 | + switch(request) { | |
946 | + case ('y1') : return parseInt(region.top); | |
947 | + case ('y2') : return parseInt(region.bottom); | |
948 | + case ('x1') : return parseInt(region.left); | |
949 | + case ('x2') : return parseInt(region.right); | |
950 | + case ('width') : return (parseInt(region.right) - parseInt(region.left)); | |
951 | + case ('height') : return (parseInt(region.bottom) - parseInt(region.top)); | |
952 | + case ('region') : return region; | |
953 | + } | |
954 | + | |
955 | + return region; | |
956 | +} | |
957 | + | |
958 | +// We don't know if numbers are overridden with strings | |
959 | +// so play it safe | |
960 | +Balloon.prototype.parseIntAll = function() { | |
961 | + this.padding = parseInt(this.padding); | |
962 | + this.shadow = parseInt(this.shadow); | |
963 | + this.stemHeight = parseInt(this.stemHeight); | |
964 | + this.stemOverlap = parseInt(this.stemOverlap); | |
965 | + this.vOffset = parseInt(this.vOffset); | |
966 | + this.delayTime = parseInt(this.delayTime); | |
967 | + this.width = parseInt(this.width); | |
968 | + this.maxWidth = parseInt(this.maxWidth); | |
969 | + this.minWidth = parseInt(this.minWidth); | |
970 | + this.fadeIn = parseInt(this.fadeIn) || 1000; | |
971 | +} | |
972 | + | |
973 | + | |
974 | +// show/hide select elements in older IE | |
975 | +// plus user-defined elements | |
976 | +Balloon.prototype.showHide = function(visible) { | |
977 | + var self = currentBalloonClass || new Balloon; | |
978 | + | |
979 | + // IE z-index bug fix (courtesy of Lincoln Stein) | |
980 | + if (self.isOldIE()) { | |
981 | + var balloonContents = document.getElementById('contentWrapper'); | |
982 | + if (!visible && balloonContents) { | |
983 | + var balloonSelects = balloonContents.getElementsByTagName('select'); | |
984 | + var myHash = new Object(); | |
985 | + for (var i=0; i<balloonSelects.length; i++) { | |
986 | + var id = balloonSelects[i].id || balloonSelects[i].name; | |
987 | + myHash[id] = 1; | |
988 | + } | |
989 | + balloonInvisibleSelects = new Array(); | |
990 | + var allSelects = document.getElementsByTagName('select'); | |
991 | + for (var i=0; i<allSelects.length; i++) { | |
992 | + var id = allSelects[i].id || allSelects[i].name; | |
993 | + if (self.isOverlap(allSelects[i],self.activeBalloon) && !myHash[id]) { | |
994 | + balloonInvisibleSelects.push(allSelects[i]); | |
995 | + self.setStyle(allSelects[i],'visibility','hidden'); | |
996 | + } | |
997 | + } | |
998 | + } | |
999 | + else if (balloonInvisibleSelects) { | |
1000 | + for (var i=0; i < balloonInvisibleSelects.length; i++) { | |
1001 | + var id = balloonInvisibleSelects[i].id || balloonInvisibleSelects[i].name; | |
1002 | + self.setStyle(balloonInvisibleSelects[i],'visibility','visible'); | |
1003 | + } | |
1004 | + balloonInvisibleSelects = null; | |
1005 | + } | |
1006 | + } | |
1007 | + | |
1008 | + // show/hide any user-specified elements that overlap the balloon | |
1009 | + if (self.hide) { | |
1010 | + var display = visible ? 'inline' : 'none'; | |
1011 | + for (var n=0;n<self.hide.length;n++) { | |
1012 | + if (self.isOverlap(self.activeBalloon,self.hide[n])) { | |
1013 | + self.setStyle(self.hide[n],'display',display); | |
1014 | + } | |
1015 | + } | |
1016 | + } | |
1017 | +} | |
1018 | + | |
1019 | +// Try to find overlap | |
1020 | +Balloon.prototype.isOverlap = function(el1,el2) { | |
1021 | + if (!el1 || !el2) return false; | |
1022 | + var R1 = this.getLoc(el1,'region'); | |
1023 | + var R2 = this.getLoc(el2,'region'); | |
1024 | + if (!R1 || !R2) return false; | |
1025 | + var intersect = R1.intersect(R2); | |
1026 | + if (intersect) { | |
1027 | + // extent of overlap; | |
1028 | + intersect = new Array((intersect.right - intersect.left),(intersect.bottom - intersect.top)); | |
1029 | + } | |
1030 | + return intersect; | |
1031 | +} | |
1032 | + | |
1033 | +// Coordinate-based test for the same element | |
1034 | +Balloon.prototype.isSameElement = function(el1,el2) { | |
1035 | + if (!el1 || !el2) return false; | |
1036 | + var R1 = this.getLoc(el1,'region'); | |
1037 | + var R2 = this.getLoc(el2,'region'); | |
1038 | + var same = R1.contains(R2) && R2.contains(R1); | |
1039 | + return same ? true : false; | |
1040 | +} | |
1041 | + | |
1042 | + | |
1043 | +/////////////////////////////////////////////////////// | |
1044 | +// Security -- get the balloon contents while checking | |
1045 | +// for disallowed elements. | |
1046 | +////////////////////////////////////////////////////// | |
1047 | +Balloon.prototype.getAndCheckContents = function(caption) { | |
1048 | + var originalCaption = caption; | |
1049 | + var notAllowed = 'are not allowed in popup balloons in this web site. \ | |
1050 | + Please contact the site administrator for assistance.'; | |
1051 | + var notSupported = 'AJAX is not supported for popup balloons in this web site. \ | |
1052 | + Please contact the site administrator for assistance.'; | |
1053 | + | |
1054 | + // no Help Url without AJAX | |
1055 | + if (this.helpUrl && !this.allowAJAX) { | |
1056 | + alert('Sorry, you have specified help URL '+this.helpUrl+' but '+notSupported); | |
1057 | + return null; | |
1058 | + } | |
1059 | + | |
1060 | + // look for a url in the balloon contents | |
1061 | + if (caption.match(/^url:/)) { | |
1062 | + this.activeUrl = caption.replace(/^url:/,''); | |
1063 | + caption = ''; | |
1064 | + } | |
1065 | + // or if the text is a bare hyperlink | |
1066 | + else if (caption.match(/^(https?:|\/|ftp:)\S+$/i)) { | |
1067 | + this.activeUrl = caption; | |
1068 | + caption = ''; | |
1069 | + } | |
1070 | + | |
1071 | + // Make sure AJAX is allowed | |
1072 | + if (this.activeUrl && !this.allowAJAX) { | |
1073 | + alert('Sorry, you asked for '+originalCaption+' but '+notSupported); | |
1074 | + return null; | |
1075 | + } | |
1076 | + | |
1077 | + // check if the contents are to be retrieved from an element | |
1078 | + if (caption.match(/^load:/)) { | |
1079 | + var load = caption.split(':'); | |
1080 | + if (!document.getElementById(load[1])) alert ('problem locating element '+load[1]); | |
1081 | + caption = document.getElementById(load[1]).innerHTML; | |
1082 | + this.loadedFromElement = true; | |
1083 | + } | |
1084 | + | |
1085 | + // check if iframes are allowed | |
1086 | + if (caption.match(/\<\s*iframe/i) && !this.allowIframes) { | |
1087 | + alert('Sorry: iframe elements '+notAllowed); | |
1088 | + return null; | |
1089 | + } | |
1090 | + | |
1091 | + // check if event handlers are allowed | |
1092 | + if (caption.match(/\bon(load|mouse|click|unload|before)[^=]*=/i) && !this.allowEventHandlers) { | |
1093 | + alert('Sorry: JavaScript event handlers '+notAllowed); | |
1094 | + return null; | |
1095 | + } | |
1096 | + | |
1097 | + // check for script elements | |
1098 | + if (caption.match(/\<\s*script/i) && !this.allowScripts) { | |
1099 | + alert('Sorry: <script> elements '+notAllowed); | |
1100 | + return null; | |
1101 | + } | |
1102 | + | |
1103 | + // request the contents | |
1104 | + this.currentHelpText = this.getContents(caption); | |
1105 | + this.loadedFromElement = false; | |
1106 | + | |
1107 | + return this.currentHelpText;; | |
1108 | +} | |
1109 | + | |
1110 | + | |
1111 | +/////////////////////////////////////////////////////// | |
1112 | +// AJAX widget to fill the balloons | |
1113 | +// requires prototype.js | |
1114 | +/////////////////////////////////////////////////////// | |
1115 | +Balloon.prototype.getContents = function(section) { | |
1116 | + | |
1117 | + // just pass it back if no AJAX handler is required. | |
1118 | + if (!this.helpUrl && !this.activeUrl) return section; | |
1119 | + | |
1120 | + // or if the contents are already loaded from another element | |
1121 | + if (this.loadedFromElement) return section; | |
1122 | + | |
1123 | + // inline URL takes precedence | |
1124 | + var url = this.activeUrl || this.helpUrl; | |
1125 | + url += this.activeUrl ? '' : '?section='+section; | |
1126 | + | |
1127 | + // activeUrl is meant to be single-use only | |
1128 | + this.activeUrl = null; | |
1129 | + | |
1130 | + var ajax; | |
1131 | + if (window.XMLHttpRequest) { | |
1132 | + ajax = new XMLHttpRequest(); | |
1133 | + } else { | |
1134 | + ajax = new ActiveXObject("Microsoft.XMLHTTP"); | |
1135 | + } | |
1136 | + | |
1137 | + if (ajax) { | |
1138 | + ajax.open("GET", url, false); | |
1139 | + ajax.onreadystatechange=function() { | |
1140 | + //alert(ajax.readyState); | |
1141 | + }; | |
1142 | + try { | |
1143 | + ajax.send(null); | |
1144 | + } | |
1145 | + catch (e) { | |
1146 | + // alert(e); | |
1147 | + } | |
1148 | + var txt = this.escapeHTML ? escape(ajax.responseText) : ajax.responseText; | |
1149 | + return txt || section; | |
1150 | + } | |
1151 | + else { | |
1152 | + return section; | |
1153 | + } | |
1154 | +} | |
1155 | + | |
1156 | + | |
1157 | +// test for internet explorer | |
1158 | +Balloon.prototype.isIE = function() { | |
1159 | + return document.all && !window.opera; | |
1160 | +} | |
1161 | + | |
1162 | +// test for internet explorer (but not IE7) | |
1163 | +Balloon.prototype.isOldIE = function() { | |
1164 | + if (navigator.appVersion.indexOf("MSIE") == -1) return false; | |
1165 | + var temp=navigator.appVersion.split("MSIE"); | |
1166 | + return parseFloat(temp[1]) < 7; | |
1167 | +} | |
1168 | + | |
1169 | +// test for Konqueror | |
1170 | +Balloon.prototype.isKonqueror = function() { | |
1171 | + return navigator.userAgent.toLowerCase().indexOf( 'konqueror' ) != -1; | |
1172 | +} | |
1173 | + | |
1174 | +// and Google chrome | |
1175 | +Balloon.prototype.isChrome = function() { | |
1176 | + return navigator.userAgent.toLowerCase().indexOf('chrome') > -1; | |
1177 | +} | |
0 | 1178 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,217 @@ |
1 | +/* | |
2 | + This is a subclass of balloon.js -- uses a simple box rather than a | |
3 | + a balloon/bubble image. It can have a background image and a styled | |
4 | + bgcolor and border but is otherwise meant to be simple and lightweight. | |
5 | +*/ | |
6 | + | |
7 | +////////////////////////////////////////////////////////////////////////// | |
8 | +// This is constructor that is called to initialize the Balloon object // | |
9 | +////////////////////////////////////////////////////////////////////////// | |
10 | +var Box = function () { | |
11 | + // Track the cursor every time the mouse moves | |
12 | + document.onmousemove = this.setActiveCoordinates; | |
13 | + | |
14 | + // scrolling aborts unsticky box | |
15 | + document.onscroll = Balloon.prototype.hideTooltip; | |
16 | + | |
17 | + // go away if the page is unloading or waiting | |
18 | + // to unload. | |
19 | + window.onbeforeunload = function(){ | |
20 | + Balloon.prototype.nukeTooltip; | |
21 | + balloonIsSuppressed = true; | |
22 | + }; | |
23 | + | |
24 | + // for IE, the box can't start until the page is finished loading | |
25 | + // set a flag that will get toggled when loading is finished | |
26 | + if (this.isIE()) { | |
27 | + this.suppress = true; | |
28 | + } | |
29 | + | |
30 | + return this; | |
31 | +} | |
32 | + | |
33 | +// Inherit from Balloon class | |
34 | +Box.prototype = new Balloon(); | |
35 | + | |
36 | + | |
37 | +// Make the box element -- this overrides the parent method | |
38 | +Box.prototype.makeBalloon = function() { | |
39 | + var self = currentBalloonClass; | |
40 | + | |
41 | + // use ID 'visibleBalloonElement' for consistency with parent class | |
42 | + var box = document.getElementById('visibleBalloonElement'); | |
43 | + if (box) self.parent.removeChild(box); | |
44 | + box = document.createElement('div'); | |
45 | + box.setAttribute('id','visibleBalloonElement'); | |
46 | + self.parent.appendChild(box); | |
47 | + self.activeBalloon = box; | |
48 | + | |
49 | + var contents = document.createElement('div'); | |
50 | + contents.setAttribute('id','contents'); | |
51 | + box.appendChild(contents); | |
52 | + self.contents = contents; | |
53 | + self.parts = new Array(box); | |
54 | + | |
55 | + self.setStyle(contents,'z-index',2); | |
56 | + self.setStyle(contents,'color',self.fontColor); | |
57 | + self.setStyle(contents,'font-family',self.fontFamily); | |
58 | + self.setStyle(contents,'font-size',self.fontSize); | |
59 | + | |
60 | + if (balloonIsSticky) { | |
61 | + self.setStyle(contents,'margin-right',10); | |
62 | + } | |
63 | + else if (self.displayTime) { | |
64 | + self.timeoutAutoClose = window.setTimeout(this.hideTooltip,self.displayTime); | |
65 | + } | |
66 | + | |
67 | + return box; | |
68 | +} | |
69 | + | |
70 | +// Set the box style -- overrides the parent method | |
71 | +Box.prototype.setBalloonStyle = function(vOrient,hOrient) { | |
72 | + var self = currentBalloonClass; | |
73 | + var box = self.activeBalloon; | |
74 | + | |
75 | + self.shadow = 0; | |
76 | + self.stem = false; | |
77 | + self.stemHeight = 0; | |
78 | + | |
79 | + self.setStyle(box,'background',self.bgColor); | |
80 | + self.setStyle(box,'border',self.borderStyle); | |
81 | + self.setStyle(box,'position','absolute'); | |
82 | + self.setStyle(box,'padding',self.padding); | |
83 | + self.setStyle(box,'top',-9999); | |
84 | + self.setStyle(box,'z-index',1000000); | |
85 | + | |
86 | + // If width and/or height are specified, harden the | |
87 | + // box at those dimensions, but not if the space needed | |
88 | + // is less tha the space that would be used. | |
89 | + if (self.width) { | |
90 | + var widthUsed = self.getLoc('contents','width') + 20; | |
91 | + var newWidth = widthUsed > self.width ? self.width : widthUsed; | |
92 | + self.setStyle('contents','width',newWidth); | |
93 | + } | |
94 | + if (self.height) { | |
95 | + var heightUsed = self.getLoc('contents','height') + 20; | |
96 | + var newHeight = heightUsed > self.height ? self.height : heightUsed; | |
97 | + self.setStyle('contents','height',newHeight+(2*self.padding)); | |
98 | + } | |
99 | + | |
100 | + // flip left or right, as required | |
101 | + if (hOrient == 'left') { | |
102 | + var pageWidth = self.pageRight - self.pageLeft; | |
103 | + var activeRight = pageWidth - self.activeLeft; | |
104 | + self.setStyle(box,'right',activeRight); | |
105 | + } | |
106 | + else { | |
107 | + self.setStyle(box,'left',self.activeRight - self.xOffset); | |
108 | + } | |
109 | + | |
110 | + if (!self.width) { | |
111 | + var width = self.getLoc('contents','width'); | |
112 | + if (self.isIE()) width += self.padding; | |
113 | + if (width > self.maxWidth) width = self.maxWidth + self.padding; | |
114 | + if (width < self.minWidth) width = self.minWidth; | |
115 | + self.setStyle(box,'width',width); | |
116 | + } | |
117 | + | |
118 | + var overflow = balloonIsSticky ? 'auto' : 'hidden'; | |
119 | + self.setStyle('contents','overflow',overflow); | |
120 | + | |
121 | + // Make sure the box is not offscreen horizontally. | |
122 | + // We handle vertical sanity checking later, after the final | |
123 | + // layout is set. | |
124 | + var boxLeft = self.getLoc(box,'x1'); | |
125 | + var boxRight = self.getLoc(box,'x2'); | |
126 | + var scrollBar = 20; | |
127 | + | |
128 | + if (hOrient == 'right' && boxRight > (self.pageRight - self.padding)) { | |
129 | + self.setStyle('contents','width',(self.pageRight - boxLeft) - self.padding - scrollBar); | |
130 | + } | |
131 | + else if (hOrient == 'left' && boxLeft < (self.pageLeft + self.padding)) { | |
132 | + self.setStyle('contents','width',(boxRight - self.pageLeft) - self.padding); | |
133 | + } | |
134 | + | |
135 | + // Get the width/height for the right and bottom outlines | |
136 | + var boxWidth = self.getLoc(box,'width'); | |
137 | + var boxHeight = self.getLoc(box,'height'); | |
138 | + | |
139 | + if (self.allowFade) { | |
140 | + self.setOpacity(0.01); | |
141 | + } | |
142 | + else { | |
143 | + self.setOpacity(self.opacity); | |
144 | + } | |
145 | + | |
146 | + if (!(self.activeTop && self.activeBottom)) { | |
147 | + self.setActiveCoordinates(); | |
148 | + } | |
149 | + | |
150 | + if (vOrient == 'up') { | |
151 | + var activeTop = self.activeTop - boxHeight; | |
152 | + self.setStyle(box,'top',activeTop); | |
153 | + } | |
154 | + else if (vOrient == 'down') { | |
155 | + var activeTop = self.activeBottom; | |
156 | + self.setStyle(box,'top',activeTop); | |
157 | + } | |
158 | + self.setStyle(box,'display','inline'); | |
159 | + | |
160 | + // Make sure the box is vertically contained in the window | |
161 | + var boxTop = self.getLoc(box,'y1'); | |
162 | + var boxBottom = self.getLoc(box,'y2'); | |
163 | + var deltaTop = boxTop < self.pageTop ? self.pageTop - boxTop : 0; | |
164 | + var deltaBottom = boxBottom > self.pageBottom ? boxBottom - self.pageBottom : 0; | |
165 | + | |
166 | + if (vOrient == 'up' && deltaTop) { | |
167 | + var newHeight = boxHeight - deltaTop; | |
168 | + if (newHeight > (self.padding*2)) { | |
169 | + self.setStyle('contents','height',newHeight); | |
170 | + self.setStyle(box,'top',self.pageTop+self.padding); | |
171 | + self.setStyle(box,'height',newHeight); | |
172 | + } | |
173 | + } | |
174 | + | |
175 | + if (vOrient == 'down' && deltaBottom) { | |
176 | + var newHeight = boxHeight - deltaBottom - scrollBar; | |
177 | + if (newHeight > (self.padding*2) + scrollBar) { | |
178 | + self.setStyle('contents','height',newHeight); | |
179 | + self.setStyle(box,'height',newHeight); | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + self.hOrient = hOrient; | |
184 | + self.vOrient = vOrient; | |
185 | +} | |
186 | + | |
187 | + | |
188 | +Box.prototype.addCloseButton = function () { | |
189 | + var self = currentBalloonClass; | |
190 | + var margin = Math.round(self.padding/2); | |
191 | + var closeWidth = self.closeButtonWidth || 16; | |
192 | + var balloonTop = self.getLoc('visibleBalloonElement','y1') + margin; | |
193 | + var balloonRight = self.getLoc('visibleBalloonElement','x2') - margin - self.closeButtonWidth; | |
194 | + var closeButton = document.getElementById('closeButton'); | |
195 | + | |
196 | + | |
197 | + if (!closeButton) { | |
198 | + closeButton = new Image; | |
199 | + closeButton.setAttribute('id','closeButton'); | |
200 | + closeButton.setAttribute('src',self.closeButton); | |
201 | + closeButton.onclick = function() { | |
202 | + Balloon.prototype.nukeTooltip(); | |
203 | + }; | |
204 | + self.setStyle(closeButton,'position','absolute'); | |
205 | + document.body.appendChild(closeButton); | |
206 | + } | |
207 | + | |
208 | + if (self.isIE()) { | |
209 | + balloonRight -= self.padding; | |
210 | + } | |
211 | + | |
212 | + self.setStyle(closeButton,'top',balloonTop); | |
213 | + self.setStyle(closeButton,'left',balloonRight); | |
214 | + self.setStyle(closeButton,'display','inline'); | |
215 | + self.setStyle(closeButton,'cursor','pointer'); | |
216 | + self.setStyle(closeButton,'z-index',999999999); | |
217 | +} | ... | ... |
... | ... | @@ -0,0 +1,197 @@ |
1 | +/* | |
2 | +Copyright (c) 2007, Yahoo! Inc. All rights reserved. | |
3 | +Code licensed under the BSD License: | |
4 | +http://developer.yahoo.net/yui/license.txt | |
5 | +version: 2.3.0 | |
6 | +*/ | |
7 | + | |
8 | +if(typeof YAHOO=="undefined"){var YAHOO={};} | |
9 | +YAHOO.namespace=function(){var a=arguments,o=null,i,j,d;for(i=0;i<a.length;i=i+1){d=a[i].split(".");o=YAHOO;for(j=(d[0]=="YAHOO")?1:0;j<d.length;j=j+1){o[d[j]]=o[d[j]]||{};o=o[d[j]];}} | |
10 | +return o;};YAHOO.log=function(msg,cat,src){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(msg,cat,src);}else{return false;}};YAHOO.register=function(name,mainClass,data){var mods=YAHOO.env.modules;if(!mods[name]){mods[name]={versions:[],builds:[]};} | |
11 | +var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners;m.name=name;m.version=v;m.build=b;m.versions.push(v);m.builds.push(b);m.mainClass=mainClass;for(var i=0;i<ls.length;i=i+1){ls[i](m);} | |
12 | +if(mainClass){mainClass.VERSION=v;mainClass.BUILD=b;}else{YAHOO.log("mainClass is undefined for module "+name,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[]};YAHOO.env.getVersion=function(name){return YAHOO.env.modules[name]||null;};YAHOO.env.ua=function(){var o={ie:0,opera:0,gecko:0,webkit:0};var ua=navigator.userAgent,m;if((/KHTML/).test(ua)){o.webkit=1;} | |
13 | +m=ua.match(/AppleWebKit\/([^\s]*)/);if(m&&m[1]){o.webkit=parseFloat(m[1]);} | |
14 | +if(!o.webkit){m=ua.match(/Opera[\s\/]([^\s]*)/);if(m&&m[1]){o.opera=parseFloat(m[1]);}else{m=ua.match(/MSIE\s([^;]*)/);if(m&&m[1]){o.ie=parseFloat(m[1]);}else{m=ua.match(/Gecko\/([^\s]*)/);if(m){o.gecko=1;m=ua.match(/rv:([^\s\)]*)/);if(m&&m[1]){o.gecko=parseFloat(m[1]);}}}}} | |
15 | +return o;}();(function(){YAHOO.namespace("util","widget","example");if(typeof YAHOO_config!="undefined"){var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;if(l){for(i=0;i<ls.length;i=i+1){if(ls[i]==l){unique=false;break;}} | |
16 | +if(unique){ls.push(l);}}}})();YAHOO.lang={isArray:function(o){if(o){var l=YAHOO.lang;return l.isNumber(o.length)&&l.isFunction(o.splice)&&!l.hasOwnProperty(o.length);} | |
17 | +return false;},isBoolean:function(o){return typeof o==='boolean';},isFunction:function(o){return typeof o==='function';},isNull:function(o){return o===null;},isNumber:function(o){return typeof o==='number'&&isFinite(o);},isObject:function(o){return(o&&(typeof o==='object'||YAHOO.lang.isFunction(o)))||false;},isString:function(o){return typeof o==='string';},isUndefined:function(o){return typeof o==='undefined';},hasOwnProperty:function(o,prop){if(Object.prototype.hasOwnProperty){return o.hasOwnProperty(prop);} | |
18 | +return!YAHOO.lang.isUndefined(o[prop])&&o.constructor.prototype[prop]!==o[prop];},_IEEnumFix:function(r,s){if(YAHOO.env.ua.ie){var add=["toString","valueOf"];for(i=0;i<add.length;i=i+1){var fname=add[i],f=s[fname];if(YAHOO.lang.isFunction(f)&&f!=Object.prototype[fname]){r[fname]=f;}}}},extend:function(subc,superc,overrides){if(!superc||!subc){throw new Error("YAHOO.lang.extend failed, please check that "+"all dependencies are included.");} | |
19 | +var F=function(){};F.prototype=superc.prototype;subc.prototype=new F();subc.prototype.constructor=subc;subc.superclass=superc.prototype;if(superc.prototype.constructor==Object.prototype.constructor){superc.prototype.constructor=superc;} | |
20 | +if(overrides){for(var i in overrides){subc.prototype[i]=overrides[i];} | |
21 | +YAHOO.lang._IEEnumFix(subc.prototype,overrides);}},augmentObject:function(r,s){if(!s||!r){throw new Error("Absorb failed, verify dependencies.");} | |
22 | +var a=arguments,i,p,override=a[2];if(override&&override!==true){for(i=2;i<a.length;i=i+1){r[a[i]]=s[a[i]];}}else{for(p in s){if(override||!r[p]){r[p]=s[p];}} | |
23 | +YAHOO.lang._IEEnumFix(r,s);}},augmentProto:function(r,s){if(!s||!r){throw new Error("Augment failed, verify dependencies.");} | |
24 | +var a=[r.prototype,s.prototype];for(var i=2;i<arguments.length;i=i+1){a.push(arguments[i]);} | |
25 | +YAHOO.lang.augmentObject.apply(this,a);},dump:function(o,d){var l=YAHOO.lang,i,len,s=[],OBJ="{...}",FUN="f(){...}",COMMA=', ',ARROW=' => ';if(!l.isObject(o)||o instanceof Date||("nodeType"in o&&"tagName"in o)){return o;}else if(l.isFunction(o)){return FUN;} | |
26 | +d=(l.isNumber(d))?d:3;if(l.isArray(o)){s.push("[");for(i=0,len=o.length;i<len;i=i+1){if(l.isObject(o[i])){s.push((d>0)?l.dump(o[i],d-1):OBJ);}else{s.push(o[i]);} | |
27 | +s.push(COMMA);} | |
28 | +if(s.length>1){s.pop();} | |
29 | +s.push("]");}else{s.push("{");for(i in o){if(l.hasOwnProperty(o,i)){s.push(i+ARROW);if(l.isObject(o[i])){s.push((d>0)?l.dump(o[i],d-1):OBJ);}else{s.push(o[i]);} | |
30 | +s.push(COMMA);}} | |
31 | +if(s.length>1){s.pop();} | |
32 | +s.push("}");} | |
33 | +return s.join("");},substitute:function(s,o,f){var i,j,k,key,v,meta,l=YAHOO.lang,saved=[],token,DUMP='dump',SPACE=' ',LBRACE='{',RBRACE='}';for(;;){i=s.lastIndexOf(LBRACE);if(i<0){break;} | |
34 | +j=s.indexOf(RBRACE,i);if(i+1>=j){break;} | |
35 | +token=s.substring(i+1,j);key=token;meta=null;k=key.indexOf(SPACE);if(k>-1){meta=key.substring(k+1);key=key.substring(0,k);} | |
36 | +v=o[key];if(f){v=f(key,v,meta);} | |
37 | +if(l.isObject(v)){if(l.isArray(v)){v=l.dump(v,parseInt(meta,10));}else{meta=meta||"";var dump=meta.indexOf(DUMP);if(dump>-1){meta=meta.substring(4);} | |
38 | +if(v.toString===Object.prototype.toString||dump>-1){v=l.dump(v,parseInt(meta,10));}else{v=v.toString();}}}else if(!l.isString(v)&&!l.isNumber(v)){v="~-"+saved.length+"-~";saved[saved.length]=token;} | |
39 | +s=s.substring(0,i)+v+s.substring(j+1);} | |
40 | +for(i=saved.length-1;i>=0;i=i-1){s=s.replace(new RegExp("~-"+i+"-~"),"{"+saved[i]+"}","g");} | |
41 | +return s;},trim:function(s){try{return s.replace(/^\s+|\s+$/g,"");}catch(e){return s;}},merge:function(){var o={},a=arguments,i;for(i=0;i<a.length;i=i+1){YAHOO.lang.augmentObject(o,a[i],true);} | |
42 | +return o;},isValue:function(o){var l=YAHOO.lang;return(l.isObject(o)||l.isString(o)||l.isNumber(o)||l.isBoolean(o));}};YAHOO.util.Lang=YAHOO.lang;YAHOO.lang.augment=YAHOO.lang.augmentProto;YAHOO.augment=YAHOO.lang.augmentProto;YAHOO.extend=YAHOO.lang.extend;YAHOO.register("yahoo",YAHOO,{version:"2.3.0",build:"442"}); | |
43 | +(function(){var Y=YAHOO.util,getStyle,setStyle,id_counter=0,propertyCache={},reClassNameCache={};var isOpera=YAHOO.env.ua.opera,isSafari=YAHOO.env.ua.webkit,isGecko=YAHOO.env.ua.gecko,isIE=YAHOO.env.ua.ie;var patterns={HYPHEN:/(-[a-z])/i,ROOT_TAG:/^body|html$/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property;} | |
44 | +if(propertyCache[property]){return propertyCache[property];} | |
45 | +var converted=property;while(patterns.HYPHEN.exec(converted)){converted=converted.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());} | |
46 | +propertyCache[property]=converted;return converted;};var getClassRegEx=function(className){var re=reClassNameCache[className];if(!re){re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');reClassNameCache[className]=re;} | |
47 | +return re;};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;if(property=='float'){property='cssFloat';} | |
48 | +var computed=document.defaultView.getComputedStyle(el,'');if(computed){value=computed[toCamel(property)];} | |
49 | +return el.style[property]||value;};}else if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case'opacity':var val=100;try{val=el.filters['DXImageTransform.Microsoft.Alpha'].opacity;}catch(e){try{val=el.filters('alpha').opacity;}catch(e){}} | |
50 | +return val/100;case'float':property='styleFloat';default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value);}};}else{getStyle=function(el,property){return el.style[property];};} | |
51 | +if(isIE){setStyle=function(el,property,val){switch(property){case'opacity':if(YAHOO.lang.isString(el.style.filter)){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}} | |
52 | +break;case'float':property='styleFloat';default:el.style[property]=val;}};}else{setStyle=function(el,property,val){if(property=='float'){property='cssFloat';} | |
53 | +el.style[property]=val;};} | |
54 | +var testElement=function(node,method){return node&&node.nodeType==1&&(!method||method(node));};YAHOO.util.Dom={get:function(el){if(!el||el.tagName||el.item){return el;} | |
55 | +if(YAHOO.lang.isString(el)){return document.getElementById(el);} | |
56 | +if(el.splice){var c=[];for(var i=0,len=el.length;i<len;++i){c[c.length]=Y.Dom.get(el[i]);} | |
57 | +return c;} | |
58 | +return el;},getStyle:function(el,property){property=toCamel(property);var f=function(element){return getStyle(element,property);};return Y.Dom.batch(el,f,Y.Dom,true);},setStyle:function(el,property,val){property=toCamel(property);var f=function(element){setStyle(element,property,val);};Y.Dom.batch(el,f,Y.Dom,true);},getXY:function(el){var f=function(el){if((el.parentNode===null||el.offsetParent===null||this.getStyle(el,'display')=='none')&&el!=document.body){return false;} | |
59 | +var parentNode=null;var pos=[];var box;var doc=el.ownerDocument;if(el.getBoundingClientRect){box=el.getBoundingClientRect();return[box.left+Y.Dom.getDocumentScrollLeft(el.ownerDocument),box.top+Y.Dom.getDocumentScrollTop(el.ownerDocument)];} | |
60 | +else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;var hasAbs=this.getStyle(el,'position')=='absolute';if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;if(isSafari&&!hasAbs&&this.getStyle(parentNode,'position')=='absolute'){hasAbs=true;} | |
61 | +parentNode=parentNode.offsetParent;}} | |
62 | +if(isSafari&&hasAbs){pos[0]-=el.ownerDocument.body.offsetLeft;pos[1]-=el.ownerDocument.body.offsetTop;}} | |
63 | +parentNode=el.parentNode;while(parentNode.tagName&&!patterns.ROOT_TAG.test(parentNode.tagName)) | |
64 | +{if(Y.Dom.getStyle(parentNode,'display').search(/^inline|table-row.*$/i)){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop;} | |
65 | +parentNode=parentNode.parentNode;} | |
66 | +return pos;};return Y.Dom.batch(el,f,Y.Dom,true);},getX:function(el){var f=function(el){return Y.Dom.getXY(el)[0];};return Y.Dom.batch(el,f,Y.Dom,true);},getY:function(el){var f=function(el){return Y.Dom.getXY(el)[1];};return Y.Dom.batch(el,f,Y.Dom,true);},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=this.getStyle(el,'position');if(style_pos=='static'){this.setStyle(el,'position','relative');style_pos='relative';} | |
67 | +var pageXY=this.getXY(el);if(pageXY===false){return false;} | |
68 | +var delta=[parseInt(this.getStyle(el,'left'),10),parseInt(this.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=(style_pos=='relative')?0:el.offsetLeft;} | |
69 | +if(isNaN(delta[1])){delta[1]=(style_pos=='relative')?0:el.offsetTop;} | |
70 | +if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';} | |
71 | +if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';} | |
72 | +if(!noRetry){var newXY=this.getXY(el);if((pos[0]!==null&&newXY[0]!=pos[0])||(pos[1]!==null&&newXY[1]!=pos[1])){this.setXY(el,pos,true);}}};Y.Dom.batch(el,f,Y.Dom,true);},setX:function(el,x){Y.Dom.setXY(el,[x,null]);},setY:function(el,y){Y.Dom.setXY(el,[null,y]);},getRegion:function(el){var f=function(el){if((el.parentNode===null||el.offsetParent===null||this.getStyle(el,'display')=='none')&&el!=document.body){return false;} | |
73 | +var region=Y.Region.getRegion(el);return region;};return Y.Dom.batch(el,f,Y.Dom,true);},getClientWidth:function(){return Y.Dom.getViewportWidth();},getClientHeight:function(){return Y.Dom.getViewportHeight();},getElementsByClassName:function(className,tag,root,apply){tag=tag||'*';root=(root)?Y.Dom.get(root):null||document;if(!root){return[];} | |
74 | +var nodes=[],elements=root.getElementsByTagName(tag),re=getClassRegEx(className);for(var i=0,len=elements.length;i<len;++i){if(re.test(elements[i].className)){nodes[nodes.length]=elements[i];if(apply){apply.call(elements[i],elements[i]);}}} | |
75 | +return nodes;},hasClass:function(el,className){var re=getClassRegEx(className);var f=function(el){return re.test(el.className);};return Y.Dom.batch(el,f,Y.Dom,true);},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return false;} | |
76 | +el.className=YAHOO.lang.trim([el.className,className].join(' '));return true;};return Y.Dom.batch(el,f,Y.Dom,true);},removeClass:function(el,className){var re=getClassRegEx(className);var f=function(el){if(!this.hasClass(el,className)){return false;} | |
77 | +var c=el.className;el.className=c.replace(re,' ');if(this.hasClass(el,className)){this.removeClass(el,className);} | |
78 | +el.className=YAHOO.lang.trim(el.className);return true;};return Y.Dom.batch(el,f,Y.Dom,true);},replaceClass:function(el,oldClassName,newClassName){if(!newClassName||oldClassName===newClassName){return false;} | |
79 | +var re=getClassRegEx(oldClassName);var f=function(el){if(!this.hasClass(el,oldClassName)){this.addClass(el,newClassName);return true;} | |
80 | +el.className=el.className.replace(re,' '+newClassName+' ');if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName);} | |
81 | +el.className=YAHOO.lang.trim(el.className);return true;};return Y.Dom.batch(el,f,Y.Dom,true);},generateId:function(el,prefix){prefix=prefix||'yui-gen';var f=function(el){if(el&&el.id){return el.id;} | |
82 | +var id=prefix+id_counter++;if(el){el.id=id;} | |
83 | +return id;};return Y.Dom.batch(el,f,Y.Dom,true)||f.apply(Y.Dom,arguments);},isAncestor:function(haystack,needle){haystack=Y.Dom.get(haystack);if(!haystack||!needle){return false;} | |
84 | +var f=function(node){if(haystack.contains&&node.nodeType&&!isSafari){return haystack.contains(node);} | |
85 | +else if(haystack.compareDocumentPosition&&node.nodeType){return!!(haystack.compareDocumentPosition(node)&16);}else if(node.nodeType){return!!this.getAncestorBy(node,function(el){return el==haystack;});} | |
86 | +return false;};return Y.Dom.batch(needle,f,Y.Dom,true);},inDocument:function(el){var f=function(el){if(isSafari){while(el=el.parentNode){if(el==document.documentElement){return true;}} | |
87 | +return false;} | |
88 | +return this.isAncestor(document.documentElement,el);};return Y.Dom.batch(el,f,Y.Dom,true);},getElementsBy:function(method,tag,root,apply){tag=tag||'*';root=(root)?Y.Dom.get(root):null||document;if(!root){return[];} | |
89 | +var nodes=[],elements=root.getElementsByTagName(tag);for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i];if(apply){apply(elements[i]);}}} | |
90 | +return nodes;},batch:function(el,method,o,override){el=(el&&el.tagName)?el:Y.Dom.get(el);if(!el||!method){return false;} | |
91 | +var scope=(override)?o:window;if(el.tagName||(!el.item&&!el.slice)){return method.call(scope,el,o);} | |
92 | +var collection=[];for(var i=0,len=el.length;i<len;++i){collection[collection.length]=method.call(scope,el[i],o);} | |
93 | +return collection;},getDocumentHeight:function(){var scrollHeight=(document.compatMode!='CSS1Compat')?document.body.scrollHeight:document.documentElement.scrollHeight;var h=Math.max(scrollHeight,Y.Dom.getViewportHeight());return h;},getDocumentWidth:function(){var scrollWidth=(document.compatMode!='CSS1Compat')?document.body.scrollWidth:document.documentElement.scrollWidth;var w=Math.max(scrollWidth,Y.Dom.getViewportWidth());return w;},getViewportHeight:function(){var height=self.innerHeight;var mode=document.compatMode;if((mode||isIE)&&!isOpera){height=(mode=='CSS1Compat')?document.documentElement.clientHeight:document.body.clientHeight;} | |
94 | +return height;},getViewportWidth:function(){var width=self.innerWidth;var mode=document.compatMode;if(mode||isIE){width=(mode=='CSS1Compat')?document.documentElement.clientWidth:document.body.clientWidth;} | |
95 | +return width;},getAncestorBy:function(node,method){while(node=node.parentNode){if(testElement(node,method)){return node;}} | |
96 | +return null;},getAncestorByClassName:function(node,className){node=Y.Dom.get(node);if(!node){return null;} | |
97 | +var method=function(el){return Y.Dom.hasClass(el,className);};return Y.Dom.getAncestorBy(node,method);},getAncestorByTagName:function(node,tagName){node=Y.Dom.get(node);if(!node){return null;} | |
98 | +var method=function(el){return el.tagName&&el.tagName.toUpperCase()==tagName.toUpperCase();};return Y.Dom.getAncestorBy(node,method);},getPreviousSiblingBy:function(node,method){while(node){node=node.previousSibling;if(testElement(node,method)){return node;}} | |
99 | +return null;},getPreviousSibling:function(node){node=Y.Dom.get(node);if(!node){return null;} | |
100 | +return Y.Dom.getPreviousSiblingBy(node);},getNextSiblingBy:function(node,method){while(node){node=node.nextSibling;if(testElement(node,method)){return node;}} | |
101 | +return null;},getNextSibling:function(node){node=Y.Dom.get(node);if(!node){return null;} | |
102 | +return Y.Dom.getNextSiblingBy(node);},getFirstChildBy:function(node,method){var child=(testElement(node.firstChild,method))?node.firstChild:null;return child||Y.Dom.getNextSiblingBy(node.firstChild,method);},getFirstChild:function(node,method){node=Y.Dom.get(node);if(!node){return null;} | |
103 | +return Y.Dom.getFirstChildBy(node);},getLastChildBy:function(node,method){if(!node){return null;} | |
104 | +var child=(testElement(node.lastChild,method))?node.lastChild:null;return child||Y.Dom.getPreviousSiblingBy(node.lastChild,method);},getLastChild:function(node){node=Y.Dom.get(node);return Y.Dom.getLastChildBy(node);},getChildrenBy:function(node,method){var child=Y.Dom.getFirstChildBy(node,method);var children=child?[child]:[];Y.Dom.getNextSiblingBy(child,function(node){if(!method||method(node)){children[children.length]=node;} | |
105 | +return false;});return children;},getChildren:function(node){node=Y.Dom.get(node);if(!node){} | |
106 | +return Y.Dom.getChildrenBy(node);},getDocumentScrollLeft:function(doc){doc=doc||document;return Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);},getDocumentScrollTop:function(doc){doc=doc||document;return Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);},insertBefore:function(newNode,referenceNode){newNode=Y.Dom.get(newNode);referenceNode=Y.Dom.get(referenceNode);if(!newNode||!referenceNode||!referenceNode.parentNode){return null;} | |
107 | +return referenceNode.parentNode.insertBefore(newNode,referenceNode);},insertAfter:function(newNode,referenceNode){newNode=Y.Dom.get(newNode);referenceNode=Y.Dom.get(referenceNode);if(!newNode||!referenceNode||!referenceNode.parentNode){return null;} | |
108 | +if(referenceNode.nextSibling){return referenceNode.parentNode.insertBefore(newNode,referenceNode.nextSibling);}else{return referenceNode.parentNode.appendChild(newNode);}}};})();YAHOO.util.Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;this.bottom=b;this.left=l;this[0]=l;};YAHOO.util.Region.prototype.contains=function(region){return(region.left>=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(YAHOO.lang.isArray(x)){y=x[1];x=x[0];} | |
109 | +this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.3.0",build:"442"}); | |
110 | +YAHOO.util.CustomEvent=function(type,oScope,silent,signature){this.type=type;this.scope=oScope||window;this.silent=silent;this.signature=signature||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){} | |
111 | +var onsubscribeType="_YUICEOnSubscribe";if(type!==onsubscribeType){this.subscribeEvent=new YAHOO.util.CustomEvent(onsubscribeType,this,true);}};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(fn,obj,override){if(!fn){throw new Error("Invalid callback for subscriber to '"+this.type+"'");} | |
112 | +if(this.subscribeEvent){this.subscribeEvent.fire(fn,obj,override);} | |
113 | +this.subscribers.push(new YAHOO.util.Subscriber(fn,obj,override));},unsubscribe:function(fn,obj){if(!fn){return this.unsubscribeAll();} | |
114 | +var found=false;for(var i=0,len=this.subscribers.length;i<len;++i){var s=this.subscribers[i];if(s&&s.contains(fn,obj)){this._delete(i);found=true;}} | |
115 | +return found;},fire:function(){var len=this.subscribers.length;if(!len&&this.silent){return true;} | |
116 | +var args=[],ret=true,i,rebuild=false;for(i=0;i<arguments.length;++i){args.push(arguments[i]);} | |
117 | +var argslength=args.length;if(!this.silent){} | |
118 | +for(i=0;i<len;++i){var s=this.subscribers[i];if(!s){rebuild=true;}else{if(!this.silent){} | |
119 | +var scope=s.getScope(this.scope);if(this.signature==YAHOO.util.CustomEvent.FLAT){var param=null;if(args.length>0){param=args[0];} | |
120 | +ret=s.fn.call(scope,param,s.obj);}else{ret=s.fn.call(scope,this.type,args,s.obj);} | |
121 | +if(false===ret){if(!this.silent){} | |
122 | +return false;}}} | |
123 | +if(rebuild){var newlist=[],subs=this.subscribers;for(i=0,len=subs.length;i<len;++i){s=subs[i];newlist.push(subs[i]);} | |
124 | +this.subscribers=newlist;} | |
125 | +return true;},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i<len;++i){this._delete(len-1-i);} | |
126 | +this.subscribers=[];return i;},_delete:function(index){var s=this.subscribers[index];if(s){delete s.fn;delete s.obj;} | |
127 | +this.subscribers[index]=null;},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(fn,obj,override){this.fn=fn;this.obj=YAHOO.lang.isUndefined(obj)?null:obj;this.override=override;};YAHOO.util.Subscriber.prototype.getScope=function(defaultScope){if(this.override){if(this.override===true){return this.obj;}else{return this.override;}} | |
128 | +return defaultScope;};YAHOO.util.Subscriber.prototype.contains=function(fn,obj){if(obj){return(this.fn==fn&&this.obj==obj);}else{return(this.fn==fn);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+this.obj+", override: "+(this.override||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var loadComplete=false;var DOMReady=false;var listeners=[];var unloadListeners=[];var legacyEvents=[];var legacyHandlers=[];var retryCount=0;var onAvailStack=[];var legacyMap=[];var counter=0;var webkitKeymap={63232:38,63233:40,63234:37,63235:39};return{POLL_RETRYS:4000,POLL_INTERVAL:10,EL:0,TYPE:1,FN:2,WFN:3,OBJ:3,ADJ_SCOPE:4,lastError:null,isSafari:YAHOO.env.ua.webkit,webkit:YAHOO.env.ua.webkit,isIE:YAHOO.env.ua.ie,_interval:null,startInterval:function(){if(!this._interval){var self=this;var callback=function(){self._tryPreloadAttach();};this._interval=setInterval(callback,this.POLL_INTERVAL);}},onAvailable:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:false});retryCount=this.POLL_RETRYS;this.startInterval();},onDOMReady:function(p_fn,p_obj,p_override){if(DOMReady){setTimeout(function(){var s=window;if(p_override){if(p_override===true){s=p_obj;}else{s=p_override;}} | |
129 | +p_fn.call(s,"DOMReady",[],p_obj);},0);}else{this.DOMReadyEvent.subscribe(p_fn,p_obj,p_override);}},onContentReady:function(p_id,p_fn,p_obj,p_override){onAvailStack.push({id:p_id,fn:p_fn,obj:p_obj,override:p_override,checkReady:true});retryCount=this.POLL_RETRYS;this.startInterval();},addListener:function(el,sType,fn,obj,override){if(!fn||!fn.call){return false;} | |
130 | +if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=this.on(el[i],sType,fn,obj,override)&&ok;} | |
131 | +return ok;}else if(YAHOO.lang.isString(el)){var oEl=this.getEl(el);if(oEl){el=oEl;}else{this.onAvailable(el,function(){YAHOO.util.Event.on(el,sType,fn,obj,override);});return true;}} | |
132 | +if(!el){return false;} | |
133 | +if("unload"==sType&&obj!==this){unloadListeners[unloadListeners.length]=[el,sType,fn,obj,override];return true;} | |
134 | +var scope=el;if(override){if(override===true){scope=obj;}else{scope=override;}} | |
135 | +var wrappedFn=function(e){return fn.call(scope,YAHOO.util.Event.getEvent(e),obj);};var li=[el,sType,fn,wrappedFn,scope];var index=listeners.length;listeners[index]=li;if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);if(legacyIndex==-1||el!=legacyEvents[legacyIndex][0]){legacyIndex=legacyEvents.length;legacyMap[el.id+sType]=legacyIndex;legacyEvents[legacyIndex]=[el,sType,el["on"+sType]];legacyHandlers[legacyIndex]=[];el["on"+sType]=function(e){YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e),legacyIndex);};} | |
136 | +legacyHandlers[legacyIndex].push(li);}else{try{this._simpleAdd(el,sType,wrappedFn,false);}catch(ex){this.lastError=ex;this.removeListener(el,sType,fn);return false;}} | |
137 | +return true;},fireLegacyEvent:function(e,legacyIndex){var ok=true,le,lh,li,scope,ret;lh=legacyHandlers[legacyIndex];for(var i=0,len=lh.length;i<len;++i){li=lh[i];if(li&&li[this.WFN]){scope=li[this.ADJ_SCOPE];ret=li[this.WFN].call(scope,e);ok=(ok&&ret);}} | |
138 | +le=legacyEvents[legacyIndex];if(le&&le[2]){le[2](e);} | |
139 | +return ok;},getLegacyIndex:function(el,sType){var key=this.generateId(el)+sType;if(typeof legacyMap[key]=="undefined"){return-1;}else{return legacyMap[key];}},useLegacyEvent:function(el,sType){if(this.webkit&&("click"==sType||"dblclick"==sType)){var v=parseInt(this.webkit,10);if(!isNaN(v)&&v<418){return true;}} | |
140 | +return false;},removeListener:function(el,sType,fn){var i,len;if(typeof el=="string"){el=this.getEl(el);}else if(this._isValidCollection(el)){var ok=true;for(i=0,len=el.length;i<len;++i){ok=(this.removeListener(el[i],sType,fn)&&ok);} | |
141 | +return ok;} | |
142 | +if(!fn||!fn.call){return this.purgeElement(el,false,sType);} | |
143 | +if("unload"==sType){for(i=0,len=unloadListeners.length;i<len;i++){var li=unloadListeners[i];if(li&&li[0]==el&&li[1]==sType&&li[2]==fn){unloadListeners[i]=null;return true;}} | |
144 | +return false;} | |
145 | +var cacheItem=null;var index=arguments[3];if("undefined"==typeof index){index=this._getCacheIndex(el,sType,fn);} | |
146 | +if(index>=0){cacheItem=listeners[index];} | |
147 | +if(!el||!cacheItem){return false;} | |
148 | +if(this.useLegacyEvent(el,sType)){var legacyIndex=this.getLegacyIndex(el,sType);var llist=legacyHandlers[legacyIndex];if(llist){for(i=0,len=llist.length;i<len;++i){li=llist[i];if(li&&li[this.EL]==el&&li[this.TYPE]==sType&&li[this.FN]==fn){llist[i]=null;break;}}}}else{try{this._simpleRemove(el,sType,cacheItem[this.WFN],false);}catch(ex){this.lastError=ex;return false;}} | |
149 | +delete listeners[index][this.WFN];delete listeners[index][this.FN];listeners[index]=null;return true;},getTarget:function(ev,resolveTextNode){var t=ev.target||ev.srcElement;return this.resolveTextNode(t);},resolveTextNode:function(node){if(node&&3==node.nodeType){return node.parentNode;}else{return node;}},getPageX:function(ev){var x=ev.pageX;if(!x&&0!==x){x=ev.clientX||0;if(this.isIE){x+=this._getScrollLeft();}} | |
150 | +return x;},getPageY:function(ev){var y=ev.pageY;if(!y&&0!==y){y=ev.clientY||0;if(this.isIE){y+=this._getScrollTop();}} | |
151 | +return y;},getXY:function(ev){return[this.getPageX(ev),this.getPageY(ev)];},getRelatedTarget:function(ev){var t=ev.relatedTarget;if(!t){if(ev.type=="mouseout"){t=ev.toElement;}else if(ev.type=="mouseover"){t=ev.fromElement;}} | |
152 | +return this.resolveTextNode(t);},getTime:function(ev){if(!ev.time){var t=new Date().getTime();try{ev.time=t;}catch(ex){this.lastError=ex;return t;}} | |
153 | +return ev.time;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getEvent:function(e){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;} | |
154 | +c=c.caller;}} | |
155 | +return ev;},getCharCode:function(ev){var code=ev.keyCode||ev.charCode||0;if(YAHOO.env.ua.webkit&&(code in webkitKeymap)){code=webkitKeymap[code];} | |
156 | +return code;},_getCacheIndex:function(el,sType,fn){for(var i=0,len=listeners.length;i<len;++i){var li=listeners[i];if(li&&li[this.FN]==fn&&li[this.EL]==el&&li[this.TYPE]==sType){return i;}} | |
157 | +return-1;},generateId:function(el){var id=el.id;if(!id){id="yuievtautoid-"+counter;++counter;el.id=id;} | |
158 | +return id;},_isValidCollection:function(o){try{return(o&&o.length&&typeof o!="string"&&!o.tagName&&!o.alert&&typeof o[0]!="undefined");}catch(e){return false;}},elCache:{},getEl:function(id){return document.getElementById(id);},clearCache:function(){},DOMReadyEvent:new YAHOO.util.CustomEvent("DOMReady",this),_load:function(e){if(!loadComplete){loadComplete=true;var EU=YAHOO.util.Event;EU._ready();EU._tryPreloadAttach();}},_ready:function(e){if(!DOMReady){DOMReady=true;var EU=YAHOO.util.Event;EU.DOMReadyEvent.fire();EU._simpleRemove(document,"DOMContentLoaded",EU._ready);}},_tryPreloadAttach:function(){if(this.locked){return false;} | |
159 | +if(this.isIE){if(!DOMReady){this.startInterval();return false;}} | |
160 | +this.locked=true;var tryAgain=!loadComplete;if(!tryAgain){tryAgain=(retryCount>0);} | |
161 | +var notAvail=[];var executeItem=function(el,item){var scope=el;if(item.override){if(item.override===true){scope=item.obj;}else{scope=item.override;}} | |
162 | +item.fn.call(scope,item.obj);};var i,len,item,el;for(i=0,len=onAvailStack.length;i<len;++i){item=onAvailStack[i];if(item&&!item.checkReady){el=this.getEl(item.id);if(el){executeItem(el,item);onAvailStack[i]=null;}else{notAvail.push(item);}}} | |
163 | +for(i=0,len=onAvailStack.length;i<len;++i){item=onAvailStack[i];if(item&&item.checkReady){el=this.getEl(item.id);if(el){if(loadComplete||el.nextSibling){executeItem(el,item);onAvailStack[i]=null;}}else{notAvail.push(item);}}} | |
164 | +retryCount=(notAvail.length===0)?0:retryCount-1;if(tryAgain){this.startInterval();}else{clearInterval(this._interval);this._interval=null;} | |
165 | +this.locked=false;return true;},purgeElement:function(el,recurse,sType){var elListeners=this.getListeners(el,sType);if(elListeners){for(var i=0,len=elListeners.length;i<len;++i){var l=elListeners[i];this.removeListener(el,l.type,l.fn,l.index);}} | |
166 | +if(recurse&&el&&el.childNodes){for(i=0,len=el.childNodes.length;i<len;++i){this.purgeElement(el.childNodes[i],recurse,sType);}}},getListeners:function(el,sType){var results=[],searchLists;if(!sType){searchLists=[listeners,unloadListeners];}else if(sType=="unload"){searchLists=[unloadListeners];}else{searchLists=[listeners];} | |
167 | +for(var j=0;j<searchLists.length;++j){var searchList=searchLists[j];if(searchList&&searchList.length>0){for(var i=0,len=searchList.length;i<len;++i){var l=searchList[i];if(l&&l[this.EL]===el&&(!sType||sType===l[this.TYPE])){results.push({type:l[this.TYPE],fn:l[this.FN],obj:l[this.OBJ],adjust:l[this.ADJ_SCOPE],index:i});}}}} | |
168 | +return(results.length)?results:null;},_unload:function(e){var EU=YAHOO.util.Event,i,j,l,len,index;for(i=0,len=unloadListeners.length;i<len;++i){l=unloadListeners[i];if(l){var scope=window;if(l[EU.ADJ_SCOPE]){if(l[EU.ADJ_SCOPE]===true){scope=l[EU.OBJ];}else{scope=l[EU.ADJ_SCOPE];}} | |
169 | +l[EU.FN].call(scope,EU.getEvent(e),l[EU.OBJ]);unloadListeners[i]=null;l=null;scope=null;}} | |
170 | +unloadListeners=null;if(listeners&&listeners.length>0){j=listeners.length;while(j){index=j-1;l=listeners[index];if(l){EU.removeListener(l[EU.EL],l[EU.TYPE],l[EU.FN],index);} | |
171 | +j=j-1;} | |
172 | +l=null;EU.clearCache();} | |
173 | +for(i=0,len=legacyEvents.length;i<len;++i){legacyEvents[i][0]=null;legacyEvents[i]=null;} | |
174 | +legacyEvents=null;EU._simpleRemove(window,"unload",EU._unload);},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var dd=document.documentElement,db=document.body;if(dd&&(dd.scrollTop||dd.scrollLeft)){return[dd.scrollTop,dd.scrollLeft];}else if(db){return[db.scrollTop,db.scrollLeft];}else{return[0,0];}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(el,sType,fn,capture){el.addEventListener(sType,fn,(capture));};}else if(window.attachEvent){return function(el,sType,fn,capture){el.attachEvent("on"+sType,fn);};}else{return function(){};}}(),_simpleRemove:function(){if(window.removeEventListener){return function(el,sType,fn,capture){el.removeEventListener(sType,fn,(capture));};}else if(window.detachEvent){return function(el,sType,fn){el.detachEvent("on"+sType,fn);};}else{return function(){};}}()};}();(function(){var EU=YAHOO.util.Event;EU.on=EU.addListener;if(EU.isIE){YAHOO.util.Event.onDOMReady(YAHOO.util.Event._tryPreloadAttach,YAHOO.util.Event,true);var el,d=document,b=d.body;if(("undefined"!==typeof YAHOO_config)&&YAHOO_config.injecting){el=document.createElement("script");var p=d.getElementsByTagName("head")[0]||b;p.insertBefore(el,p.firstChild);}else{d.write('<scr'+'ipt id="_yui_eu_dr" defer="true" src="//:"><'+'/script>');el=document.getElementById("_yui_eu_dr");} | |
175 | +if(el){el.onreadystatechange=function(){if("complete"===this.readyState){this.parentNode.removeChild(this);YAHOO.util.Event._ready();}};}else{} | |
176 | +el=null;}else if(EU.webkit){EU._drwatch=setInterval(function(){var rs=document.readyState;if("loaded"==rs||"complete"==rs){clearInterval(EU._drwatch);EU._drwatch=null;EU._ready();}},EU.POLL_INTERVAL);}else{EU._simpleAdd(document,"DOMContentLoaded",EU._ready);} | |
177 | +EU._simpleAdd(window,"load",EU._load);EU._simpleAdd(window,"unload",EU._unload);EU._tryPreloadAttach();})();} | |
178 | +YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(p_type,p_fn,p_obj,p_override){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(ce){ce.subscribe(p_fn,p_obj,p_override);}else{this.__yui_subscribers=this.__yui_subscribers||{};var subs=this.__yui_subscribers;if(!subs[p_type]){subs[p_type]=[];} | |
179 | +subs[p_type].push({fn:p_fn,obj:p_obj,override:p_override});}},unsubscribe:function(p_type,p_fn,p_obj){this.__yui_events=this.__yui_events||{};var evts=this.__yui_events;if(p_type){var ce=evts[p_type];if(ce){return ce.unsubscribe(p_fn,p_obj);}}else{for(var i in evts){var ret=true;if(YAHOO.lang.hasOwnProperty(evts,i)){ret=ret&&evts[i].unsubscribe(p_fn,p_obj);}} | |
180 | +return ret;} | |
181 | +return false;},unsubscribeAll:function(p_type){return this.unsubscribe(p_type);},createEvent:function(p_type,p_config){this.__yui_events=this.__yui_events||{};var opts=p_config||{};var events=this.__yui_events;if(events[p_type]){}else{var scope=opts.scope||this;var silent=(opts.silent);var ce=new YAHOO.util.CustomEvent(p_type,scope,silent,YAHOO.util.CustomEvent.FLAT);events[p_type]=ce;if(opts.onSubscribeCallback){ce.subscribeEvent.subscribe(opts.onSubscribeCallback);} | |
182 | +this.__yui_subscribers=this.__yui_subscribers||{};var qs=this.__yui_subscribers[p_type];if(qs){for(var i=0;i<qs.length;++i){ce.subscribe(qs[i].fn,qs[i].obj,qs[i].override);}}} | |
183 | +return events[p_type];},fireEvent:function(p_type,arg1,arg2,etc){this.__yui_events=this.__yui_events||{};var ce=this.__yui_events[p_type];if(!ce){return null;} | |
184 | +var args=[];for(var i=1;i<arguments.length;++i){args.push(arguments[i]);} | |
185 | +return ce.fire.apply(ce,args);},hasEvent:function(type){if(this.__yui_events){if(this.__yui_events[type]){return true;}} | |
186 | +return false;}};YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!attachTo){}else if(!keyData){}else if(!handler){} | |
187 | +if(!event){event=YAHOO.util.KeyListener.KEYDOWN;} | |
188 | +var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);} | |
189 | +if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);} | |
190 | +function handleKeyPress(e,obj){if(!keyData.shift){keyData.shift=false;} | |
191 | +if(!keyData.alt){keyData.alt=false;} | |
192 | +if(!keyData.ctrl){keyData.ctrl=false;} | |
193 | +if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){var dataItem;var keyPressed;if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){dataItem=keyData.keys[i];if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);break;}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);break;}}}else{dataItem=keyData.keys;if(dataItem==e.charCode){keyEvent.fire(e.charCode,e);}else if(dataItem==e.keyCode){keyEvent.fire(e.keyCode,e);}}}} | |
194 | +this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);} | |
195 | +this.enabled=true;};this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);} | |
196 | +this.enabled=false;};this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+ | |
197 | +(attachTo.id?"["+attachTo.id+"]":"");};};YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.register("event",YAHOO.util.Event,{version:"2.3.0",build:"442"});YAHOO.register("yahoo-dom-event", YAHOO, {version: "2.3.0", build: "442"}); | ... | ... |