-
Notifications
You must be signed in to change notification settings - Fork 12
/
AccesSlide.js
1339 lines (1332 loc) · 42.2 KB
/
AccesSlide.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
AccesSlide
GPL licence
https://github.com/access42/AccesSlide
Copyright (c) 2015 Access42, access42.net
**/
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
var AccessSlide = ( function(){
'use strict';
/**
Configuration
**/
var config = {
/** Conteners **/
Screen: {
id: 'screen'
},
Banner: {
id: 'banner'
},
NavBar: {
id: 'navbar'
},
WrapperNav: {
id: 'wrappernav'
},
Wrapper: {
id: 'wrapper',
classSettingLeft: 'Cagauche'
},
Flap: {
id: 'volet'
},
Slide: {
classSetting: 'slide'
},
Summary: {
id: 'sommaire',
classSettingFixed: 'fixed tool-block tool-block-summary',
Ctitle: 'Ct'
},
Setting: {
id: 'setting',
Ctitle: 'Ctitle'
},
FormConfig: {
id: 'FormConfig'
},
ConfigButton: {
id: 'configbutton',
classSetting: 'btn-group-settings'
},
LinearIndexTag: {
classSetting: 'index'
},
LiveSlideTitle: {
id: 'Dcourante'
},
/** Effects
val: entry value name
classSetting: CSS classname effect,
flap: true for flap effect
slide: true for slide effect
To set a new effect in four simples steps :
1. Create a CSS class
2. Create an entry in this section
Example :
NameOfEffect: {
val: NameOfEffect,
classSetting: 'yeah',
flap: false,
slide: true
}
3. Create an entry in the configuration lang file
NameOfEffect: {
help: 'the yeaaah effect' //text for option value in effects dropdown
}
Important : don't delete Eno entry
**/
// Noeffects
Eno: {
val: 'Eno',
flap: false,
slide: false,
group: 'Geffects'
},
// Fadein
Efadin: {
val: 'Efadin',
classSetting: 'fadein',
flap: false,
slide: true,
group: 'Geffects'
},
// Flap left to right
Eleft: {
val: 'Eleft',
classSetting: 'ALTR',
flap: true,
slide: false,
group: 'Geffects'
},
// flap right to left
Eright: {
val: 'Eright',
classSetting: 'ARTL',
flap: true,
slide: false,
group: 'Geffects'
},
// flap bottom to top
Ebottom: {
val: 'Ebottom',
classSetting: 'ATtoT',
flap: true,
slide: false,
group: 'Geffects'
},
// flap top to bottom
Etop: {
val: 'Etop',
classSetting: 'ATtoB',
flap: true,
slide: false,
group: 'Geffects'
},
// Flash
Flash: {
val: 'Flash',
classSetting: 'Flash',
flap: true,
slide: false,
group: 'Geffects'
},
// Scale
Escale: {
val: 'Escale',
classSetting: 'Escale',
flap: false,
slide: true,
group: 'Geffects'
},
// FLIP
Flip: {
val: 'Flip',
classSetting: 'Flip',
flap: false,
slide: true,
group: 'Geffects'
},
/** Players **/
Stexte: {
id: 'Stexte',
file: 'bip_texte_masque'
},
Sdiapo: {
id: 'Sdiapo',
file: 'bip_diapo_on'
},
Sdiapo1: {
id: 'Sdiapo1',
file: 'bip_diapo1_on'
},
Sdiapoend: {
id: 'Sdiapoend',
file: 'bip_diapo_end'
},
Caudio: {
id: 'Caudio'
},
/** Hidden Content Class **/
HiddenContent: {
classSetting: 'Cmasque'
},
/** Accessibility **/
//vocalize slide number on total (1 on 4 for example)
VocalizeNdiapo: {
id: 'VocalizeNdiapo',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-sound',
IconClass: 'icon icon-setting-sound',
val: 0,
group: 'Gaccess'
} ,
//Play a sound (beep) when displaying hidden text
SoundTxt: {
id: 'SoundTxt',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-sound',
IconClass: 'icon icon-setting-sound',
val: 0,
group: 'Gaccess'
},
//Play a sound (beep) when displaying a slide
SoundSlide: {
id: 'SoundSlide',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-sound',
IconClass: 'icon icon-setting-sound',
val: 0,
group: 'Gaccess'
},
//Play a sound (beep) when displaying first slide
SoundSlide1: {
id: 'SoundSlide1',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-sound',
IconClass: 'icon icon-setting-sound',
val: 0,
group: 'Gaccess'
},
//Play a sound (beep) when displaying last slide
SoundSlideEnd: {
id: 'SoundSlideEnd',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-sound',
IconClass: 'icon icon-setting-sound',
val: 0,
group: 'Gaccess'
},
//Vocalize the heading of the current slide
VocalizeTitle: {
id: 'VocalizeTitle',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-sound',
IconClass: 'icon icon-setting-sound',
val: 0,
group : 'Gaccess'
},
//Update the window heading
UpWindowTitle: {
id: 'UpWindowTitle',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-sound',
IconClass: 'icon icon-setting-sound',
val: 0 ,
group: 'Gaccess'
},
//Skip to the "next" button on slideshow onload
GotoBnext: {
id: 'GotoBnext',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-next',
IconClass: 'icon icon-setting-next',
val: 0,
group: 'Gaccess'
},
//Deactivate click button function to go to next slide
//Warning : deactivate spacebar function too
Noclick: {
id: 'Noclick',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-mouse',
IconClass: 'icon icon-setting-mouse',
val: 0,
group: 'Gaccess'
},
/** Slideshow parameters **/
// Display summary as :
// 0 : no-modal window
// 1 : modal window
SumModOn: {
id: 'SumModOn',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-summary',
IconClass: 'icon icon-setting-summary',
val: 1,
group: 'Gslide'
},
// Switch ModePlan=1 for Linear Layout
ModePlan: {
id: 'ModePlan',
classSetting : 'input-setting',
classHelpSetting: 'help',
classLabelSetting: 'label-setting setting-plan',
IconClass: 'icon icon-setting-plan',
val: 0,
group: 'Gslide'
},
/** Misceallanous **/
// Setting configuration buttons
Bsubmit: {
id: 'setconfig',
classSetting: 'btn-setting'
},
Bdefault: {
id: 'resetconfig',
classSetting: 'btn-setting'
},
//Close buttons
Bclose: {
idSummary: 'close',
idConfig: 'Close2',
classSetting: 'btn-close',
iconClass: 'icon icon-close',
fallbackClass : 'text',
fallBackSrcImg:'img/close.png'
},
/** Setting navbar
Setting navbar button and select
classSetting : CSS classNames
iconClass : CSS class for icon font injection
**/
Bprev: {
id: 'prev',
classSetting: 'tool-bar-elt btn btn-prev',
iconClass: 'icon icon-prev',
fallbackClass : 'text',
fallBackSrcImg:'img/prev.png'
},
Bnext: {
id: 'next',
classSetting: 'tool-bar-elt btn btn-next',
iconClass: 'icon icon-next',
fallbackClass : 'text',
fallBackSrcImg:'img/next.png'
},
Select:{
id: 'tocP',
classSetting: 'select-goto'
},
Bselect: {
id: 'tocp',
classSetting: 'btn btn-goto',
iconClass: 'icon icon-goto',
fallbackClass : 'text',
fallBackSrcImg:'img/goto.png'
},
Btoc: {
id: 'toc',
classSetting: 'tool-bar-elt btn btn-block-summary',
iconClass: 'icon icon-summary',
fallbackClass : 'text',
fallBackSrcImg:'img/summary.png'
},
Bconfig: {
id: 'set',
classSetting: 'tool-bar-elt btn btn-block-settings',
iconClass: 'icon icon-settings',
fallbackClass : 'text',
fallBackSrcImg:'img/settings.png'
},
SelectWrapper: {
id: 'Fgo',
classSetting: 'tool-bar-elt'
},
TocSelect : {
id: 'tocP',
},
SlideCounter: {
id: 'cpt',
idCurrent: 'current',
idTotal: 'total',
classSetting: 'tool-bar-elt slide-counter',
currentClass: 'tool-bar-elt slide-counter-current',
isHiddenClass: 'sr',
totalClass: 'tool-bar-elt slide-counter-total'
},
IconFallBack: {
classSetting: 'icon-fallback-text'
},
Ctitle:{
classSetting: 'tool-block-title'
}
}
/** End configuration setting **/
/** Global variables **/
// Modal config
var ConfigModOn = 1;
// Current Slide
var current = 0;
// Slide array
var TabSlide = [];
// Hidden content array
var TabTextSlide = [];
// Current hidden content
var Tcurrent = 0;
var Tcontrol = 0;
// Filter Tag clickable content
var TagListFiltre = new Array('BUTTON','A','SELECT','INPUT','AUDIO','VIDEO','TEXTAREA','LABEL');
// Slide dimensions
//var Slidew;
//var Slideh;
// flap dimension
//var Vheight = 100;
//var Vwidth;
// Modale window object (use for trapping focus and esc shutdown)
var openDial = null;
// Freeze hidden content if necessary
var TopenDial;
// Window title
var WTitre = document.title;
// CSS3 animation prefix
var pfx = ["webkit", "moz", "MS", "o", ""];
// Switch locale storage (for IE on local mode)
var Storage = 0;
// Base URL (used for reload the switch linear layout)
var BaseUrl;
/**
Onload
**/
window.onload = function() {
// Initialize UI controls and Config
PushConfig();
GetConfig();
PushNavBar();
// Initialize access config
if( config.VocalizeNdiapo.val === 1 )$( config.SlideCounter.id ).setAttribute( 'aria-live', 'polite' );
if( config.VocalizeNdiapo.val === 1 )$( config.SlideCounter.id ).setAttribute( 'aria-atomic', 'false' );
if( config.GotoBnext.val === 1 )$( config.Bnext.id ).focus();
if( config.SoundTxt.val === 1 )SetSon( config.Stexte.file, config.Stexte.id );
if( config.SoundSlide.val === 1 )SetSon( config.Sdiapo.file, config.Sdiapo.id );
if( config.SoundSlide1.val === 1 )SetSon( config.Sdiapo1.file, config.Sdiapo1.id );
if( config.SoundSlideEnd.val === 1 )SetSon( config.Sdiapoend.file, config.Sdiapoend.id );
// Initialize the slideshow array
InitTabSlide();
// Set the Toc index select
TocP();
/* Events manager */
// Event click for next slide
if( config.ModePlan.val === 0 && config.Noclick.val === 0 ){
document.addEventListener( 'click', function( e ) {
if ( TagListFiltre.indexOf( document.activeElement.tagName ) < 0 ) {
GotoNext();
}
}, true);
}
// Event Keys
// Left: 37, Right :39, Spacebar: 32, Enter: 13, pageDown:34, pageUp:33 (for remote control), Open summary: ALT+0 ([2]48), Home:36, End:35, special previous slide for screen reader : SHIFT+Spacebar ([1]32).
document.addEventListener( 'keydown', function( e ) {
if ( key( e ) == 248 ) { OpenToc(); }
if( config.ModePlan.val === 0 ){
if ( key( e ) === 32 && config.Noclick.val === 0 ) { GotoNext(); e.preventDefault(); }
if ( key( e ) === 39 || key( e ) === 34 ) { GotoNext(); e.preventDefault(); }
if ( key( e ) === 37 || key( e ) === 33 || key( e ) == 132 ) { GotoPrev(); e.preventDefault(); }
if ( key( e ) === 36 ) { current = 0; GotoSlide(); e.preventDefault(); }
if ( key( e ) === 35 ) { current = TabSlide.length - 1; GotoSlide(); e.preventDefault(); }
if ( key( e ) === 13 ) {
if ( TagListFiltre.indexOf( document.activeElement.tagName ) < 0 ) {
GotoNext();
e.preventDefault();
}
}
}
}, false);
// Events Button
$( config.Bnext.id ).addEventListener( "click", GotoNext, false );
$( config.Bprev.id ).addEventListener( "click", GotoPrev, false );
// Event open/close TOC
$( config.Btoc.id ).addEventListener( "click", OpenToc, false );
$( config.Bclose.idSummary ).addEventListener( "click", CloseToc, false );
// Event slide index select
$( config.Select.id ).addEventListener( "change",function(){
$( config.Bselect.id ).removeAttribute( 'disabled', 'disabled' );
},false );
$( config.Bselect.id ).addEventListener( "blur",function(){
$( config.Select.id ).value = '';
$( config.Bselect.id ).setAttribute( 'disabled','disabled' );
},false);
$( config.Bselect.id ).addEventListener( "click", Fgo, false );
// Events open/close and save/reset Configuration
$( config.Bconfig.id ).addEventListener( "click", OpenConfig, false );
$( config.Bclose.idConfig ).addEventListener( "click", CloseToc, false );
$( config.Bsubmit.id ).addEventListener( "click", SetConfig, false );
$( config.Bdefault.id ).addEventListener( "click", ResetConfig, false );
// Trapping focus
if( config.SumModOn.val == 1 || ConfigModOn == 1 ){
document.addEventListener( "focus", function( event ) {
if ( openDial && !openDial.contains( event.target ) ) {
event.stopPropagation();
openDial.focus();
}
}, true);
}
// Close modals (ESC)
document.addEventListener( "keydown", function( event ) {
if ( openDial && key( event ) == 27 ) {
CloseToc();
openDial = null;
}
}, true );
// Listener end flap animation
PrefixedEvent( $( config.Flap.id ),"AnimationEnd", function(){ $( config.Flap.id ).removeAttribute( 'class' );} )
// Get current slide when reload
window.onbeforeunload=function(){
try{
sessionStorage.setItem( 'Scurrent', current );
}
catch(e){
createCookie( 'Scurrent', current, 0 );
}
}
}
/**
Begin navigations functions
**/
/* Initialize Slide array */
function InitTabSlide(){
// Get current slide if exists
try{
current = parseInt( sessionStorage.Scurrent );
sessionStorage.clear();
}
catch( e ){
current = parseInt( readCookie( 'Scurrent' ) );
eraseCookie( 'Scurrent' );
}
// Set slide array then display current slide if linear layout shutoff
if( !current )current = 0;
TabSlide = document.getElementsByClassName( config.Slide.classSetting );
if( config.ModePlan.val === 0 ) NoSetTabSlide();
$( config.SlideCounter.idCurrent ).firstChild.nodeValue = current + 1;
if( config.VocalizeTitle.val === 1 )GetTitre();
$( config.SlideCounter.idTotal ).firstChild.nodeValue = TabSlide.length;
TabSlide[ current ].style.display = 'block';
if( config.SoundSlide1.val === 1 && current === 0 )$( config.Sdiapo1.id ).play();
if( config.UpWindowTitle.val === 1) MajTitreW();
if( config.ModePlan.val === 0){
document.body.style.height = '98.5%';
$( config.Screen.id ).classList.remove( 'modeplan');
// Hide header when first and last slide displaying
if( current === 0 || current === TabSlide.length - 1 ) $( config.Banner.id ).style.top = '-10000px';
//Animation play
wow();
}
// Set linear layout mode and shutoff global effect
else{
$( config.Screen.id ).classList.add( 'modeplan');
$( config.Screen.id ).setAttribute( 'data-effect', 'noEffect' );
SetNSlide();
}
//Set slide TOC
Toc();
}
/* Reset slides display*/
function NoSetTabSlide(){
var RefEffect = $( config.Screen.id ).getAttribute( 'data-effect' );
for( var i = 0, len = TabSlide.length ;i < len; i++ ){
TabSlide[i].style.display = 'none';
TabSlide[i].classList.remove( config[ RefEffect ].classSetting );
}
$( config.Flap.id ).classList.remove( config[ RefEffect ].classSetting );
}
/* Goto next/prev/current slide */
function GotoNext(){
// If not hidden content run
if( Tcontrol === 0 ){
current += 1;
if( current >= TabSlide.length )current -= 1;
NoSetTabSlide();
if( TabSlide[ current ] )TabSlide[ current ].style.display = 'block';
SetAdaptive();
// Hide header on first and last slide
if( current === 0 || current === TabSlide.length - 1 ){
$( config.Banner.id ).style.top = '-100000px';
}
else{
$( config.Banner.id ).style.top = '4px';
}
wow();
$( config.SlideCounter.idCurrent ).firstChild.nodeValue = current+1;
ReScaleSummary();
if( config.VocalizeTitle.val === 1)GetTitre();
// Initialize hidden content array
SetTabTextSlide();
}
// If hidden content run
else{
// Display hidden content
if( TabTextSlide[ Tcurrent ] ) TabTextSlide[ Tcurrent ].style.visibility = 'visible';
if( config.SoundTxt.val === 1) $( config.Stexte.id ).play();
Tcurrent += 1;
if( Tcurrent >= TabTextSlide.length ){
Tcontrol = 0;
Tcurrent = 0;
TabTextSlide.length = 0;
}
}
}
function GotoPrev(){
var Cprev = 1;
// If not hidden content run
if( Tcontrol === 0 ){
current -= 1;
if( current < 0 ) current = 0;
NoSetTabSlide();
if( TabSlide[ current ] )TabSlide[ current ].style.display = 'block';
SetAdaptive();
// Hide header on first and last slide
if( current === 0 || current === TabSlide.length-1 ){
$( config.Banner.id ).style.top = '-1000000px';
}
else{
$( config.Banner.id ).style.top = '4px';
}
wow();
$( config.SlideCounter.idCurrent ).firstChild.nodeValue = current+1;
ReScaleSummary();
if( config.VocalizeTitle.val == 1 )GetTitre();
// Initialize hidden content array
SetTabTextSlide( Cprev );
}
else{
// Display hidden content
TabTextSlide[ Tcurrent ].style.visibility = 'hidden';
if( config.SoundTxt.val === 1 ) $( config.Stexte.id ).play();
Tcurrent += 1;
if( Tcurrent >= TabTextSlide.length ){
Tcontrol = 0;
Tcurrent = 0;
TabTextSlide.length = 0;
}
}
}
function GotoSlide(){
// If not hidden content run or modal open
if( Tcontrol === 0 || TopenDial === 1 ){
if( current >= TabSlide.length )current = 0;
NoSetTabSlide();
if( TabSlide[ current ]) TabSlide[ current ].style.display = 'block';
SetAdaptive();
// Hide header on first and last slide
if( current === 0 || current === TabSlide.length-1 ){
$( config.Banner.id ).style.top = '-100000px';
}
else{
$( config.Banner.id ).style.top = '4px';
}
wow();
$( config.SlideCounter.idCurrent ).firstChild.nodeValue = current+1;
ReScaleSummary();
if( config.VocalizeTitle.val === 1 ) GetTitre();
// Initialize hidden content array
SetTabTextSlide();
TopenDial = null;
}
else{
// Display hidden content
TabTextSlide[ Tcurrent ].style.visibility = 'visible';
if( config.SoundTxt.val === 1 )$( config.Stexte.id ).play();
Tcurrent += 1;
if( Tcurrent >= TabTextSlide.length ){
Tcontrol = 0;
Tcurrent = 0;
TabTextSlide.length = 0;
}
}
}
/* Goto slide from index select */
function Fgo(){
if( parseInt( $( config.TocSelect.id ) .value) > -1 ){
current = parseInt( $( config.TocSelect.id ).value);
GotoSlide();
TopenDial = 1;
}
else{
$( config.TocSelect.id ).focus();
}
}
/* Goto slide from summary modal */
function FgoToc(){
var e = this.getAttribute( 'data-slide' );
current = parseInt( e );
if( config.SumModOn.val === 1 ) CloseToc();
if( config.ModePlan.val === 0 ){
GotoSlide();
}
else{
var Cid = BaseUrl + '#D' + e;
window.location.href = Cid;
}
TopenDial = 1;
}
/* Initiliaze hidden content array */
function SetTabTextSlide( Cprev ){
var target = TabSlide[ current ].querySelectorAll( '*' );
var j = 0;
for( var i = 0, len = target.length; i < len; i++ ){
if( target[i].classList.contains( config.HiddenContent.classSetting )){
TabTextSlide[j] = target[i];
j++;
}
}
if( TabTextSlide.length > 0 ){
Tcontrol = 1;
for( var i = 0, len = TabTextSlide.length; i < len; i++ ){
Cprev === 1 ? TabTextSlide[i].style.visibility = 'visible' : TabTextSlide[i].style.visibility = 'hidden';
}
if( Cprev === 1 ) TabTextSlide.reverse();
}
}
/* Set index select */
function TocP(){
var Toption = document.createElement( 'OPTION' );
var Cindex = document.createTextNode( '-' );
Toption.setAttribute( 'value', '' );
Toption.appendChild( Cindex );
document.getElementById( config.TocSelect.id ).appendChild( Toption );
for( var i = 0, len = TabSlide.length; i < len ; i++ ){
var Toption = document.createElement( 'OPTION' );
var Index = i;
var Cindex = document.createTextNode( Index + 1 );
Toption.setAttribute( 'value', Index );
Toption.appendChild( Cindex );
document.getElementById( config.TocSelect.id ).appendChild( Toption );
}
}
/* Set Summary modal */
function Toc(){
var Txt = {};
var Target;
//Set summary title
var Ctitle = document.createElement( 'H1' );
Ctitle.setAttribute( 'id', config.Summary.Ctitle );
Ctitle.appendChild( document.createTextNode( lang.SummaryTitle ) );
var Cbutton = document.createElement( 'BUTTON' );
Cbutton.setAttribute( 'type', 'button' );
Cbutton.setAttribute( 'id', config.Bclose.idSummary );
Ctitle.setAttribute( 'class', config.Ctitle.classSetting );
Cbutton.className = config.Bclose.classSetting;
//Icon implementation
var CspanFallback = document.createElement( 'SPAN' );
CspanFallback.className = config.IconFallBack.classSetting;
var CspanIcon = document.createElement( 'SPAN' );
CspanIcon.className = config.Bclose.iconClass;
CspanIcon.setAttribute( 'aria-hidden', 'true' );
var CspanText = document.createElement( 'IMG' );
CspanText.src = config.Bclose.fallBackSrcImg;
CspanText.setAttribute( 'alt', lang.Wclose );
CspanText.className = config.Bclose.fallbackClass;
CspanFallback.appendChild( CspanIcon );
CspanFallback.appendChild( CspanText );
Cbutton.appendChild( CspanFallback );
Ctitle.appendChild( Cbutton );
$( config.Summary.id ).appendChild( Ctitle );
//Set summary list
for( var i = 0; i < TabSlide.length; i++ ){
Target = TabSlide[i].querySelector( 'h2' );
if( Target ){
Txt[i] = Target.innerText || Target.textContent;
}
else{
Txt[i] = TabSlide[i].getAttribute( 'aria-label' );
}
}
var Cul = document.createElement( 'OL' );
for( var i in Txt ){
var Li = document.createElement( 'LI' );
var Btn = document.createElement('BUTTON');
Btn.setAttribute( 'type','button' );
Btn.setAttribute( 'data-slide', i );
Btn.addEventListener( 'click', FgoToc, false );
var Stxt = document.createTextNode( Txt[i] );
Btn.appendChild( Stxt );
Li.appendChild( Btn );
Cul.appendChild( Li );
}
$( config.Summary.id ).appendChild( Cul );
}
/* Open summary modal */
function OpenToc(){
if( config.SumModOn.val === 1 ){
$( config.Summary.id ).setAttribute( 'role', 'dialog' );
$( config.Summary.id ).setAttribute( 'aria-labelledby', config.Summary.Ctitle );
}
else{
if( config.ModePlan.val === 0){
$( config.Wrapper.id ).style.width = '75%';
$( config.Wrapper.id ).style.fontSize = '80%';
}
else{
$( config.Wrapper.id ).setAttribute( 'class', config.Wrapper.classSettingLeft );
}
}
$( config.Summary.id ).style.display = 'block';
$( config.Bclose.idSummary ).focus();
openDial = $( config.Summary.id );
ReScaleSummary();
}
/* Open config modal */
function OpenConfig(){
$( config.Setting.id ).style.display = 'block';
$( config.Bclose.idConfig ).focus();
openDial = $( config.Setting.id );
}
/* Close modal */
function CloseToc(){
switch( openDial.getAttribute( 'id' ) ){
case 'sommaire':
$( config.Wrapper.id ).removeAttribute( 'style' );
$( config.Summary.id ).style.display = 'none';
$( config.Btoc.id ).focus();
break
case 'setting':
$( config.Setting.id ).style.display = 'none';
$( config.Bconfig.id ).focus();
break;
}
if( config.ModePlan.val === 1 ) $( config.Wrapper.id ).removeAttribute( 'class' );
openDial = null;
}
/* Rescale summary when first or last slide displaying */
function ReScaleSummary(){
if( config.ModePlan.val === 0 ){
if( current > 0 && current + 1 < TabSlide.length ){
$( config.Summary.id ).style.top = '10%';
$( config.Summary.id ).style.height = '85%';
}
else{
$( config.Summary.id ).style.top = '0';
$( config.Summary.id ).style.height = '95%';
}
}
else{
$( config.Summary.id ).style.top = '0';
$( config.Summary.id ).setAttribute('class', config.Summary.classSettingFixed );
}
}
/* Set index slide tag on linear layout mode */
function SetNSlide(){
for( var i = 0, len = TabSlide.length; i < len; i++ ){
var Ptag = document.createElement( 'P' );
var Stag = document.createElement( 'SPAN' );
var Txt = document.createTextNode( i + 1 + ' / ' + len );
Stag.appendChild( Txt );
Ptag.appendChild( Stag );
Ptag.setAttribute( 'class', config.LinearIndexTag.classSetting );
TabSlide[i].setAttribute( 'id', 'D' + i );
TabSlide[i].appendChild( Ptag );
}
}
/* Manage CSS3 effects */
function wow(){
var RefEffect = $( config.Screen.id ).getAttribute( 'data-effect' );
if( config[ RefEffect ].flap ){
$( config.Flap.id ).classList.add( config[ RefEffect ].classSetting );
}
else if ( config[ RefEffect ].slide ){
TabSlide[ current ].classList.add( config[ RefEffect ].classSetting );
}
TabSlide[ current ].style.opacity = '1';
}
/** End navigation functions **/
/**
Begin adaptive functions
**/
/* Set adaptive sound and window title update */
function SetAdaptive(){
if( config.SoundSlide.val === 1 && current != 0 ) $( config.Sdiapo.id ).play();
if( config.SoundSlide1.val === 1 && current === 0) $( config.Sdiapo1.id ).play();
if( config.SoundSlideEnd.val === 1 && current === TabSlide.length-1 ) $( config.Sdiapoend.id ).play();
if( config.UpWindowTitle.val === 1 ) MajTitreW();
}
/* Set audio compomnents */
function SetSon( file, Sid ){
var Caudio = document.createElement( 'AUDIO' );
Caudio.setAttribute( 'id', Sid );
var Csource1 = document.createElement( 'SOURCE' );
Csource1.setAttribute( 'src', 'sound/' + file + '.mp3' );
Csource1.setAttribute( 'type', 'audio/mp3' );
var Csource2 = document.createElement( 'SOURCE' );
Csource2.setAttribute( 'src', 'sound/' + file + '.ogg' );
Csource2.setAttribute( 'type', 'audio/ogg' );
Caudio.appendChild( Csource1 );
Caudio.appendChild( Csource2 );
$( config.Caudio.id ).appendChild( Caudio );
}
/* Include Slide title (or aria-label value) in live region */
function GetTitre(){
var target = TabSlide[ current ].childNodes;
$( config.LiveSlideTitle.id ).innerHTML = '';
if( target[1].tagName === 'H2' ){
$( config.LiveSlideTitle.id ).innerHTML = target[1].innerHTML;
}
else{
var Txt = document.createTextNode( TabSlide[ current ].getAttribute( 'aria-label' ) );
$( config.LiveSlideTitle.id ).appendChild( Txt );
}
}
/* Update window title */
function MajTitreW(){
document.title = '';
var target = TabSlide[ current ].childNodes;
if( target[1].tagName === 'H2' ){
var Title = target[1].innerText || target[1].textContent;
}
else{
var Title = TabSlide[ current ].getAttribute( 'aria-label' );
}
document.title = Title + " | " + WTitre;
}
/** End adaptive functions **/
/**
Begin UI components configuration
**/
/* Configuration managers */
function SetConfig(){
var TabConfigRef = document.querySelectorAll( '#setting fieldset input, #setting fieldset select' );
for ( var i = 0, len = TabConfigRef.length; i < len; i++ ){
var ConfigRef = TabConfigRef[i].getAttribute( 'id' );
var ValueRef;
if( TabConfigRef[i].nodeName === 'INPUT' ){
TabConfigRef[i].checked ? ValueRef = 1 : ValueRef = 0;
config[ ConfigRef ].val = ValueRef;
}
if( TabConfigRef[i].nodeName === 'SELECT' ){
ValueRef = TabConfigRef[i].value;
}
try{
localStorage.setItem( ConfigRef, ValueRef );
}
catch(e){
createCookie( ConfigRef, ValueRef, 0 );
}
}
}
function ResetConfig(){
var TabConfigRef = document.querySelectorAll( '#setting fieldset input, #setting fieldset select' );
for ( var i = 0, len = TabConfigRef.length; i < len; i++){
var ConfigRef = TabConfigRef[i].getAttribute( 'id' );
try{
localStorage.removeItem( ConfigRef );
}
catch(e){
eraseCookie( ConfigRef );
}
if( TabConfigRef[i].nodeName === 'INPUT' ){
if( config[ ConfigRef ].val === 1 ) TabConfigRef[i].setAttribute( 'checked', 'checked' );
}
else if( TabConfigRef[i].nodeName === 'SELECT' ){
TabConfigRef[i].value = config.Eno.val;
}
}
}
function GetConfig(){
// Get base url for reload the linear layout or slideshow mode
var Url = window.location.href;
Url.indexOf( '#' ) > 0 ? BaseUrl = BaseUrl=Url.slice( 0, Url.indexOf( '#' ) ) : BaseUrl = Url;
$( config.FormConfig.id ).setAttribute( 'action', BaseUrl );
// Set configuration parameters and update default checkbox and select value
var TabConfigRef = document.querySelectorAll( '#setting fieldset input, #setting fieldset select' );
for ( var i = 0; i < TabConfigRef.length; i++ ){
var ConfigRef = TabConfigRef[i].getAttribute( 'id' );
try{
var ValueRef = localStorage.getItem( ConfigRef );
}
catch(e){
var ValueRef = readCookie( ConfigRef );
}
if( ValueRef ){
if( TabConfigRef[i].nodeName === 'INPUT' ){
if( parseInt( ValueRef ) === 1) TabConfigRef[i].setAttribute( 'checked', 'checked' );
config[ ConfigRef ].val = parseInt( ValueRef );
}
else if( TabConfigRef[i].nodeName === 'SELECT' ){
// update #wrapper data-effect
$( config.Screen.id ).setAttribute( 'data-effect', ValueRef );
}
}
if( TabConfigRef[i].nodeName === 'INPUT' ){
if( config[ ConfigRef ].val > 0 ) TabConfigRef[i].setAttribute( 'checked', 'checked' );
}
else if( TabConfigRef[i].nodeName === 'SELECT' ){
TabConfigRef[i].value = ValueRef;
}
}
}
//END MAJ
/* Configuration window */
function PushConfig(){
// Set window title and close button
var Ctitle = document.createElement( 'H1' );
Ctitle.appendChild(document.createTextNode( lang.ConfigTitle ) );
Ctitle.setAttribute( 'id', config.Setting.Ctitle );
Ctitle.setAttribute( 'class', config.Ctitle.classSetting );
$( config.Setting.id ).setAttribute( 'aria-labelledby', config.Setting.Ctitle );
var Cbutton = document.createElement( 'BUTTON' );
Cbutton.setAttribute( 'type', 'button' );
Cbutton.setAttribute( 'id', config.Bclose.idConfig );
Cbutton.className = config.Bclose.classSetting;
//Icon implementation
var CspanFallback = document.createElement( 'SPAN' );
CspanFallback.className = config.IconFallBack.classSetting;
var CspanIcon = document.createElement( 'SPAN' );