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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Thu Sep 4 02:41:31 2003 UTC (21 years, 2 months ago) by wakaba
Branch: MAIN
File MIME type: text/xml
Imported to CVS

1 wakaba 1.1 <?xml version="1.0"?>
2     <bindings xmlns="http://www.mozilla.org/xbl">
3     <binding id="slideCore">
4     <implementation>
5     <field name="SLIDE_XBL_BASE">'http://suika.fam.cx/~wakaba/-temp/slide/implementation/'</field>
6     <field name="NS_SLIDE">'urn:x-suika-fam-cx:markup:slide:1'</field>
7     <field name="NS_XHTML1">'http://www.w3.org/1999/xhtml'</field>
8     <field name="NS_XHTML2">'http://www.w3.org/2002/06/xhtml2'</field>
9     <constructor type="application/x-javascript" xml:space="preserve"><![CDATA[
10     var slides = document.getElementsByTagNameNS (this.NS_SLIDE, 'slides')[0].getElementsByTagNameNS (this.NS_SLIDE, 'slide');
11     for (var i = 0; i < slides.length; i++) {
12     slides[i].setAttribute ('slideIndex', i);
13     }
14    
15     var h = document.getElementsByTagNameNS (this.NS_XHTML2, 'head')[0];
16     // Common slide style
17     var l = document.createElementNS (this.NS_XHTML1, 'link');
18     l.setAttribute ('rel', 'stylesheet');
19     l.setAttribute ('href', this.SLIDE_XBL_BASE+'slide-style.css');
20     h.appendChild (l);
21    
22     // Slide listing style
23     l = document.createElementNS (this.NS_XHTML1, 'link');
24     l.setAttribute ('rel', 'stylesheet');
25     l.setAttribute ('href', this.SLIDE_XBL_BASE+'slide-list.css');
26     l.setAttribute ('title', 'Slide List');
27     h.appendChild (l);
28    
29     // Slide showing style
30     l = document.createElementNS (this.NS_XHTML1, 'link');
31     l.setAttribute ('rel', 'stylesheet alternate');
32     l.setAttribute ('href', this.SLIDE_XBL_BASE+'slide-show.css');
33     l.setAttribute ('title', 'Slideshow');
34     h.appendChild (l);
35     }
36     ]]></constructor>
37     </implementation>
38     </binding>
39     <binding id="slideshow">
40     <implementation>
41     <field name="currentSlideIndex">0</field>
42     <field name="NS_SLIDE">'urn:x-suika-fam-cx:markup:slide:1'</field>
43     <field name="NS_XHTML1">'http://www.w3.org/1999/xhtml'</field>
44     <field name="NS_XHTML2">'http://www.w3.org/2002/06/xhtml2'</field>
45     <method name="getInnerText" type="application/x-javascript">
46     <parameter name="node"/>
47     <body xml:space="preserve"><![CDATA[
48     // <http://white.sakura.ne.jp/~piro/xul/tips/x0013.html>
49     var nodes = node.childNodes;
50     var ret = [];
51     for (var i = 0; i < nodes.length; i++)
52     if (nodes[i].hasChildNodes())
53     ret.push(this.getInnerText(nodes[i]));
54     else if (nodes[i].nodeType == Node.TEXT_NODE)
55     ret.push(nodes[i].nodeValue);
56     else if (nodes[i].alt)
57     ret.push(nodes[i].alt);
58     return ret.join('');
59     ]]></body>
60     </method>
61     <method name="setCurrentSlide" type="application/x-javascript">
62     <parameter name="n"/>
63     <body xml:space="preserve"><![CDATA[
64     var slides = document.getElementsByTagNameNS (this.NS_SLIDE, 'slides')[0].getElementsByTagNameNS (this.NS_SLIDE, 'slide');
65     if (n < 0) n = slides.length + n; // -1 = slides.length-1
66     //else if (slides.length <= n) n = slides.length - 1;
67     else if (slides.length <= n) n = 0;
68     for (var i = 0; i < slides.length; i++) {
69     slides[i].setAttribute ('-isCurrentSlide', (i == n ? 'yes' : 'no'));
70     }
71     this.currentSlideIndex = n;
72     ]]></body>
73     </method>
74     <method name="getSlideTitle" type="application/x-javascript">
75     <parameter name="n"/>
76     <body xml:space="preserve"><![CDATA[
77     var slides = document.getElementsByTagNameNS (this.NS_SLIDE, 'slides')[0].getElementsByTagNameNS (this.NS_SLIDE, 'slide');
78     if (n < 0) n = slides.length + n; // -1 = slides.length-1
79     else if (slides.length <= n) n = slides.length - 1;
80     if (slides[n]) {
81     var h = this.getInnerText (slides[n].getElementsByTagNameNS (this.NS_XHTML2, 'h')[0]);
82     if (h) {
83     return h;
84     } else {
85     return 'Slide ' + n;
86     }
87     } else {
88     return '';
89     }
90     ]]></body>
91     </method>
92     <method name="onKeyDown" type="application/x-javascript">
93     <parameter name="e"/>
94     <parameter name="myThis"/>
95     <body xml:space="preserve"><![CDATA[
96     if (e.keyCode == 13 || e.keyCode == 39) { // Enter / <-
97     myThis.setCurrentSlide (myThis.currentSlideIndex + 1);
98     } else if (e.keyCode == 8 || e.keyCode == 37) { // BS / ->
99     myThis.setCurrentSlide (myThis.currentSlideIndex - 1);
100     e.preventDefault ();
101     }
102     //else alert ('KC: ' + (e.keyCode) + ', CC: ' + (e.charCode));
103     ]]></body>
104     </method>
105     <constructor type="application/x-javascript" xml:space="preserve">
106     <![CDATA[
107     if (document.__slideControl__) return;
108     document.__slideControl__ = this;
109    
110     var myThis = this;
111     document.defaultView.addEventListener ('keydown', function (e) {
112     myThis.onKeyDown (e, myThis);
113     }, false);
114    
115     var h = document.getElementsByTagNameNS (this.NS_XHTML2, 'head')[0];
116     var l = document.createElementNS (this.NS_XHTML1, 'link');
117     l.setAttribute ('rel', 'first');
118     l.setAttribute ('href', 'javascript:document.__slideControl__.setCurrentSlide(0)');
119     l.setAttribute ('title', this.getSlideTitle (0));
120     h.appendChild (l);
121    
122     l = document.createElementNS (this.NS_XHTML1, 'link');
123     l.setAttribute ('rel', 'last');
124     l.setAttribute ('href', 'javascript:document.__slideControl__.setCurrentSlide(-1)');
125     l.setAttribute ('title', this.getSlideTitle (-1));
126     h.appendChild (l);
127    
128     l = document.createElementNS (this.NS_XHTML1, 'link');
129     l.setAttribute ('rel', 'next');
130     l.setAttribute ('href', 'javascript:document.__slideControl__.setCurrentSlide(document.__slideControl__.currentSlideIndex+1)');
131     h.appendChild (l);
132    
133     l = document.createElementNS (this.NS_XHTML1, 'link');
134     l.setAttribute ('rel', 'prev');
135     l.setAttribute ('id', 'link-prev-page');
136     l.setAttribute ('href', 'javascript:document.__slideControl__.setCurrentSlide(document.__slideControl__.currentSlideIndex-1)');
137     h.appendChild (l);
138     this.setCurrentSlide (0);
139     ]]>
140     </constructor>
141     </implementation>
142     </binding>
143     <binding id="seqNo">
144     <implementation>
145     <field name="seqNo">[]</field>
146     <constructor type="application/x-javascript" xml:space="preserve"><![CDATA[
147     var t;
148     var seqName = this.getAttribute ('name');
149     if (!document.__slideSeqNo__) {
150     document.__slideSeqNo__ = [];
151     }
152     t = document.__slideSeqNo__;
153     if (t[seqName]) {
154     t[seqName]++;
155     } else {
156     t[seqName] = 1;
157     }
158     this.setAttribute ('-seq-no', t[seqName]);
159     ]]></constructor>
160     </implementation>
161     </binding>
162     <binding id="refTo">
163     <implementation>
164     <field name="NS_SLIDE">'urn:x-suika-fam-cx:markup:slide:1'</field>
165     <field name="NS_XHTML1">'http://www.w3.org/1999/xhtml'</field>
166     <field name="NS_XHTML2">'http://www.w3.org/2002/06/xhtml2'</field>
167     <field name="NS_XLINK">'http://www.w3.org/1999/xlink'</field>
168     <method name="getInnerText" type="application/x-javascript">
169     <parameter name="node"/>
170     <body xml:space="preserve"><![CDATA[
171     // <http://white.sakura.ne.jp/~piro/xul/tips/x0013.html>
172     var nodes = node.childNodes;
173     var ret = [];
174     for (var i = 0; i < nodes.length; i++)
175     if (nodes[i].hasChildNodes())
176     ret.push(this.getInnerText(nodes[i]));
177     else if (nodes[i].nodeType == Node.TEXT_NODE)
178     ret.push(nodes[i].nodeValue);
179     else if (nodes[i].alt)
180     ret.push(nodes[i].alt);
181     return ret.join('');
182     ]]></body>
183     </method>
184     <constructor type="application/x-javascript" xml:space="preserve"><![CDATA[
185     var targetId = this.getAttribute ('to');
186     var targetElement = document.getElementById (targetId);
187     if (targetElement && (targetElement.namespaceURI == this.NS_SLIDE) && (targetElement.localName == 'slide')) {
188     targetElement = targetElement.getElementsByTagNameNS (NS_XHTML2, 'h')[0];
189     }
190    
191     if (targetElement) {
192     for (var i = 0; i < targetElement.childNodes.length; i++) {
193     var cN = targetElement.childNodes[i];
194     //if (cN.nodeType != ATTRIBUTE_NODE)
195     // this.appendChild (cN.cloneNode);
196     this.appendChild (document.createTextNode (this.getInnerText (cN)));
197     }
198     this.setAttributeNS (this.NS_XLINK, 'type', 'simple');
199     this.setAttributeNS (this.NS_XLINK, 'href', '#' + targetId);
200     }
201     ]]></constructor>
202     </implementation>
203     </binding>
204     </bindings>
205     <!-- ***** BEGIN LICENSE BLOCK *****
206     - Version: MPL 1.1/GPL 2.0/LGPL 2.1
207     -
208     - The contents of this file are subject to the Mozilla Public License Version
209     - 1.1 (the "License"); you may not use this file except in compliance with
210     - the License. You may obtain a copy of the License at
211     - <http://www.mozilla.org/MPL/>
212     -
213     - Software distributed under the License is distributed on an "AS IS" basis,
214     - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
215     - for the specific language governing rights and limitations under the
216     - License.
217     -
218     - The Original Code is HSML experimental implemention code.
219     -
220     - The Initial Developer of the Original Code is Wakaba.
221     - Portions created by the Initial Developer are Copyright (C) 2003
222     - the Initial Developer. All Rights Reserved.
223     -
224     - Contributor(s):
225     - Wakaba <w@suika.fam.cx>
226     -
227     - Alternatively, the contents of this file may be used under the terms of
228     - either the GNU General Public License Version 2 or later (the "GPL"), or
229     - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
230     - in which case the provisions of the GPL or the LGPL are applicable instead
231     - of those above. If you wish to allow use of your version of this file only
232     - under the terms of either the GPL or the LGPL, and not to allow others to
233     - use your version of this file under the terms of the MPL, indicate your
234     - decision by deleting the provisions above and replace them with the notice
235     - and other provisions required by the LGPL or the GPL. If you do not delete
236     - the provisions above, a recipient may use your version of this file under
237     - the terms of any one of the MPL, the GPL or the LGPL.
238     -
239     - ***** END LICENSE BLOCK ***** -->

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24