|
1 | 1 | <%page expression_filter="h"/> |
2 | | -<!DOCTYPE html> |
| 2 | +<!DOCTYPE html> |
3 | 3 | <%namespace name='static' file='static_content.html'/> |
4 | 4 | <%! |
5 | 5 | from openedx.core.djangolib.js_utils import ( |
|
46 | 46 | PDFJS.workerSrc = "${static.url('js/vendor/pdfjs/pdf.worker.js') | n, js_escaped_string}"; |
47 | 47 | PDFJS.disableWorker = true; |
48 | 48 | PDFJS.cMapUrl = "${static.url('css/vendor/pdfjs/cmaps/') | n, js_escaped_string}"; |
49 | | - PDF_URL = '${current_url | n, js_escaped_string}'; |
| 49 | + |
| 50 | + var PDF_URL = '${current_url | n, js_escaped_string}'; |
| 51 | + |
| 52 | + if (window.parent !== window) { |
| 53 | + window.parent.postMessage({type: 'request_pdf_url'}, '*'); |
| 54 | + |
| 55 | + function handlePdfUrlResponse(event) { |
| 56 | + if (event.data && event.data.type === 'pdf_url_response') { |
| 57 | + PDF_URL = event.data.url; |
| 58 | + |
| 59 | + if (PDFViewerApplication.open) { |
| 60 | + PDFViewerApplication.open(PDF_URL); |
| 61 | + PDFViewerApplication.mouseScroll(0); |
| 62 | + |
| 63 | + setTimeout(function() { |
| 64 | + if (PDFViewerApplication.pdfDocument && PDFViewerApplication.pdfDocument.documentInfo) { |
| 65 | + var info = PDFViewerApplication.pdfDocument.documentInfo; |
| 66 | + if (event.data.title) info.Title = event.data.title; |
| 67 | + if (event.data.author) info.Author = event.data.author; |
| 68 | + if (event.data.subject) info.Subject = event.data.subject; |
| 69 | + if (event.data.keywords) info.Keywords = event.data.keywords; |
| 70 | + info.Creator = 'edX Platform'; |
| 71 | + } |
| 72 | + }, 500); |
| 73 | + } |
| 74 | + } else if (event.data && event.data.type === 'chapter_change') { |
| 75 | + window.parent.postMessage({type: 'request_pdf_url'}, '*'); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + window.addEventListener('message', handlePdfUrlResponse); |
| 80 | + } |
50 | 81 | </script> |
51 | 82 |
|
52 | | - <script ${static.url('js/vendor/pdfjs/debugger.js')}></script> |
| 83 | + <script type="text/javascript" src="${static.url('js/vendor/pdfjs/debugger.js')}"></script> |
53 | 84 |
|
54 | 85 | <%static:js group='main_vendor'/> |
55 | 86 | <%static:js group='application'/> |
|
347 | 378 |
|
348 | 379 | </div> <!-- outerContainer --> |
349 | 380 | <div id="printContainer"></div> |
350 | | -<div id="mozPrintCallback-shim" hidden> |
351 | | - <style scoped> |
352 | | -#mozPrintCallback-shim { |
353 | | - position: fixed; |
354 | | - top: 0; |
355 | | - left: 0; |
356 | | - height: 100%; |
357 | | - width: 100%; |
358 | | - z-index: 9999999; |
359 | | - |
360 | | - display: block; |
361 | | - text-align: center; |
362 | | - background-color: rgba(0, 0, 0, 0.5); |
363 | | -} |
364 | | -#mozPrintCallback-shim[hidden] { |
365 | | - display: none; |
366 | | -} |
367 | | -@media print { |
368 | | - #mozPrintCallback-shim { |
369 | | - display: none; |
370 | | - } |
371 | | -} |
372 | | - |
373 | | -#mozPrintCallback-shim .mozPrintCallback-dialog-box { |
374 | | - display: inline-block; |
375 | | - margin: -50px auto 0; |
376 | | - position: relative; |
377 | | - top: 45%; |
378 | | - left: 0; |
379 | | - min-width: 220px; |
380 | | - max-width: 400px; |
381 | | - |
382 | | - padding: 9px; |
383 | | - |
384 | | - border: 1px solid hsla(0, 0%, 0%, .5); |
385 | | - border-radius: 2px; |
386 | | - box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); |
387 | | - |
388 | | - background-color: #474747; |
389 | | - |
390 | | - color: hsl(0, 0%, 85%); |
391 | | - font-size: 16px; |
392 | | - line-height: 20px; |
393 | | -} |
394 | | -#mozPrintCallback-shim .progress-row { |
395 | | - clear: both; |
396 | | - padding: 1em 0; |
397 | | -} |
398 | | -#mozPrintCallback-shim progress { |
399 | | - width: 100%; |
400 | | -} |
401 | | -#mozPrintCallback-shim .relative-progress { |
402 | | - clear: both; |
403 | | - float: right; |
404 | | -} |
405 | | -#mozPrintCallback-shim .progress-actions { |
406 | | - clear: both; |
407 | | -} |
408 | | - </style> |
409 | | - <div class="mozPrintCallback-dialog-box"> |
410 | | - <!-- TODO: Localise the following strings --> |
411 | | - Preparing document for printing... |
412 | | - <div class="progress-row"> |
413 | | - <progress value="0" max="100"></progress> |
414 | | - <span class="relative-progress">0%</span> |
415 | | - </div> |
416 | | - <div class="progress-actions"> |
417 | | - <input type="button" value="Cancel" class="mozPrintCallback-cancel"> |
| 381 | + <div id="mozPrintCallback-shim" hidden> |
| 382 | + <style scoped> |
| 383 | + #mozPrintCallback-shim { |
| 384 | + position: fixed; |
| 385 | + top: 0; |
| 386 | + left: 0; |
| 387 | + height: 100%; |
| 388 | + width: 100%; |
| 389 | + z-index: 9999999; |
| 390 | + |
| 391 | + display: block; |
| 392 | + text-align: center; |
| 393 | + background-color: rgba(0, 0, 0, 0.5); |
| 394 | + } |
| 395 | + #mozPrintCallback-shim[hidden] { |
| 396 | + display: none; |
| 397 | + } |
| 398 | + @media print { |
| 399 | + #mozPrintCallback-shim { |
| 400 | + display: none; |
| 401 | + } |
| 402 | + } |
| 403 | + |
| 404 | + #mozPrintCallback-shim .mozPrintCallback-dialog-box { |
| 405 | + display: inline-block; |
| 406 | + margin: -50px auto 0; |
| 407 | + position: relative; |
| 408 | + top: 45%; |
| 409 | + left: 0; |
| 410 | + min-width: 220px; |
| 411 | + max-width: 400px; |
| 412 | + |
| 413 | + padding: 9px; |
| 414 | + |
| 415 | + border: 1px solid hsla(0, 0%, 0%, .5); |
| 416 | + border-radius: 2px; |
| 417 | + box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); |
| 418 | + |
| 419 | + background-color: #474747; |
| 420 | + |
| 421 | + color: hsl(0, 0%, 85%); |
| 422 | + font-size: 16px; |
| 423 | + line-height: 20px; |
| 424 | + } |
| 425 | + #mozPrintCallback-shim .progress-row { |
| 426 | + clear: both; |
| 427 | + padding: 1em 0; |
| 428 | + } |
| 429 | + #mozPrintCallback-shim progress { |
| 430 | + width: 100%; |
| 431 | + } |
| 432 | + #mozPrintCallback-shim .relative-progress { |
| 433 | + clear: both; |
| 434 | + float: right; |
| 435 | + } |
| 436 | + #mozPrintCallback-shim .progress-actions { |
| 437 | + clear: both; |
| 438 | + } |
| 439 | + </style> |
| 440 | + <div class="mozPrintCallback-dialog-box"> |
| 441 | + <!-- TODO: Localise the following strings --> |
| 442 | + Preparing document for printing... |
| 443 | + <div class="progress-row"> |
| 444 | + <progress value="0" max="100"></progress> |
| 445 | + <span class="relative-progress">0%</span> |
| 446 | + </div> |
| 447 | + <div class="progress-actions"> |
| 448 | + <input type="button" value="Cancel" class="mozPrintCallback-cancel"> |
| 449 | + </div> |
| 450 | + </div> |
418 | 451 | </div> |
419 | | - </div> |
420 | | -</div> |
421 | 452 | <script type="text/javascript" src="${static.url('js/vendor/pdfjs/viewer.js')}"></script> |
422 | 453 | <script type="text/javascript" src="${static.url('js/pdf-analytics.js')}"></script> |
423 | 454 | </body> |
|
0 commit comments