/[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.1 - (hide annotations) (download) (as text)
Sun Jul 6 23:39:47 2003 UTC (21 years, 5 months ago) by w
Branch: MAIN
File MIME type: text/xml
2003-03-01 11:27 version

1 w 1.1 <?xml version="1.0"?>
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';
12    
13     var eLinks = doc.getElementsByTagNameNS (XHTML1NS, 'link');
14     for (var i = 0; i < eLinks.length; i++)
15     if (eLinks[i].getAttribute ('type').toLowerCase () == 'application/x-hlink+xml'
16     && eLinks[i].getAttribute ('rel') == 'stylesheet' //.match (/stylesheet/i)
17     ) linkizeByHTMLLinkElement (eLinks[i]);
18    
19     function linkizeByHTMLLinkElement (eLink) {
20     var oHLink = eLink.ownerDocument.createElementNS (XHTML1NS, 'object');
21     oHLink.setAttributeNS (tempNS, 'HLinkStatus', 100);
22     oHLink.setAttribute ('data', eLink.getAttribute ('href'));
23     //oHLink.setAttribute ('type', 'application/xml');
24     oHLink.style.display = 'inline';
25     oHLink.style.width = 0;
26     oHLink.style.height = 0;
27     oHLink.addEventListener ('load', function () {
28     var hlink = oHLink.contentDocument.getElementsByTagNameNS
29     (HLinkNS, 'hlink');
30     for (var k = 0; k < hlink.length; k++) linkizeElement (hlink[k]);
31     }, false);
32     eLink.ownerDocument.documentElement.appendChild (oHLink);
33     }
34    
35     function linkizeElement (e) {
36     var elementNS = e.getAttribute ('namespace');
37     var elementType = e.getAttribute ('element');
38     var linkAttr = [];
39     var linkAttrList = new Array ('locator', 'effect', 'actuate', 'mediaType');
40     for (var k = 0; k < linkAttrList.length; k++) {
41     linkAttr[linkAttrList[k]] = [];
42     linkAttr[linkAttrList[k]].value = e.getAttribute (linkAttrList[k]);
43     if (linkAttr[linkAttrList[k]].value
44     && linkAttr[linkAttrList[k]].value.substr (0,1) == '@') {
45     linkAttr[linkAttrList[k]].attrName = linkAttr[linkAttrList[k]].value.substr (1);
46     linkAttr[linkAttrList[k]].value = undefined;
47     }
48     }
49     var linkElements = document.getElementsByTagNameNS (elementNS, elementType);
50     for (var i = 0; i < linkElements.length; i++) {
51     var elFlag = 1*linkElements[i].getAttributeNS (tempNS, 'HLinkStatus');
52     if (elFlag < 20) {
53     var myLinkAttr = [];
54     for (var j = 0; j < linkAttrList.length; j++) {
55     myLinkAttr[linkAttrList[j]] = linkAttr[linkAttrList[j]].value;
56     if (linkAttr[linkAttrList[j]].attrName
57     && linkElements[i].hasAttribute
58     (linkAttr[linkAttrList[j]].attrName)) {
59     myLinkAttr[linkAttrList[j]] = linkElements[i].getAttribute
60     (linkAttr[linkAttrList[j]].attrName);
61     }
62     }
63     if (myLinkAttr.locator != undefined) {
64     if (myLinkAttr.effect == 'embed' && myLinkAttr.actuate == 'onLoad'
65     && myLinkAttr.locator != '' && myLinkAttr.locator.substr (0,1) != '#') {
66     var oEl = linkElements[i].ownerDocument.createElementNS (XHTML1NS, 'object');
67     linkElements[i].setAttributeNS (tempNS, 'HLinkStatus', elFlag+1);
68     oEl.setAttributeNS (tempNS, 'HLinkStatus', 100);
69     oEl.setAttribute ('data', myLinkAttr.locator);
70     oEl.setAttribute ('type', myLinkAttr.mediaType);
71     while (linkElements[i].childNodes.length) {
72     oEl.appendChild (linkElements[i].firstChild);
73     //linkElements[i].removeChild (linkElements[i].firstChild);
74     }
75     linkElements[i].appendChild(oEl);
76     } else {
77     linkElements[i].setAttributeNS (tempNS, 'HLinkStatus', elFlag+1);
78     linkElements[i].setAttributeNS (XLinkNS, 'type', 'simple');
79     if (myLinkAttr.effect == 'submit' || myLinkAttr.effect == 'map')
80     myLinkAttr.effect = 'other';
81     linkElements[i].setAttributeNS (XLinkNS, 'show', myLinkAttr.effect);
82     if (myLinkAttr.actuate == 'onRequestSecondary')
83     myLinkAttr.actuate = 'other';
84     linkElements[i].setAttributeNS (XLinkNS, 'actuate', myLinkAttr.actuate);
85     if (!myLinkAttr.locator) myLinkAttr.locator = '#';
86     linkElements[i].setAttributeNS (XLinkNS, 'href', myLinkAttr.locator);
87     }
88     }
89     }
90     }
91     }
92     ]]></body>
93     </method>
94     <constructor type="application/x-javascript"><![CDATA[
95     var myThis = this;
96     window.addEventListener ('load', function () {myThis.linkizeHTML(document)}, false);
97     ]]></constructor>
98     </implementation>
99     </binding>
100     <binding id="style-hlink">
101     <implementation>
102     <method name="linkize" type="application/x-javascript">
103     <parameter name="e" />
104     <body>
105     <![CDATA[
106     const tempNS = 'urn:x-suika-fam-cx:markup:temporary';
107     const XLinkNS = 'http://www.w3.org/1999/xlink';
108     const XHTML1NS = 'http://www.w3.org/1999/xhtml';
109     var elementNS = e.getAttribute ('namespace');
110     var elementType = e.getAttribute ('element');
111     var linkAttr = [];
112     var linkAttrList = new Array ('locator', 'effect', 'actuate', 'mediaType');
113     for (var i = 0; i < linkAttrList.length; i++) {
114     linkAttr[linkAttrList[i]] = [];
115     linkAttr[linkAttrList[i]].value = e.getAttribute (linkAttrList[i]);
116     if (linkAttr[linkAttrList[i]].value
117     && linkAttr[linkAttrList[i]].value.substr (0,1) == '@') {
118     linkAttr[linkAttrList[i]].attrName = linkAttr[linkAttrList[i]].value.substr (1);
119     linkAttr[linkAttrList[i]].value = undefined;
120     }
121     }
122     var linkElements = document.getElementsByTagNameNS (elementNS, elementType);
123     for (var i = 0; i < linkElements.length; i++) {
124     var elFlag = linkElements[i].getAttributeNS (tempNS, 'HLinkStatus');
125     if (elFlag < 20) {
126     var myLinkAttr = [];
127     for (var j = 0; j < linkAttrList.length; j++) {
128     myLinkAttr[linkAttrList[j]] = linkAttr[linkAttrList[j]].value;
129     if (linkAttr[linkAttrList[j]].attrName
130     && linkElements[i].hasAttribute
131     (linkAttr[linkAttrList[j]].attrName)) {
132     myLinkAttr[linkAttrList[j]] = linkElements[i].getAttribute
133     (linkAttr[linkAttrList[j]].attrName);
134     }
135     }
136     if (myLinkAttr.locator != undefined) {
137     if (myLinkAttr.effect == 'embed' && myLinkAttr.actuate == 'onLoad'
138     && myLinkAttr.locator != '' && myLinkAttr.locator.substr (0,1) != '#') {
139     var oEl = linkElements[i].ownerDocument.createElementNS (XHTML1NS, 'object');
140     oEl.setAttributeNS (tempNS, 'HLinkStatus', 100);
141     oEl.setAttribute ('data', myLinkAttr.locator);
142     oEl.setAttribute ('type', myLinkAttr.mediaType);
143     while (linkElements[i].childNodes.length) {
144     oEl.appendChild (linkElements[i].firstChild);
145     //linkElements[i].removeChild (linkElements[i].firstChild);
146     }
147     linkElements[i].appendChild(oEl);
148     } else {
149     linkElements[i].setAttributeNS (tempNS, 'HLinkStatus', elFlag+1);
150     linkElements[i].setAttributeNS (XLinkNS, 'type', 'simple');
151     if (myLinkAttr.effect == 'submit' || myLinkAttr.effect == 'map')
152     myLinkAttr.effect = 'other';
153     linkElements[i].setAttributeNS (XLinkNS, 'show', myLinkAttr.effect);
154     if (myLinkAttr.actuate == 'onRequestSecondary')
155     myLinkAttr.actuate = 'other';
156     linkElements[i].setAttributeNS (XLinkNS, 'actuate', myLinkAttr.actuate);
157     if (!myLinkAttr.locator) myLinkAttr.locator = '#';
158     linkElements[i].setAttributeNS (XLinkNS, 'href', myLinkAttr.locator);
159     }
160     }
161     }
162     }
163     ]]>
164     </body>
165     </method>
166     <constructor type="application/x-javascript">
167     <![CDATA[
168     var myThis = this;
169     window.addEventListener ('load', function () {myThis.linkize(myThis)}, false);
170     ]]>
171     </constructor>
172     </implementation>
173     </binding>
174     </bindings>
175     <!-- ***** BEGIN LICENSE BLOCK *****
176     - Version: MPL 1.1/GPL 2.0/LGPL 2.1
177     -
178     - The contents of this file are subject to the Mozilla Public License Version
179     - 1.1 (the "License"); you may not use this file except in compliance with
180     - the License. You may obtain a copy of the License at
181     - <http://www.mozilla.org/MPL/>
182     -
183     - Software distributed under the License is distributed on an "AS IS" basis,
184     - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
185     - for the specific language governing rights and limitations under the
186     - License.
187     -
188     - The Original Code is SuikaWiki code.
189     -
190     - The Initial Developer of the Original Code is Wakaba.
191     - Portions created by the Initial Developer are Copyright (C) 2003
192     - the Initial Developer. All Rights Reserved.
193     -
194     - Contributor(s):
195     - Wakaba <w@suika.fam.cx>
196     -
197     - Alternatively, the contents of this file may be used under the terms of
198     - either the GNU General Public License Version 2 or later (the "GPL"), or
199     - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
200     - in which case the provisions of the GPL or the LGPL are applicable instead
201     - of those above. If you wish to allow use of your version of this file only
202     - under the terms of either the GPL or the LGPL, and not to allow others to
203     - use your version of this file under the terms of the MPL, indicate your
204     - decision by deleting the provisions above and replace them with the notice
205     - and other provisions required by the LGPL or the GPL. If you do not delete
206     - the provisions above, a recipient may use your version of this file under
207     - the terms of any one of the MPL, the GPL or the LGPL.
208     -
209     - ***** END LICENSE BLOCK ***** -->

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24