1
|
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
|
2
|
<html>
|
3
|
<head>
|
4
|
<title>
|
5
|
<a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008 Overview
|
6
|
</title>
|
7
|
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
|
8
|
<script>
|
9
|
function asd() {
|
10
|
|
11
|
parent.document.title="TipWidgetOL.js Overview";
|
12
|
|
13
|
}
|
14
|
</script>
|
15
|
</head>
|
16
|
<body bgcolor="white" onload="asd();">
|
17
|
|
18
|
<!-- ========== START OF NAVBAR ========== -->
|
19
|
<a name="navbar_top"><!-- --></a>
|
20
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
21
|
<tr>
|
22
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
23
|
<a name="navbar_top_firstrow"><!-- --></a>
|
24
|
<table border="0" cellpadding="0" cellspacing="3">
|
25
|
<tr align="center" valign="top">
|
26
|
|
27
|
|
28
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
29
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
30
|
|
31
|
|
32
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
33
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
34
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
35
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
36
|
</tr>
|
37
|
</table>
|
38
|
</td>
|
39
|
<td bgcolor="#EEEEFF" align="right" valign="top">
|
40
|
<em>
|
41
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
42
|
</td>
|
43
|
</tr>
|
44
|
|
45
|
<tr>
|
46
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
47
|
PREV
|
48
|
NEXT</font></td>
|
49
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
50
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
51
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
52
|
|
53
|
<script>
|
54
|
<!--
|
55
|
if(window==top) {
|
56
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
57
|
}
|
58
|
//-->
|
59
|
</script>
|
60
|
<noscript>
|
61
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
62
|
</noscript>
|
63
|
</font></td>
|
64
|
</tr>
|
65
|
</table>
|
66
|
<!-- =========== END OF NAVBAR =========== -->
|
67
|
|
68
|
<hr>
|
69
|
<center>
|
70
|
|
71
|
<h2>TipWidgetOL.js</h2>
|
72
|
|
73
|
</center>
|
74
|
|
75
|
|
76
|
|
77
|
|
78
|
<h4>Summary</h4>
|
79
|
<p>
|
80
|
|
81
|
No overview generated for 'TipWidgetOL.js'<BR/><BR/>
|
82
|
|
83
|
</p>
|
84
|
|
85
|
<hr>
|
86
|
|
87
|
|
88
|
<table border="1" cellpadding="3" cellspacing="0" width="100%">
|
89
|
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
|
90
|
<td colspan=2><font size="+2">
|
91
|
|
92
|
<b>Class Summary</b>
|
93
|
|
94
|
</font></td>
|
95
|
</tr>
|
96
|
|
97
|
<tr bgcolor="white" class="TableRowColor">
|
98
|
<td width="15%"><b><a href="TipWidgetOL.html">TipWidgetOL</a></b></td>
|
99
|
<td> </td>
|
100
|
</tr>
|
101
|
|
102
|
</table>
|
103
|
<hr/>
|
104
|
|
105
|
|
106
|
<!-- ========== METHOD SUMMARY =========== -->
|
107
|
|
108
|
<!-- ========== END METHOD SUMMARY =========== -->
|
109
|
|
110
|
|
111
|
<pre class="sourceview"><span class="comment">/*
|
112
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
113
|
$Id: TipWidgetOL.js 3955 2008-03-31 13:00:49Z ahocevar $
|
114
|
*/</span>
|
115
|
<span class="comment">
|
116
|
// Ensure this object's dependancies are loaded.</span>
|
117
|
mapbuilder.loadScript(baseDir+<span class="literal">"/widget/TipWidgetBase.js"</span>);
|
118
|
mapbuilder.loadScript(baseDir+<span class="literal">"/util/openlayers/OpenLayers.js"</span>);
|
119
|
|
120
|
<span class="comment">/**
|
121
|
* Manages MapTips on the map. This widget works with models that
|
122
|
* have a FeatureSelectHandler tool.
|
123
|
* <span class="attrib">@base</span> TipWidgetBase
|
124
|
* <span class="attrib">@author</span> Andreas Hocevar andreas.hocevarATgmail.com
|
125
|
* <span class="attrib">@param</span> widgetNode The tool node from the Config XML file.
|
126
|
* <span class="attrib">@param</span> model The ButtonBar widget.
|
127
|
*/</span>
|
128
|
<span class="reserved">function</span> TipWidgetOL(widgetNode, model) {
|
129
|
TipWidgetBase.apply(<span class="reserved">this</span>, new Array(widgetNode, model));
|
130
|
|
131
|
<span class="comment">/**
|
132
|
* This method is triggered when a user clicks on a feature.
|
133
|
* <span class="attrib">@param</span> objRef reference to this widget
|
134
|
*/</span>
|
135
|
<span class="reserved">this</span>.onClick = <span class="reserved">function</span>(objRef) {
|
136
|
var evt = objRef.model.getParam(<span class="literal">"olFeatureSelect"</span>);
|
137
|
var popup = objRef.createPopup(objRef, evt, false);
|
138
|
evt.feature.layer.mbClickPopup = popup;
|
139
|
}
|
140
|
|
141
|
<span class="comment">/**
|
142
|
* This method is triggered when the mouse is over a feature.
|
143
|
* <span class="attrib">@param</span> objRef reference to this widget
|
144
|
*/</span>
|
145
|
<span class="reserved">this</span>.onMouseover = <span class="reserved">function</span>(objRef) {
|
146
|
var evt = objRef.model.getParam(<span class="literal">"olFeatureHover"</span>);
|
147
|
<span class="comment"> // only create popup if there is no visible click popup</span>
|
148
|
<span class="reserved">if</span> (evt.feature && !evt.feature.layer.mbClickPopup || !evt.feature.layer.mbClickPopup.visible()) {
|
149
|
var popup = objRef.createPopup(objRef, evt, true);
|
150
|
evt.feature.layer.mbHoverPopup = popup;
|
151
|
<span class="comment"> // if the olFeatureOut event gets lost (eg during drag operation),</span>
|
152
|
<span class="comment"> // registering this additional event will help to get rid of the</span>
|
153
|
<span class="comment"> // popup quickly</span>
|
154
|
popup.events.register(<span class="literal">'mouseover'</span>, popup, popup.hide);
|
155
|
}
|
156
|
}
|
157
|
|
158
|
<span class="comment">/**
|
159
|
* This method is triggered when the mouse moves out of a feature.
|
160
|
* <span class="attrib">@param</span> objRef reference to this widget
|
161
|
*/</span>
|
162
|
<span class="reserved">this</span>.onMouseout = <span class="reserved">function</span>(objRef) {
|
163
|
var feature = objRef.model.getParam(<span class="literal">"olFeatureOut"</span>);
|
164
|
<span class="reserved">if</span> (feature && feature.layer && feature.layer.mbHoverPopup) {
|
165
|
feature.layer.mbHoverPopup.destroy();
|
166
|
feature.layer.mbHoverPopup = null;
|
167
|
}
|
168
|
}
|
169
|
|
170
|
<span class="comment">/**
|
171
|
* Creates a popup.
|
172
|
* <span class="attrib">@param</span> objRef reference to this widget
|
173
|
* <span class="attrib">@param</span> evt OpenLayers.Event that triggered the popup action
|
174
|
* <span class="attrib">@param</span> hover true if the popup should be styled as a hover popup,
|
175
|
* false if it is a click popup.
|
176
|
* <span class="attrib">@return</span> reference to the created popup
|
177
|
*/</span>
|
178
|
<span class="reserved">this</span>.createPopup = <span class="reserved">function</span>(objRef, evt, hover) {
|
179
|
var feature = evt.feature;
|
180
|
<span class="comment"> // check if there is a source model linked with this feature</span>
|
181
|
var sourceNode = objRef.model.doc.selectSingleNode(<span class="literal">"//*[@fid='"</span>+feature.fid+<span class="literal">"']"</span>);
|
182
|
var sourceModel = null;
|
183
|
<span class="reserved">if</span> (sourceNode) {
|
184
|
sourceModel = sourceNode.getAttribute(<span class="literal">'sourceModel'</span>);
|
185
|
}
|
186
|
<span class="comment"> // if so, use the config from the source model</span>
|
187
|
var widgetConfig = null;
|
188
|
<span class="reserved">if</span> (sourceModel && config.objects[sourceModel].config && config.objects[sourceModel].config[objRef.id]) {
|
189
|
widgetConfig = config.objects[sourceModel].config[objRef.id];
|
190
|
} <span class="reserved">else</span> {
|
191
|
widgetConfig = objRef.config;
|
192
|
}
|
193
|
widgetConfig.stylesheet.setParameter(<span class="literal">'fid'</span>, feature.fid);
|
194
|
var lonlat = feature.layer.map.getLonLatFromPixel(evt.xy);
|
195
|
var popup = new Mapbuilder.Popup(null, lonlat, new OpenLayers.Size(widgetConfig.width, widgetConfig.height),
|
196
|
new XMLSerializer().serializeToString(widgetConfig.stylesheet.transformNodeToObject(widgetConfig.model.doc)).replace(/&lt;/g,<span class="literal">"<"</span>).replace(/&gt;/g,<span class="literal">">"</span>).replace(/&amp;/g,<span class="literal">"&"</span>),
|
197
|
null, hover == false);
|
198
|
popup.setOpacity(widgetConfig.opacity);
|
199
|
popup.setBackgroundColor(widgetConfig.backgroundColor);
|
200
|
popup.setBorder(widgetConfig.border);
|
201
|
var quadrant = feature.layer.map.getExtent().determineQuadrant(lonlat);
|
202
|
var lonOffset = quadrant.charAt(1) == <span class="literal">'r'</span> ? -5 : 5;
|
203
|
var latOffset = quadrant.charAt(0) == <span class="literal">'t'</span> ? 5 : -5;
|
204
|
popup.anchor = { size: new OpenLayers.Size(0,0), offset: new OpenLayers.Pixel(lonOffset, latOffset)};
|
205
|
|
206
|
feature.layer.map.addPopup(popup, true);
|
207
|
<span class="reserved">return</span> popup;
|
208
|
}
|
209
|
|
210
|
}
|
211
|
|
212
|
<span class="comment">/**
|
213
|
* Derived from OpenLayers.Popup (svn r6430) and
|
214
|
* OpenLayers.Popup.Anchored (svn r5614), this class preserves the
|
215
|
* functionality of OpenLayers.Popup.Anchored before the new style popups
|
216
|
* of http://trac.openlayers.org/ticket/926 were introduced.
|
217
|
*/</span>
|
218
|
Mapbuilder.Popup = OpenLayers.Class(OpenLayers.Popup.Anchored, {
|
219
|
|
220
|
initialize: <span class="reserved">function</span>(id, lonlat, size, contentHTML, anchor, closeBox,
|
221
|
closeBoxCallback) {
|
222
|
OpenLayers.Popup.Anchored.<span class="reserved">prototype</span>.initialize.apply(<span class="reserved">this</span>, arguments);
|
223
|
<span class="reserved">this</span>.contentDiv.style.overflow = <span class="literal">"hidden"</span>;
|
224
|
},
|
225
|
|
226
|
setSize:<span class="reserved">function</span>(size) {
|
227
|
<span class="reserved">if</span> (size != undefined) {
|
228
|
<span class="reserved">this</span>.size = size;
|
229
|
}
|
230
|
|
231
|
<span class="reserved">if</span> (<span class="reserved">this</span>.div != null) {
|
232
|
<span class="reserved">this</span>.div.style.width = <span class="reserved">this</span>.size.w + <span class="literal">"px"</span>;
|
233
|
<span class="reserved">this</span>.div.style.height = <span class="reserved">this</span>.size.h + <span class="literal">"px"</span>;
|
234
|
}
|
235
|
<span class="reserved">if</span> (<span class="reserved">this</span>.contentDiv != null){
|
236
|
<span class="reserved">this</span>.contentDiv.style.width = <span class="reserved">this</span>.size.w + <span class="literal">"px"</span>;
|
237
|
<span class="reserved">this</span>.contentDiv.style.height = <span class="reserved">this</span>.size.h + <span class="literal">"px"</span>;
|
238
|
}
|
239
|
|
240
|
<span class="reserved">if</span> ((<span class="reserved">this</span>.lonlat) && (<span class="reserved">this</span>.map)) {
|
241
|
var px = <span class="reserved">this</span>.map.getLayerPxFromLonLat(<span class="reserved">this</span>.lonlat);
|
242
|
<span class="reserved">this</span>.moveTo(px);
|
243
|
}
|
244
|
},
|
245
|
|
246
|
addCloseBox:<span class="reserved">function</span>(closeBoxCallback) {
|
247
|
<span class="comment"> // close icon</span>
|
248
|
var closeSize = new OpenLayers.Size(17,17);
|
249
|
var img = config.skinDir + <span class="literal">"/openlayers/img/close.gif"</span>;
|
250
|
<span class="reserved">this</span>.closeDiv = OpenLayers.Util.createAlphaImageDiv(
|
251
|
<span class="reserved">this</span>.id + <span class="literal">"_close"</span>, null, closeSize, img
|
252
|
);
|
253
|
<span class="reserved">this</span>.closeDiv.style.right = <span class="reserved">this</span>.padding + <span class="literal">"px"</span>;
|
254
|
<span class="reserved">this</span>.closeDiv.style.top = <span class="reserved">this</span>.padding + <span class="literal">"px"</span>;
|
255
|
<span class="reserved">this</span>.groupDiv.appendChild(<span class="reserved">this</span>.closeDiv);
|
256
|
|
257
|
var closePopup = closeBoxCallback || <span class="reserved">function</span>(e) {
|
258
|
<span class="reserved">this</span>.hide();
|
259
|
OpenLayers.Event.stop(e);
|
260
|
};
|
261
|
OpenLayers.Event.observe(<span class="reserved">this</span>.closeDiv, <span class="literal">"click"</span>,
|
262
|
OpenLayers.Function.bindAsEventListener(closePopup, <span class="reserved">this</span>));
|
263
|
},
|
264
|
|
265
|
CLASS_NAME: <span class="literal">"Mapbuilder.Popup"</span>
|
266
|
});
|
267
|
|
268
|
</pre>
|
269
|
<hr>
|
270
|
|
271
|
|
272
|
|
273
|
<!-- ========== START OF NAVBAR ========== -->
|
274
|
<a name="navbar_top"><!-- --></a>
|
275
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
276
|
<tr>
|
277
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
278
|
<a name="navbar_top_firstrow"><!-- --></a>
|
279
|
<table border="0" cellpadding="0" cellspacing="3">
|
280
|
<tr align="center" valign="top">
|
281
|
|
282
|
|
283
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
284
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
285
|
|
286
|
|
287
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
288
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
289
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
290
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
291
|
</tr>
|
292
|
</table>
|
293
|
</td>
|
294
|
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
|
295
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
296
|
</td>
|
297
|
</tr>
|
298
|
|
299
|
<tr>
|
300
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
301
|
PREV
|
302
|
NEXT</font></td>
|
303
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
304
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
305
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
306
|
|
307
|
<script>
|
308
|
<!--
|
309
|
if(window==top) {
|
310
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
311
|
}
|
312
|
//-->
|
313
|
</script>
|
314
|
<noscript>
|
315
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
316
|
</noscript>
|
317
|
</font></td>
|
318
|
</tr>
|
319
|
</table>
|
320
|
<!-- =========== END OF NAVBAR =========== -->
|
321
|
|
322
|
<hr>
|
323
|
<font size="-1">
|
324
|
|
325
|
</font>
|
326
|
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sun Apr 27 20:30:54 2008</div>
|
327
|
</body>
|
328
|
</html>
|