/[suikacvs]/markup/hlink/implementation/hlink-xbl.xml
Suika

Contents of /markup/hlink/implementation/hlink-xbl.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download) (as text)
Sun Jul 6 23:42:56 2003 UTC (20 years, 10 months ago) by w
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +368 -222 lines
File MIME type: text/xml
2003-04-22 08:22 (non-stable) version

1 <?xml version="1.0" encoding="iso-2022-jp"?>
2 <bindings xmlns="http://www.mozilla.org/xbl">
3 <binding id="link-hlink">
4 <implementation>
5 <method name="linkizeHTML" type="application/x-javascript">
6 <parameter name="doc" />
7 <body><![CDATA[
8 const XHTML1NS = 'http://www.w3.org/1999/xhtml';
9 const HLinkNS = 'http://www.w3.org/2002/06/hlink';
10 const XLinkNS = 'http://www.w3.org/1999/xlink';
11 const tempNS = 'urn:x-suika-fam-cx:markup:temporary:hlink';
12 const XLinkPfx = '';
13 const tempPfx = '';
14
15 var hObject = doc.createElementNS (tempNS, 'objects');
16 doc.documentElement.appendChild (hObject);
17
18 var eLinks = doc.getElementsByTagNameNS (XHTML1NS, 'link');
19 for (var i = 0; i < eLinks.length; i++)
20 if (eLinks[i].getAttribute ('type').toLowerCase () == 'application/x-hlink+xml'
21 && eLinks[i].getAttribute ('rel') == 'stylesheet' //.match (/stylesheet/i)
22 ) this.linkizeByHTMLLinkElement (eLinks[i], hObject);
23 ]]></body>
24 </method>
25 <field name="tempNS">'urn:x-suika-fam-cx:markup:temporary:hlink'</field>
26 <field name="tempPfx">''</field>
27 <field name="tempLinksNS">'http://www.w3.org/1999/xhtml'</field>
28 <field name="tempLinksElementTypeName">'div'</field>
29 <field name="XLinkNS">'http://www.w3.org/1999/xlink'</field>
30 <field name="XLinkPfx">''</field>
31 <field name="XHTML1NS">'http://www.w3.org/1999/xhtml'</field>
32 <field name="HLinkNS">'http://www.w3.org/2002/06/hlink'</field>
33 <field name="HLinkPfx">''</field>
34 <field name="hLinkAttrList">
35 new Array ('locator', 'effect', 'actuate', 'mediaType', 'role', 'reverseRole', 'replace');
36 </field>
37 <method name="linkizeByHTMLLinkElement" type="application/x-javascript">
38 <parameter name="eLink" />
39 <parameter name="hObject" />
40 <body><![CDATA[
41 var xT = this;
42
43 //var oHLink = eLink.ownerDocument.createElementNS (xT.XHTML1NS, 'object');
44 var oHLink = hObject.ownerDocument.createElementNS (xT.XHTML1NS, 'object');
45 oHLink.setAttributeNS (xT.tempNS, 'HLinkStatus', 100);
46 oHLink.setAttributeNS (xT.tempNS, 'HLinkType', 'HLinkDocument');
47 oHLink.setAttribute ('data', eLink.getAttribute ('href'));
48 //oHLink.setAttribute ('type', 'application/xml');
49 oHLink.style.display = 'inline';
50 oHLink.style.width = 0;
51 oHLink.style.height = 0;
52 oHLink.addEventListener ('load', function () {
53 var hlink = oHLink.contentDocument.getElementsByTagNameNS
54 (xT.HLinkNS, 'hlink');
55 for (var k = 0; k < hlink.length; k++) xT.linkizeElement (hlink[k], hObject);
56 }, false);
57 //eLink.ownerDocument.documentElement.appendChild (oHLink);
58 hObject.appendChild (oHLink);
59 ]]></body>
60 </method>
61 <method name="linkizeElement" type="application/x-javascript">
62 <parameter name="e" />
63 <parameter name="hObject" />
64 <body><![CDATA[
65 var xT = this;
66 var elementNS = e.getAttribute ('namespace');
67 var elementType = e.getAttribute ('element');
68 var linkAttr = [];
69 var linkAttrList = xT.hLinkAttrList;
70 for (var k = 0; k < linkAttrList.length; k++) {
71 linkAttr[linkAttrList[k]] = [];
72 linkAttr[linkAttrList[k]].value = e.getAttribute (linkAttrList[k]);
73 if (linkAttr[linkAttrList[k]].value
74 && linkAttr[linkAttrList[k]].value.substr (0,1) == '@') {
75 linkAttr[linkAttrList[k]].attrName = linkAttr[linkAttrList[k]].value.substr (1);
76 linkAttr[linkAttrList[k]].value = undefined;
77 }
78 }
79 var linkElements = document.getElementsByTagNameNS (elementNS, elementType);
80 for (var i = 0; i < linkElements.length; i++) {
81 var elFlag = 1*linkElements[i].getAttributeNS (xT.tempNS, xT.tempPfx+'HLinkStatus');
82 if (elFlag < 20) {
83 var myLinkAttr = [];
84 for (var j = 0; j < linkAttrList.length; j++) {
85 myLinkAttr[linkAttrList[j]] = linkAttr[linkAttrList[j]].value;
86 if (linkAttr[linkAttrList[j]].attrName
87 && linkElements[i].hasAttribute
88 (linkAttr[linkAttrList[j]].attrName)) {
89 myLinkAttr[linkAttrList[j]] = linkElements[i].getAttribute
90 (linkAttr[linkAttrList[j]].attrName);
91 }
92 }
93 if (myLinkAttr.locator != undefined) {
94 if (myLinkAttr.effect == 'embed' && myLinkAttr.actuate == 'onLoad'
95 && myLinkAttr.locator != '' && myLinkAttr.locator.substr (0,1) != '#') {
96 var oEl = linkElements[i].ownerDocument.createElementNS (xT.XHTML1NS, 'object');
97 linkElements[i].setAttributeNS (xT.tempNS, xT.tempPfx+'HLinkStatus', elFlag+1);
98 linkElements[i].setAttributeNS (xT.tempNS, xT.tempPfx+'HLinkType', 'hyperLink');
99 oEl.setAttributeNS (xT.tempNS, xT.tempPfx+'HLinkStatus', 100);
100 oEl.setAttribute ('data', myLinkAttr.locator);
101 oEl.setAttribute ('type', myLinkAttr.mediaType);
102 while (linkElements[i].childNodes.length) {
103 oEl.appendChild (linkElements[i].firstChild);
104 //linkElements[i].removeChild (linkElements[i].firstChild);
105 }
106 linkElements[i].appendChild(oEl);
107 } else {
108 linkElements[i].setAttributeNS (xT.tempNS, xT.tempPfx+'HLinkStatus', elFlag+1);
109 linkElements[i].setAttributeNS (xT.tempNS, xT.tempPfx+'HLinkType', 'hyperLink');
110 linkElements[i].setAttributeNS (xT.XLinkNS, xT.XLinkPfx+'type', 'simple');
111 if (myLinkAttr.effect == 'submit' || myLinkAttr.effect == 'map')
112 myLinkAttr.effect = 'other';
113 linkElements[i].setAttributeNS (xT.XLinkNS, xT.XLinkPfx+'show', myLinkAttr.effect);
114 if (myLinkAttr.actuate == 'onRequestSecondary')
115 myLinkAttr.actuate = 'other';
116 linkElements[i].setAttributeNS (xT.XLinkNS, xT.XLinkPfx+'actuate', myLinkAttr.actuate);
117 if (!myLinkAttr.locator) myLinkAttr.locator = '#';
118 linkElements[i].setAttributeNS (xT.XLinkNS, xT.XLinkPfx+'href', myLinkAttr.locator);
119 }
120 }
121 var eFlag = 1*linkElements[i].getAttributeNS (xT.tempNS, xT.tempPfx+'HLinkList');
122 if (!eFlag) {
123 var linkElement = linkElements[i];
124 var xThis = this;
125 linkElement.setAttributeNS (xT.tempNS, xT.tempPfx+'HLinkList', 1);
126 linkElement.addEventListener ('mouseover', function (e) {
127 if (linkElement.getAttributeNS (xT.tempNS, xT.tempPfx+'HLinkType')
128 == 'hyperLink') {
129 var doc = hObject.ownerDocument; //== linkElement.ownerDocument;
130 if (linkElement.__HLinkListElement) { // LinkList exist
131 if (linkElement.__HLinkListElement.getAttributeNS
132 (xT.tempNS, xT.tempPfx+'display') != 'yes') {
133 var eLinksElements = hObject.getElementsByTagNameNS
134 (xT.tempLinksNS,
135 xT.tempLinksElementTypeName);
136 for (var i = 0; i < eLinksElements.length; i++) {
137 eLinksElements[i].setAttributeNS
138 (xT.tempNS, xT.tempPfx+'display', 'no');
139 }
140 with (linkElement.__HLinkListElement) {
141 setAttributeNS (xT.tempNS, xT.tempPfx+'display', 'yes');
142 style.left = (e.clientX + 10) + 'px';
143 style.top = (e.clientY + 10) + 'px';
144 }
145 }
146 } else { // LinkList not exist
147 var eLinksElements = hObject.getElementsByTagNameNS
148 (xT.tempLinksNS,
149 xT.tempLinksElementTypeName);
150 for (var i = 0; i < eLinksElements.length; i++) {
151 eLinksElements[i].setAttributeNS
152 (xT.tempNS, xT.tempPfx+'display', 'no');
153 }
154 var eLinks = doc.createElementNS
155 (xT.tempLinksNS, xT.tempLinksElementTypeName);
156 eLinks.setAttributeNS (xT.tempNS, xT.tempPfx+'type', 'links');
157 eLinks.__HLinkTargetElement = linkElement;
158 xT.createLinkList (linkElement, eLinks, hObject);
159 eLinks.setAttributeNS
160 (xT.tempNS, xT.tempPfx+'display', 'yes');
161 eLinks.style.left = (e.clientX + 10) + 'px';
162 eLinks.style.top = (e.clientY + 10) + 'px';
163 hObject.appendChild (eLinks);
164 linkElement.__HLinkListElement = eLinks;
165 }
166 }
167 },false);
168 }
169 }
170 }
171 ]]></body>
172 </method>
173 <method name="getHLinkAttrs" type="application/x-javascript">
174 <parameter name="hLink"/>
175 <body><![CDATA[
176 var linkAttr = [];
177 for (var i = 0; i < hLink.attributes.length; i++) {
178 linkAttr[hLink.attributes[i].nodeName] = [];
179 var lA = linkAttr[hLink.attributes[i].nodeName];
180 lA.value = hLink.attributes[i].nodeValue;
181 if (lA.value && lA.value.substr (0,1) == '@') {
182 lA.valueAttrName = lA.value.substr (1);
183 lA.value = undefined;
184 }
185 }
186 return linkAttr;
187 ]]></body>
188 </method>
189 <method name="getLinkAttr" type="application/x-javascript">
190 <parameter name="attrName"/>
191 <parameter name="hLinkAttr"/>
192 <parameter name="e"/>
193 <parameter name="eLink"/>
194 <body><![CDATA[
195 var xT = this;
196 if (eLink.hasAttributeNS (xT.HLinkNS, xT.HLinkPfx+attrName)) {
197 return eLink.getAttributeNS (xT.HLinkNS, xT.HLinkPfx+attrName);
198 } else if (hLinkAttr[attrName]) {
199 var attrValue = hLinkAttr[attrName].value;
200 if (!attrValue) {
201 if (hLinkAttr[attrName].valueAttrName) {
202 attrValue = e.getAttribute (hLinkAttr[attrName].valueAttrName);
203 }
204 eLink.setAttribute ('attributeName', hLinkAttr[attrName].valueAttrName);
205 }
206 if (attrValue) {
207 eLink.setAttributeNS (xT.HLinkNS, xT.HLinkPfx+attrName, attrValue);
208 }
209 return attrValue;
210 }
211 return undefined;
212 ]]></body>
213 </method>
214 <method name="createLinkList" type="application/x-javascript">
215 <parameter name="e"/>
216 <parameter name="eLinks"/>
217 <parameter name="hObject"/>
218 <body><![CDATA[
219 var xT = this;
220 var hObject = hObject.getElementsByTagNameNS (xT.XHTML1NS, 'object');
221 var doc = eLinks.ownerDocument;
222 for (var i = 0; i < hObject.length; i++) {
223 var hLink = hObject[i].contentDocument.getElementsByTagNameNS (xT.HLinkNS, 'hlink');
224 for (var j = 0; j < hLink.length; j++) {
225 if (hLink[j].getAttribute ('namespace') == e.namespaceURI
226 && hLink[j].getAttribute ('element') == e.localName) {
227 var eLink = doc.createElementNS (xT.tempNS, 'link');
228 var hLA = xT.getHLinkAttrs(hLink[j]);
229 var hRef = xT.getLinkAttr ('locator', hLA, e, eLink);
230 if (hRef) {
231 eLink.appendChild (doc.createTextNode (hRef));
232 eLink.setAttributeNS (xT.XLinkNS, xT.XLinkPfx+'href', hRef);
233 eLink.setAttributeNS (xT.XLinkNS, xT.XLinkPfx+'type', 'simple');
234 var lANL = xT.hLinkAttrList;
235 for (var k = 0; k < lANL.length; k++) {
236 xT.getLinkAttr (lANL[k], hLA, e, eLink);
237 }
238 eLinks.appendChild (eLink);
239 }
240 }
241 }
242 }
243 ]]></body>
244 </method>
245 <constructor type="application/x-javascript"><![CDATA[
246 var myThis = this;
247 window.addEventListener ('load', function () {myThis.linkizeHTML(document)}, false);
248 ]]></constructor>
249 </implementation>
250 </binding>
251 <binding id="style-hlink">
252 <implementation>
253 <method name="linkize" type="application/x-javascript">
254 <parameter name="e" />
255 <body>
256 <![CDATA[
257 const tempNS = 'urn:x-suika-fam-cx:markup:temporary';
258 const XLinkNS = 'http://www.w3.org/1999/xlink';
259 const XHTML1NS = 'http://www.w3.org/1999/xhtml';
260 var elementNS = e.getAttribute ('namespace');
261 var elementType = e.getAttribute ('element');
262 var linkAttr = [];
263 var linkAttrList = new Array ('locator', 'effect', 'actuate', 'mediaType');
264 for (var i = 0; i < linkAttrList.length; i++) {
265 linkAttr[linkAttrList[i]] = [];
266 linkAttr[linkAttrList[i]].value = e.getAttribute (linkAttrList[i]);
267 if (linkAttr[linkAttrList[i]].value
268 && linkAttr[linkAttrList[i]].value.substr (0,1) == '@') {
269 linkAttr[linkAttrList[i]].attrName = linkAttr[linkAttrList[i]].value.substr (1);
270 linkAttr[linkAttrList[i]].value = undefined;
271 }
272 }
273 var linkElements = document.getElementsByTagNameNS (elementNS, elementType);
274 for (var i = 0; i < linkElements.length; i++) {
275 var elFlag = linkElements[i].getAttributeNS (tempNS, 'HLinkStatus');
276 if (elFlag < 20) {
277 var myLinkAttr = [];
278 for (var j = 0; j < linkAttrList.length; j++) {
279 myLinkAttr[linkAttrList[j]] = linkAttr[linkAttrList[j]].value;
280 if (linkAttr[linkAttrList[j]].attrName
281 && linkElements[i].hasAttribute
282 (linkAttr[linkAttrList[j]].attrName)) {
283 myLinkAttr[linkAttrList[j]] = linkElements[i].getAttribute
284 (linkAttr[linkAttrList[j]].attrName);
285 }
286 }
287 if (myLinkAttr.locator != undefined) {
288 if (myLinkAttr.effect == 'embed' && myLinkAttr.actuate == 'onLoad'
289 && myLinkAttr.locator != '' && myLinkAttr.locator.substr (0,1) != '#') {
290 var oEl = linkElements[i].ownerDocument.createElementNS (XHTML1NS, 'object');
291 oEl.setAttributeNS (tempNS, 'HLinkStatus', 100);
292 oEl.setAttribute ('data', myLinkAttr.locator);
293 oEl.setAttribute ('type', myLinkAttr.mediaType);
294 while (linkElements[i].childNodes.length) {
295 oEl.appendChild (linkElements[i].firstChild);
296 //linkElements[i].removeChild (linkElements[i].firstChild);
297 }
298 linkElements[i].appendChild(oEl);
299 } else {
300 linkElements[i].setAttributeNS (tempNS, 'HLinkStatus', elFlag+1);
301 linkElements[i].setAttributeNS (XLinkNS, 'type', 'simple');
302 if (myLinkAttr.effect == 'submit' || myLinkAttr.effect == 'map')
303 myLinkAttr.effect = 'other';
304 linkElements[i].setAttributeNS (XLinkNS, 'show', myLinkAttr.effect);
305 if (myLinkAttr.actuate == 'onRequestSecondary')
306 myLinkAttr.actuate = 'other';
307 linkElements[i].setAttributeNS (XLinkNS, 'actuate', myLinkAttr.actuate);
308 if (!myLinkAttr.locator) myLinkAttr.locator = '#';
309 linkElements[i].setAttributeNS (XLinkNS, 'href', myLinkAttr.locator);
310 }
311 }
312 }
313 }
314 ]]>
315 </body>
316 </method>
317 <constructor type="application/x-javascript">
318 <![CDATA[
319 var myThis = this;
320 window.addEventListener ('load', function () {myThis.linkize(myThis)}, false);
321 ]]>
322 </constructor>
323 </implementation>
324 </binding>
325 <binding id="ll-links">
326 <content xmlns:t="urn:x-suika-fam-cx:markup:temporary:hlink">
327 <t:container xbl:inherits="" xmlns:xbl="http://www.mozilla.org/xbl">
328 <h:div t:type="closeBox" onclick="this.parentNode.parentNode.setAttributeNS('urn:x-suika-fam-cx:markup:temporary:hlink',''+'display','no')" xmlns:h="http://www.w3.org/1999/xhtml">×</h:div>
329 <children/>
330 </t:container>
331 </content>
332 </binding>
333 </bindings>
334 <!-- ***** BEGIN LICENSE BLOCK *****
335 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
336 -
337 - The contents of this file are subject to the Mozilla Public License Version
338 - 1.1 (the "License"); you may not use this file except in compliance with
339 - the License. You may obtain a copy of the License at
340 - <http://www.mozilla.org/MPL/>
341 -
342 - Software distributed under the License is distributed on an "AS IS" basis,
343 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
344 - for the specific language governing rights and limitations under the
345 - License.
346 -
347 - The Original Code is SuikaWiki code.
348 -
349 - The Initial Developer of the Original Code is Wakaba.
350 - Portions created by the Initial Developer are Copyright (C) 2003
351 - the Initial Developer. All Rights Reserved.
352 -
353 - Contributor(s):
354 - Wakaba <w@suika.fam.cx>
355 -
356 - Alternatively, the contents of this file may be used under the terms of
357 - either the GNU General Public License Version 2 or later (the "GPL"), or
358 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
359 - in which case the provisions of the GPL or the LGPL are applicable instead
360 - of those above. If you wish to allow use of your version of this file only
361 - under the terms of either the GPL or the LGPL, and not to allow others to
362 - use your version of this file under the terms of the MPL, indicate your
363 - decision by deleting the provisions above and replace them with the notice
364 - and other provisions required by the LGPL or the GPL. If you do not delete
365 - the provisions above, a recipient may use your version of this file under
366 - the terms of any one of the MPL, the GPL or the LGPL.
367 -
368 - ***** END LICENSE BLOCK ***** -->

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24