annotate Applications/StoneWebViewer/WebApplication/print.js @ 1801:64dad1d7aca4

renamed subclass
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 May 2021 13:23:59 +0200
parents 9ac2a65d4172
children 3889ae96d2e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
1 /**
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
2 * Stone of Orthanc
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
4 * Department, University Hospital of Liege, Belgium
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1657
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
6 *
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
7 * This program is free software: you can redistribute it and/or
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
10 * the License, or (at your option) any later version.
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
11 *
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
12 * This program is distributed in the hope that it will be useful, but
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
15 * Affero General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1589
diff changeset
16 *
1589
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
19 **/
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
20
8c5f9864545f adding missing headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1575
diff changeset
21
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
22 function beforePrint(event) {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
23 var body = $('body');
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
24 body.addClass('print');
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
1654
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
26 if (0) {
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
27 // This is Letter
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
28 body.css('width', '8.5in');
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
29 body.css('height', '11in');
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
30 } else {
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
31 // This is A4
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
32 body.css('width', '210mm');
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
33 body.css('height', '296mm'); // If using "297mm", Firefox creates a second blank page
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 }
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
1654
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
36 // https://webglfundamentals.org/webgl/lessons/webgl-resizing-the-canvas.html
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
37 var realToCSSPixels = window.devicePixelRatio;
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
38
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
39 $('.viewport-canvas').each(function(key, canvas) {
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
40 if ($(canvas).is(':visible')) {
1654
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
41 $(canvas).width(Math.floor(realToCSSPixels * $(canvas).get(0).clientWidth));
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
42 $(canvas).height(Math.floor(realToCSSPixels * $(canvas).get(0).clientHeight));
1563
e0045462a25c cont print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
43 }
e0045462a25c cont print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
44 });
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
46 stone.FitForPrint();
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
47 };
1563
e0045462a25c cont print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
48
e0045462a25c cont print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
49
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
50 function afterPrint() {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
51 var body = $('body');
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
52 body.removeClass('print');
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
53 body.css('width', '100%');
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
54 body.css('height', '100%');
1657
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
55 $('.viewport-canvas').css('width', '100%');
66e5fcdf5597 pdf viewer is working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1654
diff changeset
56 $('.viewport-canvas').css('height', '100%');
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
57
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
58 stone.FitForPrint();
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
61
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
62 window.addEventListener('beforeprint', function(event) {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
63 beforePrint(event);
1563
e0045462a25c cont print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
64 });
e0045462a25c cont print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
65
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
66
1654
39137da83b0b fix print.js, no need for ua-parser.js anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
67 window.matchMedia('print').addListener(function(mql) {
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
68 if (mql.matches) {
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
69 // webkit equivalent of onbeforeprint
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 beforePrint();
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 });
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
74
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
75 window.addEventListener('afterprint', function() {
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 afterPrint();
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
77 });
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
1575
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
79
e4a52cbbdd70 working on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1563
diff changeset
80 /*vm.cancelPrintMode = function() {
1562
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 afterPrint();
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 }
2a4a6b967053 starting work on print
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 */