slideshow 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,285 @@
1
+ var snum = 1; /* current slide # (non-zero based index e.g. starting with 1) */
2
+ var smax = 1; /* max number of slides */
3
+ var incpos = 0; /* current step in slide */
4
+ var s6mode = true; /* are we in slide mode (in contrast to outline mode)? */
5
+ var defaultView = 'slideshow'; /* slideshow | outline */
6
+
7
+
8
+ function debug( msg )
9
+ {
10
+ /* uncomment to enable debug messages in console such as Firebug */
11
+ /* console.log( '[debug] ' + msg ); */
12
+ }
13
+
14
+ function showHide(action)
15
+ {
16
+ switch( action ) {
17
+ case 's': $( '#navLinks' ).css( 'visibility', 'visible' ); break;
18
+ case 'h': $( '#navLinks' ).css( 'visibility', 'hidden' ); break;
19
+ case 'c': /* toggle control panel */
20
+ if( $( '#navLinks' ).css( 'visibility' ) != 'visible' )
21
+ $( '#navLinks' ).css( 'visibility', 'visible' );
22
+ else
23
+ $( '#navLinks' ).css( 'visibility', 'hidden' );
24
+ break;
25
+ }
26
+ }
27
+
28
+ function updateCurrentSlideCounter() {
29
+
30
+ $( '#currentSlide' ).html( '<a id="plink" href="">' +
31
+ '<span id="csHere">' + snum + '<\/span> ' +
32
+ '<span id="csSep">\/<\/span> ' +
33
+ '<span id="csTotal">' + smax + '<\/span>' +
34
+ '<\/a>' );
35
+ }
36
+
37
+
38
+ function updatePermaLink() {
39
+ $('#plink').get(0).href = window.location.pathname + '#slide' + snum;
40
+ }
41
+
42
+ function goTo( target ) {
43
+ if( target > smax || target == snum ) return;
44
+ go( target - snum );
45
+ }
46
+
47
+ function go( dir ) {
48
+
49
+ debug( 'go: ' + dir );
50
+
51
+ if( dir == 0 ) return; /* same slide; nothing to do */
52
+
53
+ var cid = '#slide' + snum; /* current slide (selector) id */
54
+ var csteps = steps[snum-1]; /* current slide steps array */
55
+
56
+ /* remove all step and stepcurrent classes from current slide */
57
+ if( csteps.length > 0) {
58
+ $( csteps ).each( function() {
59
+ $( this ).removeClass( 'step' ).removeClass( 'stepcurrent' );
60
+ } );
61
+ }
62
+
63
+ /* set snum to next slide */
64
+ snum += dir;
65
+ if( snum > smax ) snum = smax;
66
+ if (snum < 1) snum = 1;
67
+
68
+ var nid = '#slide' + snum; /* next slide (selector) id */
69
+ var nsteps = steps[snum-1]; /* next slide steps array */
70
+
71
+ if( dir < 0 ) /* go backwards? */
72
+ {
73
+ incpos = nsteps.length;
74
+ /* mark last step as current step */
75
+ if( nsteps.length > 0 )
76
+ $( nsteps[incpos-1] ).addClass( 'stepcurrent' );
77
+ }
78
+ else /* go forwards? */
79
+ {
80
+ incpos = 0;
81
+ if( nsteps.length > 0 ) {
82
+ $( nsteps ).each( function() {
83
+ $(this).addClass( 'step' ).removeClass( 'stepcurrent' );
84
+ } );
85
+ }
86
+ }
87
+
88
+ $( cid ).hide();
89
+ $( nid ).show();
90
+
91
+ $('#jumplist').get(0).selectedIndex = (snum-1);
92
+ updateCurrentSlideCounter();
93
+ updatePermaLink();
94
+ }
95
+
96
+ function subgo( dir ) {
97
+
98
+ debug( 'subgo: ' + dir + ', incpos before: ' + incpos + ', after: ' + (incpos+dir) );
99
+
100
+ var csteps = steps[snum-1]; /* current slide steps array */
101
+
102
+ if( dir > 0) { /* go forward? */
103
+ if( incpos > 0 ) $( csteps[incpos-1] ).removeClass( 'stepcurrent' );
104
+ $( csteps[incpos] ).removeClass( 'step').addClass( 'stepcurrent' );
105
+ incpos++;
106
+ } else { /* go backwards? */
107
+ incpos--;
108
+ $( csteps[incpos] ).removeClass( 'stepcurrent' ).addClass( 'step' );
109
+ if( incpos > 0 ) $( csteps[incpos-1] ).addClass( 'stepcurrent' );
110
+ }
111
+ }
112
+
113
+
114
+
115
+ function toggle() {
116
+
117
+ /* get stylesheets */
118
+ var slides = $('#slideProj').get(0);
119
+ var outline = $('#outlineStyle').get(0);
120
+
121
+ if( !slides.disabled ) {
122
+ slides.disabled = true;
123
+ outline.disabled = false;
124
+ s6mode = false;
125
+ $('.slide').each( function() { $(this).show(); } );
126
+ } else {
127
+ slides.disabled = false;
128
+ outline.disabled = true;
129
+ s6mode = true;
130
+ $('.slide').each( function(i) {
131
+ if( i == (snum-1) )
132
+ $(this).show();
133
+ else
134
+ $(this).hide();
135
+ });
136
+ }
137
+ }
138
+
139
+
140
+ function populateJumpList() {
141
+
142
+ var list = $('#jumplist').get(0);
143
+
144
+ $( '.slide' ).each( function(i) {
145
+ list.options[list.length] = new Option( (i+1)+' : '+ $(this).find('h1').text(), (i+1) );
146
+ });
147
+ }
148
+
149
+ function createControls() {
150
+
151
+ $('#controls').html( '<div id="navLinks">' +
152
+ '<a accesskey="t" id="toggle" href="#">&#216;<\/a>' +
153
+ '<a accesskey="z" id="prev" href="#">&laquo;<\/a>' +
154
+ '<a accesskey="x" id="next" href="#">&raquo;<\/a>' +
155
+ '<div id="navList"><select id="jumplist" /><\/div>' +
156
+ '<\/div>' );
157
+
158
+ $('#controls').mouseover( function() { showHide('s'); } );
159
+ $('#controls').mouseout( function() { showHide('h'); } );
160
+ $('#toggle').click( function() { toggle(); } );
161
+ $('#prev').click( function() { go(-1); } );
162
+ $('#next').click( function() { go(1); } );
163
+
164
+ $('#jumplist').change( function() { goTo( parseInt( $( '#jumplist' ).val() )); } );
165
+
166
+ populateJumpList();
167
+ updateCurrentSlideCounter();
168
+ }
169
+
170
+ function addSlideIds() {
171
+ $( '.slide' ).each( function(i) {
172
+ $(this).attr( 'id', 'slide'+(i+1) );
173
+ });
174
+
175
+ smax = $( '.slide' ).length;
176
+ }
177
+
178
+ function notOperaFix() {
179
+
180
+ $('#slideProj').attr( 'media','screen' );
181
+
182
+ var outline = $('#outlineStyle').get(0);
183
+ outline.disabled = true;
184
+ }
185
+
186
+
187
+ function defaultCheck() {
188
+ $( 'meta' ).each( function() {
189
+ if( $(this).attr( 'name' ) == 'defaultView' )
190
+ defaultView = $(this).attr( 'content' );
191
+ } );
192
+ }
193
+
194
+ function keys(key) {
195
+ if (!key) {
196
+ key = event;
197
+ key.which = key.keyCode;
198
+ }
199
+ if (key.which == 84) {
200
+ toggle();
201
+ return;
202
+ }
203
+ if (s6mode) {
204
+ switch (key.which) {
205
+ case 32: // spacebar
206
+ case 34: // page down
207
+ case 39: // rightkey
208
+ case 40: // downkey
209
+
210
+ if (!steps[snum-1] || incpos >= steps[snum-1].length) {
211
+ go(1);
212
+ } else {
213
+ subgo(1);
214
+ }
215
+ break;
216
+ case 33: // page up
217
+ case 37: // leftkey
218
+ case 38: // upkey
219
+
220
+ if( !steps[snum-1] || incpos <= 0 ) {
221
+ go(-1);
222
+ } else {
223
+ subgo(-1);
224
+ }
225
+ break;
226
+ case 36: // home
227
+ goTo(1);
228
+ break;
229
+ case 35: // end
230
+ goTo(smax);
231
+ break;
232
+ case 67: // c
233
+ showHide('c');
234
+ break;
235
+ }
236
+ }
237
+ return false;
238
+ }
239
+
240
+
241
+ function collectStepsWorker(obj) {
242
+
243
+ var steps = new Array();
244
+ if( !obj )
245
+ return steps;
246
+
247
+ $(obj).children().each( function() {
248
+ if( $(this).hasClass( 'step' ) ) {
249
+
250
+ debug( 'step found for ' + this.tagName );
251
+ $(this).removeClass( 'step' );
252
+
253
+ /* don't add enclosing list; instead add step class to all list items/children */
254
+ if( $(this).is( 'ol,ul' ) ) {
255
+ debug( ' ol or ul found; adding auto steps' );
256
+ $(this).children().addClass( 'step' );
257
+ }
258
+ else
259
+ {
260
+ steps.push( this )
261
+ }
262
+ }
263
+
264
+ steps = steps.concat( collectStepsWorker(this) );
265
+ });
266
+
267
+ return steps;
268
+ }
269
+
270
+ function collectSteps() {
271
+
272
+ var steps = new Array();
273
+
274
+ $( '.slide' ).each( function(i) {
275
+ debug ( $(this).attr( 'id' ) + ':' );
276
+ steps[i] = collectStepsWorker( this );
277
+ });
278
+
279
+ $( steps ).each( function(i) {
280
+ debug( 'slide ' + (i+1) + ': found ' + this.length + ' steps' );
281
+ });
282
+
283
+ return steps;
284
+ }
285
+
@@ -1,179 +1,17 @@
1
- var snum = 1; /* current slide # (non-zero based index e.g. starting with 1) */
2
- var smax = 1; /* max number of slides */
3
- var s6mode = true; /* are we in slide mode (in contrast to outline mode)? */
4
- var defaultView = 'slideshow'; /* slideshow | outline */
1
+ /* Just an example for an all-in-one convenience include
5
2
 
6
- function showHide(action)
7
- {
8
- switch( action ) {
9
- case 's': $( '#navLinks' ).css( 'visibility', 'visible' ); break;
10
- case 'h': $( '#navLinks' ).css( 'visibility', 'hidden' ); break;
11
- case 'c': /* toggle control panel */
12
- if( $( '#navLinks' ).css( 'visibility' ) != 'visible' )
13
- $( '#navLinks' ).css( 'visibility', 'visible' );
14
- else
15
- $( '#navLinks' ).css( 'visibility', 'hidden' );
16
- break;
17
- }
18
- }
19
-
20
- function currentSlide() {
21
-
22
- $( '#currentSlide' ).html( '<a id="plink" href="">' +
23
- '<span id="csHere">' + snum + '<\/span> ' +
24
- '<span id="csSep">\/<\/span> ' +
25
- '<span id="csTotal">' + smax + '<\/span>' +
26
- '<\/a>' );
27
- }
28
-
29
-
30
- function permaLink() {
31
- $('#plink').get(0).href = window.location.pathname + '#slide' + snum;
32
- }
33
-
34
- function goTo( target ) {
35
- if( target > smax || target == snum ) return;
36
- go( target - snum );
37
- }
38
-
39
- function go( step ) {
40
-
41
- var cid = '#slide' + snum;
42
-
43
- if (step != 'j') {
44
- snum += step;
45
- if( snum > smax ) snum = smax;
46
- if (snum < 1) snum = 1;
47
- } else
48
- snum = parseInt( $( '#jumplist' ).val() );
49
-
50
- var nid = '#slide' + snum;
51
-
52
- $( cid ).hide();
53
- $( nid ).show();
54
-
55
- $('#jumplist').get(0).selectedIndex = (snum-1);
56
- currentSlide();
57
- permaLink();
58
- }
3
+ create your own slide.js to include your own extensions and
4
+ change the startup (document ready) code as needed
5
+
6
+ Tell us about your extentions or changes on the forum. Thank!
7
+ Find the forum @ http://groups.google.com/group/webslideshow
8
+ */
59
9
 
60
10
 
61
- function toggle() {
62
-
63
- /* get stylesheets */
64
- var slides = $('#slideProj').get(0);
65
- var outline = $('#outlineStyle').get(0);
66
-
67
- if( !slides.disabled ) {
68
- slides.disabled = true;
69
- outline.disabled = false;
70
- s6mode = false;
71
- $('.slide').each( function() { $(this).show(); } );
72
- } else {
73
- slides.disabled = false;
74
- outline.disabled = true;
75
- s6mode = true;
76
- $('.slide').each( function(i) {
77
- if( i == (snum-1) )
78
- $(this).show();
79
- else
80
- $(this).hide();
81
- });
82
- }
83
- }
84
-
85
-
86
- function populateJumpList() {
87
-
88
- var list = $('#jumplist').get(0);
89
-
90
- $( '.slide' ).each( function(i) {
91
- list.options[list.length] = new Option( (i+1)+' : '+ $(this).find('h1').text(), (i+1) );
92
- });
93
- }
94
-
95
- function createControls() {
96
-
97
- $('#controls').html( '<div id="navLinks">' +
98
- '<a accesskey="t" id="toggle" href="#">&#216;<\/a>' +
99
- '<a accesskey="z" id="prev" href="#">&laquo;<\/a>' +
100
- '<a accesskey="x" id="next" href="#">&raquo;<\/a>' +
101
- '<div id="navList"><select id="jumplist" /><\/div>' +
102
- '<\/div>' );
103
-
104
- $('#controls').mouseover( function() { showHide('s'); } );
105
- $('#controls').mouseout( function() { showHide('h'); } );
106
- $('#toggle').click( function() { toggle(); } );
107
- $('#prev').click( function() { go(-1); } );
108
- $('#next').click( function() { go(1); } );
109
-
110
- $('#jumplist').change( function() { go('j'); } );
111
-
112
- populateJumpList();
113
- currentSlide();
114
- }
115
-
116
- function addSlideIds() {
117
- $( '.slide' ).each( function(i) {
118
- $(this).attr( 'id', 'slide'+(i+1) );
119
- });
120
-
121
- smax = $( '.slide' ).length;
122
- }
123
-
124
- function notOperaFix() {
125
-
126
- $('#slideProj').attr( 'media','screen' );
127
-
128
- var outline = $('#outlineStyle').get(0);
129
- outline.disabled = true;
130
- }
131
-
132
-
133
- function defaultCheck() {
134
- $( 'meta' ).each( function() {
135
- if( $(this).attr( 'name' ) == 'defaultView' )
136
- defaultView = $(this).attr( 'content' );
137
- } );
138
- }
139
-
140
- function keys(key) {
141
- if (!key) {
142
- key = event;
143
- key.which = key.keyCode;
144
- }
145
- if (key.which == 84) {
146
- toggle();
147
- return;
148
- }
149
- if (s6mode) {
150
- switch (key.which) {
151
- case 32: // spacebar
152
- case 34: // page down
153
- case 39: // rightkey
154
- case 40: // downkey
155
- go(1);
156
- break;
157
- case 33: // page up
158
- case 37: // leftkey
159
- case 38: // upkey
160
- go(-1);
161
- break;
162
- case 36: // home
163
- goTo(1);
164
- break;
165
- case 35: // end
166
- goTo(smax);
167
- break;
168
- case 67: // c
169
- showHide('c');
170
- break;
171
- }
172
- }
173
- return false;
174
- }
11
+ $.ajaxSetup({async: false});
12
+ $.getScript( 's6/slides.core.js' );
13
+ $.ajaxSetup({async: true});
175
14
 
176
-
177
15
  $(document).ready(function(){
178
16
 
179
17
  if( $.browser.msie )
@@ -192,6 +30,8 @@ $(document).ready(function(){
192
30
  /* opera is the only browser currently supporting css projection mode */
193
31
  /* if( !$.browser.opera ) */
194
32
  notOperaFix();
33
+
34
+ steps = collectSteps();
195
35
 
196
36
  if( defaultView == 'outline' )
197
37
  toggle();