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