1 |
dpavlin |
1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 |
|
|
<!-- |
3 |
|
|
高橋メソッドなプレゼンツール in XUL リターンズ |
4 |
|
|
made by Piro |
5 |
|
|
http://piro.sakura.ne.jp/ |
6 |
|
|
|
7 |
|
|
based on |
8 |
|
|
高橋メソッドなプレゼン作成ツール ver.2 made by mala |
9 |
|
|
http://la.ma.la/blog/diary_200504080545.htm |
10 |
|
|
もんたメソッドなプレゼン作成ツール made by mala |
11 |
|
|
http://la.ma.la/blog/diary_200505310749.htm |
12 |
|
|
--> |
13 |
|
|
|
14 |
|
|
<!-- ***** BEGIN LICENSE BLOCK ***** |
15 |
|
|
- Version: MPL 1.1 |
16 |
|
|
- |
17 |
|
|
- The contents of this file are subject to the Mozilla Public License Version |
18 |
|
|
- 1.1 (the "License"); you may not use this file except in compliance with |
19 |
|
|
- the License. You may obtain a copy of the License at |
20 |
|
|
- http://www.mozilla.org/MPL/ |
21 |
|
|
- |
22 |
|
|
- Software distributed under the License is distributed on an "AS IS" basis, |
23 |
|
|
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
24 |
|
|
- for the specific language governing rights and limitations under the |
25 |
|
|
- License. |
26 |
|
|
- |
27 |
|
|
- The Original Code is the Takahashi-Method-based Presentation Tool |
28 |
|
|
- in XUL/Returns. |
29 |
|
|
- |
30 |
|
|
- The Initial Developer of the Original Code is SHIMODA Hiroshi. |
31 |
|
|
- Portions created by the Initial Developer are Copyright (C) 2005-2006 |
32 |
|
|
- the Initial Developer. All Rights Reserved. |
33 |
|
|
- |
34 |
|
|
- Contributor(s): SHIMODA Hiroshi <piro@p.club.ne.jp> |
35 |
|
|
- dynamis <dynamis@mozilla-japan.org> |
36 |
|
|
- matobaa <matobaa@lily.freemail.ne.jp> |
37 |
|
|
- |
38 |
|
|
- ***** END LICENSE BLOCK ***** --> |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> |
42 |
|
|
<?xml-stylesheet href="takahashi.css" type="text/css"?> |
43 |
|
|
|
44 |
|
|
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
45 |
|
|
id="presentation" |
46 |
|
|
xmlns:html="http:/www.w3.org/1999/xhtml" |
47 |
|
|
orient="vertical" |
48 |
|
|
onkeypress="Presentation.onKeyPress(event);"> |
49 |
|
|
|
50 |
|
|
|
51 |
|
|
<html:textarea id="builtinCode" style="visibility: collapse"> |
52 |
|
|
TITLE::高橋メソッドなプレゼンツール in XUL リターンズ |
53 |
|
|
高橋メソッド |
54 |
|
|
in XUL |
55 |
|
|
[[EM:RETURNS]] |
56 |
|
|
---- |
57 |
|
|
HEADER::高橋メソッドなプレゼンツール in XUL リターンズ |
58 |
|
|
CHAPTER::操作説明 |
59 |
|
|
操作 |
60 |
|
|
---- |
61 |
|
|
HEADER::操作 |
62 |
|
|
基本的に |
63 |
|
|
高橋メソッド |
64 |
|
|
in XUL |
65 |
|
|
と同じ |
66 |
|
|
---- |
67 |
|
|
ALIGN::left |
68 |
|
|
Enterか |
69 |
|
|
Page Downか |
70 |
|
|
左クリック |
71 |
|
|
で[次のページ] |
72 |
|
|
---- |
73 |
|
|
ALIGN::right |
74 |
|
|
→でも |
75 |
|
|
↓でも |
76 |
|
|
次のページ |
77 |
|
|
---- |
78 |
|
|
ALIGN::center |
79 |
|
|
キーボード操作時は |
80 |
|
|
次のページへ進む操作で |
81 |
|
|
ラベルをめくれます |
82 |
|
|
(めくっていない |
83 |
|
|
ラベルがなければ |
84 |
|
|
そのまま次のページへ) |
85 |
|
|
---- |
86 |
|
|
一度めくったラベルは |
87 |
|
|
状態を保持するので |
88 |
|
|
---- |
89 |
|
|
ALIGN::right |
90 |
|
|
前のページに戻して |
91 |
|
|
「奥さん、いいですか! |
92 |
|
|
ここですよここ!」 |
93 |
|
|
ができる |
94 |
|
|
---- |
95 |
|
|
Back Spaceか |
96 |
|
|
Page Upか |
97 |
|
|
右クリック |
98 |
|
|
で[前のページ] |
99 |
|
|
---- |
100 |
|
|
←でも |
101 |
|
|
↑でも |
102 |
|
|
前のページ |
103 |
|
|
---- |
104 |
|
|
ALIGN::right |
105 |
|
|
Homeで |
106 |
|
|
最初の |
107 |
|
|
ページ |
108 |
|
|
---- |
109 |
|
|
ALIGN::left |
110 |
|
|
Endで |
111 |
|
|
最後の |
112 |
|
|
ページ |
113 |
|
|
---- |
114 |
|
|
Ctrl-R |
115 |
|
|
で[リロード] |
116 |
|
|
---- |
117 |
|
|
Ctrl-Eで |
118 |
|
|
[編集]モード |
119 |
|
|
突入 |
120 |
|
|
---- |
121 |
|
|
HEADER:: |
122 |
|
|
CHAPTER::編集機能 |
123 |
|
|
編集 |
124 |
|
|
---- |
125 |
|
|
HEADER::編集 |
126 |
|
|
編集モード時は |
127 |
|
|
Ctrl-Nで新しい |
128 |
|
|
ページの追加 |
129 |
|
|
---- |
130 |
|
|
HEADER::機能 |
131 |
|
|
部分 |
132 |
|
|
強調 |
133 |
|
|
---- |
134 |
|
|
テキストを部分的に |
135 |
|
|
[[EM:強調]]できる |
136 |
|
|
[[PRE: |
137 |
|
|
[[EM:強調テキスト]­] |
138 |
|
|
[[EM:強調テキスト:EM]­] |
139 |
|
|
]] |
140 |
|
|
---- |
141 |
|
|
整形済み |
142 |
|
|
テキスト |
143 |
|
|
[[PRE: |
144 |
|
|
[[PRE:整形済み]­] |
145 |
|
|
[[PRE:整形済み:PRE]­] |
146 |
|
|
]] |
147 |
|
|
---- |
148 |
|
|
行内に[[PRE:preformatted text]]を |
149 |
|
|
書ける(けどあんまり意味ない) |
150 |
|
|
---- |
151 |
|
|
複数行にまたがる整形済みテキスト |
152 |
|
|
[[PRE:<html> |
153 |
|
|
<head> |
154 |
|
|
<title>サンプル</title> |
155 |
|
|
</head> |
156 |
|
|
<body> |
157 |
|
|
<p>サンプル</p> |
158 |
|
|
</body> |
159 |
|
|
</html>:PRE]] |
160 |
|
|
ソースコードの例示などに使える |
161 |
|
|
---- |
162 |
|
|
リンク |
163 |
|
|
[[PRE: |
164 |
|
|
[[URI]­] |
165 |
|
|
[[ラベル|URI]­] |
166 |
|
|
]] |
167 |
|
|
---- |
168 |
|
|
[[リンクも埋め込める|http://piro.sakura.ne.jp/]] |
169 |
|
|
ラベル無しリンクも可能↓ |
170 |
|
|
[[http://piro.sakura.ne.jp/]] |
171 |
|
|
---- |
172 |
|
|
[[image src="takahashi.png" width="300" height="168"]] |
173 |
|
|
---- |
174 |
|
|
画像 |
175 |
|
|
---- |
176 |
|
|
[[PRE: |
177 |
|
|
[[IMAGE src="*" width="*" height="*"]­] |
178 |
|
|
[[IMG src="*" width="*" height="*"]­] |
179 |
|
|
]] |
180 |
|
|
---- |
181 |
|
|
インライン[[image src="takahashi.png" width="300" height="168"]]で |
182 |
|
|
[[image src="takahashi.png" width="300" height="168"]] |
183 |
|
|
いくつでも |
184 |
|
|
埋め込める |
185 |
|
|
---- |
186 |
|
|
リンクや |
187 |
|
|
画像のパスの |
188 |
|
|
相対指定は |
189 |
|
|
---- |
190 |
|
|
データファイルの |
191 |
|
|
あるディレクトリ |
192 |
|
|
もしくは |
193 |
|
|
本体のある |
194 |
|
|
ディレクトリを |
195 |
|
|
基準として解釈 |
196 |
|
|
---- |
197 |
|
|
カスタム |
198 |
|
|
スタイル |
199 |
|
|
---- |
200 |
|
|
自分だけのカスタム |
201 |
|
|
指定も可能 |
202 |
|
|
[[PRE: |
203 |
|
|
[[#クラス名:文字列]­] |
204 |
|
|
]] |
205 |
|
|
このように↓解釈 |
206 |
|
|
[[PRE: |
207 |
|
|
<description |
208 |
|
|
class="クラス名" |
209 |
|
|
value="文字列"/> |
210 |
|
|
]] |
211 |
|
|
---- |
212 |
|
|
複数行にまたがる |
213 |
|
|
指定も可能 |
214 |
|
|
[[PRE: |
215 |
|
|
[[#クラス名: |
216 |
|
|
1行目 |
217 |
|
|
2行目 |
218 |
|
|
]­] |
219 |
|
|
]] |
220 |
|
|
このように↓解釈 |
221 |
|
|
[[PRE: |
222 |
|
|
<vbox class="クラス名 block"> |
223 |
|
|
<description value="1行目"/> |
224 |
|
|
<description value="2行目"/> |
225 |
|
|
</vbox> |
226 |
|
|
]] |
227 |
|
|
---- |
228 |
|
|
takahashi.css |
229 |
|
|
に自分で好きな |
230 |
|
|
スタイル指定を |
231 |
|
|
追加しよう! |
232 |
|
|
---- |
233 |
|
|
[[装飾記号|http://homepage2.nifty.com/k_maeda/code/uni/uni44.html]]などの |
234 |
|
|
[[Unicodeの記号文字|http://homepage2.nifty.com/k_maeda/code/unicode.html]] |
235 |
|
|
と組み合わせると |
236 |
|
|
色々できるかも? |
237 |
|
|
---- |
238 |
|
|
HEADER::ヘッダ |
239 |
|
|
FOOTER::フッタ |
240 |
|
|
ヘッダとフッタも |
241 |
|
|
自由に指定できる |
242 |
|
|
[[PRE: |
243 |
|
|
­HEADER::ヘッダ |
244 |
|
|
­FOOTER::フッタ |
245 |
|
|
]] |
246 |
|
|
---- |
247 |
|
|
HEADER:: |
248 |
|
|
FOOTER:: |
249 |
|
|
テキストの水平配置 |
250 |
|
|
(ページ単位) |
251 |
|
|
[[PRE: |
252 |
|
|
­ALIGN::left |
253 |
|
|
­ALIGN::right |
254 |
|
|
­ALIGN::center |
255 |
|
|
]] |
256 |
|
|
---- |
257 |
|
|
テキストの水平配置 |
258 |
|
|
(以後のページすべて) |
259 |
|
|
[[PRE: |
260 |
|
|
­GLOBAL-ALIGN::left |
261 |
|
|
­GLOBAL-ALIGN::right |
262 |
|
|
­GLOBAL-ALIGN::center |
263 |
|
|
]] |
264 |
|
|
---- |
265 |
|
|
HEADER::機能 |
266 |
|
|
FOOTER:: |
267 |
|
|
CHAPTER::起動パラメータ |
268 |
|
|
起動 |
269 |
|
|
パラ |
270 |
|
|
メータ |
271 |
|
|
---- |
272 |
|
|
?page=[数値] |
273 |
|
|
---- |
274 |
|
|
表示ページを |
275 |
|
|
指定して起動 |
276 |
|
|
---- |
277 |
|
|
?data=[パス] |
278 |
|
|
---- |
279 |
|
|
外部データ |
280 |
|
|
ファイルを |
281 |
|
|
読み込み |
282 |
|
|
---- |
283 |
|
|
?edit=true |
284 |
|
|
---- |
285 |
|
|
編集モード |
286 |
|
|
の状態で起動 |
287 |
|
|
---- |
288 |
|
|
HEADER:: |
289 |
|
|
CHAPTER::このアプリケーションについて |
290 |
|
|
ファイ |
291 |
|
|
ル構成 |
292 |
|
|
---- |
293 |
|
|
HEADER::ファイル構成 |
294 |
|
|
[[takahashi.xul]] |
295 |
|
|
[[takahashi.css]] |
296 |
|
|
[[monta-label.png]] |
297 |
|
|
---- |
298 |
|
|
HEADER:: |
299 |
|
|
ライセンスは |
300 |
|
|
[MPL1.1] |
301 |
|
|
ってことで |
302 |
|
|
---- |
303 |
|
|
ご自由に |
304 |
|
|
お使い |
305 |
|
|
下さい |
306 |
|
|
---- |
307 |
|
|
説明 |
308 |
|
|
おわり |
309 |
|
|
---- |
310 |
|
|
Let's Enjoy |
311 |
|
|
Takahashi |
312 |
|
|
Method |
313 |
|
|
Life !! |
314 |
|
|
</html:textarea> |
315 |
|
|
|
316 |
|
|
|
317 |
|
|
<deck flex="1" id="deck"> |
318 |
|
|
|
319 |
|
|
<vbox flex="1" |
320 |
|
|
onmouseup="Presentation.handleEvent(event);" |
321 |
|
|
onmousedown="Presentation.handleEvent(event);" |
322 |
|
|
onmousemove="Presentation.handleEvent(event);"> |
323 |
|
|
<toolbox id="canvasToolbar"> |
324 |
|
|
<toolbar> |
325 |
|
|
<toolbarbutton oncommand="Presentation.home()" label="|<<" |
326 |
|
|
observes="canBack"/> |
327 |
|
|
<toolbarbutton oncommand="Presentation.back()" label="<" |
328 |
|
|
observes="canBack"/> |
329 |
|
|
<toolbarbutton oncommand="Presentation.forward()" label=">" |
330 |
|
|
observes="canForward"/> |
331 |
|
|
<toolbarbutton oncommand="Presentation.end()" label=">>|" |
332 |
|
|
observes="canForward"/> |
333 |
|
|
<toolbarseparator/> |
334 |
|
|
<hbox align="center"> |
335 |
|
|
<textbox id="current_page" size="4" |
336 |
|
|
oninput="if (this.value) Presentation.showPage(parseInt(this.value)-1);"/> |
337 |
|
|
<toolbarbutton id="pages-list-button" |
338 |
|
|
type="menu" |
339 |
|
|
label="Select Page" |
340 |
|
|
tooltiptext="Select Page" |
341 |
|
|
class="dropmarker-button"> |
342 |
|
|
<menupopup id="pages-list" |
343 |
|
|
onpopupshowing="if (event.target == this) Presentation.preventToShowHideToolbar = true;" |
344 |
|
|
onpopuphiding="if (event.target == this) Presentation.preventToShowHideToolbar = false;" |
345 |
|
|
oncommand="Presentation.showPage(parseInt(event.target.value));"/> |
346 |
|
|
</toolbarbutton> |
347 |
|
|
<description value="/"/> |
348 |
|
|
<description id="max_page"/> |
349 |
|
|
</hbox> |
350 |
|
|
<toolbarseparator/> |
351 |
|
|
<vbox flex="2"> |
352 |
|
|
<spacer flex="1"/> |
353 |
|
|
<scrollbar id="scroller" |
354 |
|
|
align="center" orient="horizontal" |
355 |
|
|
oncommand="Presentation.showPage(parseInt(event.target.getAttribute('curpos')));" |
356 |
|
|
onclick="Presentation.showPage(parseInt(event.target.getAttribute('curpos')));" |
357 |
|
|
onmousedown="Presentation.onScrollerDragStart();" |
358 |
|
|
onmousemove="Presentation.onScrollerDragMove();" |
359 |
|
|
onmouseup="Presentation.onScrollerDragDrop();"/> |
360 |
|
|
<spacer flex="1"/> |
361 |
|
|
</vbox> |
362 |
|
|
<toolbarseparator/> |
363 |
|
|
<hbox> |
364 |
|
|
<toolbarbutton label="timer" |
365 |
|
|
oncommand="Presentation.setTimer();" /> |
366 |
|
|
</hbox> |
367 |
|
|
<spacer flex="1"/> |
368 |
|
|
<hbox> |
369 |
|
|
<toolbarbutton label="auto" |
370 |
|
|
id="autoButton" |
371 |
|
|
type="checkbox" |
372 |
|
|
autoCheck="false" |
373 |
|
|
oncommand="Presentation.toggleAutoCruiseMode();" /> |
374 |
|
|
<toolbarbutton id="auto-interval-button" |
375 |
|
|
type="menu" |
376 |
|
|
label="Interval" |
377 |
|
|
tooltiptext="Change Interval" |
378 |
|
|
class="dropmarker-button"> |
379 |
|
|
<menupopup id="auto-interval-list" |
380 |
|
|
onpopupshowing=" |
381 |
|
|
Presentation.preventToShowHideToolbar = true; |
382 |
|
|
(this.getElementsByAttribute('value', Presentation.autoCruiseInterval)[0] || this.lastChild).setAttribute('checked', true); |
383 |
|
|
" |
384 |
|
|
onpopuphiding="Presentation.preventToShowHideToolbar = false;" |
385 |
|
|
oncommand="Presentation.changeAutoCruiseInterval(parseInt(event.target.value));"> |
386 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
387 |
|
|
label="1 sec" value="1000"/> |
388 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
389 |
|
|
label="2 sec" value="2000"/> |
390 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
391 |
|
|
label="3 sec" value="3000"/> |
392 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
393 |
|
|
label="4 sec" value="4000"/> |
394 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
395 |
|
|
label="5 sec" value="5000"/> |
396 |
|
|
<menuseparator/> |
397 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
398 |
|
|
label="1 min" value="60000"/> |
399 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
400 |
|
|
label="2 min" value="120000"/> |
401 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
402 |
|
|
label="3 min" value="180000"/> |
403 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
404 |
|
|
label="4 min" value="240000"/> |
405 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
406 |
|
|
label="5 min" value="300000"/> |
407 |
|
|
<menuseparator/> |
408 |
|
|
<menuitem type="radio" radiogroup="autocruise-interval" |
409 |
|
|
label="Custom" |
410 |
|
|
oncommand=" |
411 |
|
|
var current = Presentation.autoCruiseInterval; |
412 |
|
|
var val = parseInt(prompt('input interval (sec)', parseInt(current/1000))); |
413 |
|
|
if (isNaN(val)) { |
414 |
|
|
event.preventBubble(); |
415 |
|
|
return; |
416 |
|
|
} |
417 |
|
|
else |
418 |
|
|
val = val * 1000; |
419 |
|
|
this.value = val; |
420 |
|
|
"/> |
421 |
|
|
</menupopup> |
422 |
|
|
</toolbarbutton> |
423 |
|
|
</hbox> |
424 |
|
|
<toolbarbutton label="Pen" |
425 |
|
|
id="penButton" |
426 |
|
|
type="checkbox" |
427 |
|
|
autoCheck="false" |
428 |
|
|
oncommand="StrokablePresentationService.toggleCheck();"/> |
429 |
|
|
<toolbarseparator/> |
430 |
|
|
<toolbarbutton id="toggleEva" label="Eva" |
431 |
|
|
type="checkbox" |
432 |
|
|
autoCheck="false" |
433 |
|
|
oncommand="Presentation.toggleEvaMode();"/> |
434 |
|
|
<toolbarseparator/> |
435 |
|
|
<toolbarbutton label="Edit" |
436 |
|
|
oncommand="Presentation.toggleEditMode();"/> |
437 |
|
|
<toolbarbutton oncommand="Presentation.reload();" label="Reload"/> |
438 |
|
|
</toolbar> |
439 |
|
|
</toolbox> |
440 |
|
|
<vbox flex="1" id="canvas"> |
441 |
|
|
<stack flex="1"> |
442 |
|
|
<vbox flex="1"> |
443 |
|
|
<hbox id="headerBox" flex="1"> |
444 |
|
|
<label id="header"/> |
445 |
|
|
<spacer flex="1"/> |
446 |
|
|
</hbox> |
447 |
|
|
<spacer flex="19"/> |
448 |
|
|
<hbox id="footerBox" flex="1"> |
449 |
|
|
<spacer flex="1"/> |
450 |
|
|
<label id="footer"/> |
451 |
|
|
</hbox> |
452 |
|
|
</vbox> |
453 |
|
|
<vbox flex="1" |
454 |
|
|
onclick="Presentation.onPresentationClick(event);"> |
455 |
|
|
<spacer flex="1"/> |
456 |
|
|
<hbox flex="1" id="contentBox"> |
457 |
|
|
<spacer flex="1"/> |
458 |
|
|
<vbox id="content"/> |
459 |
|
|
<spacer flex="1"/> |
460 |
|
|
</hbox> |
461 |
|
|
<spacer flex="1"/> |
462 |
|
|
</vbox> |
463 |
|
|
</stack> |
464 |
|
|
</vbox> |
465 |
|
|
<hbox id="indicatorBar" |
466 |
|
|
onclick="Presentation.onIndicatorBarClick(event);"> |
467 |
|
|
<stack flex="1"> |
468 |
|
|
<vbox> |
469 |
|
|
<progressmeter id="remainingPageIndicator" |
470 |
|
|
type="determined" value="0" |
471 |
|
|
flex="1"/> |
472 |
|
|
<progressmeter id="remainingTimeIndicator" |
473 |
|
|
type="determined" value="0" |
474 |
|
|
flex="1" |
475 |
|
|
collapsed="true"/> |
476 |
|
|
</vbox> |
477 |
|
|
<hbox flex="1"> |
478 |
|
|
<label value="Next:"/> |
479 |
|
|
<description id="nextPage" flex="1" crop="end"/> |
480 |
|
|
</hbox> |
481 |
|
|
</stack> |
482 |
|
|
</hbox> |
483 |
|
|
</vbox> |
484 |
|
|
|
485 |
|
|
|
486 |
|
|
<vbox flex="1" id="edit"> |
487 |
|
|
<toolbox> |
488 |
|
|
<toolbar> |
489 |
|
|
<menubar flex="1"> |
490 |
|
|
<menu label="File"> |
491 |
|
|
<menupopup> |
492 |
|
|
<menuitem label="Save" |
493 |
|
|
key="key_save" |
494 |
|
|
oncommand="Presentation.output()"/> |
495 |
|
|
<menuitem label="Reload" |
496 |
|
|
key="key_reload" |
497 |
|
|
oncommand="Presentation.reload()"/> |
498 |
|
|
</menupopup> |
499 |
|
|
</menu> |
500 |
|
|
<menu label="Insert"> |
501 |
|
|
<menupopup> |
502 |
|
|
<menuitem label="New Page" |
503 |
|
|
key="key_insert_newpage" |
504 |
|
|
oncommand="Presentation.insert('page')"/> |
505 |
|
|
<menuseparator/> |
506 |
|
|
<menuitem label="Header" |
507 |
|
|
oncommand="Presentation.insert('header')"/> |
508 |
|
|
<menuitem label="Footer" |
509 |
|
|
oncommand="Presentation.insert('footer')"/> |
510 |
|
|
<menuseparator/> |
511 |
|
|
<menuitem label="Link" |
512 |
|
|
oncommand="Presentation.insert('link')"/> |
513 |
|
|
<menuitem label="Emphasis" |
514 |
|
|
oncommand="Presentation.insert('em')"/> |
515 |
|
|
<menuitem label="Preformatted" |
516 |
|
|
oncommand="Presentation.insert('pre')"/> |
517 |
|
|
<menuitem label="Monta" |
518 |
|
|
oncommand="Presentation.insert('monta')"/> |
519 |
|
|
<menuitem label="Image" |
520 |
|
|
oncommand="Presentation.insert('img')"/> |
521 |
|
|
</menupopup> |
522 |
|
|
</menu> |
523 |
|
|
</menubar> |
524 |
|
|
<toolbarseparator/> |
525 |
|
|
<toolbarbutton label="View" |
526 |
|
|
oncommand="Presentation.toggleEditMode();"/> |
527 |
|
|
<toolbarbutton oncommand="Presentation.reload();" label="Reload"/> |
528 |
|
|
</toolbar> |
529 |
|
|
</toolbox> |
530 |
|
|
<textbox id="textField" flex="1" multiline="true" |
531 |
|
|
oninput="Presentation.onEdit()"/> |
532 |
|
|
</vbox> |
533 |
|
|
|
534 |
|
|
</deck> |
535 |
|
|
|
536 |
|
|
|
537 |
|
|
<broadcasterset> |
538 |
|
|
<broadcaster id="canBack"/> |
539 |
|
|
<broadcaster id="canForward"/> |
540 |
|
|
</broadcasterset> |
541 |
|
|
|
542 |
|
|
<commandset> |
543 |
|
|
<command id="cmd_forward" |
544 |
|
|
oncommand="if (Presentation.isPresentationMode) Presentation.forward();"/> |
545 |
|
|
<command id="cmd_forwardStep" |
546 |
|
|
oncommand="if (Presentation.isPresentationMode) Presentation.forwardStep();"/> |
547 |
|
|
<command id="cmd_back" |
548 |
|
|
oncommand="if (Presentation.isPresentationMode) Presentation.back();"/> |
549 |
|
|
<command id="cmd_home" |
550 |
|
|
oncommand="if (Presentation.isPresentationMode) Presentation.home();"/> |
551 |
|
|
<command id="cmd_end" |
552 |
|
|
oncommand="if (Presentation.isPresentationMode) Presentation.end();"/> |
553 |
|
|
</commandset> |
554 |
|
|
<keyset> |
555 |
|
|
<key keycode="VK_ENTER" command="cmd_forwardStep"/> |
556 |
|
|
<key keycode="VK_RETURN" command="cmd_forwardStep"/> |
557 |
|
|
<key keycode="VK_PAGE_DOWN" command="cmd_forwardStep"/> |
558 |
|
|
<key keycode="VK_RIGHT" command="cmd_forwardStep"/> |
559 |
|
|
<key keycode="VK_DOWN" command="cmd_forwardStep"/> |
560 |
|
|
<!--key keycode="VK_BACK_SPACE" command="cmd_back"/--> |
561 |
|
|
<key keycode="VK_PAGE_UP" command="cmd_back"/> |
562 |
|
|
<key keycode="VK_UP" command="cmd_back"/> |
563 |
|
|
<key keycode="VK_LEFT" command="cmd_back"/> |
564 |
|
|
<key keycode="VK_HOME" command="cmd_home"/> |
565 |
|
|
<key keycode="VK_END" command="cmd_end"/> |
566 |
|
|
|
567 |
|
|
<key id="key_insert_newpage" |
568 |
|
|
key="n" modifiers="accel" oncommand="Presentation.insert('page');"/> |
569 |
|
|
|
570 |
|
|
<key id="key_save" |
571 |
|
|
key="s" modifiers="accel" oncommand="Presentation.output();"/> |
572 |
|
|
<key id="key_reload" |
573 |
|
|
key="r" modifiers="accel" oncommand="Presentation.reload();"/> |
574 |
|
|
|
575 |
|
|
<key key="e" modifiers="accel" oncommand="Presentation.toggleEditMode();"/> |
576 |
|
|
<key key="e" modifiers="accel,shift" oncommand="Presentation.toggleEvaMode();"/> |
577 |
|
|
</keyset> |
578 |
|
|
|
579 |
|
|
|
580 |
|
|
<script type="application/x-javascript"><![CDATA[ |
581 |
|
|
|
582 |
|
|
var Presentation = { |
583 |
|
|
|
584 |
|
|
size : 9, |
585 |
|
|
montaLabelImage : 'monta-label.png', |
586 |
|
|
|
587 |
|
|
phraseOpenParen : '[', |
588 |
|
|
phraseCloseParen : ']', |
589 |
|
|
makePhraseRegExp : function(aPattern, aFlags) |
590 |
|
|
{ |
591 |
|
|
return new RegExp( |
592 |
|
|
aPattern.replace(/%o(pen)?/gi, '\\'+this.phraseOpenParen) |
593 |
|
|
.replace(/%c(lose)?/gi, '\\'+this.phraseCloseParen), |
594 |
|
|
aFlags |
595 |
|
|
); |
596 |
|
|
}, |
597 |
|
|
|
598 |
|
|
dragStartDelta : 8, |
599 |
|
|
|
600 |
|
|
|
601 |
|
|
initialized : false, |
602 |
|
|
|
603 |
|
|
preventToShowHideToolbar : false, |
604 |
|
|
|
605 |
|
|
showMontaKeywordTimeout : 100, |
606 |
|
|
autoCruiseInterval : 2000, |
607 |
|
|
timerUpdatingInterval : 30000, |
608 |
|
|
standByMontaLabels : [], |
609 |
|
|
shownMontaLabels : [], |
610 |
|
|
|
611 |
|
|
init : function(option){ |
612 |
|
|
if (this.initialized) { |
613 |
|
|
this.startPresentation(); |
614 |
|
|
return; |
615 |
|
|
} |
616 |
|
|
this.initialized = true; |
617 |
|
|
|
618 |
|
|
|
619 |
|
|
this._offset = 0; |
620 |
|
|
this.canvas = document.getElementById('canvas'); |
621 |
|
|
this.content = document.getElementById('content'); |
622 |
|
|
this.header = document.getElementById('header'); |
623 |
|
|
this.footer = document.getElementById('footer'); |
624 |
|
|
this.next = document.getElementById('nextPage'); |
625 |
|
|
|
626 |
|
|
this.indicatorBar = document.getElementById('indicatorBar'); |
627 |
|
|
this.remainder = document.getElementById('remainingPageIndicator'); |
628 |
|
|
this.timer = document.getElementById('remainingTimeIndicator'); |
629 |
|
|
|
630 |
|
|
this.list = document.getElementById('pages-list'); |
631 |
|
|
this.textbox = document.getElementById('textField'); |
632 |
|
|
this.deck = document.getElementById('deck'); |
633 |
|
|
this.scroller = document.getElementById('scroller'); |
634 |
|
|
|
635 |
|
|
this.toolbar = document.getElementById('canvasToolbar'); |
636 |
|
|
this.toolbarHeight = this.toolbar.boxObject.height; |
637 |
|
|
this.isToolbarHidden = true; |
638 |
|
|
this.toolbar.setAttribute('style', 'margin-top:'+(0-this.toolbarHeight)+'px;margin-bottom:0px;'); |
639 |
|
|
|
640 |
|
|
this.preloadImage(this.montaLabelImage); |
641 |
|
|
|
642 |
|
|
window.addEventListener('resize', this, false); |
643 |
|
|
window.addEventListener('contextmenu', this, false); |
644 |
|
|
|
645 |
|
|
if(option){ |
646 |
|
|
for(var i in option){this[i] = option[i]} |
647 |
|
|
} |
648 |
|
|
|
649 |
|
|
if (this.readParameter()) { |
650 |
|
|
this.startPresentation(); |
651 |
|
|
} |
652 |
|
|
|
653 |
|
|
document.documentElement.focus(); |
654 |
|
|
}, |
655 |
|
|
|
656 |
|
|
startPresentation : function() |
657 |
|
|
{ |
658 |
|
|
if (this.data.length) |
659 |
|
|
document.title = this.data[0].title || this.data[0].header || this.data[0].text.join(' '); |
660 |
|
|
|
661 |
|
|
this.takahashi(); |
662 |
|
|
}, |
663 |
|
|
|
664 |
|
|
takahashi : function() { |
665 |
|
|
if(!this.data[this.offset]){ |
666 |
|
|
this.offset = this.data.length-1; |
667 |
|
|
} |
668 |
|
|
document.getElementById("current_page").value = this.offset+1; |
669 |
|
|
document.getElementById("max_page").value = this.data.length; |
670 |
|
|
|
671 |
|
|
this.scroller.setAttribute('maxpos', this.data.length-1); |
672 |
|
|
this.scroller.setAttribute('curpos', this.offset); |
673 |
|
|
|
674 |
|
|
var broadcaster = document.getElementById('canBack'); |
675 |
|
|
if (!this.offset) |
676 |
|
|
broadcaster.setAttribute('disabled', true); |
677 |
|
|
else |
678 |
|
|
broadcaster.removeAttribute('disabled'); |
679 |
|
|
|
680 |
|
|
var broadcaster = document.getElementById('canForward'); |
681 |
|
|
if (this.offset == this.data.length-1) |
682 |
|
|
broadcaster.setAttribute('disabled', true); |
683 |
|
|
else |
684 |
|
|
broadcaster.removeAttribute('disabled'); |
685 |
|
|
|
686 |
|
|
this.canvas.setAttribute('rendering', true); |
687 |
|
|
|
688 |
|
|
|
689 |
|
|
|
690 |
|
|
this.header.removeAttribute('style'); |
691 |
|
|
this.footer.removeAttribute('style'); |
692 |
|
|
this.content.removeAttribute('style'); |
693 |
|
|
|
694 |
|
|
this.standByMontaLabels = []; |
695 |
|
|
this.clickableNodes = []; |
696 |
|
|
|
697 |
|
|
|
698 |
|
|
if ('title' in this.data[this.offset]) |
699 |
|
|
document.title = this.data[this.offset].title; |
700 |
|
|
|
701 |
|
|
this.header.setAttribute('style', 'font-size:10px;'); |
702 |
|
|
this.header.value = this.data[this.offset].header; |
703 |
|
|
this.footer.setAttribute('style', 'font-size:10px;'); |
704 |
|
|
this.footer.value = this.data[this.offset].footer; |
705 |
|
|
|
706 |
|
|
var text = this.data[this.offset].text; |
707 |
|
|
var range = document.createRange(); |
708 |
|
|
range.selectNodeContents(this.content); |
709 |
|
|
range.deleteContents(); |
710 |
|
|
range.detach(); |
711 |
|
|
|
712 |
|
|
var line; |
713 |
|
|
var newLine; |
714 |
|
|
var uri; |
715 |
|
|
var image_width; |
716 |
|
|
var image_total_width = 0; |
717 |
|
|
var image_height; |
718 |
|
|
var image_total_height = 0; |
719 |
|
|
var image_src; |
720 |
|
|
|
721 |
dpavlin |
2 |
var labelId = 0; |
722 |
dpavlin |
1 |
var lineRegExp = this.makePhraseRegExp('^([^%O]+)?(%O%Oem:((.+?)(:em)?%C%C)?|%O%Opre:((.+?)(:pre)?%C%C)?|%O%O\#[^:]+:((.+?)%C%C)?|%O%Oima?ge? +src="([^"]+)" +width="([0-9]+)" +height="([0-9]+)"[^%C]*%C%C|%O%O(([^\|]+)?\\||)([^%C]+)%C%C|%O([^%C]+)%C)(.+)?', 'i'); |
723 |
|
|
|
724 |
dpavlin |
3 |
var emRegExp = this.makePhraseRegExp('^([^%O]+)?%O%Oem:(.+?)(:em)?%C%C', 'i'); |
725 |
dpavlin |
1 |
var emStartRegExp = this.makePhraseRegExp('^([^%O]+)?%O%Oem:(.*)', 'i'); |
726 |
|
|
var emEndRegExp = this.makePhraseRegExp('^(.*?)((:em)?%C%C)', 'i'); |
727 |
|
|
|
728 |
|
|
var preRegExp = this.makePhraseRegExp('^([^%O]+)?%O%Opre:(.+?)(:pre)?%C%C', 'i'); |
729 |
|
|
var preStartRegExp = this.makePhraseRegExp('^([^%O]+)?%O%Opre:(.*)', 'i'); |
730 |
|
|
var preEndRegExp = this.makePhraseRegExp('^(.*?)((:pre)?%C%C)', 'i'); |
731 |
|
|
|
732 |
|
|
var styleRegExp = this.makePhraseRegExp('^([^%O]+)?%O%O\\#([^:]+):(.+?)%C%C', ''); |
733 |
|
|
var styleStartRegExp = this.makePhraseRegExp('^([^%O]+)?%O%O\\#([^:]+):(.*)', ''); |
734 |
|
|
var styleEndRegExp = this.makePhraseRegExp('^(.*?)(%C%C)', ''); |
735 |
|
|
|
736 |
|
|
var imagesRegExp = this.makePhraseRegExp('^([^%O]+)?%O%Oima?ge? +src="([^"]+)" +width="([0-9]+)" +height="([0-9]+)"[^%C]*%C%C', 'i'); |
737 |
|
|
|
738 |
|
|
var linksRegExp = this.makePhraseRegExp('^([^%O]+)?%O%O(([^|]+)?\\||)([^%C]+)%C%C', ''); |
739 |
|
|
|
740 |
dpavlin |
7 |
var wikiRegExp = this.makePhraseRegExp('^([^%O]+)?%O([0-9]*)([#!])?([:\/\*_-])([^%C]+)[:\/\*_-]%C', ''); |
741 |
dpavlin |
4 |
|
742 |
dpavlin |
1 |
var montaRegExp = this.makePhraseRegExp('^([^%O]+)?%O([^%C]+)%C', ''); |
743 |
|
|
|
744 |
|
|
var inBlock = false, |
745 |
|
|
blockClass = '', |
746 |
|
|
blockContents = []; |
747 |
|
|
|
748 |
|
|
var fragment = document.createDocumentFragment(); |
749 |
|
|
|
750 |
|
|
for (var i = 0, max = text.length; i < max; i++) |
751 |
|
|
{ |
752 |
|
|
fragment.appendChild(document.createElement('hbox')); |
753 |
|
|
fragment.lastChild.setAttribute('align', 'center'); |
754 |
|
|
fragment.lastChild.setAttribute('pack', this.data[this.offset].align); |
755 |
|
|
|
756 |
|
|
line = text[i]; |
757 |
|
|
image_width = 0; |
758 |
|
|
image_height = 0; |
759 |
|
|
if (!line) line = ' '; |
760 |
|
|
|
761 |
|
|
if (inBlock) { |
762 |
|
|
if (blockClass == 'preformatted-text' && |
763 |
|
|
preEndRegExp.test(line)) { |
764 |
|
|
inBlock = false; |
765 |
|
|
blockContents.push(RegExp.$1); |
766 |
|
|
line = line.substring((RegExp.$1+RegExp.$2).length); |
767 |
|
|
|
768 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
769 |
|
|
fragment.lastChild.lastChild.setAttribute('class', 'preformatted-text block'); |
770 |
|
|
fragment.lastChild.lastChild.appendChild(document.createTextNode( |
771 |
|
|
blockContents.join('\n') |
772 |
|
|
.replace(/^[\r\n\s]+/, '') |
773 |
|
|
.replace(/[\r\n\s]+$/, '') |
774 |
|
|
.replace(/&/g, '&') |
775 |
|
|
.replace(/"/g, '"') |
776 |
|
|
.replace(/>/g, '>') |
777 |
|
|
.replace(/</g, '<') |
778 |
|
|
)); |
779 |
|
|
|
780 |
|
|
blockClass = ''; |
781 |
|
|
blockContents = []; |
782 |
|
|
} |
783 |
|
|
else if (emEndRegExp.test(line) || styleEndRegExp.test(line)) { |
784 |
|
|
inBlock = false; |
785 |
|
|
blockContents.push(RegExp.$1); |
786 |
|
|
line = line.substring((RegExp.$1+RegExp.$2).length); |
787 |
|
|
|
788 |
|
|
fragment.lastChild.appendChild(document.createElement('vbox')); |
789 |
|
|
fragment.lastChild.lastChild.setAttribute('class', blockClass+' block'); |
790 |
|
|
fragment.lastChild.lastChild.setAttribute('align', this.data[this.offset].align); |
791 |
|
|
blockContents = blockContents.join('\n') |
792 |
|
|
.replace(/^[\r\n\s]+/, '') |
793 |
|
|
.replace(/[\r\n\s]+$/, '') |
794 |
|
|
.split('\n'); |
795 |
|
|
for (var j = 0, jmax = blockContents.length; j < jmax; j++) |
796 |
|
|
{ |
797 |
|
|
fragment.lastChild.lastChild.appendChild(document.createElement('description')); |
798 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('value', blockContents[j]); |
799 |
|
|
} |
800 |
|
|
|
801 |
|
|
blockClass = ''; |
802 |
|
|
blockContents = []; |
803 |
|
|
} |
804 |
|
|
else { |
805 |
|
|
blockContents.push(line); |
806 |
|
|
continue; |
807 |
|
|
} |
808 |
|
|
} |
809 |
|
|
|
810 |
|
|
while (line.match(lineRegExp)) |
811 |
|
|
{ |
812 |
|
|
if (RegExp.$1) { |
813 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
814 |
|
|
fragment.lastChild.lastChild.setAttribute('value', RegExp.$1); |
815 |
|
|
} |
816 |
|
|
newLine = line.substring((RegExp.$1+RegExp.$2).length); |
817 |
|
|
|
818 |
|
|
// Preformatted Text |
819 |
|
|
if (preRegExp.test(line)) { |
820 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
821 |
|
|
fragment.lastChild.lastChild.setAttribute('value', RegExp.$2); |
822 |
|
|
fragment.lastChild.lastChild.setAttribute('class', 'preformatted-text'); |
823 |
|
|
} |
824 |
|
|
else if (preStartRegExp.test(line)) { |
825 |
|
|
inBlock = true; |
826 |
|
|
blockClass = 'preformatted-text'; |
827 |
|
|
blockContents = [RegExp.$2]; |
828 |
|
|
newLine = ''; |
829 |
|
|
} |
830 |
|
|
|
831 |
|
|
// Emphasis |
832 |
|
|
else if (emRegExp.test(line)) { |
833 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
834 |
|
|
fragment.lastChild.lastChild.setAttribute('value', RegExp.$2); |
835 |
|
|
fragment.lastChild.lastChild.setAttribute('class', 'em-text'); |
836 |
|
|
} |
837 |
|
|
else if (emStartRegExp.test(line)) { |
838 |
|
|
inBlock = true; |
839 |
|
|
blockClass = 'em-text'; |
840 |
|
|
blockContents = [RegExp.$2]; |
841 |
|
|
newLine = ''; |
842 |
|
|
} |
843 |
|
|
|
844 |
|
|
// User-defined Styles |
845 |
|
|
else if (styleRegExp.test(line)) { |
846 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
847 |
|
|
fragment.lastChild.lastChild.setAttribute('value', RegExp.$3); |
848 |
|
|
fragment.lastChild.lastChild.setAttribute('class', RegExp.$2); |
849 |
|
|
} |
850 |
|
|
else if (styleStartRegExp.test(line)) { |
851 |
|
|
inBlock = true; |
852 |
|
|
blockClass = RegExp.$2; |
853 |
|
|
blockContents = [RegExp.$3]; |
854 |
|
|
newLine = ''; |
855 |
|
|
} |
856 |
|
|
|
857 |
|
|
// Images |
858 |
|
|
else if (imagesRegExp.test(line)) { |
859 |
|
|
fragment.lastChild.appendChild(document.createElement('image')); |
860 |
|
|
image_src = RegExp.$2; |
861 |
|
|
if (image_src.indexOf('http://') < 0 && |
862 |
|
|
image_src.indexOf('https://') < 0) |
863 |
|
|
image_src = this.dataFolder+image_src; |
864 |
|
|
fragment.lastChild.lastChild.setAttribute('src', image_src); |
865 |
|
|
fragment.lastChild.lastChild.setAttribute('width', parseInt(RegExp.$3 || '0')); |
866 |
|
|
fragment.lastChild.lastChild.setAttribute('height', parseInt(RegExp.$4 || '0')); |
867 |
|
|
image_width += parseInt(RegExp.$3 || '0'); |
868 |
|
|
image_height = Math.max(image_height, parseInt(RegExp.$4 || '0')); |
869 |
|
|
} |
870 |
|
|
|
871 |
|
|
// Links |
872 |
|
|
else if (linksRegExp.test(line)) { |
873 |
|
|
uri = RegExp.$4; |
874 |
|
|
if (uri.indexOf('://') < 0) |
875 |
|
|
uri = this.dataFolder+uri; |
876 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
877 |
|
|
fragment.lastChild.lastChild.setAttribute('value', RegExp.$3 || RegExp.$4); |
878 |
|
|
fragment.lastChild.lastChild.setAttribute('href', uri); |
879 |
|
|
fragment.lastChild.lastChild.setAttribute('tooltiptext', uri); |
880 |
|
|
fragment.lastChild.lastChild.setAttribute('statustext', uri); |
881 |
|
|
fragment.lastChild.lastChild.setAttribute('class', 'link-text'); |
882 |
|
|
|
883 |
|
|
this.clickableNodes.push(fragment.lastChild.lastChild); |
884 |
|
|
} |
885 |
|
|
|
886 |
dpavlin |
4 |
// modify font size and wiki-style |
887 |
|
|
else if (wikiRegExp.test(line)) { |
888 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
889 |
dpavlin |
5 |
fragment.lastChild.lastChild.setAttribute('value', RegExp.$5); |
890 |
dpavlin |
4 |
var style = 'font-size:'+ ( RegExp.$2 || 100 ) +'%'; |
891 |
dpavlin |
5 |
if (RegExp.$4 == '*') { |
892 |
dpavlin |
4 |
style += '; font-weight: bold;'; |
893 |
dpavlin |
5 |
} else if (RegExp.$4 == '/') { |
894 |
dpavlin |
4 |
style += '; font-style: italic;'; |
895 |
dpavlin |
5 |
} else if (RegExp.$4 == '_') { |
896 |
dpavlin |
4 |
style += '; text-decoration: underline;'; |
897 |
dpavlin |
7 |
} else if (RegExp.$4 == '-') { |
898 |
|
|
style += '; text-decoration: line-through;'; |
899 |
dpavlin |
4 |
} |
900 |
|
|
fragment.lastChild.lastChild.setAttribute('style', style); |
901 |
dpavlin |
5 |
if (RegExp.$3 == '!') fragment.lastChild.lastChild.setAttribute('class', 'em-text'); |
902 |
|
|
else if (RegExp.$3 == '#') fragment.lastChild.lastChild.setAttribute('class', 'preformatted-text'); |
903 |
dpavlin |
4 |
} |
904 |
|
|
|
905 |
dpavlin |
1 |
// Monta |
906 |
|
|
else if (montaRegExp.test(line)) { |
907 |
|
|
fragment.lastChild.appendChild(document.createElement('stack')); |
908 |
|
|
|
909 |
|
|
fragment.lastChild.lastChild.appendChild(document.createElement('description')); |
910 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('value', RegExp.$2); |
911 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('class', 'monta-text'); |
912 |
|
|
|
913 |
|
|
fragment.lastChild.lastChild.appendChild(document.createElement('spacer')); |
914 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('flex', 1); |
915 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('class', 'monta-label'); |
916 |
|
|
|
917 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('label-id', 'label-' + (++labelId)); |
918 |
|
|
|
919 |
|
|
if (!this.shownMontaLabels[this.offset] || !this.shownMontaLabels[this.offset]['label-'+labelId]) { |
920 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('monta-hidden', 'true'); |
921 |
|
|
this.standByMontaLabels[this.standByMontaLabels.length] = fragment.lastChild.lastChild.lastChild; |
922 |
|
|
} |
923 |
|
|
else { |
924 |
|
|
fragment.lastChild.lastChild.lastChild.setAttribute('monta-hidden', 'false'); |
925 |
|
|
} |
926 |
|
|
|
927 |
|
|
this.clickableNodes.push(fragment.lastChild.lastChild.lastChild); |
928 |
|
|
} |
929 |
|
|
|
930 |
|
|
line = newLine; |
931 |
|
|
} |
932 |
|
|
|
933 |
|
|
if (line) { |
934 |
|
|
fragment.lastChild.appendChild(document.createElement('description')); |
935 |
|
|
fragment.lastChild.lastChild.setAttribute('value', line); |
936 |
|
|
} |
937 |
|
|
|
938 |
|
|
image_total_width = Math.max(image_total_width, image_width); |
939 |
|
|
image_total_height += image_height; |
940 |
|
|
} |
941 |
|
|
|
942 |
|
|
this.content.setAttribute('style', 'font-size:10px;'); |
943 |
|
|
this.content.appendChild(fragment); |
944 |
|
|
|
945 |
|
|
this.clickableNodes.push(this.content); |
946 |
|
|
|
947 |
|
|
|
948 |
|
|
this.fitToCanvas(this.header, this.header.parentNode, 0, 0); |
949 |
|
|
this.fitToCanvas(this.footer, this.footer.parentNode, 0, 0); |
950 |
|
|
this.fitToCanvas( |
951 |
|
|
this.content, |
952 |
|
|
this.canvas, |
953 |
|
|
image_total_width, |
954 |
|
|
image_total_height |
955 |
|
|
+(this.header.boxObject.height*2) |
956 |
|
|
// +(this.footer.boxObject.height*2) |
957 |
|
|
); |
958 |
|
|
|
959 |
|
|
|
960 |
|
|
var checkedItems = this.list.getElementsByAttribute('checked', 'true'); |
961 |
|
|
max = checkedItems.length; |
962 |
|
|
for (i = 0; i < max; i++) |
963 |
|
|
checkedItems[i].removeAttribute('checked'); |
964 |
|
|
|
965 |
|
|
this.list.getElementsByAttribute('value', this.offset)[0].setAttribute('checked', true); |
966 |
|
|
|
967 |
|
|
this.canvas.removeAttribute('rendering'); |
968 |
|
|
this.setHash('page', 'page'+(this.offset+1)); |
969 |
|
|
|
970 |
|
|
this.next.value = (this.offset <= this.data.length-2) ? (this.data[this.offset+1].plain.join('') || this.data[this.offset+1].text.join('')).replace(/\s+/g, ' ') : '(no page)' ; |
971 |
|
|
this.remainder.setAttribute('value', this.offset == 0 ? 0 : parseInt(((this.offset)/(this.data.length-1))*100)); |
972 |
|
|
|
973 |
|
|
var event = document.createEvent('Events'); |
974 |
|
|
event.initEvent('PresentationRedraw', false, true); |
975 |
|
|
this.canvas.dispatchEvent(event); |
976 |
|
|
}, |
977 |
|
|
fitToCanvas : function(aContent, aCanvas, aOffsetWidth, aOffsetHeight) |
978 |
|
|
{ |
979 |
|
|
aContent.removeAttribute('style'); |
980 |
|
|
aContent.setAttribute('style', 'font-size:10px;'); |
981 |
|
|
|
982 |
|
|
if (!aContent.boxObject.width) return; |
983 |
|
|
|
984 |
|
|
var canvas_w = aCanvas.boxObject.width; |
985 |
|
|
var canvas_h = aCanvas.boxObject.height-aOffsetHeight; |
986 |
|
|
|
987 |
|
|
var content_w = aContent.boxObject.width; |
988 |
|
|
var new_fs = Math.round((canvas_w/content_w) * this.size); |
989 |
|
|
aContent.setAttribute('style', 'font-size:'+ new_fs + "px"); |
990 |
|
|
|
991 |
|
|
if (aContent.boxObject.width < aOffsetWidth) { |
992 |
|
|
content_w = aOffsetWidth; |
993 |
|
|
new_fs = Math.round((canvas_w/content_w) * this.size); |
994 |
|
|
aContent.setAttribute('style', 'font-size:'+ new_fs + "px"); |
995 |
|
|
} |
996 |
|
|
|
997 |
|
|
var content_h = aContent.boxObject.height; |
998 |
|
|
if(content_h >= canvas_h){ |
999 |
|
|
state='height'; |
1000 |
|
|
content_h = aContent.boxObject.height; |
1001 |
|
|
new_fs = Math.round((canvas_h/content_h) * new_fs); |
1002 |
|
|
aContent.setAttribute('style', 'font-size:'+ new_fs + "px"); |
1003 |
|
|
} |
1004 |
|
|
}, |
1005 |
|
|
|
1006 |
|
|
reload : function() { |
1007 |
|
|
var file = String(location.href).replace(/#.+$/, ''); |
1008 |
|
|
if (this.dataPath != file) { |
1009 |
|
|
var path = this.dataPath; |
1010 |
|
|
var request = new XMLHttpRequest(); |
1011 |
|
|
request.open('GET', path); |
1012 |
|
|
request.onload = function() { |
1013 |
|
|
Presentation.textbox.value = request.responseText; |
1014 |
|
|
Presentation.data = Presentation.textbox.value; |
1015 |
|
|
Presentation.init(); |
1016 |
|
|
|
1017 |
|
|
path = null; |
1018 |
|
|
request = null; |
1019 |
|
|
}; |
1020 |
|
|
request.send(null); |
1021 |
|
|
} |
1022 |
|
|
else |
1023 |
|
|
window.location.reload(); |
1024 |
|
|
}, |
1025 |
|
|
|
1026 |
|
|
forward : function(){ |
1027 |
|
|
this.offset++; |
1028 |
|
|
this.takahashi(); |
1029 |
|
|
}, |
1030 |
|
|
forwardStep : function(){ |
1031 |
|
|
if (this.standByMontaLabels.length > 0) { |
1032 |
|
|
while (this.standByMontaLabels.length && |
1033 |
|
|
this.standByMontaLabels[0].getAttribute('monta-hidden') != 'true') |
1034 |
|
|
this.standByMontaLabels.splice(0, 1); |
1035 |
|
|
|
1036 |
|
|
if (this.standByMontaLabels.length) { |
1037 |
|
|
this.showMontaKeyword(this.standByMontaLabels[0]); |
1038 |
|
|
this.standByMontaLabels.splice(0, 1); |
1039 |
|
|
} |
1040 |
|
|
} |
1041 |
|
|
else |
1042 |
|
|
this.forward(); |
1043 |
|
|
}, |
1044 |
|
|
back : function(){ |
1045 |
|
|
this.offset--; |
1046 |
|
|
if(this.offset < 0){this.offset = 0} |
1047 |
|
|
this.takahashi(); |
1048 |
|
|
}, |
1049 |
|
|
home : function(){ |
1050 |
|
|
this.offset = 0; |
1051 |
|
|
this.takahashi(); |
1052 |
|
|
}, |
1053 |
|
|
end : function(){ |
1054 |
|
|
this.offset = this.data.length-1; |
1055 |
|
|
this.takahashi(); |
1056 |
|
|
}, |
1057 |
|
|
showPage : function(aPageOffset){ |
1058 |
|
|
this.offset = aPageOffset ? aPageOffset : 0 ; |
1059 |
|
|
this.takahashi(); |
1060 |
|
|
}, |
1061 |
|
|
|
1062 |
|
|
insert : function(aType) { |
1063 |
dpavlin |
6 |
var scrollTop = this.textbox.scrollTop; |
1064 |
|
|
// alert(this.textbox.scrollTop); |
1065 |
dpavlin |
1 |
switch (aType) |
1066 |
|
|
{ |
1067 |
|
|
case 'page': |
1068 |
|
|
this.insertTextFor('\n----\n', this.textbox, 6); |
1069 |
|
|
break; |
1070 |
|
|
case 'header': |
1071 |
|
|
this.insertTextFor('\nHEADER::\n', this.textbox, 9); |
1072 |
|
|
break; |
1073 |
|
|
case 'footer': |
1074 |
|
|
this.insertTextFor('\nFOOTER::\n', this.textbox, 9); |
1075 |
|
|
break; |
1076 |
|
|
|
1077 |
|
|
case 'em': |
1078 |
|
|
case 'emphasis': |
1079 |
|
|
this.insertTextFor(this.phraseOpenParen+this.phraseOpenParen+'EM:'+this.phraseCloseParen+this.phraseCloseParen, this.textbox, 5); |
1080 |
|
|
break; |
1081 |
|
|
case 'pre': |
1082 |
|
|
case 'preformatted': |
1083 |
|
|
this.insertTextFor(this.phraseOpenParen+this.phraseOpenParen+'PRE:'+this.phraseCloseParen+this.phraseCloseParen, this.textbox, 6); |
1084 |
|
|
break; |
1085 |
|
|
case 'monta': |
1086 |
|
|
this.insertTextFor(this.phraseOpenParen+this.phraseCloseParen, this.textbox, 1); |
1087 |
|
|
break; |
1088 |
|
|
case 'link': |
1089 |
|
|
this.insertTextFor(this.phraseOpenParen+this.phraseOpenParen+'|http://'+this.phraseCloseParen+this.phraseCloseParen, this.textbox, 2); |
1090 |
|
|
break; |
1091 |
|
|
case 'img': |
1092 |
|
|
case 'image': |
1093 |
|
|
this.insertTextFor(this.phraseOpenParen+this.phraseOpenParen+'image src="" width="" height=""'+this.phraseCloseParen+this.phraseCloseParen, this.textbox, 13); |
1094 |
|
|
break; |
1095 |
|
|
|
1096 |
|
|
default: |
1097 |
|
|
return; |
1098 |
|
|
} |
1099 |
dpavlin |
6 |
this.textbox.scrollTop = scrollTop; |
1100 |
dpavlin |
1 |
this.onEdit(); |
1101 |
|
|
}, |
1102 |
|
|
insertTextFor : function(aString, aNode, aPosOffset) |
1103 |
|
|
{ |
1104 |
|
|
var pos = aNode.selectionStart; |
1105 |
|
|
var value = aNode.value; |
1106 |
|
|
aNode.value = [value.substring(0, pos), aString, value.substring(pos, value.length)].join(''); |
1107 |
|
|
aNode.selectionEnd = aNode.selectionStart = pos + (aPosOffset || 0); |
1108 |
|
|
}, |
1109 |
|
|
|
1110 |
|
|
|
1111 |
|
|
output : function() |
1112 |
|
|
{ |
1113 |
|
|
location.href = 'data:application/octet-stream,'+encodeURIComponent(this.textbox.value); |
1114 |
|
|
}, |
1115 |
|
|
|
1116 |
|
|
|
1117 |
|
|
toggleEditMode : function(){ |
1118 |
|
|
this.deck.selectedIndex = this.deck.selectedIndex == 0 ? 1 : 0 ; |
1119 |
|
|
this.setHash('edit', this.deck.selectedIndex == 0 ? '' : 'edit' ); |
1120 |
|
|
}, |
1121 |
|
|
toggleEvaMode : function(){ |
1122 |
|
|
var check = document.getElementById('toggleEva'); |
1123 |
|
|
if (this.canvas.getAttribute('eva') == 'true') { |
1124 |
|
|
this.canvas.removeAttribute('eva'); |
1125 |
|
|
check.checked = false; |
1126 |
|
|
} |
1127 |
|
|
else { |
1128 |
|
|
this.canvas.setAttribute('eva', true); |
1129 |
|
|
check.checked = true; |
1130 |
|
|
} |
1131 |
|
|
this.setHash('eva', check.checked ? 'eva' : '' ); |
1132 |
|
|
}, |
1133 |
|
|
|
1134 |
|
|
|
1135 |
|
|
|
1136 |
|
|
toggleAutoCruiseMode : function() |
1137 |
|
|
{ |
1138 |
|
|
var autoCruise = document.getElementById('autoButton'); |
1139 |
|
|
if(!autoCruise.checked) |
1140 |
|
|
this.startAutoCruise(); |
1141 |
|
|
else |
1142 |
|
|
autoCruise.checked = false; |
1143 |
|
|
}, |
1144 |
|
|
startAutoCruise : function() |
1145 |
|
|
{ |
1146 |
|
|
var autoCruise = document.getElementById('autoButton'); |
1147 |
|
|
autoCruise.checked = true; |
1148 |
|
|
|
1149 |
|
|
if (this.autoCruiseTimer) { |
1150 |
|
|
window.clearTimeout(this.autoCruiseTimer); |
1151 |
|
|
} |
1152 |
|
|
this.autoCruiseTimer = window.setTimeout(this.autoCruise, this.autoCruiseInterval); |
1153 |
|
|
}, |
1154 |
|
|
|
1155 |
|
|
changeAutoCruiseInterval : function(aInterval) |
1156 |
|
|
{ |
1157 |
|
|
this.autoCruiseInterval = aInterval; |
1158 |
|
|
this.startAutoCruise(); |
1159 |
|
|
}, |
1160 |
|
|
|
1161 |
|
|
autoCruise : function() |
1162 |
|
|
{ |
1163 |
|
|
var autoCruise = document.getElementById('autoButton'); |
1164 |
|
|
if (!autoCruise.checked) return; |
1165 |
|
|
|
1166 |
|
|
if(Presentation.offset == Presentation.data.length-1) { |
1167 |
|
|
Presentation.home(); |
1168 |
|
|
} |
1169 |
|
|
else { |
1170 |
|
|
Presentation.forwardStep(); |
1171 |
|
|
} |
1172 |
|
|
Presentation.autoCruiseTimer = window.setTimeout(arguments.callee, Presentation.autoCruiseInterval); |
1173 |
|
|
}, |
1174 |
|
|
autoCruiseTimer : null, |
1175 |
|
|
|
1176 |
|
|
|
1177 |
|
|
|
1178 |
|
|
setHash : function(aKey, aValue) |
1179 |
|
|
{ |
1180 |
|
|
aKey = String(aKey).toLowerCase(); |
1181 |
|
|
var hashArray = String(location.hash).replace(/^#/, '').toLowerCase().split(','); |
1182 |
|
|
|
1183 |
|
|
for (var i = hashArray.length-1; i > -1; i--) |
1184 |
|
|
if (!hashArray[i] || hashArray[i].indexOf(aKey) == 0) |
1185 |
|
|
hashArray.splice(i, 1); |
1186 |
|
|
|
1187 |
|
|
if (aValue) hashArray.push(aValue); |
1188 |
|
|
hashArray.sort(); |
1189 |
|
|
|
1190 |
|
|
location.hash = hashArray.length ? hashArray.join(',') : '' ; |
1191 |
|
|
}, |
1192 |
|
|
|
1193 |
|
|
|
1194 |
|
|
showMontaKeyword : function(aNode) { |
1195 |
|
|
if (aNode.getAttribute('monta-hidden') != 'true') return; |
1196 |
|
|
|
1197 |
|
|
aNode.setAttribute('monta-hidden', 'progress'); |
1198 |
|
|
|
1199 |
|
|
window.setTimeout(this.showMontaKeywordCallback, 0, { |
1200 |
|
|
position : -100, |
1201 |
|
|
node : aNode, |
1202 |
|
|
interval : this.showMontaKeywordTimeout/10 |
1203 |
|
|
}); |
1204 |
|
|
}, |
1205 |
|
|
showMontaKeywordCallback : function(aInfo) { |
1206 |
|
|
if (aInfo.position >= aInfo.node.boxObject.width) { |
1207 |
|
|
aInfo.node.setAttribute('monta-hidden', 'false'); |
1208 |
|
|
if (!Presentation.shownMontaLabels[Presentation.offset]) |
1209 |
|
|
Presentation.shownMontaLabels[Presentation.offset] = []; |
1210 |
|
|
Presentation.shownMontaLabels[Presentation.offset][aInfo.node.getAttribute('label-id')] = true; |
1211 |
|
|
return; |
1212 |
|
|
} |
1213 |
|
|
|
1214 |
|
|
aInfo.position += (aInfo.node.boxObject.width/10); |
1215 |
|
|
aInfo.node.setAttribute('style', 'background-position: '+aInfo.position+'px 0 !important;'); |
1216 |
|
|
window.setTimeout(arguments.callee, aInfo.interval, aInfo); |
1217 |
|
|
}, |
1218 |
|
|
|
1219 |
|
|
|
1220 |
|
|
|
1221 |
|
|
onPresentationClick : function(aEvent) |
1222 |
|
|
{ |
1223 |
|
|
if (!this.isToolbarHidden) |
1224 |
|
|
this.showHideToolbar(); |
1225 |
|
|
|
1226 |
|
|
switch(aEvent.button) |
1227 |
|
|
{ |
1228 |
|
|
case 0: |
1229 |
|
|
switch (aEvent.target.getAttribute('class')) |
1230 |
|
|
{ |
1231 |
|
|
case 'link-text': |
1232 |
|
|
var uri = aEvent.target.getAttribute('href'); |
1233 |
|
|
if (uri) { |
1234 |
|
|
window.open(uri); |
1235 |
|
|
return; |
1236 |
|
|
} |
1237 |
|
|
break; |
1238 |
|
|
|
1239 |
|
|
case 'monta-label': |
1240 |
|
|
if (aEvent.target.getAttribute('monta-hidden') == 'true') { |
1241 |
|
|
this.showMontaKeyword(aEvent.target); |
1242 |
|
|
aEvent.preventBubble(); |
1243 |
|
|
return; |
1244 |
|
|
} |
1245 |
|
|
|
1246 |
|
|
default: |
1247 |
|
|
break; |
1248 |
|
|
} |
1249 |
|
|
this.forward(); |
1250 |
|
|
document.documentElement.focus(); |
1251 |
|
|
break; |
1252 |
|
|
case 2: |
1253 |
|
|
this.back(); |
1254 |
|
|
document.documentElement.focus(); |
1255 |
|
|
break; |
1256 |
|
|
default: |
1257 |
|
|
break; |
1258 |
|
|
} |
1259 |
|
|
}, |
1260 |
|
|
|
1261 |
|
|
onScrollerDragStart : function(){ |
1262 |
|
|
this.scroller.dragging = true; |
1263 |
|
|
}, |
1264 |
|
|
onScrollerDragMove : function(){ |
1265 |
|
|
if (this.scroller.dragging) |
1266 |
|
|
this.showPage(parseInt(this.scroller.getAttribute('curpos'))); |
1267 |
|
|
}, |
1268 |
|
|
onScrollerDragDrop : function(){ |
1269 |
|
|
this.onScrollerDragMove(); |
1270 |
|
|
this.scroller.dragging = false; |
1271 |
|
|
}, |
1272 |
|
|
|
1273 |
|
|
onIndicatorBarClick : function(aEvent) |
1274 |
|
|
{ |
1275 |
|
|
var bar = this.indicatorBar; |
1276 |
|
|
this.showPage(Math.round((aEvent.screenX - bar.boxObject.screenX) / bar.boxObject.width * this.data.length)); |
1277 |
|
|
}, |
1278 |
|
|
onIndicatorBarDragStart : function() |
1279 |
|
|
{ |
1280 |
|
|
this.indicatorBar.dragging = true; |
1281 |
|
|
}, |
1282 |
|
|
onIndicatorBarDragMove : function(aEvent) |
1283 |
|
|
{ |
1284 |
|
|
var bar = this.indicatorBar; |
1285 |
|
|
this.showPage(Math.round((aEvent.screenX - bar.boxObject.screenX) / bar.boxObject.width * this.data.length)); |
1286 |
|
|
}, |
1287 |
|
|
onIndicatorBarDragEnd : function(aEvent) |
1288 |
|
|
{ |
1289 |
|
|
this.onIndicatorBarDragMove(aEvent); |
1290 |
|
|
this.indicatorBar.dragging = false; |
1291 |
|
|
}, |
1292 |
|
|
|
1293 |
|
|
onEdit : function() { |
1294 |
|
|
this.data = this.textbox.value; |
1295 |
|
|
this.init(); |
1296 |
|
|
}, |
1297 |
|
|
|
1298 |
|
|
onKeyPress : function(aEvent) { |
1299 |
|
|
switch(aEvent.keyCode) |
1300 |
|
|
{ |
1301 |
|
|
case aEvent.DOM_VK_BACK_SPACE: |
1302 |
|
|
if (this.isPresentationMode) { |
1303 |
|
|
aEvent.preventBubble(); |
1304 |
|
|
aEvent.preventDefault(); |
1305 |
|
|
Presentation.back(); |
1306 |
|
|
} |
1307 |
|
|
break; |
1308 |
|
|
default: |
1309 |
|
|
break; |
1310 |
|
|
} |
1311 |
|
|
}, |
1312 |
|
|
|
1313 |
|
|
|
1314 |
|
|
|
1315 |
|
|
handleEvent : function(aEvent) |
1316 |
|
|
{ |
1317 |
|
|
switch (aEvent.type) |
1318 |
|
|
{ |
1319 |
|
|
default: |
1320 |
|
|
break; |
1321 |
|
|
|
1322 |
|
|
case 'resize': |
1323 |
|
|
this.takahashi(); // redrwa |
1324 |
|
|
break; |
1325 |
|
|
|
1326 |
|
|
case 'contextmenu': |
1327 |
|
|
aEvent.stopPropagation(); |
1328 |
|
|
aEvent.preventCapture(); |
1329 |
|
|
aEvent.preventDefault(); |
1330 |
|
|
aEvent.preventBubble(); |
1331 |
|
|
break; |
1332 |
|
|
|
1333 |
|
|
|
1334 |
|
|
case 'mouseup': |
1335 |
|
|
this.dragStartX = -1; |
1336 |
|
|
this.dragStartY = -1; |
1337 |
|
|
if (this.indicatorBar.dragging) |
1338 |
|
|
this.onIndicatorBarDragEnd(aEvent); |
1339 |
|
|
break; |
1340 |
|
|
|
1341 |
|
|
case 'mousedown': |
1342 |
|
|
if (this.dragStartX < 0) { |
1343 |
|
|
this.dragStartX = aEvent.clientX; |
1344 |
|
|
this.dragStartY = aEvent.clientY; |
1345 |
|
|
} |
1346 |
|
|
var box = this.indicatorBar.boxObject; |
1347 |
|
|
if (!(aEvent.screenX < box.screenX || |
1348 |
|
|
aEvent.screenY < box.screenY || |
1349 |
|
|
aEvent.screenX > box.screenX+box.width || |
1350 |
|
|
aEvent.screenY > box.screenY+box.height)) |
1351 |
|
|
this.onIndicatorBarDragStart(); |
1352 |
|
|
break; |
1353 |
|
|
|
1354 |
|
|
case 'mousemove': |
1355 |
|
|
this.checkShowHideToolbar(aEvent); |
1356 |
|
|
if (this.indicatorBar.dragging) { |
1357 |
|
|
this.onIndicatorBarDragMove(aEvent); |
1358 |
|
|
return; |
1359 |
|
|
} |
1360 |
|
|
if (this.dragStartX > -1) { |
1361 |
|
|
if (Math.abs(this.dragStartX-aEvent.clientX) > Math.abs(this.dragStartDelta) || |
1362 |
|
|
Math.abs(this.dragStartY-aEvent.clientY) > Math.abs(this.dragStartDelta)) { |
1363 |
|
|
var event = document.createEvent('Events'); |
1364 |
|
|
event.initEvent('StartDragOnCanvas', false, true); |
1365 |
|
|
this.canvas.dispatchEvent(event); |
1366 |
|
|
} |
1367 |
|
|
} |
1368 |
|
|
break; |
1369 |
|
|
|
1370 |
|
|
|
1371 |
|
|
} |
1372 |
|
|
}, |
1373 |
|
|
dragStartX : -1, |
1374 |
|
|
dragStartY : -1, |
1375 |
|
|
|
1376 |
|
|
|
1377 |
|
|
|
1378 |
|
|
onToolbarArea : false, |
1379 |
|
|
toolbarHeight : 0, |
1380 |
|
|
toolbarDelay : 300, |
1381 |
|
|
toolbarTimer : null, |
1382 |
|
|
isToolbarHidden : false, |
1383 |
|
|
checkShowHideToolbar : function(aEvent) { |
1384 |
|
|
if (this.scroller.dragging || this.preventToShowHideToolbar) return; |
1385 |
|
|
|
1386 |
|
|
this.onToolbarArea = (aEvent.clientY < this.toolbarHeight); |
1387 |
|
|
|
1388 |
|
|
if (this.isToolbarHidden == this.onToolbarArea) { |
1389 |
|
|
if (this.toolbarTimer) window.clearTimeout(this.toolbarTimer); |
1390 |
|
|
this.toolbarTimer = window.setTimeout('Presentation.checkShowHideToolbarCallback()', this.toolbarDelay); |
1391 |
|
|
} |
1392 |
|
|
}, |
1393 |
|
|
checkShowHideToolbarCallback : function() { |
1394 |
|
|
if (this.isToolbarHidden == this.onToolbarArea) |
1395 |
|
|
this.showHideToolbar(); |
1396 |
|
|
}, |
1397 |
|
|
|
1398 |
|
|
toolbarAnimationDelay : 100, |
1399 |
|
|
toolbarAnimationSteps : 5, |
1400 |
|
|
toolbarAnimationInfo : null, |
1401 |
|
|
toolbarAnimationTimer : null, |
1402 |
|
|
showHideToolbar : function() |
1403 |
|
|
{ |
1404 |
|
|
if (this.toolbarAnimationTimer) window.clearTimeout(this.toolbarAnimationTimer); |
1405 |
|
|
|
1406 |
|
|
this.toolbarAnimationInfo = { count : 0 }; |
1407 |
|
|
if (this.isToolbarHidden) { |
1408 |
|
|
this.toolbarAnimationInfo.start = 0; |
1409 |
|
|
this.toolbarAnimationInfo.end = this.toolbarHeight; |
1410 |
|
|
} |
1411 |
|
|
else { |
1412 |
|
|
this.toolbarAnimationInfo.start = this.toolbarHeight; |
1413 |
|
|
this.toolbarAnimationInfo.end = 0; |
1414 |
|
|
} |
1415 |
|
|
this.toolbarAnimationInfo.current = 0; |
1416 |
|
|
|
1417 |
|
|
this.toolbar.setAttribute('style', 'margin-top:'+(0-(this.toolbarHeight-this.toolbarAnimationInfo.start))+'px; margin-bottom:'+(0-this.toolbarAnimationInfo.start)+'px;'); |
1418 |
|
|
|
1419 |
|
|
this.toolbarAnimationTimer = window.setTimeout('Presentation.animateToolbar()', this.toolbarAnimationDelay/this.toolbarAnimationSteps); |
1420 |
|
|
}, |
1421 |
|
|
animateToolbar : function() |
1422 |
|
|
{ |
1423 |
|
|
this.toolbarAnimationInfo.current += parseInt(this.toolbarHeight/this.toolbarAnimationSteps); |
1424 |
|
|
|
1425 |
|
|
var top, bottom; |
1426 |
|
|
if (this.toolbarAnimationInfo.start < this.toolbarAnimationInfo.end) { |
1427 |
|
|
top = this.toolbarHeight-this.toolbarAnimationInfo.current; |
1428 |
|
|
bottom = this.toolbarAnimationInfo.current; |
1429 |
|
|
} |
1430 |
|
|
else { |
1431 |
|
|
top = this.toolbarAnimationInfo.current; |
1432 |
|
|
bottom = this.toolbarHeight-this.toolbarAnimationInfo.current; |
1433 |
|
|
} |
1434 |
|
|
|
1435 |
|
|
top = Math.min(Math.max(top, 0), this.toolbarHeight); |
1436 |
|
|
bottom = Math.min(Math.max(bottom, 0), this.toolbarHeight); |
1437 |
|
|
|
1438 |
|
|
this.toolbar.setAttribute('style', 'margin-top:'+(0-top)+'px; margin-bottom:'+(0-bottom)+'px'); |
1439 |
|
|
|
1440 |
|
|
if (this.toolbarAnimationInfo.count < this.toolbarAnimationSteps) { |
1441 |
|
|
this.toolbarAnimationInfo.count++; |
1442 |
|
|
this.toolbarAnimationTimer = window.setTimeout('Presentation.animateToolbar()', this.toolbarAnimationDelay/this.toolbarAnimationSteps); |
1443 |
|
|
} |
1444 |
|
|
else |
1445 |
|
|
this.isToolbarHidden = !this.isToolbarHidden; |
1446 |
|
|
}, |
1447 |
|
|
|
1448 |
|
|
|
1449 |
|
|
|
1450 |
|
|
get offset(){ |
1451 |
|
|
return this._offset; |
1452 |
|
|
}, |
1453 |
|
|
set offset(aValue){ |
1454 |
|
|
this._offset = parseInt(aValue || 0); |
1455 |
|
|
document.documentElement.setAttribute('lastoffset', this.offset); |
1456 |
|
|
return this.offset; |
1457 |
|
|
}, |
1458 |
|
|
|
1459 |
|
|
get data(){ |
1460 |
|
|
if (!this._data) { |
1461 |
|
|
// mozilla splits very long text node into multiple text nodes whose length is less than 4096 bytes. |
1462 |
|
|
// so, we must concat all the text nodes. |
1463 |
|
|
this.textbox.value = ""; |
1464 |
|
|
for (var i = 0; i < document.getElementById('builtinCode').childNodes.length; i++) { |
1465 |
|
|
this.textbox.value += document.getElementById('builtinCode').childNodes[i].nodeValue; |
1466 |
|
|
} |
1467 |
|
|
|
1468 |
|
|
this._data = this.textbox.value.split(/----+/); |
1469 |
|
|
this.initData(); |
1470 |
|
|
} |
1471 |
|
|
|
1472 |
|
|
return this._data; |
1473 |
|
|
}, |
1474 |
|
|
set data(aValue){ |
1475 |
|
|
this._data = aValue.split(/----+/); |
1476 |
|
|
this.initData(); |
1477 |
|
|
return aValue; |
1478 |
|
|
}, |
1479 |
|
|
initData : function() |
1480 |
|
|
{ |
1481 |
|
|
var range = document.createRange(); |
1482 |
|
|
range.selectNodeContents(this.list); |
1483 |
|
|
range.deleteContents(); |
1484 |
|
|
|
1485 |
|
|
|
1486 |
|
|
var regexp = [ |
1487 |
|
|
/^[\r\n\s]+/g, |
1488 |
|
|
/[\r\n\s]+$/g, |
1489 |
|
|
/(\r\n|[\r\n])/g |
1490 |
|
|
]; |
1491 |
|
|
|
1492 |
|
|
var title; |
1493 |
|
|
var titleRegExp = /^(TITLE::)([^\n]*)\n?/im; |
1494 |
|
|
var header = ''; |
1495 |
|
|
var headerRegExp = /^(HEADER::)([^\n]*)\n?/im; |
1496 |
|
|
var footer = ''; |
1497 |
|
|
var footerRegExp = /^(FOOTER::)([^\n]*)\n?/im; |
1498 |
|
|
var chapter = ''; |
1499 |
|
|
var chapterRegExp = /^(CHAPTER::)([^\n]*)\n?/im; |
1500 |
|
|
var lastChapter; |
1501 |
|
|
var alignGlobal = 'center'; |
1502 |
|
|
var align; |
1503 |
|
|
var alignRegExp = /^((GLOBAL-)?ALIGN::)(left|right|center|start|end)?\n?/im; |
1504 |
|
|
|
1505 |
|
|
var imageMatchResults; |
1506 |
|
|
var imagesRegExp = this.makePhraseRegExp('%O%Oima?ge? +src="[^"]+" +width="[0-9]+" +height="[0-9]+"[^%C]*%C%C', 'gi'); |
1507 |
|
|
var imagesRegExp2 = this.makePhraseRegExp('%O%Oima?ge? +src="([^"]+)"', 'i'); |
1508 |
|
|
var image_src; |
1509 |
|
|
|
1510 |
|
|
var plainTextRegExp = this.makePhraseRegExp('(%O%O\#[^:]+:(.+)%C%C|%O%OEM:(.+)(:EM)?%C%C|%O%OPRE:(.+)(:PRE)?%C%C|%O%Oima?ge? +src="[^"]*"[^%C]+%C%C|%O%O([^\\|%C]+)(\\|[^%C]+)?%C%C|%O([^%O]+)%C)', 'gi'); |
1511 |
|
|
|
1512 |
|
|
var dataObj; |
1513 |
|
|
var i, j, |
1514 |
|
|
max = this._data.length; |
1515 |
|
|
var fragment = document.createDocumentFragment(); |
1516 |
|
|
var popup; |
1517 |
|
|
for (i = 0; i < max; i++) |
1518 |
|
|
{ |
1519 |
|
|
image_src = null; |
1520 |
|
|
align = null; |
1521 |
|
|
|
1522 |
|
|
this._data[i] = this._data[i] |
1523 |
|
|
.replace(regexp[0], '') |
1524 |
|
|
.replace(regexp[1], '') |
1525 |
|
|
.replace(regexp[2], '\n'); |
1526 |
|
|
|
1527 |
|
|
while (titleRegExp.test(this._data[i])) { |
1528 |
|
|
this._data[i] = this._data[i].replace(titleRegExp, ''); |
1529 |
|
|
if (String(RegExp.$1).toUpperCase() == 'TITLE::') |
1530 |
|
|
title = RegExp.$2 || '' ; |
1531 |
|
|
} |
1532 |
|
|
|
1533 |
|
|
while (headerRegExp.test(this._data[i])) { |
1534 |
|
|
this._data[i] = this._data[i].replace(headerRegExp, ''); |
1535 |
|
|
if (String(RegExp.$1).toUpperCase() == 'HEADER::') |
1536 |
|
|
header = RegExp.$2 || '' ; |
1537 |
|
|
} |
1538 |
|
|
|
1539 |
|
|
while (footerRegExp.test(this._data[i])) { |
1540 |
|
|
this._data[i] = this._data[i].replace(footerRegExp, ''); |
1541 |
|
|
if (String(RegExp.$1).toUpperCase() == 'FOOTER::') |
1542 |
|
|
footer = RegExp.$2 || '' ; |
1543 |
|
|
} |
1544 |
|
|
|
1545 |
|
|
while (chapterRegExp.test(this._data[i])) { |
1546 |
|
|
this._data[i] = this._data[i].replace(chapterRegExp, ''); |
1547 |
|
|
if (String(RegExp.$1).toUpperCase() == 'CHAPTER::') |
1548 |
|
|
chapter = RegExp.$2 || '' ; |
1549 |
|
|
} |
1550 |
|
|
|
1551 |
|
|
while (alignRegExp.test(this._data[i])) { |
1552 |
|
|
this._data[i] = this._data[i].replace(alignRegExp, ''); |
1553 |
|
|
|
1554 |
|
|
align = (RegExp.$3 || '').toLowerCase(); |
1555 |
|
|
if (align == 'left') |
1556 |
|
|
align = 'start'; |
1557 |
|
|
else if (align == 'right') |
1558 |
|
|
align = 'end'; |
1559 |
|
|
|
1560 |
|
|
if (String(RegExp.$1).toUpperCase() == 'GLOBAL-ALIGN::') { |
1561 |
|
|
alignGlobal = align; |
1562 |
|
|
align = null; |
1563 |
|
|
} |
1564 |
|
|
} |
1565 |
|
|
|
1566 |
|
|
imageMatchResults = this._data[i].match(imagesRegExp); |
1567 |
|
|
if (imageMatchResults) { |
1568 |
|
|
for (j = imageMatchResults.length-1; j > -1; j--) |
1569 |
|
|
image_src = this.preloadImage(imageMatchResults[j].match(imagesRegExp2)[1]); |
1570 |
|
|
} |
1571 |
|
|
|
1572 |
|
|
this._data[i] = { |
1573 |
|
|
header : header, |
1574 |
|
|
footer : footer, |
1575 |
|
|
text : this._data[i].split('\n'), |
1576 |
|
|
image : image_src, |
1577 |
|
|
align : align || alignGlobal |
1578 |
|
|
}; |
1579 |
|
|
this._data[i].plain = this._data[i].text |
1580 |
|
|
.join('\n') |
1581 |
|
|
.replace(plainTextRegExp, '$2$3$5$7$9') |
1582 |
|
|
.split('\n'); |
1583 |
|
|
if (title !== void(0)) |
1584 |
|
|
this._data[i].title = title; |
1585 |
|
|
|
1586 |
|
|
this._data[i].chapter = chapter || title || ''; |
1587 |
|
|
if (lastChapter === void(0) || |
1588 |
|
|
lastChapter != this._data[i].chapter) { |
1589 |
|
|
lastChapter = this._data[i].chapter; |
1590 |
|
|
|
1591 |
|
|
if (popup && popup.childNodes.length == 1) { |
1592 |
|
|
fragment.removeChild(fragment.lastChild); |
1593 |
|
|
fragment.appendChild(popup.removeChild(popup.lastChild)); |
1594 |
|
|
} |
1595 |
|
|
|
1596 |
|
|
popup = document.createElement('menupopup'); |
1597 |
|
|
fragment.appendChild(document.createElement('menu')); |
1598 |
|
|
fragment.lastChild.setAttribute('label', this._data[i].chapter); |
1599 |
|
|
fragment.lastChild.appendChild(popup); |
1600 |
|
|
} |
1601 |
|
|
|
1602 |
|
|
popup.appendChild(document.createElement('menuitem')); |
1603 |
|
|
popup.lastChild.setAttribute('type', 'radio'); |
1604 |
|
|
popup.lastChild.setAttribute('radiogroup', 'pages'); |
1605 |
|
|
popup.lastChild.setAttribute('label', (i+1)+': '+( |
1606 |
|
|
(this._data[i].plain.join('') || this._data[i].text.join(' ')).replace(/\s+/g, ' ') |
1607 |
|
|
)); |
1608 |
|
|
popup.lastChild.setAttribute('value', i); |
1609 |
|
|
|
1610 |
|
|
// if (image_src) { |
1611 |
|
|
// popup.lastChild.setAttribute('image', image_src); |
1612 |
|
|
// popup.lastChild.setAttribute('class', 'menuitem-iconic'); |
1613 |
|
|
// } |
1614 |
|
|
} |
1615 |
|
|
|
1616 |
|
|
if (fragment.childNodes.length == 1) { |
1617 |
|
|
range.selectNodeContents(fragment.firstChild.firstChild); |
1618 |
|
|
fragment = range.extractContents(); |
1619 |
|
|
} |
1620 |
|
|
this.list.appendChild(fragment); |
1621 |
|
|
|
1622 |
|
|
range.detach(); |
1623 |
|
|
|
1624 |
|
|
|
1625 |
|
|
this.shownMontaLabels = []; |
1626 |
|
|
}, |
1627 |
|
|
|
1628 |
|
|
preloadImage : function(aURI) |
1629 |
|
|
{ |
1630 |
|
|
if (aURI in this.imageRequests) return; |
1631 |
|
|
|
1632 |
|
|
if (aURI.indexOf('http://') < 0 && |
1633 |
|
|
aURI.indexOf('https://') < 0) |
1634 |
|
|
aURI = this.dataFolder+aURI; |
1635 |
|
|
|
1636 |
|
|
this.imageRequests[aURI] = new XMLHttpRequest(); |
1637 |
|
|
try { |
1638 |
|
|
this.imageRequests[aURI].open('GET', aURI); |
1639 |
|
|
this.imageRequests[aURI].onload = function() { |
1640 |
|
|
Presentation.imageRequests[aURI] = null; |
1641 |
|
|
}; |
1642 |
|
|
this.imageRequests[aURI].send(null); |
1643 |
|
|
} |
1644 |
|
|
catch(e) { |
1645 |
|
|
this.imageRequests[aURI] = null; |
1646 |
|
|
} |
1647 |
|
|
return aURI; |
1648 |
|
|
}, |
1649 |
|
|
imageRequests : {}, |
1650 |
|
|
|
1651 |
|
|
|
1652 |
|
|
get isPresentationMode(){ |
1653 |
|
|
return (this.deck.selectedIndex == 0); |
1654 |
|
|
}, |
1655 |
|
|
|
1656 |
|
|
|
1657 |
|
|
get dataPath(){ |
1658 |
|
|
if (!this._dataPath) |
1659 |
|
|
this.dataPath = String(location.href).replace(/#.+$/, ''); |
1660 |
|
|
return this._dataPath; |
1661 |
|
|
}, |
1662 |
|
|
set dataPath(aValue){ |
1663 |
|
|
var oldDataPath = this._dataPath; |
1664 |
|
|
this._dataPath = aValue; |
1665 |
|
|
if (oldDataPath != aValue) { |
1666 |
|
|
this._dataFolder = this._dataPath.split('?')[0].replace(/[^\/]+$/, ''); |
1667 |
|
|
} |
1668 |
|
|
return this._dataPath; |
1669 |
|
|
}, |
1670 |
|
|
|
1671 |
|
|
get dataFolder(){ |
1672 |
|
|
if (!this._dataFolder) |
1673 |
|
|
this.dataPath = this.dataPath; |
1674 |
|
|
return this._dataFolder; |
1675 |
|
|
}, |
1676 |
|
|
set dataFolder(aValue){ |
1677 |
|
|
this._dataFolder = aValue; |
1678 |
|
|
return this._dataFolder; |
1679 |
|
|
}, |
1680 |
|
|
|
1681 |
|
|
readParameter : function() { |
1682 |
|
|
if (location.search || location.hash) { |
1683 |
|
|
var param = location.search.replace(/^\?/, ''); |
1684 |
|
|
|
1685 |
|
|
if (location.hash.match(/page([0-9]+)/i) || |
1686 |
|
|
param.match(/page=([0-9]+)/i)) |
1687 |
|
|
this.offset = parseInt(RegExp.$1)-1; |
1688 |
|
|
|
1689 |
|
|
if (location.hash.match(/edit/i) || |
1690 |
|
|
param.match(/edit=(1|true|yes)/i)) |
1691 |
|
|
this.toggleEditMode(); |
1692 |
|
|
|
1693 |
|
|
if (location.hash.match(/eva/i) || |
1694 |
|
|
param.match(/eva=(1|true|yes)/i)) |
1695 |
|
|
this.toggleEvaMode(); |
1696 |
|
|
|
1697 |
|
|
if (location.hash.match(/timer(\d+)\-(\d+)/i)) |
1698 |
|
|
this.setTimer(RegExp.$1, RegExp.$2); |
1699 |
|
|
|
1700 |
|
|
if (param.match(/(style|css)=([^&;]+)/i)) { |
1701 |
|
|
var style = unescape(RegExp.$2); |
1702 |
|
|
var pi = document.createProcessingInstruction('xml-stylesheet', 'href="'+style+'" type="text/css"'); |
1703 |
|
|
document.insertBefore(pi, document.documentElement); |
1704 |
|
|
} |
1705 |
|
|
|
1706 |
|
|
if (param.match(/data=([^&;]+)/i)) { |
1707 |
|
|
var path = unescape(RegExp.$1); |
1708 |
|
|
this.dataPath = path; |
1709 |
|
|
var request = new XMLHttpRequest(); |
1710 |
|
|
request.open('GET', path); |
1711 |
|
|
request.onload = function() { |
1712 |
|
|
Presentation.textbox.value = request.responseText; |
1713 |
|
|
Presentation.data = Presentation.textbox.value; |
1714 |
|
|
Presentation.init(); |
1715 |
|
|
}; |
1716 |
|
|
request.send(null); |
1717 |
|
|
return false; |
1718 |
|
|
} |
1719 |
|
|
} |
1720 |
|
|
return true; |
1721 |
|
|
}, |
1722 |
|
|
|
1723 |
|
|
|
1724 |
|
|
|
1725 |
|
|
resetTimer : function() |
1726 |
|
|
{ |
1727 |
|
|
if (this.timerTimer) { |
1728 |
|
|
window.clearInterval(this.timerTimer); |
1729 |
|
|
this.timerTimer = null; |
1730 |
|
|
} |
1731 |
|
|
this.timer.setAttribute('value', 0); |
1732 |
|
|
this.timer.setAttribute('collapsed', true); |
1733 |
|
|
this.setHash('timer', ''); |
1734 |
|
|
}, |
1735 |
|
|
setTimer : function(aStart, aEnd) |
1736 |
|
|
{ |
1737 |
|
|
var now = (new Date()).getTime(); |
1738 |
|
|
if (aStart === void(0) || aEnd === void(0)) { |
1739 |
dpavlin |
2 |
var rest = prompt('Remaining Time (minits)'); |
1740 |
|
|
if (rest == '') { |
1741 |
|
|
this.resetTimer(); |
1742 |
dpavlin |
1 |
return; |
1743 |
dpavlin |
2 |
} |
1744 |
dpavlin |
1 |
else { |
1745 |
|
|
rest = Number(rest); |
1746 |
dpavlin |
2 |
if (!rest || isNaN(rest)) return; |
1747 |
dpavlin |
1 |
} |
1748 |
|
|
|
1749 |
|
|
rest = Math.abs(rest); |
1750 |
|
|
this.timerStart = now; |
1751 |
|
|
this.timerEnd = this.timerStart + (rest * 60000); |
1752 |
|
|
} |
1753 |
|
|
else { |
1754 |
|
|
aStart = Number(aStart); |
1755 |
|
|
aEnd = Number(aEnd); |
1756 |
|
|
if (isNaN(aStart) || isNaN(aEnd)) return; |
1757 |
|
|
|
1758 |
|
|
this.timerStart = Math.min(aStart, aEnd); |
1759 |
|
|
this.timerEnd = Math.max(aStart, aEnd); |
1760 |
|
|
|
1761 |
|
|
if (this.timerStart >= now || this.timerEnd <= now) return; |
1762 |
|
|
} |
1763 |
|
|
|
1764 |
|
|
this.resetTimer(); |
1765 |
|
|
|
1766 |
|
|
this.timer.removeAttribute('collapsed'); |
1767 |
|
|
this.setHash('timer', 'timer'+this.timerStart+'-'+this.timerEnd); |
1768 |
|
|
|
1769 |
|
|
if (now != this.timerStart) |
1770 |
|
|
this.updateTimer(this); |
1771 |
|
|
|
1772 |
|
|
window.setInterval(this.updateTimer, Math.min(this.timerUpdatingInterval, (this.timerEnd-this.timerStart)/(this.data.length*2)), this); |
1773 |
|
|
}, |
1774 |
|
|
updateTimer : function(aThis) |
1775 |
|
|
{ |
1776 |
|
|
var now = (new Date()).getTime(); |
1777 |
|
|
if (now >= aThis.timerEnd) { |
1778 |
|
|
aThis.resetTimer(); |
1779 |
|
|
aThis.timer.setAttribute('value', 100); |
1780 |
|
|
aThis.timer.removeAttribute('collapsed'); |
1781 |
|
|
aThis.setHash('timer', ''); |
1782 |
|
|
} |
1783 |
|
|
else { |
1784 |
|
|
var value = parseInt(((now - aThis.timerStart) / (aThis.timerEnd - aThis.timerStart)) * 100); |
1785 |
|
|
aThis.timer.setAttribute('value', value); |
1786 |
|
|
} |
1787 |
|
|
}, |
1788 |
|
|
timerStart : 0, |
1789 |
|
|
timerEnd : 0, |
1790 |
|
|
timerTimer : null |
1791 |
|
|
|
1792 |
|
|
}; |
1793 |
|
|
|
1794 |
|
|
|
1795 |
|
|
|
1796 |
|
|
|
1797 |
|
|
|
1798 |
|
|
var StrokeService = { |
1799 |
|
|
className : 'stroke-dot', |
1800 |
|
|
dragStartDelta : 8, |
1801 |
|
|
lineColor : 'red', |
1802 |
|
|
lineWidth : 3, |
1803 |
|
|
|
1804 |
|
|
initialized : false, |
1805 |
|
|
|
1806 |
|
|
|
1807 |
|
|
mode : null, |
1808 |
|
|
canvas : null, |
1809 |
|
|
canvasContext : null, |
1810 |
|
|
startX : -1, |
1811 |
|
|
startY : -1, |
1812 |
|
|
|
1813 |
|
|
init : function(aCanvas) |
1814 |
|
|
{ |
1815 |
|
|
this.initialized = true; |
1816 |
|
|
|
1817 |
|
|
this.canvas = aCanvas; |
1818 |
|
|
|
1819 |
|
|
var canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas'); |
1820 |
|
|
this.canvas.appendChild(canvas); |
1821 |
|
|
if (!('getContext' in canvas) || !canvas.getContext) { |
1822 |
|
|
this.canvas.removeChild(canvas); |
1823 |
|
|
this.mode = 'box'; |
1824 |
|
|
} |
1825 |
|
|
else { |
1826 |
|
|
this.canvas = canvas; |
1827 |
|
|
this.canvasContext = this.canvas.getContext('2d'); |
1828 |
|
|
this.mode = 'canvas'; |
1829 |
|
|
} |
1830 |
|
|
|
1831 |
|
|
document.documentElement.addEventListener('PresentationRedraw', this, false); |
1832 |
|
|
window.addEventListener('resize', this, false); |
1833 |
|
|
this.canvas.addEventListener('mouseup', this, false); |
1834 |
|
|
this.canvas.addEventListener('mousedown', this, false); |
1835 |
|
|
this.canvas.addEventListener('mousemove', this, false); |
1836 |
|
|
|
1837 |
|
|
this.canvas.addEventListener('click', this, false); |
1838 |
|
|
this.canvas.addEventListener('dblclick', this, false); |
1839 |
|
|
|
1840 |
|
|
this.clear(); |
1841 |
|
|
}, |
1842 |
|
|
|
1843 |
|
|
destroy : function() |
1844 |
|
|
{ |
1845 |
|
|
document.documentElement.removeEventListener('PresentationRedraw', this, false); |
1846 |
|
|
window.removeEventListener('resize', this, false); |
1847 |
|
|
this.canvas.removeEventListener('mouseup', this, false); |
1848 |
|
|
this.canvas.removeEventListener('mousedown', this, false); |
1849 |
|
|
this.canvas.removeEventListener('mousemove', this, false); |
1850 |
|
|
this.canvas.removeEventListener('click', this, false); |
1851 |
|
|
|
1852 |
|
|
this.cliclableNodesManager = null; |
1853 |
|
|
this.canvas = null; |
1854 |
|
|
|
1855 |
|
|
this.initialized = false; |
1856 |
|
|
}, |
1857 |
|
|
|
1858 |
|
|
|
1859 |
|
|
|
1860 |
|
|
handleEvent : function(aEvent) |
1861 |
|
|
{ |
1862 |
|
|
switch(aEvent.type) |
1863 |
|
|
{ |
1864 |
|
|
default: |
1865 |
|
|
break; |
1866 |
|
|
|
1867 |
|
|
case 'mouseup': |
1868 |
|
|
this.finish(aEvent); |
1869 |
|
|
this.startX = -1; |
1870 |
|
|
this.startY = -1; |
1871 |
|
|
window.setTimeout('StrokeService.preventToSendClickEvent = false', 10); |
1872 |
|
|
break; |
1873 |
|
|
|
1874 |
|
|
case 'mousedown': |
1875 |
|
|
if (this.startX < 0) { |
1876 |
|
|
this.startX = aEvent.clientX; |
1877 |
|
|
this.startY = aEvent.clientY; |
1878 |
|
|
} |
1879 |
|
|
break; |
1880 |
|
|
|
1881 |
|
|
case 'mousemove': |
1882 |
|
|
if (this.startX > -1 && !this.active) { |
1883 |
|
|
if (Math.abs(this.startX-aEvent.clientX) > Math.abs(this.dragStartDelta) || |
1884 |
|
|
Math.abs(this.startY-aEvent.clientY) > Math.abs(this.dragStartDelta)) { |
1885 |
|
|
this.start(aEvent, this.startX, this.startY); |
1886 |
|
|
this.preventToSendClickEvent = true; |
1887 |
|
|
} |
1888 |
|
|
} |
1889 |
|
|
else |
1890 |
|
|
this.trace(aEvent); |
1891 |
|
|
|
1892 |
|
|
break; |
1893 |
|
|
|
1894 |
|
|
case 'PresentationRedraw': |
1895 |
|
|
case 'resize': |
1896 |
|
|
this.clear(); |
1897 |
|
|
break; |
1898 |
|
|
|
1899 |
|
|
case 'click': |
1900 |
|
|
if (this.preventToSendClickEvent) { |
1901 |
|
|
aEvent.stopPropagation(); |
1902 |
|
|
aEvent.preventCapture(); |
1903 |
|
|
aEvent.preventDefault(); |
1904 |
|
|
aEvent.preventBubble(); |
1905 |
|
|
this.preventToSendClickEvent = false; |
1906 |
|
|
} |
1907 |
|
|
else if (this.cliclableNodesManager && this.cliclableNodesManager.clickableNodes) { |
1908 |
|
|
var nodes = this.cliclableNodesManager.clickableNodes; |
1909 |
|
|
var max = nodes.length; |
1910 |
|
|
var x, y, width, height |
1911 |
|
|
for (var i = 0; i < max; i++) |
1912 |
|
|
{ |
1913 |
|
|
if (nodes[i].boxObject) { |
1914 |
|
|
x = nodes[i].boxObject.x; |
1915 |
|
|
y = nodes[i].boxObject.y; |
1916 |
|
|
width = nodes[i].boxObject.width; |
1917 |
|
|
height = nodes[i].boxObject.height; |
1918 |
|
|
} |
1919 |
|
|
else { |
1920 |
|
|
x = nodes[i].offsetLeft; |
1921 |
|
|
y = nodes[i].offsetTop; |
1922 |
|
|
width = nodes[i].offsetWidth; |
1923 |
|
|
height = nodes[i].offsetHeight; |
1924 |
|
|
} |
1925 |
|
|
if (aEvent.clientX < x || |
1926 |
|
|
aEvent.clientX > x+width || |
1927 |
|
|
aEvent.clientY < y || |
1928 |
|
|
aEvent.clientY > y+height) |
1929 |
|
|
continue; |
1930 |
|
|
|
1931 |
|
|
var event = document.createEvent('MouseEvents'); |
1932 |
|
|
event.initMouseEvent( |
1933 |
|
|
aEvent.type, aEvent.canBubble, aEvent.cancelable, aEvent.view, |
1934 |
|
|
aEvent.detail, |
1935 |
|
|
aEvent.screenX, aEvent.screenY, aEvent.clientX, aEvent.clientY, |
1936 |
|
|
aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey, aEvent.metaKey, |
1937 |
|
|
aEvent.button, |
1938 |
|
|
aEvent.relatedTarget |
1939 |
|
|
); |
1940 |
|
|
nodes[i].dispatchEvent(event); |
1941 |
|
|
break; |
1942 |
|
|
} |
1943 |
|
|
} |
1944 |
|
|
break; |
1945 |
|
|
} |
1946 |
|
|
}, |
1947 |
|
|
preventToSendClickEvent : false, |
1948 |
|
|
|
1949 |
|
|
|
1950 |
|
|
|
1951 |
|
|
start : function(aEvent, aX, aY) |
1952 |
|
|
{ |
1953 |
|
|
this.active = true; |
1954 |
|
|
this.trace(aEvent, aX, aY); |
1955 |
|
|
}, |
1956 |
|
|
|
1957 |
|
|
finish : function(aEvent) |
1958 |
|
|
{ |
1959 |
|
|
if (!this.active) return; |
1960 |
|
|
this.trace(aEvent); |
1961 |
|
|
this.finishStroke(); |
1962 |
|
|
}, |
1963 |
|
|
|
1964 |
|
|
trace : function(aEvent, aX, aY) |
1965 |
|
|
{ |
1966 |
|
|
if (!this.active) return; |
1967 |
|
|
this.addPoint((aX === void(0) ? aEvent.clientX : aX ), (aY === void(0) ? aEvent.clientY : aY )); |
1968 |
|
|
}, |
1969 |
|
|
|
1970 |
|
|
|
1971 |
|
|
finishStroke : function() |
1972 |
|
|
{ |
1973 |
|
|
this.active = false; |
1974 |
|
|
this.lastX = -1; |
1975 |
|
|
this.lastY = -1; |
1976 |
|
|
}, |
1977 |
|
|
|
1978 |
|
|
|
1979 |
|
|
addPoint : function(aX, aY) |
1980 |
|
|
{ |
1981 |
|
|
if (this.lastX != -1) |
1982 |
|
|
this.drawLine(this.lastX, this.lastY, aX, aY); |
1983 |
|
|
else |
1984 |
|
|
this.drawDot(aX, aY); |
1985 |
|
|
|
1986 |
|
|
this.lastX = aX; |
1987 |
|
|
this.lastY = aY; |
1988 |
|
|
}, |
1989 |
|
|
|
1990 |
|
|
|
1991 |
|
|
|
1992 |
|
|
clear : function() |
1993 |
|
|
{ |
1994 |
|
|
this.active = false; |
1995 |
|
|
this.lastX = -1; |
1996 |
|
|
this.lastY = -1; |
1997 |
|
|
|
1998 |
|
|
if (this.mode == 'canvas') { |
1999 |
|
|
if (this.canvas.lastWindowWidth != window.innerWidth || |
2000 |
|
|
this.canvas.lastWindowHeight != window.innerHeight) { |
2001 |
|
|
this.canvas.width = this.canvas.parentNode.boxObject.width-2; |
2002 |
|
|
this.canvas.height = this.canvas.parentNode.boxObject.height-2; |
2003 |
|
|
|
2004 |
|
|
this.canvas.lastWindowWidth = window.innerWidth; |
2005 |
|
|
this.canvas.lastWindowHeight = window.innerHeight; |
2006 |
|
|
} |
2007 |
|
|
this.canvasContext.clearRect(0, 0, this.canvas.width, this.canvas.height); |
2008 |
|
|
this.canvasContext.strokeStyle = this.lineColor; |
2009 |
|
|
this.canvasContext.lineWidth = this.lineWidth; |
2010 |
|
|
} |
2011 |
|
|
else { |
2012 |
|
|
var dotes = this.canvas.getElementsByAttribute('class', this.className); |
2013 |
|
|
if (!dotes.length) return; |
2014 |
|
|
|
2015 |
|
|
var range = document.createRange(); |
2016 |
|
|
range.selectNodeContents(this.canvas); |
2017 |
|
|
range.setStartBefore(dotes[0]); |
2018 |
|
|
range.setEndAfter(dotes[dotes.length-1]); |
2019 |
|
|
range.deleteContents(); |
2020 |
|
|
range.detach(); |
2021 |
|
|
} |
2022 |
|
|
}, |
2023 |
|
|
|
2024 |
|
|
drawDot : function(aX, aY, aParent) |
2025 |
|
|
{ |
2026 |
|
|
if (this.mode == 'canvas') { |
2027 |
|
|
this.canvasContext.strokeRect(aX, aY, 0, 0); |
2028 |
|
|
this.canvasContext.stroke(); |
2029 |
|
|
} |
2030 |
|
|
else { |
2031 |
|
|
var dot = document.createElement('spacer'); |
2032 |
|
|
dot.setAttribute('style', 'left:'+aX+'px; top:'+aY+'px'); |
2033 |
|
|
dot.setAttribute('class', this.className); |
2034 |
|
|
(aParent || this.canvas).appendChild(dot); |
2035 |
|
|
} |
2036 |
|
|
}, |
2037 |
|
|
drawLine : function(aX1, aY1, aX2, aY2) |
2038 |
|
|
{ |
2039 |
|
|
if (aX1 == aX2 && aY1 == aY2) return; |
2040 |
|
|
|
2041 |
|
|
|
2042 |
|
|
if (this.mode == 'canvas') { |
2043 |
|
|
this.canvasContext.beginPath(); |
2044 |
|
|
this.canvasContext.moveTo(aX1, aY1); |
2045 |
|
|
this.canvasContext.lineTo(aX2, aY2); |
2046 |
|
|
/* |
2047 |
|
|
this.canvasContext.bezierCurveTo( |
2048 |
|
|
parseInt(aX1+((aX2-this.lastX)*0.3)), parseInt(aY1+((aY2-this.lastY)*0.3)), |
2049 |
|
|
parseInt(aX1+((aX2-this.lastX)*0.6)), parseInt(aY1+((aY2-this.lastY)*0.6)), |
2050 |
|
|
aX2, aY2 |
2051 |
|
|
); |
2052 |
|
|
*/ |
2053 |
|
|
this.canvasContext.closePath(); |
2054 |
|
|
this.canvasContext.stroke(); |
2055 |
|
|
} |
2056 |
|
|
else { |
2057 |
|
|
var x_move = aX2 - aX1; |
2058 |
|
|
var y_move = aY2 - aY1; |
2059 |
|
|
var x_diff = x_move < 0 ? 1 : -1; |
2060 |
|
|
var y_diff = y_move < 0 ? 1 : -1; |
2061 |
|
|
|
2062 |
|
|
var fragment = document.createDocumentFragment(); |
2063 |
|
|
if (Math.abs(x_move) >= Math.abs(y_move)) { |
2064 |
|
|
for (var i = x_move; i != 0; i += x_diff) |
2065 |
|
|
this.drawDot(aX2 - i, aY2 - Math.round(y_move * i / x_move), fragment); |
2066 |
|
|
} |
2067 |
|
|
else { |
2068 |
|
|
for (var i = y_move; i != 0; i += y_diff) |
2069 |
|
|
this.drawDot(aX2 - Math.round(x_move * i / y_move), aY2 - i, fragment); |
2070 |
|
|
} |
2071 |
|
|
this.canvas.appendChild(fragment); |
2072 |
|
|
} |
2073 |
|
|
} |
2074 |
|
|
}; |
2075 |
|
|
|
2076 |
|
|
|
2077 |
|
|
|
2078 |
|
|
|
2079 |
|
|
|
2080 |
|
|
var StrokablePresentationService = { |
2081 |
|
|
|
2082 |
|
|
id : 'stroke-canvas-box', |
2083 |
|
|
|
2084 |
|
|
strokeService : null, |
2085 |
|
|
cliclableNodesManager : null, |
2086 |
|
|
canvasContainer : null, |
2087 |
|
|
canvas : null, |
2088 |
|
|
|
2089 |
|
|
autoStart : false, |
2090 |
|
|
|
2091 |
|
|
init : function(aPresentation, aStrokeService) |
2092 |
|
|
{ |
2093 |
|
|
this.cliclableNodesManager = aPresentation; |
2094 |
|
|
this.strokeService = aStrokeService; |
2095 |
|
|
this.canvasContainer = document.getElementById('canvas').firstChild; |
2096 |
|
|
this.check = document.getElementById('penButton'); |
2097 |
|
|
|
2098 |
|
|
document.documentElement.addEventListener('StartDragOnCanvas', this, false); |
2099 |
|
|
document.documentElement.addEventListener('PresentationRedraw', this, false); |
2100 |
|
|
}, |
2101 |
|
|
|
2102 |
|
|
toggle : function(aEnable) |
2103 |
|
|
{ |
2104 |
|
|
if (aEnable) |
2105 |
|
|
this.start(); |
2106 |
|
|
else |
2107 |
|
|
this.end(); |
2108 |
|
|
}, |
2109 |
|
|
|
2110 |
|
|
start : function() |
2111 |
|
|
{ |
2112 |
|
|
if (!this.strokeService || !this.canvasContainer) return; |
2113 |
|
|
|
2114 |
|
|
this.strokeService.cliclableNodesManager = this.cliclableNodesManager; |
2115 |
|
|
var box = document.createElement('vbox'); |
2116 |
|
|
box.setAttribute('flex', 1); |
2117 |
|
|
box.setAttribute('id', this.id); |
2118 |
|
|
this.canvas = this.canvasContainer.appendChild(box); |
2119 |
|
|
this.strokeService.init(this.canvas); |
2120 |
|
|
|
2121 |
|
|
this.canvas.addEventListener('dblclick', this, false); |
2122 |
|
|
}, |
2123 |
|
|
|
2124 |
|
|
end : function() |
2125 |
|
|
{ |
2126 |
|
|
this.canvas.removeEventListener('dblclick', this, false); |
2127 |
|
|
|
2128 |
|
|
this.strokeService.destroy(); |
2129 |
|
|
this.canvasContainer.removeChild(this.canvas); |
2130 |
|
|
this.canvas = null; |
2131 |
|
|
}, |
2132 |
|
|
|
2133 |
|
|
handleEvent : function(aEvent) |
2134 |
|
|
{ |
2135 |
|
|
switch (aEvent.type) |
2136 |
|
|
{ |
2137 |
|
|
default: |
2138 |
|
|
break; |
2139 |
|
|
|
2140 |
|
|
case 'StartDragOnCanvas': |
2141 |
|
|
if (!this.check.checked) { |
2142 |
|
|
this.toggleCheck(); |
2143 |
|
|
this.strokeService.startX = Presentation.dragStartX; |
2144 |
|
|
this.strokeService.startY = Presentation.dragStartY; |
2145 |
|
|
|
2146 |
|
|
this.autoStart = true; |
2147 |
|
|
} |
2148 |
|
|
break; |
2149 |
|
|
|
2150 |
|
|
case 'PresentationRedraw': |
2151 |
|
|
if (this.autoStart && this.check.checked) { |
2152 |
|
|
this.autoStart = false; |
2153 |
|
|
this.toggleCheck(); |
2154 |
|
|
} |
2155 |
|
|
break; |
2156 |
|
|
|
2157 |
|
|
case 'dblclick': |
2158 |
|
|
if (this.canvas) |
2159 |
|
|
this.end(); |
2160 |
|
|
break; |
2161 |
|
|
} |
2162 |
|
|
}, |
2163 |
|
|
|
2164 |
|
|
toggleCheck : function() |
2165 |
|
|
{ |
2166 |
|
|
var enable = !this.check.checked; |
2167 |
|
|
this.toggle(enable); |
2168 |
|
|
this.check.checked = enable; |
2169 |
|
|
|
2170 |
|
|
this.autoStart = false; |
2171 |
|
|
} |
2172 |
|
|
|
2173 |
|
|
}; |
2174 |
|
|
|
2175 |
|
|
|
2176 |
|
|
|
2177 |
|
|
|
2178 |
|
|
function init() |
2179 |
|
|
{ |
2180 |
|
|
window.removeEventListener('load', init, false); |
2181 |
|
|
|
2182 |
|
|
Presentation.init(); |
2183 |
|
|
StrokablePresentationService.init(Presentation, StrokeService); |
2184 |
|
|
} |
2185 |
|
|
window.addEventListener('load', init, false); |
2186 |
|
|
|
2187 |
|
|
|
2188 |
|
|
]]></script> |
2189 |
|
|
|
2190 |
|
|
</page> |