1 |
4307
|
leinfelder
|
<!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="WidgetBaseXSL.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>WidgetBaseXSL.js</h2>
|
72 |
|
|
|
73 |
|
|
</center>
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
<h4>Summary</h4>
|
79 |
|
|
<p>
|
80 |
|
|
|
81 |
|
|
No overview generated for 'WidgetBaseXSL.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="WidgetBaseXSL.html">WidgetBaseXSL</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: WidgetBaseXSL.js 3892 2008-02-29 18:21:12Z ahocevar $
|
114 |
|
|
*/</span>
|
115 |
|
|
|
116 |
|
|
mapbuilder.loadScript(baseDir+<span class="literal">"/widget/WidgetBase.js"</span>);
|
117 |
|
|
|
118 |
|
|
<span class="comment">/**
|
119 |
|
|
* Base Class for widgets. Associates a node on the page with a stylesheet and
|
120 |
|
|
* model. All widgets must extend this base class.
|
121 |
|
|
* Defines the default paint() method for all widgets which is where the
|
122 |
|
|
* stylesheet is applied to the model XML document.
|
123 |
|
|
* To override widget.paint(), define it before calling this constructor.
|
124 |
|
|
* The stylesheet URL defaults to "widget/<widgetName>.xsl" if it is not defined
|
125 |
|
|
* in config file. Set a stylesheet property containing an XSL URL in config
|
126 |
|
|
* to customize the stylesheet used.
|
127 |
|
|
* All stylesheets will have "modelId" and "widgetId" parameters set when called.
|
128 |
|
|
*
|
129 |
|
|
* <span class="attrib">@constructor</span>
|
130 |
|
|
* <span class="attrib">@base</span> WidgetBase
|
131 |
|
|
* <span class="attrib">@author</span> Mike Adair
|
132 |
|
|
* <span class="attrib">@param</span> widget Pointer to the widget instance being created
|
133 |
|
|
* <span class="attrib">@param</span> widgetNode The widget's XML object node from the configuration document.
|
134 |
|
|
* <span class="attrib">@param</span> model The model object that this widget belongs to.
|
135 |
|
|
*/</span>
|
136 |
|
|
<span class="reserved">function</span> WidgetBaseXSL(widgetNode,model) {
|
137 |
|
|
<span class="comment"> // Extend WidgetBase</span>
|
138 |
|
|
WidgetBase.apply(<span class="reserved">this</span>, new Array(widgetNode, model));
|
139 |
|
|
<span class="comment">
|
140 |
|
|
// Set this.stylesheet</span>
|
141 |
|
|
<span class="comment"> // Defaults to "widget/<widgetName>.xsl" if not defined in config file.</span>
|
142 |
|
|
<span class="reserved">if</span> ( !<span class="reserved">this</span>.stylesheet ) {
|
143 |
|
|
<span class="reserved">this</span>.stylesheet = new XslProcessor(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:stylesheet"</span>, baseDir+<span class="literal">"/widget/"</span>+widgetNode.nodeName+<span class="literal">".xsl"</span>, model.namespace));
|
144 |
|
|
}
|
145 |
|
|
<span class="comment">
|
146 |
|
|
// Do we allow to parse HTML nodes?</span>
|
147 |
|
|
<span class="reserved">this</span>.parseHTMLNodes = Mapbuilder.parseBoolean(<span class="reserved">this</span>.getProperty(<span class="literal">"mb:parseHTMLNodes"</span>, false));
|
148 |
|
|
<span class="comment">
|
149 |
|
|
// Set widget text values as parameters </span>
|
150 |
|
|
<span class="reserved">if</span> (config.widgetText) {
|
151 |
|
|
var textNodeXpath = <span class="literal">"/mb:WidgetText/mb:widgets/mb:"</span> + widgetNode.nodeName;
|
152 |
|
|
var textParams = config.widgetText.selectNodes(textNodeXpath+<span class="literal">"/*"</span>);
|
153 |
|
|
<span class="reserved">for</span> (var j=0;j<textParams.length;j++) {
|
154 |
|
|
<span class="reserved">this</span>.stylesheet.setParameter(textParams[j].nodeName,getNodeValue(textParams[j]));
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
<span class="comment">
|
158 |
|
|
// Set stylesheet parameters for all the child nodes from the config file</span>
|
159 |
|
|
<span class="reserved">for</span> (var j=0;j<widgetNode.childNodes.length;j++) {
|
160 |
|
|
<span class="reserved">if</span> (widgetNode.childNodes[j].firstChild)
|
161 |
|
|
{
|
162 |
|
|
<span class="reserved">this</span>.stylesheet.setParameter(
|
163 |
|
|
widgetNode.childNodes[j].nodeName, widgetNode.childNodes[j].firstChild.nodeValue);
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
<span class="comment">
|
167 |
|
|
//all stylesheets will have these properties available</span>
|
168 |
|
|
<span class="reserved">this</span>.stylesheet.setParameter(<span class="literal">"modelId"</span>, <span class="reserved">this</span>.model.id );
|
169 |
|
|
<span class="reserved">this</span>.stylesheet.setParameter(<span class="literal">"modelTitle"</span>, <span class="reserved">this</span>.model.title );
|
170 |
|
|
<span class="reserved">this</span>.stylesheet.setParameter(<span class="literal">"widgetId"</span>, <span class="reserved">this</span>.id );
|
171 |
|
|
<span class="reserved">this</span>.stylesheet.setParameter(<span class="literal">"skinDir"</span>, config.skinDir );
|
172 |
|
|
<span class="reserved">this</span>.stylesheet.setParameter(<span class="literal">"lang"</span>, config.lang );
|
173 |
|
|
|
174 |
|
|
<span class="comment">/**
|
175 |
|
|
* Render the widget.
|
176 |
|
|
* <span class="attrib">@param</span> objRef Pointer to widget object.
|
177 |
|
|
*/</span>
|
178 |
|
|
<span class="reserved">this</span>.paint = <span class="reserved">function</span>(objRef, refreshId) {
|
179 |
|
|
<span class="comment">
|
180 |
|
|
//pass in a widget ID to refresh only that widget</span>
|
181 |
|
|
<span class="reserved">if</span> (refreshId && (refreshId!=objRef.id)) <span class="reserved">return</span>;
|
182 |
|
|
|
183 |
|
|
<span class="reserved">if</span> (objRef.model.doc && objRef.getNode()) {
|
184 |
|
|
objRef.stylesheet.setParameter(<span class="literal">"modelUrl"</span>, objRef.model.url);
|
185 |
|
|
objRef.stylesheet.setParameter(<span class="literal">"targetModelId"</span>, objRef.targetModel.id );
|
186 |
|
|
<span class="comment">
|
187 |
|
|
//if (objRef.debug) mbDebugMessage(objRef, "source:"+(new XMLSerializer()).serializeToString(objRef.model.doc));</span>
|
188 |
|
|
objRef.resultDoc = objRef.model.doc; // resultDoc sometimes modified by prePaint()
|
189 |
|
|
objRef.model.setParam(<span class="literal">"prePaint"</span>, objRef);
|
190 |
|
|
objRef.prePaint(objRef);
|
191 |
|
|
<span class="comment">
|
192 |
|
|
//confirm inputs</span>
|
193 |
|
|
<span class="reserved">if</span> (objRef.debug) mbDebugMessage(objRef, <span class="literal">"prepaint:"</span>+(new XMLSerializer()).serializeToString(objRef.resultDoc));
|
194 |
|
|
<span class="reserved">if</span> (objRef.debug) mbDebugMessage(objRef, <span class="literal">"stylesheet:"</span>+(new XMLSerializer()).serializeToString(objRef.stylesheet.xslDom));
|
195 |
|
|
<span class="comment">
|
196 |
|
|
//set to output to a temporary node</span>
|
197 |
|
|
<span class="comment"> //hack to get by doc parsing problem in IE</span>
|
198 |
|
|
<span class="comment"> //the firstChild of tempNode will be the root element output by the stylesheet</span>
|
199 |
|
|
var outputNode = document.getElementById( objRef.outputNodeId );
|
200 |
|
|
var tempNode = document.createElement(<span class="literal">"DIV"</span>);
|
201 |
|
|
<span class="comment">
|
202 |
|
|
//process the doc with the stylesheet</span>
|
203 |
|
|
var s = objRef.stylesheet.transformNodeToString(objRef.resultDoc);
|
204 |
|
|
<span class="reserved">if</span> (config.serializeUrl && objRef.debug) postLoad(config.serializeUrl, s);
|
205 |
|
|
<span class="reserved">if</span> (objRef.debug) mbDebugMessage(objRef, <span class="literal">"painting:"</span>+objRef.id+<span class="literal">":"</span>+s);
|
206 |
|
|
tempNode.innerHTML = objRef.parseHTMLNodes ? Sarissa.unescape(s) : s;
|
207 |
|
|
<span class="reserved">if</span>( tempNode.firstChild != null ) { //Could be null!
|
208 |
|
|
tempNode.firstChild.setAttribute(<span class="literal">"id"</span>, objRef.outputNodeId);
|
209 |
|
|
<span class="comment">
|
210 |
|
|
//look for this widgets output and replace if found,</span>
|
211 |
|
|
<span class="comment"> //otherwise append it</span>
|
212 |
|
|
<span class="reserved">if</span> (outputNode) {
|
213 |
|
|
objRef.getNode().replaceChild(tempNode.firstChild,outputNode);
|
214 |
|
|
} <span class="reserved">else</span> {
|
215 |
|
|
objRef.getNode().appendChild(tempNode.firstChild);
|
216 |
|
|
}
|
217 |
|
|
}
|
218 |
|
|
objRef.postPaint(objRef);
|
219 |
|
|
objRef.model.setParam(<span class="literal">"postPaint"</span>, objRef);
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
<span class="comment"> // Call paint when model changes</span>
|
223 |
|
|
<span class="reserved">this</span>.model.addListener(<span class="literal">"refresh"</span>,<span class="reserved">this</span>.paint, <span class="reserved">this</span>);
|
224 |
|
|
|
225 |
|
|
}
|
226 |
|
|
</pre>
|
227 |
|
|
<hr>
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
<!-- ========== START OF NAVBAR ========== -->
|
232 |
|
|
<a name="navbar_top"><!-- --></a>
|
233 |
|
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
234 |
|
|
<tr>
|
235 |
|
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
236 |
|
|
<a name="navbar_top_firstrow"><!-- --></a>
|
237 |
|
|
<table border="0" cellpadding="0" cellspacing="3">
|
238 |
|
|
<tr align="center" valign="top">
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
242 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
246 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
247 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
248 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
249 |
|
|
</tr>
|
250 |
|
|
</table>
|
251 |
|
|
</td>
|
252 |
|
|
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
|
253 |
|
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
254 |
|
|
</td>
|
255 |
|
|
</tr>
|
256 |
|
|
|
257 |
|
|
<tr>
|
258 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
259 |
|
|
PREV
|
260 |
|
|
NEXT</font></td>
|
261 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
262 |
|
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
263 |
|
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
264 |
|
|
|
265 |
|
|
<script>
|
266 |
|
|
<!--
|
267 |
|
|
if(window==top) {
|
268 |
|
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
269 |
|
|
}
|
270 |
|
|
//-->
|
271 |
|
|
</script>
|
272 |
|
|
<noscript>
|
273 |
|
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
274 |
|
|
</noscript>
|
275 |
|
|
</font></td>
|
276 |
|
|
</tr>
|
277 |
|
|
</table>
|
278 |
|
|
<!-- =========== END OF NAVBAR =========== -->
|
279 |
|
|
|
280 |
|
|
<hr>
|
281 |
|
|
<font size="-1">
|
282 |
|
|
|
283 |
|
|
</font>
|
284 |
|
|
<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>
|
285 |
|
|
</body>
|
286 |
|
|
</html>
|