app/assets/javascripts/pdfjs_viewer/pdfjs/compatibility.js in pdfjs_viewer-rails-0.0.6 vs app/assets/javascripts/pdfjs_viewer/pdfjs/compatibility.js in pdfjs_viewer-rails-0.0.7

- old
+ new

@@ -1,7 +1,5 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* Copyright 2012 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -445,24 +443,14 @@ } })(); // Checks if navigator.language is supported (function checkNavigatorLanguage() { - if ('language' in navigator && - /^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) { + if ('language' in navigator) { return; } - function formatLocale(locale) { - var split = locale.split(/[-_]/); - split[0] = split[0].toLowerCase(); - if (split.length > 1) { - split[1] = split[1].toUpperCase(); - } - return split.join('-'); - } - var language = navigator.language || navigator.userLanguage || 'en-US'; - PDFJS.locale = formatLocale(language); + PDFJS.locale = navigator.userLanguage || 'en-US'; })(); (function checkRangeRequests() { // Safari has issues with cached range requests see: // https://github.com/mozilla/pdf.js/issues/3260 @@ -477,11 +465,14 @@ // since Firefox/Fennec works as expected. // Support: Android<3.0 var regex = /Android\s[0-2][^\d]/; var isOldAndroid = regex.test(navigator.userAgent); - if (isSafari || isOldAndroid) { + // Range requests are broken in Chrome 39 and 40, https://crbug.com/442318 + var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(navigator.userAgent); + + if (isSafari || isOldAndroid || isChromeWithRangeBug) { PDFJS.disableRange = true; PDFJS.disableStream = true; } })(); @@ -527,20 +518,22 @@ polyfill = versionMatch && parseInt(versionMatch[1]) < 6; } if (polyfill) { var contextPrototype = window.CanvasRenderingContext2D.prototype; - contextPrototype._createImageData = contextPrototype.createImageData; + var createImageData = contextPrototype.createImageData; contextPrototype.createImageData = function(w, h) { - var imageData = this._createImageData(w, h); + var imageData = createImageData.call(this, w, h); imageData.data.set = function(arr) { for (var i = 0, ii = this.length; i < ii; i++) { this[i] = arr[i]; } }; return imageData; }; + // this closure will be kept referenced, so clear its vars + contextPrototype = null; } } })(); // Support: IE<10, Android<4.0, iOS @@ -569,6 +562,32 @@ var isAndroid = /Android/g.test(navigator.userAgent); if (isIOS || isAndroid) { // 5MP PDFJS.maxCanvasPixels = 5242880; } +})(); + +// Disable fullscreen support for certain problematic configurations. +// Support: IE11+ (when embedded). +(function checkFullscreenSupport() { + var isEmbeddedIE = (navigator.userAgent.indexOf('Trident') >= 0 && + window.parent !== window); + if (isEmbeddedIE) { + PDFJS.disableFullscreen = true; + } +})(); + +// Provides document.currentScript support +// Support: IE, Chrome<29. +(function checkCurrentScript() { + if ('currentScript' in document) { + return; + } + Object.defineProperty(document, 'currentScript', { + get: function () { + var scripts = document.getElementsByTagName('script'); + return scripts[scripts.length - 1]; + }, + enumerable: true, + configurable: true + }); })();