OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function() { | 5 (function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 <include src="../../../../ui/webui/resources/js/util.js"></include> | 8 <include src="../../../../ui/webui/resources/js/util.js"></include> |
9 <include src="viewport.js"></include> | 9 <include src="viewport.js"></include> |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 viewerProgressBar.progress = progress; | 42 viewerProgressBar.progress = progress; |
43 if (progress == -1) { | 43 if (progress == -1) { |
44 // Document load failed. | 44 // Document load failed. |
45 sizer.style.display = 'none'; | 45 sizer.style.display = 'none'; |
46 viewerToolbar.style.visibility = 'hidden'; | 46 viewerToolbar.style.visibility = 'hidden'; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 // Called when a message is received from the plugin. | 50 // Called when a message is received from the plugin. |
51 function handleMessage(message) { | 51 function handleMessage(message) { |
52 if (message.data.type == 'documentDimensions') { | 52 switch (message.data.type.toString()) { |
53 documentDimensions = message.data; | 53 case 'documentDimensions': |
54 viewport.setDocumentDimensions(documentDimensions); | 54 documentDimensions = message.data; |
55 viewerToolbar.style.visibility = 'visible'; | 55 viewport.setDocumentDimensions(documentDimensions); |
56 viewerPageIndicator.initialFadeIn(); | 56 viewerToolbar.style.visibility = 'visible'; |
57 viewerToolbar.initialFadeIn(); | 57 viewerPageIndicator.initialFadeIn(); |
58 } else if (message.data.type == 'loadProgress') { | 58 viewerToolbar.initialFadeIn(); |
59 updateProgress(message.data['progress']); | 59 break; |
| 60 case 'loadProgress': |
| 61 updateProgress(message.data.progress); |
| 62 break; |
| 63 case 'goToPage': |
| 64 viewport.goToPage(message.data.page); |
| 65 break; |
60 } | 66 } |
61 } | 67 } |
62 | 68 |
63 // Callback that's called when the viewport changes. | 69 // Callback that's called when the viewport changes. |
64 function viewportChangedCallback(zoom, | 70 function viewportChangedCallback(zoom, |
65 x, | 71 x, |
66 y, | 72 y, |
67 scrollbarWidth, | 73 scrollbarWidth, |
68 hasScrollbars, | 74 hasScrollbars, |
69 page) { | 75 page) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 e.preventDefault(); | 162 e.preventDefault(); |
157 } | 163 } |
158 return; | 164 return; |
159 } | 165 } |
160 }; | 166 }; |
161 } | 167 } |
162 | 168 |
163 load(); | 169 load(); |
164 | 170 |
165 })(); | 171 })(); |
OLD | NEW |