Bonjour,
Je suis en train de mettre en ligne, sur un site internet, le journal réalisé par des enfants. Pour cela, je souhaite utiliser un effet feuilleté. Auparavant, j'utilisais un appel
, mais il ne fonctionne plus ....
Code html : Sélectionner tout - Visualiser dans une fenêtre à part <applet name="lvbook" codebase="lvbook" code="lvbook" height="600" width="800" z-index: 0; >
Après des recherches sur le net, j'ai trouvé un code source qui fait la même chose mais en javascript. Le soucis, c'est que mes images ne s'affichent pas, alors que lorsque je vais dans le code source généré par le navigateur, elles apparaissent. Pourriez vous m'aider ?
Gazette.jsp
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
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 <div class="magazine-viewport"> <div class="container"> <div class="magazine" style="height: 100px;"> <!-- Next button --> <div ignore="1" class="next-button"></div> <!-- Previous button --> <div ignore="1" class="previous-button"></div> </div> </div> </div> <!-- Thumbnails --> <div class="thumbnails"> <div> <ul> <li class="i"> <img src="resources/pages/1-thumb.jpg" width="76" height="100" class="page-1"> <span>1</span> </li> <li class="d"> <img src="resources/pages/2-thumb.jpg" width="76" height="100" class="page-2"> <img src="resources/pages/3-thumb.jpg" width="76" height="100" class="page-3"> <span>2-3</span> </li> <li class="d"> <img src="resources/pages/4-thumb.jpg" width="76" height="100" class="page-4"> <img src="resources/pages/5-thumb.jpg" width="76" height="100" class="page-5"> <span>4-5</span> </li> <li class="d"> <img src="resources/pages/6-thumb.jpg" width="76" height="100" class="page-6"> <img src="resources/pages/7-thumb.jpg" width="76" height="100" class="page-7"> <span>6-7</span> </li> <li class="d"> <img src="resources/pages/8-thumb.jpg" width="76" height="100" class="page-8"> <img src="resources/pages/9-thumb.jpg" width="76" height="100" class="page-9"> <span>8-9</span> </li> <li class="d"> <img src="resources/pages/10-thumb.jpg" width="76" height="100" class="page-10"> <img src="resources/pages/11-thumb.jpg" width="76" height="100" class="page-11"> <span>10-11</span> </li> <li class="i"> <img src="resources/pages/12-thumb.jpg" width="76" height="100" class="page-12"> <span>12</span> </li> <ul> <div> </div> </div> </div>
magazine.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 function loadApp() { $('#canvas').fadeIn(1000); var flipbook = $('.magazine'); alert(flipbook.width() +"/"+flipbook.height()); // Check if the CSS was already loaded if (flipbook.width()==0 || flipbook.height()==0) { setTimeout(loadApp, 10); return; } // Create the flipbook flipbook.turn({ // Magazine width width: 922, // Magazine height height: 600, // Duration in millisecond duration: 1000, // Hardware acceleration //acceleration: !isChrome(), // Enables gradients gradients: true, // Auto center this flipbook autoCenter: true, // Elevation from the edge of the flipbook when turning a page elevation: 50, // The number of pages pages: 12, // Events when: { turning: function(event, page, view) { var book = $(this), currentPage = book.turn('page'), pages = book.turn('pages'); // Update the current URI Hash.go('page/' + page).update(); // Show and hide navigation buttons disableControls(page); alert($('.thumbnails .page-'+currentPage)); $('.thumbnails .page-'+currentPage). parent(). removeClass('current'); $('.thumbnails .page-'+page). parent(). addClass('current'); }, turned: function(event, page, view) { disableControls(page); $(this).turn('center'); if (page==1) { $(this).turn('peel', 'br'); } }, missing: function (event, pages) { // Add pages that aren't in the magazine for (var i = 0; i < pages.length; i++) addPage(pages[i], $(this)); } } }); // Zoom.js $('.magazine-viewport').zoom({ flipbook: $('.magazine'), max: function() { return largeMagazineWidth()/$('.magazine').width(); }, when: { swipeLeft: function() { $(this).zoom('flipbook').turn('next'); }, swipeRight: function() { $(this).zoom('flipbook').turn('previous'); }, resize: function(event, scale, page, pageElement) { if (scale==1) loadSmallPage(page, pageElement); else loadLargePage(page, pageElement); }, zoomIn: function () { $('.thumbnails').hide(); $('.made').hide(); $('.magazine').removeClass('animated').addClass('zoom-in'); $('.zoom-icon').removeClass('zoom-icon-in').addClass('zoom-icon-out'); if (!window.escTip && !$.isTouch) { escTip = true; $('<div />', {'class': 'exit-message'}). html('<div>Press ESC to exit</div>'). appendTo($('body')). delay(2000). animate({opacity:0}, 500, function() { $(this).remove(); }); } }, zoomOut: function () { $('.exit-message').hide(); $('.thumbnails').fadeIn(); $('.made').fadeIn(); $('.zoom-icon').removeClass('zoom-icon-out').addClass('zoom-icon-in'); setTimeout(function(){ $('.magazine').addClass('animated').removeClass('zoom-in'); resizeViewport(); }, 0); } } }); // Zoom event if ($.isTouch) $('.magazine-viewport').bind('zoom.doubleTap', zoomTo); else $('.magazine-viewport').bind('zoom.tap', zoomTo); // Using arrow keys to turn the page $(document).keydown(function(e){ var previous = 37, next = 39, esc = 27; switch (e.keyCode) { case previous: // left arrow $('.magazine').turn('previous'); e.preventDefault(); break; case next: //right arrow $('.magazine').turn('next'); e.preventDefault(); break; case esc: $('.magazine-viewport').zoom('zoomOut'); e.preventDefault(); break; } }); // URIs - Format #/page/1 Hash.on('^page\/([0-9]*)$', { yep: function(path, parts) { var page = parts[1]; if (page!==undefined) { if ($('.magazine').turn('is')) $('.magazine').turn('page', page); } }, nop: function(path) { if ($('.magazine').turn('is')) $('.magazine').turn('page', 1); } }); $(window).resize(function() { resizeViewport(); }).bind('orientationchange', function() { resizeViewport(); }); // Events for thumbnails $('.thumbnails').click(function(event) { var page; if (event.target && (page=/page-([0-9]+)/.exec($(event.target).attr('class'))) ) { $('.magazine').turn('page', page[1]); } }); $('.thumbnails li'). bind($.mouseEvents.over, function() { $(this).addClass('thumb-hover'); }).bind($.mouseEvents.out, function() { $(this).removeClass('thumb-hover'); }); if ($.isTouch) { $('.thumbnails'). addClass('thumbanils-touch'). bind($.mouseEvents.move, function(event) { event.preventDefault(); }); } else { $('.thumbnails ul').mouseover(function() { $('.thumbnails').addClass('thumbnails-hover'); }).mousedown(function() { return false; }).mouseout(function() { $('.thumbnails').removeClass('thumbnails-hover'); }); } // Regions if ($.isTouch) { $('.magazine').bind('touchstart', regionClick); } else { $('.magazine').click(regionClick); } // Events for the next button $('.next-button').bind($.mouseEvents.over, function() { $(this).addClass('next-button-hover'); }).bind($.mouseEvents.out, function() { $(this).removeClass('next-button-hover'); }).bind($.mouseEvents.down, function() { $(this).addClass('next-button-down'); }).bind($.mouseEvents.up, function() { $(this).removeClass('next-button-down'); }).click(function() { $('.magazine').turn('next'); }); // Events for the next button $('.previous-button').bind($.mouseEvents.over, function() { $(this).addClass('previous-button-hover'); }).bind($.mouseEvents.out, function() { $(this).removeClass('previous-button-hover'); }).bind($.mouseEvents.down, function() { $(this).addClass('previous-button-down'); }).bind($.mouseEvents.up, function() { $(this).removeClass('previous-button-down'); }).click(function() { $('.magazine').turn('previous'); }); resizeViewport(); $('.magazine').addClass('animated'); } // Zoom icon $('.zoom-icon').bind('mouseover', function() { if ($(this).hasClass('zoom-icon-in')) $(this).addClass('zoom-icon-in-hover'); if ($(this).hasClass('zoom-icon-out')) $(this).addClass('zoom-icon-out-hover'); }).bind('mouseout', function() { if ($(this).hasClass('zoom-icon-in')) $(this).removeClass('zoom-icon-in-hover'); if ($(this).hasClass('zoom-icon-out')) $(this).removeClass('zoom-icon-out-hover'); }).bind('click', function() { if ($(this).hasClass('zoom-icon-in')) $('.magazine-viewport').zoom('zoomIn'); else if ($(this).hasClass('zoom-icon-out')) $('.magazine-viewport').zoom('zoomOut'); }); $('#canvas').hide(); // Load the HTML4 version if there's not CSS transform yepnope({ test : Modernizr.csstransforms, yep: ['resources/lib/turn.js'], nope: ['resources/lib/turn.html4.min.js'], both: ['resources/lib/zoom.min.js', 'resources/js/magazine.js', 'resources/css/magazine.css'], complete: loadApp });
Merci pour tout
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 /* * Magazine sample */ function addPage(page, book) { var id, pages = book.turn('pages'); // Create a new element for this page var element = $('<div />', {}); // Add the page to the flipbook if (book.turn('addPage', element, page)) { // Add the initial HTML // It will contain a loader indicator and a gradient element.html('<div class="gradient"></div><div class="loader"></div>'); // Load the page loadPage(page, element); } } function loadPage(page, pageElement) { // Create an image element var img = $('<img />'); img.mousedown(function(e) { e.preventDefault(); }); img.load(function() { // Set the size $(this).css({width: '100%', height: '100%'}); // Add the image to the page after loaded $(this).appendTo(pageElement); // Remove the loader indicator pageElement.find('.loader').remove(); }); // Load the page img.attr('src', 'pages/' + page + '.jpg'); loadRegions(page, pageElement); } // Zoom in / Zoom out function zoomTo(event) { setTimeout(function() { if ($('.magazine-viewport').data().regionClicked) { $('.magazine-viewport').data().regionClicked = false; } else { if ($('.magazine-viewport').zoom('value')==1) { $('.magazine-viewport').zoom('zoomIn', event); } else { $('.magazine-viewport').zoom('zoomOut'); } } }, 1); } // Load regions function loadRegions(page, element) { $.getJSON('pages/'+page+'-regions.json'). done(function(data) { $.each(data, function(key, region) { addRegion(region, element); }); }); } // Add region function addRegion(region, pageElement) { var reg = $('<div />', {'class': 'region ' + region['class']}), options = $('.magazine').turn('options'), pageWidth = options.width/2, pageHeight = options.height; reg.css({ top: Math.round(region.y/pageHeight*100)+'%', left: Math.round(region.x/pageWidth*100)+'%', width: Math.round(region.width/pageWidth*100)+'%', height: Math.round(region.height/pageHeight*100)+'%' }).attr('region-data', $.param(region.data||'')); reg.appendTo(pageElement); } // Process click on a region function regionClick(event) { var region = $(event.target); if (region.hasClass('region')) { $('.magazine-viewport').data().regionClicked = true; setTimeout(function() { $('.magazine-viewport').data().regionClicked = false; }, 100); var regionType = $.trim(region.attr('class').replace('region', '')); return processRegion(region, regionType); } } // Process the data of every region function processRegion(region, regionType) { data = decodeParams(region.attr('region-data')); switch (regionType) { case 'link' : window.open(data.url); break; case 'zoom' : var regionOffset = region.offset(), viewportOffset = $('.magazine-viewport').offset(), pos = { x: regionOffset.left-viewportOffset.left, y: regionOffset.top-viewportOffset.top }; $('.magazine-viewport').zoom('zoomIn', pos); break; case 'to-page' : $('.magazine').turn('page', data.page); break; } } // Load large page function loadLargePage(page, pageElement) { var img = $('<img />'); img.load(function() { var prevImg = pageElement.find('img'); $(this).css({width: '100%', height: '100%'}); $(this).appendTo(pageElement); prevImg.remove(); }); // Loadnew page img.attr('src', 'pages/' + page + '-large.jpg'); } // Load small page function loadSmallPage(page, pageElement) { var img = pageElement.find('img'); img.css({width: '100%', height: '100%'}); img.unbind('load'); // Loadnew page img.attr('src', 'pages/' + page + '.jpg'); } // http://code.google.com/p/chromium/issues/detail?id=128488 function isChrome() { return navigator.userAgent.indexOf('Chrome')!=-1; } function disableControls(page) { if (page==1) $('.previous-button').hide(); else $('.previous-button').show(); if (page==$('.magazine').turn('pages')) $('.next-button').hide(); else $('.next-button').show(); } // Set the width and height for the viewport function resizeViewport() { var width = $(window).width(), height = $(window).height(), options = $('.magazine').turn('options'); $('.magazine').removeClass('animated'); $('.magazine-viewport').css({ width: width, height: height }). zoom('resize'); if ($('.magazine').turn('zoom')==1) { var bound = calculateBound({ width: options.width, height: options.height, boundWidth: Math.min(options.width, width), boundHeight: Math.min(options.height, height) }); if (bound.width%2!==0) bound.width-=1; if (bound.width!=$('.magazine').width() || bound.height!=$('.magazine').height()) { $('.magazine').turn('size', bound.width, bound.height); if ($('.magazine').turn('page')==1) $('.magazine').turn('peel', 'br'); $('.next-button').css({height: bound.height, backgroundPosition: '-38px '+(bound.height/2-32/2)+'px'}); $('.previous-button').css({height: bound.height, backgroundPosition: '-4px '+(bound.height/2-32/2)+'px'}); } $('.magazine').css({top: -bound.height/2, left: -bound.width/2}); } var magazineOffset = $('.magazine').offset(), boundH = height - magazineOffset.top - $('.magazine').height(), marginTop = (boundH - $('.thumbnails > div').height()) / 2; if (marginTop<0) { $('.thumbnails').css({height:1}); } else { $('.thumbnails').css({height: boundH}); $('.thumbnails > div').css({marginTop: marginTop}); } if (magazineOffset.top<$('.made').height()) $('.made').hide(); else $('.made').show(); $('.magazine').addClass('animated'); } // Number of views in a flipbook function numberOfViews(book) { return book.turn('pages') / 2 + 1; } // Current view in a flipbook function getViewNumber(book, page) { return parseInt((page || book.turn('page'))/2 + 1, 10); } function moveBar(yes) { if (Modernizr && Modernizr.csstransforms) { $('#slider .ui-slider-handle').css({zIndex: yes ? -1 : 10000}); } } function setPreview(view) { var previewWidth = 112, previewHeight = 73, previewSrc = 'pages/preview.jpg', preview = $(_thumbPreview.children(':first')), numPages = (view==1 || view==$('#slider').slider('option', 'max')) ? 1 : 2, width = (numPages==1) ? previewWidth/2 : previewWidth; _thumbPreview. addClass('no-transition'). css({width: width + 15, height: previewHeight + 15, top: -previewHeight - 30, left: ($($('#slider').children(':first')).width() - width - 15)/2 }); preview.css({ width: width, height: previewHeight }); if (preview.css('background-image')==='' || preview.css('background-image')=='none') { preview.css({backgroundImage: 'url(' + previewSrc + ')'}); setTimeout(function(){ _thumbPreview.removeClass('no-transition'); }, 0); } preview.css({backgroundPosition: '0px -'+((view-1)*previewHeight)+'px' }); } // Width of the flipbook when zoomed in function largeMagazineWidth() { return 2214; } // decode URL Parameters function decodeParams(data) { var parts = data.split('&'), d, obj = {}; for (var i =0; i<parts.length; i++) { d = parts[i].split('='); obj[decodeURIComponent(d[0])] = decodeURIComponent(d[1]); } return obj; } // Calculate the width and height of a square within another square function calculateBound(d) { var bound = {width: d.width, height: d.height}; if (bound.width>d.boundWidth || bound.height>d.boundHeight) { var rel = bound.width/bound.height; if (d.boundWidth/rel>d.boundHeight && d.boundHeight*rel<=d.boundWidth) { bound.width = Math.round(d.boundHeight*rel); bound.height = d.boundHeight; } else { bound.width = d.boundWidth; bound.height = Math.round(d.boundWidth/rel); } } return bound; }
Partager