OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Creates a new Navigator for navigating to links inside or outside the PDF. | 8 * Creates a new Navigator for navigating to links inside or outside the PDF. |
9 * @param {string} originalUrl The original page URL. | 9 * @param {string} originalUrl The original page URL. |
10 * @param {Object} viewport The viewport info of the page. | 10 * @param {Object} viewport The viewport info of the page. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 } | 64 } |
65 // Make sure inputURL is not only a scheme. | 65 // Make sure inputURL is not only a scheme. |
66 if (url == 'http://' || | 66 if (url == 'http://' || |
67 url == 'https://' || | 67 url == 'https://' || |
68 url == 'ftp://' || | 68 url == 'ftp://' || |
69 url == 'file://' || | 69 url == 'file://' || |
70 url == 'mailto:') { | 70 url == 'mailto:') { |
71 return; | 71 return; |
72 } | 72 } |
73 | 73 |
74 if (newTab) { | 74 if (newTab) |
75 this.navigateInNewTabCallback_(url); | 75 this.navigateInNewTabCallback_(url); |
76 } else { | 76 else |
77 var pageNumber = | 77 this.onViewportReceived_(url); |
raymes
2015/02/16 22:44:04
This isn't what I meant. Please keep this the same
Deepak
2015/02/17 07:12:12
Done.
| |
78 this.paramsParser_.getViewportFromUrlParams(url).page; | 78 }, |
79 if (pageNumber != undefined) | 79 |
80 this.viewport_.goToPage(pageNumber); | 80 /** |
81 else | 81 * @private |
82 this.navigateInCurrentTabCallback_(url); | 82 * Function to decide weather to scroll the page to corresponding named |
83 } | 83 * destination or open the url in the current tab. |
84 * param {string} url The new url for name destination or opening it in | |
85 * current tab. | |
86 */ | |
87 onViewportReceived_: function(url) { | |
88 this.paramsParser_.getViewportFromUrlParams( | |
89 url, function(viewportPosition) { | |
90 var pageNumber = viewportPosition.page; | |
91 if (pageNumber != undefined) | |
92 this.viewport_.goToPage(pageNumber); | |
93 else | |
94 this.navigateInCurrentTabCallback_(url); | |
95 }.bind(this)); | |
84 } | 96 } |
85 }; | 97 }; |
OLD | NEW |