comparison before_s6/2014/2014_07_01/js/jquery.slideshow.autoplay.js @ 5:ab2d529bb1d7

add slide
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 14 Oct 2014 19:17:35 +0900
parents 2014/2014_01_14/s6_trunk/js/jquery.slideshow.autoplay.js@845ff8ff4fc9
children
comparison
equal deleted inserted replaced
4:10fb2b05e390 5:ab2d529bb1d7
1 /***********
2 *
3 * autoplay addon:
4 *
5 * - use key-a/p/s to toggle autoplay (in projection mode)
6 */
7
8
9 Slideshow.playInit = function()
10 {
11 this.debug( 'calling playInit()' );
12
13 this.playInterval = null;
14 }
15
16 Slideshow.playStart = function()
17 {
18 this.debug( 'calling playStart()' );
19
20 if( this.settings.mode == 'autoplay' )
21 this.playToggle();
22 }
23
24
25 Slideshow.playKeys = function( event, key )
26 {
27 this.debug( 'calling playKeys()' );
28
29 switch( key.which ) {
30 case 65: //a
31 case 80: //p
32 case 83: //s
33 this.playToggle();
34 break;
35 }
36 }
37
38
39 // ------------------------------------------------
40
41
42 Slideshow.playWorker = function()
43 {
44 this.debug( 'calling playWorker()' );
45
46 // suspend autoplay in outline view (just slideshow view)
47 if( !this.isProjection )
48 return;
49
50 // next slide/step, please
51 var csteps = this.steps[this.snum-1]; // current slide steps array
52
53 if( !csteps || this.incpos >= csteps.length ) {
54 if( this.snum >= this.smax )
55 this.goTo( 1 ); // reached end of show? start with 1st slide again (for endless cycle)
56 else
57 this.go(1);
58 }
59 else {
60 this.subgo(1);
61 }
62 }
63
64
65 Slideshow.playToggle = function()
66 {
67 this.debug( 'calling playToggle()' );
68
69 if( this.playInterval )
70 {
71 this.debug( 'stopping autoplay' );
72 clearInterval( this.playInterval );
73 this.playInterval = null;
74 }
75 else
76 {
77 this.debug( 'starting autoplay' );
78 this.playInterval = setInterval( $.proxy( Slideshow.playWorker, this), 2000 );
79 }
80 }
81
82 // ------------------------------------------------
83
84 Slideshow.playAddEvents = function()
85 {
86 $( document ).on( 'slideshow.init', $.proxy( Slideshow.playInit, this ));
87 $( document ).on( 'slideshow.start', $.proxy( Slideshow.playStart, this ));
88 $( document ).on( 'slideshow.keys', $.proxy( Slideshow.playKeys, this ));
89 }
90
91 Slideshow.playAddEvents();