Project

General

Profile

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="WidgetBase.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>&nbsp;</td>
29
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
30
  
31

    
32
  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
33
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
34
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
35
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</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
&nbsp;PREV&nbsp;
48
&nbsp;NEXT</font></td>
49
<td bgcolor="white" class="NavBarCell2"><font size="-2">
50
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
51
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
52
&nbsp;&nbsp;
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>WidgetBase.js</h2>
72
	
73
</center>
74

    
75
	
76

    
77

    
78
<h4>Summary</h4>
79
<p>
80
	
81
		No overview generated for 'WidgetBase.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="WidgetBase.html">WidgetBase</a></b></td>
99
    <td>&nbsp;</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: WidgetBase.js 3880 2008-02-27 15:37:08Z gjvoosten $
114
*/</span>
115

    
116
<span class="comment">/**
117
 * Base Class for widgets. All widgets must extend this base class.
118
 * Defines the default prePaint() and postPaint() methods for all widgets.
119
 *
120
 * <span class="attrib">@constructor</span>
121
 * <span class="attrib">@author</span> Mike Adair 
122
 * <span class="attrib">@param</span> widget      Pointer to the widget instance being created
123
 * <span class="attrib">@param</span> widgetNode  The widget's XML object node from the configuration document.
124
 * <span class="attrib">@param</span> model       The model object that this widget belongs to.
125
 */</span>
126
<span class="reserved">function</span> WidgetBase(widgetNode,model) {
127
  <span class="reserved">this</span>.model = model;
128
  <span class="reserved">this</span>.widgetNode = widgetNode;
129
<span class="comment">//alert(widgetNode.nodeName);</span>
130
	var templatedWidget = false;
131
	<span class="reserved">if</span>(model.modelNode.attributes.getNamedItem(<span class="literal">"createByTemplate"</span>) &amp;&amp; model.modelNode.attributes.getNamedItem(<span class="literal">"createByTemplate"</span>).nodeValue==<span class="literal">'true'</span>){
132
		widgetNode.setAttribute(<span class="literal">"id"</span>,<span class="literal">"MbWidget_"</span> + mbIds.getId());
133
	  templatedWidget = true;
134
  }
135

    
136
  <span class="comment">/** Widget's Id defined in the Config (required) */</span>
137
  <span class="reserved">if</span> (widgetNode.attributes.getNamedItem(<span class="literal">"id"</span>)) {
138
    <span class="reserved">this</span>.id = widgetNode.attributes.getNamedItem(<span class="literal">"id"</span>).nodeValue;
139
  } <span class="reserved">else</span> {
140
    alert(mbGetMessage(<span class="literal">"idRequired"</span>, widgetNode.nodeName));
141
  }
142
  
143
  <span class="comment">/**
144
   * Convenient access to Mapbuilder.getProperty
145
   * <span class="attrib">@param</span> property property to get
146
   * <span class="attrib">@param</span> default value to use if property is not set
147
   * <span class="attrib">@return</span> the value for the property
148
   */</span>
149
  <span class="reserved">this</span>.getProperty = <span class="reserved">function</span>(property, defaultValue) {
150
    <span class="reserved">return</span> Mapbuilder.getProperty(widgetNode, property, defaultValue);
151
  }
152
<span class="comment">
153
  //allow the widget output to be replaced on each paint call</span>
154
  <span class="reserved">if</span>(templatedWidget){
155
    <span class="reserved">this</span>.outputNodeId = <span class="reserved">this</span>.id;
156
  }<span class="reserved">else</span> {
157
    <span class="reserved">this</span>.outputNodeId = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:outputNodeId"</span>, <span class="literal">"MbWidget_"</span> + mbIds.getId());
158
  }
159
<span class="comment">
160
  //until htmlTagNode becomes required allow setting of it by widget id</span>
161
  <span class="reserved">if</span> (!<span class="reserved">this</span>.htmlTagId) {
162
    <span class="reserved">this</span>.htmlTagId = <span class="reserved">this</span>.getProperty(<span class="literal">"mb:htmlTagId"</span>, <span class="reserved">this</span>.id);
163
  }
164

    
165
  <span class="reserved">this</span>.getNode = <span class="reserved">function</span>() {
166
<span class="comment">    // Node in main HTML to attach widget to.</span>
167
    var node = document.getElementById(<span class="reserved">this</span>.htmlTagId);
168
    <span class="reserved">if</span>(!node) {
169
<span class="comment">      //alert("htmlTagId: "+this.htmlTagId+" for widget "+widgetNode.nodeName+" not found in config");</span>
170
    }
171
    <span class="reserved">return</span> node;
172
  }
173
<span class="comment">
174
  //allow widgets to not automatically update themseleves in certain circumstances (see layerControl for example)</span>
175
  <span class="reserved">this</span>.autoRefresh = Mapbuilder.parseBoolean(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:autoRefresh"</span>, true));
176
<span class="comment">
177
  //set a debug property in config to see inputs and outputs of stylehseet</span>
178
  <span class="reserved">this</span>.debug = Mapbuilder.parseBoolean(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:debug"</span>, false));
179

    
180
  <span class="comment">/**
181
   * Initialize dynamic properties.set the target model
182
   * <span class="attrib">@param</span> toolRef Pointer to this object.
183
   */</span>
184
  <span class="reserved">this</span>.initTargetModel = <span class="reserved">function</span>(objRef) {
185
<span class="comment">    //set the target model</span>
186
    var targetModel = objRef.getProperty(<span class="literal">"mb:targetModel"</span>);
187
    <span class="reserved">if</span> (targetModel) {
188
      objRef.targetModel = window.config.objects[targetModel];
189
      <span class="reserved">if</span> ( !objRef.targetModel ) {
190
        alert(mbGetMessage(<span class="literal">"noTargetModelWidget"</span>, targetModel, objRef.id));
191
      }
192
    } <span class="reserved">else</span> {
193
      objRef.targetModel = objRef.model;
194
    }
195
  }
196
  <span class="reserved">this</span>.model.addListener(<span class="literal">"init"</span>, <span class="reserved">this</span>.initTargetModel, <span class="reserved">this</span>);
197

    
198
  <span class="comment">/**
199
   * Called before paint(), can be used to set up a widget's paint parameters,
200
   * or modify model using this.resultDoc().
201
   * <span class="attrib">@param</span> objRef Pointer to this object.
202
   */</span>
203
  <span class="reserved">this</span>.prePaint = <span class="reserved">function</span>(objRef) {
204
<span class="comment">    //no-op by default</span>
205
  }
206

    
207
  <span class="comment">/**
208
   * Called after paint(), can be used to initialize things that depend on the
209
   * the widget output being presetn, eg. form and form elements
210
   * <span class="attrib">@param</span> objRef Pointer to this object.
211
   */</span>
212
  <span class="reserved">this</span>.postPaint = <span class="reserved">function</span>(objRef) {
213
<span class="comment">    //no-op by default</span>
214
  }
215

    
216
  <span class="comment">/**
217
   * Remove widget from display.
218
   * <span class="attrib">@param</span> objRef Pointer to this object.
219
   */</span> 
220
  <span class="reserved">this</span>.clearWidget = <span class="reserved">function</span>(objRef) {
221
<span class="comment">    //with node remove child</span>
222
    var outputNode = document.getElementById( objRef.outputNodeId );
223
    var node = objRef.getNode();
224
    <span class="reserved">if</span> (node &amp;&amp; outputNode) node.removeChild(outputNode);
225
  }
226
  <span class="reserved">this</span>.model.addListener(<span class="literal">"newModel"</span>,<span class="reserved">this</span>.clearWidget, <span class="reserved">this</span>);
227
}
228
</pre>
229
	<hr>
230

    
231

    
232

    
233
<!-- ========== START OF NAVBAR ========== -->
234
<a name="navbar_top"><!-- --></a>
235
<table border="0" width="100%" cellpadding="1" cellspacing="0">
236
<tr>
237
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
238
<a name="navbar_top_firstrow"><!-- --></a>
239
<table border="0" cellpadding="0" cellspacing="3">
240
  <tr align="center" valign="top">
241
  
242
  
243
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
244
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
245
  
246

    
247
  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
248
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
249
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
250
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
251
  </tr>
252
</table>
253
</td>
254
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
255
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
256
</td>
257
</tr>
258

    
259
<tr>
260
<td bgcolor="white" class="NavBarCell2"><font size="-2">
261
&nbsp;PREV&nbsp;
262
&nbsp;NEXT</font></td>
263
<td bgcolor="white" class="NavBarCell2"><font size="-2">
264
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
265
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
266
&nbsp;&nbsp;
267
<script>
268
  <!--
269
  if(window==top) {
270
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
271
  }
272
  //-->
273
</script>
274
<noscript>
275
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
276
</noscript>
277
</font></td>
278
</tr>
279
</table>
280
<!-- =========== END OF NAVBAR =========== -->
281

    
282
<hr>
283
<font size="-1">
284

    
285
</font>
286
<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>
287
</body>
288
</html>
(306-306/316)