Check if viewer is embedded only once and cache the result

This commit is contained in:
Jonas 2013-07-20 16:33:40 +02:00
parent 12d9b6570b
commit d99b7753d6
2 changed files with 7 additions and 6 deletions

View File

@ -23,9 +23,9 @@ var PDFHistory = {
initialDestination: null, initialDestination: null,
initialize: function pdfHistoryInitialize(fingerprint) { initialize: function pdfHistoryInitialize(fingerprint) {
if (PDFJS.disableHistory || window.parent !== window) { if (PDFJS.disableHistory || PDFView.isViewerEmbedded) {
// The browsing history is only enabled when the viewer is standalone, // The browsing history is only enabled when the viewer is standalone,
// i.e. not when it is embedded in a page. // i.e. not when it is embedded in a web page.
return; return;
} }
this.initialized = true; this.initialized = true;

View File

@ -191,6 +191,7 @@ var PDFView = {
mouseScrollDelta: 0, mouseScrollDelta: 0,
lastScroll: 0, lastScroll: 0,
previousPageNumber: 1, previousPageNumber: 1,
isViewerEmbedded: (window.parent !== window),
// called once when the document is loaded // called once when the document is loaded
initialize: function pdfViewInitialize() { initialize: function pdfViewInitialize() {
@ -947,11 +948,11 @@ var PDFView = {
self.setInitialView(storedHash, scale); self.setInitialView(storedHash, scale);
// Make all navigation keys work on document load, // Make all navigation keys work on document load,
// unless the viewer is embedded in another page. // unless the viewer is embedded in a web page.
if (window.parent === window) { if (!self.isViewerEmbedded) {
PDFView.container.focus(); self.container.focus();
//#if (FIREFOX || MOZCENTRAL) //#if (FIREFOX || MOZCENTRAL)
// PDFView.container.blur(); // self.container.blur();
//#endif //#endif
} }
}); });