Browse Source

Merge pull request #7172 from yurydelendik/umd-web

Introduces UMD headers to the web/ folder.
Yury Delendik 9 years ago
parent
commit
6282ec24d1
  1. 9
      external/builder/builder.js
  2. 7
      external/umdutils/verifier.js
  3. 162
      make.js
  4. 2
      src/display/api.js
  5. 9
      test/unit/jasmine-boot.js
  6. 2
      test/unit/unit_test.html
  7. 21
      web/annotation_layer_builder.js
  8. 125
      web/app.js
  9. 29
      web/chromecom.js
  10. 11
      web/debugger.js
  11. 19
      web/download_manager.js
  12. 23
      web/firefoxcom.js
  13. 14
      web/grab_to_pan.js
  14. 25
      web/hand_tool.js
  15. 16
      web/mozPrintCallback_polyfill.js
  16. 13
      web/overlay_manager.js
  17. 21
      web/password_prompt.js
  18. 15
      web/pdf_attachment_viewer.js
  19. 20
      web/pdf_document_properties.js
  20. 20
      web/pdf_find_bar.js
  21. 20
      web/pdf_find_controller.js
  22. 15
      web/pdf_history.js
  23. 67
      web/pdf_link_service.js
  24. 15
      web/pdf_outline_viewer.js
  25. 35
      web/pdf_page_view.js
  26. 13
      web/pdf_presentation_mode.js
  27. 14
      web/pdf_rendering_queue.js
  28. 18
      web/pdf_sidebar.js
  29. 21
      web/pdf_thumbnail_view.js
  30. 25
      web/pdf_thumbnail_viewer.js
  31. 68
      web/pdf_viewer.component.js
  32. 99
      web/pdf_viewer.js
  33. 32
      web/pdfjs.js
  34. 17
      web/preferences.js
  35. 26
      web/secondary_toolbar.js
  36. 16
      web/text_layer_builder.js
  37. 36
      web/ui_utils.js
  38. 13
      web/view_history.js
  39. 27
      web/viewer.html
  40. 33
      web/viewer.js

9
external/builder/builder.js vendored

@ -66,7 +66,14 @@ function preprocess(inFilename, outFilename, defines) {
var realPath = fs.realpathSync(inFilename); var realPath = fs.realpathSync(inFilename);
var dir = path.dirname(realPath); var dir = path.dirname(realPath);
try { try {
preprocess(path.join(dir, file), writeLine, defines); var fullpath;
if (file.indexOf('$ROOT/') === 0) {
fullpath = path.join(__dirname, '../..',
file.substring('$ROOT/'.length));
} else {
fullpath = path.join(dir, file);
}
preprocess(fullpath, writeLine, defines);
} catch (e) { } catch (e) {
if (e.code === 'ENOENT') { if (e.code === 'ENOENT') {
throw new Error('Failed to include "' + file + '" at ' + loc()); throw new Error('Failed to include "' + file + '" at ' + loc());

7
external/umdutils/verifier.js vendored

@ -245,7 +245,8 @@ function validateFile(path, name, context) {
if (name !== umd.amdId) { if (name !== umd.amdId) {
error('AMD name does not match module name'); error('AMD name does not match module name');
} }
if (name.replace(/[_\/]/g, '') !== umd.jsRootName.toLowerCase()) { if (name.replace(/[_\-\/]/g, '').toLowerCase() !==
umd.jsRootName.toLowerCase()) {
error('root name does not look like module name'); error('root name does not look like module name');
} }
@ -272,7 +273,7 @@ function validateFile(path, name, context) {
return; return;
} }
i = i.substring('root.'.length); i = i.substring('root.'.length);
var j = umd.imports[index]; var j = umd.imports[index].replace(/(_|Lib)$/, '');
var offset = i.toLowerCase().lastIndexOf(j.toLowerCase()); var offset = i.toLowerCase().lastIndexOf(j.toLowerCase());
if (offset + j.length !== i.length) { if (offset + j.length !== i.length) {
error('JS import name does not look like corresponding body import ' + error('JS import name does not look like corresponding body import ' +
@ -281,7 +282,7 @@ function validateFile(path, name, context) {
j = umd.amdImports[index]; j = umd.amdImports[index];
if (j) { if (j) {
if (j.replace(/[_\/]/g, '') !== i.toLowerCase()) { if (j.replace(/[_\-\/]/g, '').toLowerCase() !== i.toLowerCase()) {
error('JS import name does not look like corresponding AMD import ' + error('JS import name does not look like corresponding AMD import ' +
'name: ' + i + ' vs ' + j); 'name: ' + i + ' vs ' + j);
} }

162
make.js

@ -36,6 +36,7 @@ var config = JSON.parse(fs.readFileSync(CONFIG_FILE));
// Defined by buildnumber target. // Defined by buildnumber target.
var BUILD_NUMBER, var BUILD_NUMBER,
BUILD_COMMIT,
VERSION; VERSION;
var ROOT_DIR = __dirname + '/', // absolute path to project's root var ROOT_DIR = __dirname + '/', // absolute path to project's root
@ -100,8 +101,7 @@ var COMMON_WEB_FILES =
['web/images', ['web/images',
'web/debugger.js'], 'web/debugger.js'],
COMMON_WEB_FILES_PREPROCESS = COMMON_WEB_FILES_PREPROCESS =
['web/viewer.js', ['web/viewer.html'],
'web/viewer.html'],
COMMON_FIREFOX_FILES_PREPROCESS = COMMON_FIREFOX_FILES_PREPROCESS =
[FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm', [FIREFOX_CONTENT_DIR + 'PdfStreamConverter.jsm',
FIREFOX_CONTENT_DIR + 'PdfjsContentUtils.jsm', FIREFOX_CONTENT_DIR + 'PdfjsContentUtils.jsm',
@ -127,6 +127,13 @@ target.generic = function() {
var defines = builder.merge(DEFINES, {GENERIC: true}); var defines = builder.merge(DEFINES, {GENERIC: true});
var TMP_VIEWER = GENERIC_DIR + '/web/viewer.js.tmp';
cd('web/');
var viewerBundleFiles = ['app.js'];
bundle('viewer.js', ROOT_DIR + TMP_VIEWER, viewerBundleFiles,
'pdfjs-dist/web/viewer', defines, true);
cd(ROOT_DIR);
var setup = { var setup = {
defines: defines, defines: defines,
copy: [ copy: [
@ -140,6 +147,7 @@ target.generic = function() {
], ],
preprocess: [ preprocess: [
[BUILD_TARGETS, GENERIC_DIR + BUILD_DIR], [BUILD_TARGETS, GENERIC_DIR + BUILD_DIR],
[TMP_VIEWER, GENERIC_DIR + '/web/viewer.js'],
[COMMON_WEB_FILES_PREPROCESS, GENERIC_DIR + '/web'] [COMMON_WEB_FILES_PREPROCESS, GENERIC_DIR + '/web']
], ],
preprocessCSS: [ preprocessCSS: [
@ -152,6 +160,7 @@ target.generic = function() {
cleanupJSSource(GENERIC_DIR + '/build/pdf.js'); cleanupJSSource(GENERIC_DIR + '/build/pdf.js');
cleanupJSSource(GENERIC_DIR + '/web/viewer.js'); cleanupJSSource(GENERIC_DIR + '/web/viewer.js');
cleanupCSSSource(GENERIC_DIR + '/web/viewer.css'); cleanupCSSSource(GENERIC_DIR + '/web/viewer.css');
rm(TMP_VIEWER);
}; };
target.components = function() { target.components = function() {
@ -163,7 +172,18 @@ target.components = function() {
mkdir('-p', COMPONENTS_DIR); mkdir('-p', COMPONENTS_DIR);
mkdir('-p', COMPONENTS_DIR + 'images'); mkdir('-p', COMPONENTS_DIR + 'images');
var defines = builder.merge(DEFINES, {COMPONENTS: true}); var defines = builder.merge(DEFINES, {COMPONENTS: true, GENERIC: true});
var TMP_PDF_VIEWER = COMPONENTS_DIR + 'pdf_viewer.js.tmp';
cd('web/');
var bundleFiles = [
'pdf_viewer.js',
'pdf_history.js',
'download_manager.js'
];
bundle('pdf_viewer.component.js', ROOT_DIR + TMP_PDF_VIEWER, bundleFiles,
'pdfjs-dist/web/pdf_viewer', defines, true);
cd(ROOT_DIR);
var COMPONENTS_IMAGES = [ var COMPONENTS_IMAGES = [
'web/images/annotation-*.svg', 'web/images/annotation-*.svg',
@ -179,7 +199,7 @@ target.components = function() {
['web/compatibility.js', COMPONENTS_DIR], ['web/compatibility.js', COMPONENTS_DIR],
], ],
preprocess: [ preprocess: [
['web/pdf_viewer.component.js', COMPONENTS_DIR + 'pdf_viewer.js'], [TMP_PDF_VIEWER, COMPONENTS_DIR + 'pdf_viewer.js'],
], ],
preprocessCSS: [ preprocessCSS: [
['components', 'web/pdf_viewer.css', COMPONENTS_DIR + 'pdf_viewer.css'], ['components', 'web/pdf_viewer.css', COMPONENTS_DIR + 'pdf_viewer.css'],
@ -189,6 +209,7 @@ target.components = function() {
cleanupJSSource(COMPONENTS_DIR + 'pdf_viewer.js'); cleanupJSSource(COMPONENTS_DIR + 'pdf_viewer.js');
cleanupCSSSource(COMPONENTS_DIR + 'pdf_viewer.css'); cleanupCSSSource(COMPONENTS_DIR + 'pdf_viewer.css');
rm(TMP_PDF_VIEWER);
}; };
target.jsdoc = function() { target.jsdoc = function() {
@ -479,27 +500,20 @@ target.cmaps = function () {
compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true); compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
}; };
// function bundle(filename, outfilename, initFiles, amdName, defines,
// make bundle isMainFile) {
// Bundles all source files into one wrapper 'pdf.js' file, in the given order. // Reading UMD headers and building loading orders of modules. The
// // readDependencies returns AMD module names: removing 'pdfjs' prefix and
target.bundle = function(args) { // adding '.js' extensions to the name.
args = args || {}; var umd = require('./external/umdutils/verifier.js');
var defines = args.defines || DEFINES; var files = umd.readDependencies(initFiles).loadOrder.map(
function (name) { return name.replace(/^[\w\-]+\//, '') + '.js'; });
target.buildnumber();
cd(ROOT_DIR); crlfchecker.checkIfCrlfIsPresent(files);
echo();
echo('### Bundling files into ' + BUILD_TARGET);
function bundle(filename, outfilename, files, distname, isMainFile) {
var bundleContent = cat(files), var bundleContent = cat(files),
bundleVersion = VERSION, bundleVersion = VERSION,
bundleBuild = exec('git log --format="%h" -n 1', bundleBuild = BUILD_COMMIT;
{silent: true}).output.replace('\n', '');
crlfchecker.checkIfCrlfIsPresent(files);
// Prepend a newline because stripCommentHeaders only strips comments that // Prepend a newline because stripCommentHeaders only strips comments that
// follow a line feed. The file where bundleContent is inserted already // follow a line feed. The file where bundleContent is inserted already
@ -509,70 +523,76 @@ target.bundle = function(args) {
// Removes AMD and CommonJS branches from UMD headers. // Removes AMD and CommonJS branches from UMD headers.
bundleContent = stripUMDHeaders(bundleContent); bundleContent = stripUMDHeaders(bundleContent);
var amdName = 'pdfjs-dist/build/' + distname.replace(/\.js$/, '');
var jsName = amdName.replace(/[\-_\.\/]\w/g, function (all) { var jsName = amdName.replace(/[\-_\.\/]\w/g, function (all) {
return all[1].toUpperCase(); return all[1].toUpperCase();
}); });
// This just preprocesses the empty pdf.js file, we don't actually want to // This just preprocesses the empty pdf.js file, we don't actually want to
// preprocess everything yet since other build targets use this file. // preprocess everything yet since other build targets use this file.
builder.preprocess(filename, outfilename, builder.merge(defines, builder.preprocess(filename, outfilename,
{BUNDLE: bundleContent, builder.merge(defines, {
BUNDLE: bundleContent,
BUNDLE_VERSION: bundleVersion, BUNDLE_VERSION: bundleVersion,
BUNDLE_BUILD: bundleBuild, BUNDLE_BUILD: bundleBuild,
BUNDLE_AMD_NAME: amdName, BUNDLE_AMD_NAME: amdName,
BUNDLE_JS_NAME: jsName, BUNDLE_JS_NAME: jsName,
MAIN_FILE: isMainFile})); MAIN_FILE: isMainFile
}));
} }
//
// make bundle
// Bundles all source files into one wrapper 'pdf.js' file, in the given order.
//
target.bundle = function(args) {
args = args || {};
var defines = args.defines || DEFINES;
target.buildnumber();
cd(ROOT_DIR);
echo();
echo('### Bundling files into ' + BUILD_TARGET);
if (!test('-d', BUILD_DIR)) { if (!test('-d', BUILD_DIR)) {
mkdir(BUILD_DIR); mkdir(BUILD_DIR);
} }
var umd = require('./external/umdutils/verifier.js'); var mainFiles = [
var MAIN_SRC_FILES = [ 'display/global.js'
SRC_DIR + 'display/global.js'
]; ];
var WORKER_SRC_FILES = [ var workerFiles = [
SRC_DIR + 'core/worker.js' 'core/worker.js'
]; ];
var mainFileName = 'pdf.js'; var mainAMDName = 'pdfjs-dist/build/pdf';
var workerFileName = 'pdf.worker.js'; var workerAMDName = 'pdfjs-dist/build/pdf.worker';
// Extension does not need network.js file. // Extension does not need network.js file.
if (!defines.FIREFOX && !defines.MOZCENTRAL) { if (!defines.FIREFOX && !defines.MOZCENTRAL) {
WORKER_SRC_FILES.push(SRC_DIR + 'core/network.js'); workerFiles.push('core/network.js');
} }
if (defines.SINGLE_FILE) { if (defines.SINGLE_FILE) {
// In singlefile mode, all of the src files will be bundled into // In singlefile mode, all of the src files will be bundled into
// the main pdf.js output. // the main pdf.js output.
MAIN_SRC_FILES = MAIN_SRC_FILES.concat(WORKER_SRC_FILES); mainFiles = mainFiles.concat(workerFiles);
WORKER_SRC_FILES = null; // no need for worker file workerFiles = null; // no need for worker file
mainFileName = 'pdf.combined.js'; mainAMDName = 'pdfjs-dist/build/pdf.combined';
workerFileName = null; workerAMDName = null;
} }
// Reading UMD headers and building loading orders of modules. The
// readDependencies returns AMD module names: removing 'pdfjs' prefix and
// adding '.js' extensions to the name.
var mainFiles = umd.readDependencies(MAIN_SRC_FILES).loadOrder.map(
function (name) { return name.replace('pdfjs/', '') + '.js'; });
var workerFiles = WORKER_SRC_FILES &&
umd.readDependencies(WORKER_SRC_FILES).loadOrder.map(
function (name) { return name.replace('pdfjs/', '') + '.js'; });
cd(SRC_DIR); cd(SRC_DIR);
bundle('pdf.js', ROOT_DIR + BUILD_TARGET, mainFiles, mainFileName, true); bundle('pdf.js', ROOT_DIR + BUILD_TARGET, mainFiles, mainAMDName, defines,
true);
if (workerFiles) { if (workerFiles) {
var srcCopy = ROOT_DIR + BUILD_DIR + 'pdf.worker.js.temp'; var srcCopy = ROOT_DIR + BUILD_DIR + 'pdf.worker.js.temp';
cp('pdf.js', srcCopy); cp('pdf.js', srcCopy);
bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, workerFiles, bundle(srcCopy, ROOT_DIR + BUILD_WORKER_TARGET, workerFiles, workerAMDName,
workerFileName, false); defines, false);
rm(srcCopy); rm(srcCopy);
} }
}; };
@ -676,6 +696,13 @@ target.minified = function() {
var defines = builder.merge(DEFINES, {GENERIC: true, MINIFIED: true}); var defines = builder.merge(DEFINES, {GENERIC: true, MINIFIED: true});
var TMP_VIEWER = MINIFIED_DIR + '/web/viewer.js.tmp';
cd('web/');
var viewerBundleFiles = ['app.js'];
bundle('viewer.js', ROOT_DIR + TMP_VIEWER, viewerBundleFiles,
'pdfjs-dist/web/viewer', defines, true);
cd(ROOT_DIR);
var setup = { var setup = {
defines: defines, defines: defines,
copy: [ copy: [
@ -686,6 +713,7 @@ target.minified = function() {
], ],
preprocess: [ preprocess: [
[BUILD_TARGETS, MINIFIED_DIR + BUILD_DIR], [BUILD_TARGETS, MINIFIED_DIR + BUILD_DIR],
[TMP_VIEWER, MINIFIED_DIR + '/web/viewer.js'],
[COMMON_WEB_FILES_PREPROCESS, MINIFIED_DIR + '/web'] [COMMON_WEB_FILES_PREPROCESS, MINIFIED_DIR + '/web']
], ],
preprocessCSS: [ preprocessCSS: [
@ -696,6 +724,7 @@ target.minified = function() {
builder.build(setup); builder.build(setup);
cleanupCSSSource(MINIFIED_DIR + '/web/viewer.css'); cleanupCSSSource(MINIFIED_DIR + '/web/viewer.css');
rm(TMP_VIEWER);
var viewerFiles = [ var viewerFiles = [
'web/compatibility.js', 'web/compatibility.js',
@ -762,6 +791,9 @@ target.buildnumber = function() {
echo('Extension build number: ' + BUILD_NUMBER); echo('Extension build number: ' + BUILD_NUMBER);
VERSION = config.versionPrefix + BUILD_NUMBER; VERSION = config.versionPrefix + BUILD_NUMBER;
BUILD_COMMIT = exec('git log --format="%h" -n 1', {silent: true}).
output.replace('\n', '');
}; };
// //
@ -819,6 +851,14 @@ target.firefox = function() {
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + FIREFOX_BUILD_DIR); cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + FIREFOX_BUILD_DIR);
cd(ROOT_DIR); cd(ROOT_DIR);
var TMP_VIEWER = FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.js.tmp';
cd('web/');
var viewerBundleFiles = ['app.js', 'firefoxcom.js'];
bundle('viewer.js', ROOT_DIR + TMP_VIEWER, viewerBundleFiles,
'pdfjs-dist/web/viewer', defines, true);
cd(ROOT_DIR);
var setup = { var setup = {
defines: defines, defines: defines,
copy: [ copy: [
@ -829,6 +869,7 @@ target.firefox = function() {
FIREFOX_BUILD_CONTENT_DIR + '/web'] FIREFOX_BUILD_CONTENT_DIR + '/web']
], ],
preprocess: [ preprocess: [
[TMP_VIEWER, FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.js'],
[COMMON_WEB_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR + '/web'], [COMMON_WEB_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR + '/web'],
[BUILD_TARGETS, FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR], [BUILD_TARGETS, FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR],
[COMMON_FIREFOX_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR], [COMMON_FIREFOX_FILES_PREPROCESS, FIREFOX_BUILD_CONTENT_DIR],
@ -846,6 +887,7 @@ target.firefox = function() {
cleanupJSSource(FIREFOX_BUILD_DIR + 'bootstrap.js'); cleanupJSSource(FIREFOX_BUILD_DIR + 'bootstrap.js');
cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm'); cleanupJSSource(FIREFOX_BUILD_CONTENT_DIR + 'PdfjsChromeUtils.jsm');
cleanupCSSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.css'); cleanupCSSSource(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer.css');
rm(TMP_VIEWER);
// Remove '.DS_Store' and other hidden files // Remove '.DS_Store' and other hidden files
find(FIREFOX_BUILD_DIR).forEach(function(file) { find(FIREFOX_BUILD_DIR).forEach(function(file) {
@ -946,6 +988,13 @@ target.mozcentral = function() {
ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome.manifest'); ROOT_DIR + MOZCENTRAL_EXTENSION_DIR + '/chrome.manifest');
cd(ROOT_DIR); cd(ROOT_DIR);
var TMP_VIEWER = MOZCENTRAL_CONTENT_DIR + '/web/viewer.js.tmp';
cd('web/');
var viewerBundleFiles = ['app.js', 'firefoxcom.js'];
bundle('viewer.js', ROOT_DIR + TMP_VIEWER, viewerBundleFiles,
'pdfjs-dist/web/viewer', defines, true);
cd(ROOT_DIR);
var setup = { var setup = {
defines: defines, defines: defines,
copy: [ copy: [
@ -954,6 +1003,7 @@ target.mozcentral = function() {
['extensions/firefox/tools/l10n.js', MOZCENTRAL_CONTENT_DIR + '/web'] ['extensions/firefox/tools/l10n.js', MOZCENTRAL_CONTENT_DIR + '/web']
], ],
preprocess: [ preprocess: [
[TMP_VIEWER, MOZCENTRAL_CONTENT_DIR + '/web/viewer.js'],
[COMMON_WEB_FILES_PREPROCESS, MOZCENTRAL_CONTENT_DIR + '/web'], [COMMON_WEB_FILES_PREPROCESS, MOZCENTRAL_CONTENT_DIR + '/web'],
[FIREFOX_CONTENT_DIR + 'pdfjschildbootstrap.js', MOZCENTRAL_CONTENT_DIR], [FIREFOX_CONTENT_DIR + 'pdfjschildbootstrap.js', MOZCENTRAL_CONTENT_DIR],
[BUILD_TARGETS, MOZCENTRAL_CONTENT_DIR + BUILD_DIR], [BUILD_TARGETS, MOZCENTRAL_CONTENT_DIR + BUILD_DIR],
@ -973,6 +1023,7 @@ target.mozcentral = function() {
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfJs.jsm'); cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfJs.jsm');
cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfjsChromeUtils.jsm'); cleanupJSSource(MOZCENTRAL_CONTENT_DIR + '/PdfjsChromeUtils.jsm');
cleanupCSSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.css'); cleanupCSSSource(MOZCENTRAL_CONTENT_DIR + '/web/viewer.css');
rm(TMP_VIEWER);
// Remove '.DS_Store' and other hidden files // Remove '.DS_Store' and other hidden files
find(MOZCENTRAL_DIR).forEach(function(file) { find(MOZCENTRAL_DIR).forEach(function(file) {
@ -1078,6 +1129,13 @@ target.chromium = function() {
mkdir('-p', CHROME_BUILD_CONTENT_DIR + BUILD_DIR); mkdir('-p', CHROME_BUILD_CONTENT_DIR + BUILD_DIR);
mkdir('-p', CHROME_BUILD_CONTENT_DIR + '/web'); mkdir('-p', CHROME_BUILD_CONTENT_DIR + '/web');
var TMP_VIEWER = CHROME_BUILD_CONTENT_DIR + '/web/viewer.js.tmp';
cd('web/');
var viewerBundleFiles = ['app.js', 'chromecom.js'];
bundle('viewer.js', ROOT_DIR + TMP_VIEWER, viewerBundleFiles,
'pdfjs-dist/web/viewer', defines, true);
cd(ROOT_DIR);
var setup = { var setup = {
defines: defines, defines: defines,
copy: [ copy: [
@ -1096,6 +1154,7 @@ target.chromium = function() {
], ],
preprocess: [ preprocess: [
[BUILD_TARGETS, CHROME_BUILD_CONTENT_DIR + BUILD_DIR], [BUILD_TARGETS, CHROME_BUILD_CONTENT_DIR + BUILD_DIR],
[TMP_VIEWER, CHROME_BUILD_CONTENT_DIR + '/web/viewer.js'],
[COMMON_WEB_FILES_PREPROCESS, CHROME_BUILD_CONTENT_DIR + '/web'] [COMMON_WEB_FILES_PREPROCESS, CHROME_BUILD_CONTENT_DIR + '/web']
], ],
preprocessCSS: [ preprocessCSS: [
@ -1107,6 +1166,7 @@ target.chromium = function() {
cleanupJSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.js'); cleanupJSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.js');
cleanupCSSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.css'); cleanupCSSSource(CHROME_BUILD_CONTENT_DIR + '/web/viewer.css');
rm(TMP_VIEWER);
// Update the build version number // Update the build version number
sed('-i', /PDFJSSCRIPT_VERSION/, VERSION, sed('-i', /PDFJSSCRIPT_VERSION/, VERSION,
@ -1508,7 +1568,7 @@ target.lint = function() {
echo(); echo();
echo('### Checking UMD dependencies'); echo('### Checking UMD dependencies');
var umd = require('./external/umdutils/verifier.js'); var umd = require('./external/umdutils/verifier.js');
if (!umd.validateFiles({'pdfjs': './src'})) { if (!umd.validateFiles({'pdfjs': './src', 'pdfjs-web': './web'})) {
exit(1); exit(1);
} }

2
src/display/api.js

@ -71,7 +71,7 @@ var isPostMessageTransfersDisabled = false;
//#if PRODUCTION && !SINGLE_FILE //#if PRODUCTION && !SINGLE_FILE
//#if GENERIC //#if GENERIC
//#include ../src/frameworks.js //#include $ROOT/src/frameworks.js
//#else //#else
//var fakeWorkerFilesLoader = null; //var fakeWorkerFilesLoader = null;
//#endif //#endif

9
test/unit/jasmine-boot.js

@ -43,19 +43,19 @@
var pdfjsLibs; var pdfjsLibs;
function initializePDFJS(callback) { function initializePDFJS(callback) {
require.config({paths: {'pdfjs': '../../src'}}); require.config({paths: {'pdfjs': '../../src', 'pdfjs-web': '../../web'}});
require(['pdfjs/shared/util', 'pdfjs/display/global', 'pdfjs/core/primitives', require(['pdfjs/shared/util', 'pdfjs/display/global', 'pdfjs/core/primitives',
'pdfjs/core/annotation', 'pdfjs/core/crypto', 'pdfjs/core/stream', 'pdfjs/core/annotation', 'pdfjs/core/crypto', 'pdfjs/core/stream',
'pdfjs/core/fonts', 'pdfjs/core/ps_parser', 'pdfjs/core/function', 'pdfjs/core/fonts', 'pdfjs/core/ps_parser', 'pdfjs/core/function',
'pdfjs/core/parser', 'pdfjs/core/evaluator', 'pdfjs/core/cmap', 'pdfjs/core/parser', 'pdfjs/core/evaluator', 'pdfjs/core/cmap',
'pdfjs/core/worker', 'pdfjs/core/network', 'pdfjs/core/type1_parser', 'pdfjs/core/worker', 'pdfjs/core/network', 'pdfjs/core/type1_parser',
'pdfjs/core/cff_parser', 'pdfjs/display/api', 'pdfjs/display/metadata', 'pdfjs/core/cff_parser', 'pdfjs/display/api', 'pdfjs/display/metadata',
'pdfjs/display/dom_utils'], 'pdfjs/display/dom_utils', 'pdfjs-web/ui_utils'],
function (sharedUtil, displayGlobal, corePrimitives, coreAnnotation, function (sharedUtil, displayGlobal, corePrimitives, coreAnnotation,
coreCrypto, coreStream, coreFonts, corePsParser, coreFunction, coreCrypto, coreStream, coreFonts, corePsParser, coreFunction,
coreParser, coreEvaluator, coreCMap, coreWorker, coreNetwork, coreParser, coreEvaluator, coreCMap, coreWorker, coreNetwork,
coreType1Parser, coreCFFParser, displayAPI, displayMetadata, coreType1Parser, coreCFFParser, displayAPI, displayMetadata,
displayDOMUtils) { displayDOMUtils, webUIUtils) {
pdfjsLibs = { pdfjsLibs = {
sharedUtil: sharedUtil, sharedUtil: sharedUtil,
@ -76,7 +76,8 @@ function initializePDFJS(callback) {
coreCFFParser: coreCFFParser, coreCFFParser: coreCFFParser,
displayAPI: displayAPI, displayAPI: displayAPI,
displayMetadata: displayMetadata, displayMetadata: displayMetadata,
displayDOMUtils: displayDOMUtils displayDOMUtils: displayDOMUtils,
webUIUtils: webUIUtils
}; };
// Expose all loaded internal exported members to global scope. // Expose all loaded internal exported members to global scope.

2
test/unit/unit_test.html

@ -11,8 +11,6 @@
<script src="testreporter.js"></script> <script src="testreporter.js"></script>
<script src="jasmine-boot.js"></script> <script src="jasmine-boot.js"></script>
<script src="../../web/ui_utils.js"></script>
<!-- include spec files here... --> <!-- include spec files here... -->
<script src="primitives_spec.js"></script> <script src="primitives_spec.js"></script>
<script src="font_spec.js"></script> <script src="font_spec.js"></script>

21
web/annotation_layer_builder.js

@ -12,10 +12,26 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*globals pdfjsLib, mozL10n, SimpleLinkService */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/annotation_layer_builder', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/pdf_link_service',
'pdfjs-web/pdfjs'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'),
require('./pdf_link_service.js'), require('./pdfjs.js'));
} else {
factory((root.pdfjsWebAnnotationLayerBuilder = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFLinkService, root.pdfjsWebPDFJS);
}
}(this, function (exports, uiUtils, pdfLinkService, pdfjsLib) {
var mozL10n = uiUtils.mozL10n;
var SimpleLinkService = pdfLinkService.SimpleLinkService;
/** /**
* @typedef {Object} AnnotationLayerBuilderOptions * @typedef {Object} AnnotationLayerBuilderOptions
* @property {HTMLDivElement} pageDiv * @property {HTMLDivElement} pageDiv
@ -119,3 +135,6 @@ DefaultAnnotationLayerFactory.prototype = {
}); });
} }
}; };
exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
}));

125
web/app.js

@ -12,18 +12,93 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals pdfjsLib, PDFBug, FirefoxCom, Stats, ProgressBar, DownloadManager, /* globals DEFAULT_URL, PDFBug, Stats */
getPDFFileNameFromURL, PDFHistory, Preferences, SidebarView,
ViewHistory, Stats, PDFThumbnailViewer, URL, noContextMenuHandler,
SecondaryToolbar, PasswordPrompt, PDFPresentationMode, PDFSidebar,
PDFDocumentProperties, HandTool, Promise, PDFLinkService,
PDFOutlineViewer, PDFAttachmentViewer, OverlayManager,
PDFFindController, PDFFindBar, PDFViewer, PDFRenderingQueue,
PresentationModeState, parseQueryString, RenderingStates,
UNKNOWN_SCALE, DEFAULT_SCALE_VALUE, DEFAULT_URL, mozL10n */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/app', ['exports', 'pdfjs-web/ui_utils',
'pdfjs-web/firefoxcom', 'pdfjs-web/download_manager',
'pdfjs-web/pdf_history', 'pdfjs-web/preferences', 'pdfjs-web/pdf_sidebar',
'pdfjs-web/view_history', 'pdfjs-web/pdf_thumbnail_viewer',
'pdfjs-web/secondary_toolbar', 'pdfjs-web/password_prompt',
'pdfjs-web/pdf_presentation_mode', 'pdfjs-web/pdf_document_properties',
'pdfjs-web/hand_tool', 'pdfjs-web/pdf_viewer',
'pdfjs-web/pdf_rendering_queue', 'pdfjs-web/pdf_link_service',
'pdfjs-web/pdf_outline_viewer', 'pdfjs-web/overlay_manager',
'pdfjs-web/pdf_attachment_viewer', 'pdfjs-web/pdf_find_controller',
'pdfjs-web/pdf_find_bar', 'pdfjs-web/mozPrintCallback_polyfill',
'pdfjs-web/pdfjs'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'), require('./firefoxcom.js'),
require('./download_manager.js'), require('./pdf_history.js'),
require('./preferences.js'), require('./pdf_sidebar.js'),
require('./view_history.js'), require('./pdf_thumbnail_viewer.js'),
require('./secondary_toolbar.js'), require('./password_prompt.js'),
require('./pdf_presentation_mode.js'),
require('./pdf_document_properties.js'), require('./hand_tool.js'),
require('./pdf_viewer.js'), require('./pdf_rendering_queue.js'),
require('./pdf_link_service.js'), require('./pdf_outline_viewer.js'),
require('./overlay_manager.js'), require('./pdf_attachment_viewer.js'),
require('./pdf_find_controller.js'), require('./pdf_find_bar.js'),
require('./mozPrintCallback_polyfill.js'), require('./pdfjs.js'));
} else {
factory((root.pdfjsWebApp = {}), root.pdfjsWebUIUtils,
root.pdfjsWebFirefoxCom, root.pdfjsWebDownloadManager,
root.pdfjsWebPDFHistory, root.pdfjsWebPreferences,
root.pdfjsWebPDFSidebar, root.pdfjsWebViewHistory,
root.pdfjsWebPDFThumbnailViewer, root.pdfjsWebSecondaryToolbar,
root.pdfjsWebPasswordPrompt, root.pdfjsWebPDFPresentationMode,
root.pdfjsWebPDFDocumentProperties, root.pdfjsWebHandTool,
root.pdfjsWebPDFViewer, root.pdfjsWebPDFRenderingQueue,
root.pdfjsWebPDFLinkService, root.pdfjsWebPDFOutlineViewer,
root.pdfjsWebOverlayManager, root.pdfjsWebPDFAttachmentViewer,
root.pdfjsWebPDFFindController, root.pdfjsWebPDFFindBar,
root.pdfjsWebMozPrintCallbackPolyfill, root.pdfjsWebPDFJS);
}
}(this, function (exports, uiUtilsLib, firefoxComLib, downloadManagerLib,
pdfHistoryLib, preferencesLib, pdfSidebarLib, viewHistoryLib,
pdfThumbnailViewerLib, secondaryToolbarLib, passwordPromptLib,
pdfPresentationModeLib, pdfDocumentPropertiesLib, handToolLib,
pdfViewerLib, pdfRenderingQueueLib, pdfLinkServiceLib,
pdfOutlineViewerLib, overlayManagerLib,
pdfAttachmentViewerLib, pdfFindControllerLib, pdfFindBarLib,
mozPrintCallbackPolyfillLib, pdfjsLib) {
var FirefoxCom = firefoxComLib.FirefoxCom;
var UNKNOWN_SCALE = uiUtilsLib.UNKNOWN_SCALE;
var DEFAULT_SCALE_VALUE = uiUtilsLib.DEFAULT_SCALE_VALUE;
var ProgressBar = uiUtilsLib.ProgressBar;
var getPDFFileNameFromURL = uiUtilsLib.getPDFFileNameFromURL;
var noContextMenuHandler = uiUtilsLib.noContextMenuHandler;
var mozL10n = uiUtilsLib.mozL10n;
var parseQueryString = uiUtilsLib.parseQueryString;
var DownloadManager = downloadManagerLib.DownloadManager ||
firefoxComLib.DownloadManager;
var PDFHistory = pdfHistoryLib.PDFHistory;
var Preferences = preferencesLib.Preferences;
var SidebarView = pdfSidebarLib.SidebarView;
var PDFSidebar = pdfSidebarLib.PDFSidebar;
var ViewHistory = viewHistoryLib.ViewHistory;
var PDFThumbnailViewer = pdfThumbnailViewerLib.PDFThumbnailViewer;
var SecondaryToolbar = secondaryToolbarLib.SecondaryToolbar;
var PasswordPrompt = passwordPromptLib.PasswordPrompt;
var PDFPresentationMode = pdfPresentationModeLib.PDFPresentationMode;
var PDFDocumentProperties = pdfDocumentPropertiesLib.PDFDocumentProperties;
var HandTool = handToolLib.HandTool;
var PresentationModeState = pdfViewerLib.PresentationModeState;
var PDFViewer = pdfViewerLib.PDFViewer;
var RenderingStates = pdfRenderingQueueLib.RenderingStates;
var PDFRenderingQueue = pdfRenderingQueueLib.PDFRenderingQueue;
var PDFLinkService = pdfLinkServiceLib.PDFLinkService;
var PDFOutlineViewer = pdfOutlineViewerLib.PDFOutlineViewer;
var OverlayManager = overlayManagerLib.OverlayManager;
var PDFAttachmentViewer = pdfAttachmentViewerLib.PDFAttachmentViewer;
var PDFFindController = pdfFindControllerLib.PDFFindController;
var PDFFindBar = pdfFindBarLib.PDFFindBar;
var DEFAULT_SCALE_DELTA = 1.1; var DEFAULT_SCALE_DELTA = 1.1;
var MIN_SCALE = 0.25; var MIN_SCALE = 0.25;
var MAX_SCALE = 10.0; var MAX_SCALE = 10.0;
@ -47,26 +122,6 @@ function configure(PDFJS) {
//#endif //#endif
} }
//#include ui_utils.js
//#include preferences.js
//#include platform_integration.js
//#include view_history.js
//#include pdf_find_bar.js
//#include pdf_find_controller.js
//#include pdf_link_service.js
//#include pdf_history.js
//#include secondary_toolbar.js
//#include pdf_presentation_mode.js
//#include hand_tool.js
//#include overlay_manager.js
//#include password_prompt.js
//#include pdf_document_properties.js
//#include pdf_viewer.js
//#include pdf_thumbnail_viewer.js
//#include pdf_sidebar.js
//#include pdf_outline_viewer.js
//#include pdf_attachment_viewer.js
var PDFViewerApplication = { var PDFViewerApplication = {
initialBookmark: document.location.hash.substring(1), initialBookmark: document.location.hash.substring(1),
initialDestination: null, initialDestination: null,
@ -1230,9 +1285,6 @@ var PDFViewerApplication = {
this.pdfPresentationMode.mouseScroll(delta); this.pdfPresentationMode.mouseScroll(delta);
} }
}; };
//#if GENERIC
window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias
//#endif
//#if GENERIC //#if GENERIC
var HOSTED_VIEWER_ORIGINS = ['null', var HOSTED_VIEWER_ORIGINS = ['null',
@ -1369,7 +1421,7 @@ function webViewerInitialized() {
var pdfBug = hashParams['pdfbug']; var pdfBug = hashParams['pdfbug'];
var enabled = pdfBug.split(','); var enabled = pdfBug.split(',');
PDFBug.enable(enabled); PDFBug.enable(enabled);
PDFBug.init(); PDFBug.init(pdfjsLib);
} }
} }
@ -2144,3 +2196,10 @@ window.addEventListener('afterprint', function afterPrint(evt) {
window.requestAnimationFrame(resolve); window.requestAnimationFrame(resolve);
}); });
})(); })();
exports.PDFViewerApplication = PDFViewerApplication;
// TODO remove circular reference of pdfjs-web/secondary_toolbar on app.
secondaryToolbarLib._setApp(exports);
}));

29
web/chromecom.js

@ -13,10 +13,28 @@
* limitations under the License. * limitations under the License.
*/ */
/* globals chrome, pdfjsLib, PDFViewerApplication, OverlayManager */ /* globals chrome */
'use strict'; 'use strict';
var ChromeCom = (function ChromeComClosure() { (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/chromecom', ['exports', 'pdfjs-web/app',
'pdfjs-web/overlay_manager', 'pdfjs-web/pdfjs'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./app.js'), require('./overlay_manager.js'),
require('./pdfjs.js'));
} else {
factory((root.pdfjsWebChromeCom = {}), root.pdfjsWebApp,
root.pdfjsWebOverlayManager, root.pdfjsWebPDFJS);
}
}(this, function (exports, app, overlayManager, pdfjsLib) {
//#if CHROME
//#if !CHROME
if (true) { return; } // TODO ensure nothing depends on this module.
//#endif
var PDFViewerApplication = app.PDFViewerApplication;
var OverlayManager = overlayManager.OverlayManager;
var ChromeCom = {}; var ChromeCom = {};
/** /**
* Creates an event that the extension is listening for and will * Creates an event that the extension is listening for and will
@ -205,7 +223,7 @@ var ChromeCom = (function ChromeComClosure() {
// because the shown string should match the UI at chrome://extensions. // because the shown string should match the UI at chrome://extensions.
// These strings are from chrome/app/resources/generated_resources_*.xtb. // These strings are from chrome/app/resources/generated_resources_*.xtb.
var i18nFileAccessLabel = var i18nFileAccessLabel =
//#include chrome-i18n-allow-access-to-file-urls.json //#include $ROOT/web/chrome-i18n-allow-access-to-file-urls.json
[chrome.i18n.getUILanguage && chrome.i18n.getUILanguage()]; [chrome.i18n.getUILanguage && chrome.i18n.getUILanguage()];
if (i18nFileAccessLabel) { if (i18nFileAccessLabel) {
@ -304,5 +322,6 @@ var ChromeCom = (function ChromeComClosure() {
} }
} }
return ChromeCom; exports.ChromeCom = ChromeCom;
})(); //#endif
}));

11
web/debugger.js

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals pdfjsLib */
'use strict'; 'use strict';
@ -65,7 +64,7 @@ var FontInspector = (function FontInspectorClosure() {
name: 'Font Inspector', name: 'Font Inspector',
panel: null, panel: null,
manager: null, manager: null,
init: function init() { init: function init(pdfjsLib) {
var panel = this.panel; var panel = this.panel;
panel.setAttribute('style', 'padding: 5px;'); panel.setAttribute('style', 'padding: 5px;');
var tmp = document.createElement('button'); var tmp = document.createElement('button');
@ -291,7 +290,7 @@ var Stepper = (function StepperClosure() {
this.operatorListIdx = 0; this.operatorListIdx = 0;
} }
Stepper.prototype = { Stepper.prototype = {
init: function init() { init: function init(pdfjsLib) {
var panel = this.panel; var panel = this.panel;
var content = c('div', 'c=continue, s=step'); var content = c('div', 'c=continue, s=step');
var table = c('table'); var table = c('table');
@ -458,7 +457,7 @@ var Stats = (function Stats() {
name: 'Stats', name: 'Stats',
panel: null, panel: null,
manager: null, manager: null,
init: function init() { init: function init(pdfjsLib) {
this.panel.setAttribute('style', 'padding: 5px;'); this.panel.setAttribute('style', 'padding: 5px;');
pdfjsLib.PDFJS.enableStats = true; pdfjsLib.PDFJS.enableStats = true;
}, },
@ -532,7 +531,7 @@ var PDFBug = (function PDFBugClosure() {
}); });
} }
}, },
init: function init() { init: function init(pdfjsLib) {
/* /*
* Basic Layout: * Basic Layout:
* PDFBug * PDFBug
@ -576,7 +575,7 @@ var PDFBug = (function PDFBugClosure() {
tool.panel = panel; tool.panel = panel;
tool.manager = this; tool.manager = this;
if (tool.enabled) { if (tool.enabled) {
tool.init(); tool.init(pdfjsLib);
} else { } else {
panel.textContent = tool.name + ' is disabled. To enable add ' + panel.textContent = tool.name + ' is disabled. To enable add ' +
' "' + tool.id + '" to the pdfBug parameter ' + ' "' + tool.id + '" to the pdfBug parameter ' +

19
web/download_manager.js

@ -12,12 +12,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals URL, pdfjsLib */
'use strict'; 'use strict';
var DownloadManager = (function DownloadManagerClosure() { (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/download_manager', ['exports', 'pdfjs-web/pdfjs'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./pdfjs.js'));
} else {
factory((root.pdfjsWebDownloadManager = {}), root.pdfjsWebPDFJS);
}
}(this, function (exports, pdfjsLib) {
//#if GENERIC || CHROME
function download(blobUrl, filename) { function download(blobUrl, filename) {
var a = document.createElement('a'); var a = document.createElement('a');
if (a.click) { if (a.click) {
@ -97,5 +105,6 @@ var DownloadManager = (function DownloadManagerClosure() {
} }
}; };
return DownloadManager; exports.DownloadManager = DownloadManager;
})(); //#endif
}));

23
web/firefoxcom.js

@ -12,10 +12,26 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals Preferences, pdfjsLib, Promise */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/firefoxcom', ['exports', 'pdfjs-web/preferences',
'pdfjs-web/pdfjs'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./preferences.js'), require('./pdfjs.js'));
} else {
factory((root.pdfjsWebFirefoxCom = {}), root.pdfjsWebPreferences,
root.pdfjsWebPDFJS);
}
}(this, function (exports, preferences, pdfjsLib) {
//#if FIREFOX || MOZCENTRAL
//#if !(FIREFOX || MOZCENTRAL)
if (true) { return; } // TODO ensure nothing depends on this module.
//#endif
var Preferences = preferences.Preferences;
var FirefoxCom = (function FirefoxComClosure() { var FirefoxCom = (function FirefoxComClosure() {
return { return {
/** /**
@ -132,3 +148,8 @@ Preferences._readFromStorage = function (prefObj) {
}); });
}); });
}; };
exports.DownloadManager = DownloadManager;
exports.FirefoxCom = FirefoxCom;
//#endif
}));

14
web/grab_to_pan.js

@ -16,7 +16,15 @@
'use strict'; 'use strict';
var GrabToPan = (function GrabToPanClosure() { (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/grab_to_pan', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebGrabToPan = {}));
}
}(this, function (exports) {
/** /**
* Construct a GrabToPan instance for a given HTML element. * Construct a GrabToPan instance for a given HTML element.
* @param options.element {Element} * @param options.element {Element}
@ -217,5 +225,5 @@ var GrabToPan = (function GrabToPanClosure() {
} }
} }
return GrabToPan; exports.GrabToPan = GrabToPan;
})(); }));

25
web/hand_tool.js

@ -12,11 +12,29 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals mozL10n, GrabToPan, Preferences, SecondaryToolbar */
'use strict'; 'use strict';
//#include grab_to_pan.js (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/hand_tool', ['exports', 'pdfjs-web/ui_utils',
'pdfjs-web/grab_to_pan', 'pdfjs-web/preferences',
'pdfjs-web/secondary_toolbar'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'), require('./grab_to_pan.js'),
require('./preferences.js'), require('./secondary_toolbar.js'));
} else {
factory((root.pdfjsWebHandTool = {}), root.pdfjsWebUIUtils,
root.pdfjsWebGrabToPan, root.pdfjsWebPreferences,
root.pdfjsWebSecondaryToolbar);
}
}(this, function (exports, uiUtils, grabToPan, preferences, secondaryToolbar) {
var mozL10n = uiUtils.mozL10n;
var GrabToPan = grabToPan.GrabToPan;
var Preferences = preferences.Preferences;
var SecondaryToolbar = secondaryToolbar.SecondaryToolbar;
var HandTool = { var HandTool = {
initialize: function handToolInitialize(options) { initialize: function handToolInitialize(options) {
var toggleHandTool = options.toggleHandTool; var toggleHandTool = options.toggleHandTool;
@ -82,3 +100,6 @@ var HandTool = {
} }
} }
}; };
exports.HandTool = HandTool;
}));

16
web/mozPrintCallback_polyfill.js

@ -15,10 +15,21 @@
/* globals HTMLCanvasElement */ /* globals HTMLCanvasElement */
'use strict'; 'use strict';
(function mozPrintCallbackPolyfillClosure() {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/mozPrintCallback_polyfill', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebMozPrintCallbackPolyfill = {}));
}
}(this, function (exports) {
//#if !(FIREFOX || MOZCENTRAL)
if ('mozPrintCallback' in document.createElement('canvas')) { if ('mozPrintCallback' in document.createElement('canvas')) {
return; return;
} }
// Cause positive result on feature-detection: // Cause positive result on feature-detection:
HTMLCanvasElement.prototype.mozPrintCallback = undefined; HTMLCanvasElement.prototype.mozPrintCallback = undefined;
@ -139,4 +150,5 @@
window.addEventListener('beforeprint', stopPropagationIfNeeded, false); window.addEventListener('beforeprint', stopPropagationIfNeeded, false);
window.addEventListener('afterprint', stopPropagationIfNeeded, false); window.addEventListener('afterprint', stopPropagationIfNeeded, false);
} }
})(); //#endif
}));

13
web/overlay_manager.js

@ -15,6 +15,16 @@
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/overlay_manager', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebOverlayManager = {}));
}
}(this, function (exports) {
var OverlayManager = { var OverlayManager = {
overlays: {}, overlays: {},
active: null, active: null,
@ -141,3 +151,6 @@ var OverlayManager = {
} }
} }
}; };
exports.OverlayManager = OverlayManager;
}));

21
web/password_prompt.js

@ -12,10 +12,26 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals pdfjsLib, mozL10n, OverlayManager */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/password_prompt', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/overlay_manager', 'pdfjs-web/pdfjs'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'), require('./overlay_manager.js'),
require('./pdfjs.js'));
} else {
factory((root.pdfjsWebPasswordPrompt = {}), root.pdfjsWebUIUtils,
root.pdfjsWebOverlayManager, root.pdfjsWebPDFJS);
}
}(this, function (exports, uiUtils, overlayManager, pdfjsLib) {
var mozL10n = uiUtils.mozL10n;
var OverlayManager = overlayManager.OverlayManager;
var PasswordPrompt = { var PasswordPrompt = {
overlayName: null, overlayName: null,
updatePassword: null, updatePassword: null,
@ -79,3 +95,6 @@ var PasswordPrompt = {
} }
} }
}; };
exports.PasswordPrompt = PasswordPrompt;
}));

15
web/pdf_attachment_viewer.js

@ -12,10 +12,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals pdfjsLib */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_attachment_viewer', ['exports', 'pdfjs-web/pdfjs'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./pdfjs.js'));
} else {
factory((root.pdfjsWebPDFAttachmentViewer = {}), root.pdfjsWebPDFJS);
}
}(this, function (exports, pdfjsLib) {
/** /**
* @typedef {Object} PDFAttachmentViewerOptions * @typedef {Object} PDFAttachmentViewerOptions
* @property {HTMLDivElement} container - The viewer element. * @property {HTMLDivElement} container - The viewer element.
@ -114,3 +124,6 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() {
return PDFAttachmentViewer; return PDFAttachmentViewer;
})(); })();
exports.PDFAttachmentViewer = PDFAttachmentViewer;
}));

20
web/pdf_document_properties.js

@ -12,10 +12,25 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals mozL10n, getPDFFileNameFromURL, OverlayManager */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_document_properties', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/overlay_manager'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'), require('./overlay_manager.js'));
} else {
factory((root.pdfjsWebPDFDocumentProperties = {}), root.pdfjsWebUIUtils,
root.pdfjsWebOverlayManager);
}
}(this, function (exports, uiUtils, overlayManager) {
var getPDFFileNameFromURL = uiUtils.getPDFFileNameFromURL;
var mozL10n = uiUtils.mozL10n;
var OverlayManager = overlayManager.OverlayManager;
/** /**
* @typedef {Object} PDFDocumentPropertiesOptions * @typedef {Object} PDFDocumentPropertiesOptions
* @property {string} overlayName - Name/identifier for the overlay. * @property {string} overlayName - Name/identifier for the overlay.
@ -222,3 +237,6 @@ var PDFDocumentProperties = (function PDFDocumentPropertiesClosure() {
return PDFDocumentProperties; return PDFDocumentProperties;
})(); })();
exports.PDFDocumentProperties = PDFDocumentProperties;
}));

20
web/pdf_find_bar.js

@ -12,10 +12,25 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals FindStates, mozL10n */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_find_bar', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/pdf_find_controller'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'),
require('./pdf_find_controller.js'));
} else {
factory((root.pdfjsWebPDFFindBar = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFFindController);
}
}(this, function (exports, uiUtils, pdfFindController) {
var mozL10n = uiUtils.mozL10n;
var FindStates = pdfFindController.FindStates;
/** /**
* Creates a "search bar" given a set of DOM elements that act as controls * Creates a "search bar" given a set of DOM elements that act as controls
* for searching or for setting search preferences in the UI. This object * for searching or for setting search preferences in the UI. This object
@ -188,3 +203,6 @@ var PDFFindBar = (function PDFFindBarClosure() {
}; };
return PDFFindBar; return PDFFindBar;
})(); })();
exports.PDFFindBar = PDFFindBar;
}));

20
web/pdf_find_controller.js

@ -12,10 +12,24 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals FirefoxCom, Promise, scrollIntoView */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_find_controller', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/firefoxcom'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'), require('./firefoxcom.js'));
} else {
factory((root.pdfjsWebPDFFindController = {}), root.pdfjsWebUIUtils,
root.pdfjsWebFirefoxCom);
}
}(this, function (exports, uiUtils, firefoxCom) {
var scrollIntoView = uiUtils.scrollIntoView;
var FirefoxCom = firefoxCom.FirefoxCom;
var FindStates = { var FindStates = {
FIND_FOUND: 0, FIND_FOUND: 0,
FIND_NOTFOUND: 1, FIND_NOTFOUND: 1,
@ -416,3 +430,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
}; };
return PDFFindController; return PDFFindController;
})(); })();
exports.FindStates = FindStates;
exports.PDFFindController = PDFFindController;
}));

15
web/pdf_history.js

@ -15,7 +15,16 @@
'use strict'; 'use strict';
var PDFHistory = (function () { (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_history', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebPDFHistory = {}));
}
}(this, function (exports) {
function PDFHistory(options) { function PDFHistory(options) {
this.linkService = options.linkService; this.linkService = options.linkService;
@ -423,5 +432,5 @@ var PDFHistory = (function () {
} }
}; };
return PDFHistory; exports.PDFHistory = PDFHistory;
})(); }));

67
web/pdf_link_service.js

@ -12,10 +12,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFViewer, PDFHistory, Promise, parseQueryString */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_link_service', ['exports', 'pdfjs-web/ui_utils'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'));
} else {
factory((root.pdfjsWebPDFLinkService = {}), root.pdfjsWebUIUtils);
}
}(this, function (exports, uiUtils) {
var parseQueryString = uiUtils.parseQueryString;
/** /**
* Performs navigation functions inside PDF, such as opening specified page, * Performs navigation functions inside PDF, such as opening specified page,
* or destination. * or destination.
@ -299,3 +311,56 @@ var PDFLinkService = (function () {
return PDFLinkService; return PDFLinkService;
})(); })();
var SimpleLinkService = (function SimpleLinkServiceClosure() {
function SimpleLinkService() {}
SimpleLinkService.prototype = {
/**
* @returns {number}
*/
get page() {
return 0;
},
/**
* @param {number} value
*/
set page(value) {},
/**
* @param dest - The PDF destination object.
*/
navigateTo: function (dest) {},
/**
* @param dest - The PDF destination object.
* @returns {string} The hyperlink to the PDF object.
*/
getDestinationHash: function (dest) {
return '#';
},
/**
* @param hash - The PDF parameters/hash.
* @returns {string} The hyperlink to the PDF object.
*/
getAnchorUrl: function (hash) {
return '#';
},
/**
* @param {string} hash
*/
setHash: function (hash) {},
/**
* @param {string} action
*/
executeNamedAction: function (action) {},
/**
* @param {number} pageNum - page number.
* @param {Object} pageRef - reference to the page.
*/
cachePageRef: function (pageNum, pageRef) {}
};
return SimpleLinkService;
})();
exports.PDFLinkService = PDFLinkService;
exports.SimpleLinkService = SimpleLinkService;
}));

15
web/pdf_outline_viewer.js

@ -12,10 +12,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals pdfjsLib */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_outline_viewer', ['exports', 'pdfjs-web/pdfjs'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./pdfjs.js'));
} else {
factory((root.pdfjsWebPDFOutlineViewer = {}), root.pdfjsWebPDFJS);
}
}(this, function (exports, pdfjsLib) {
var DEFAULT_TITLE = '\u2013'; var DEFAULT_TITLE = '\u2013';
/** /**
@ -210,3 +220,6 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() {
return PDFOutlineViewer; return PDFOutlineViewer;
})(); })();
exports.PDFOutlineViewer = PDFOutlineViewer;
}));

35
web/pdf_page_view.js

@ -12,11 +12,30 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals RenderingStates, pdfjsLib, DEFAULT_SCALE, CSS_UNITS, getOutputScale,
TextLayerBuilder, Promise, approximateFraction, roundToDivide */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_page_view', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/pdf_rendering_queue',
'pdfjs-web/pdfjs'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'),
require('./pdf_rendering_queue.js'), require('./pdfjs.js'));
} else {
factory((root.pdfjsWebPDFPageView = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFRenderingQueue, root.pdfjsWebPDFJS);
}
}(this, function (exports, uiUtils, pdfRenderingQueue, pdfjsLib) {
var CSS_UNITS = uiUtils.CSS_UNITS;
var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
var getOutputScale = uiUtils.getOutputScale;
var approximateFraction = uiUtils.approximateFraction;
var roundToDivide = uiUtils.roundToDivide;
var RenderingStates = pdfRenderingQueue.RenderingStates;
var TEXT_LAYER_RENDER_DELAY = 200; // ms var TEXT_LAYER_RENDER_DELAY = 200; // ms
/** /**
@ -437,15 +456,6 @@ var PDFPageView = (function PDFPageViewClosure() {
cssTransform: false, cssTransform: false,
}); });
div.dispatchEvent(event); div.dispatchEvent(event);
//#if GENERIC
// This custom event is deprecated, and will be removed in the future,
// please use the |pagerendered| event instead.
var deprecatedEvent = document.createEvent('CustomEvent');
deprecatedEvent.initCustomEvent('pagerender', true, true, {
pageNumber: pdfPage.pageNumber
});
div.dispatchEvent(deprecatedEvent);
//#endif
if (!error) { if (!error) {
resolveRenderPromise(undefined); resolveRenderPromise(undefined);
@ -582,3 +592,6 @@ var PDFPageView = (function PDFPageViewClosure() {
return PDFPageView; return PDFPageView;
})(); })();
exports.PDFPageView = PDFPageView;
}));

13
web/pdf_presentation_mode.js

@ -15,6 +15,16 @@
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_presentation_mode', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebPDFPresentationMode = {}));
}
}(this, function (exports) {
var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500; // in ms var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500; // in ms
var DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms var DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms
var ACTIVE_SELECTOR = 'pdfPresentationMode'; var ACTIVE_SELECTOR = 'pdfPresentationMode';
@ -389,3 +399,6 @@ var PDFPresentationMode = (function PDFPresentationModeClosure() {
return PDFPresentationMode; return PDFPresentationMode;
})(); })();
exports.PDFPresentationMode = PDFPresentationMode;
}));

14
web/pdf_rendering_queue.js

@ -15,6 +15,16 @@
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_rendering_queue', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebPDFRenderingQueue = {}));
}
}(this, function (exports) {
var CLEANUP_TIMEOUT = 30000; var CLEANUP_TIMEOUT = 30000;
var RenderingStates = { var RenderingStates = {
@ -175,3 +185,7 @@ var PDFRenderingQueue = (function PDFRenderingQueueClosure() {
return PDFRenderingQueue; return PDFRenderingQueue;
})(); })();
exports.RenderingStates = RenderingStates;
exports.PDFRenderingQueue = PDFRenderingQueue;
}));

18
web/pdf_sidebar.js

@ -12,10 +12,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals RenderingStates */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_sidebar', ['exports',
'pdfjs-web/pdf_rendering_queue'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./pdf_rendering_queue.js'));
} else {
factory((root.pdfjsWebPDFSidebar = {}), root.pdfjsWebPDFRenderingQueue);
}
}(this, function (exports, pdfRenderingQueue) {
var RenderingStates = pdfRenderingQueue.RenderingStates;
var SidebarView = { var SidebarView = {
NONE: 0, NONE: 0,
THUMBS: 1, THUMBS: 1,
@ -330,3 +342,7 @@ var PDFSidebar = (function PDFSidebarClosure() {
return PDFSidebar; return PDFSidebar;
})(); })();
exports.SidebarView = SidebarView;
exports.PDFSidebar = PDFSidebar;
}));

21
web/pdf_thumbnail_view.js

@ -12,10 +12,26 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals mozL10n, RenderingStates, Promise, getOutputScale */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_thumbnail_view', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/pdf_rendering_queue'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'),
require('./pdf_rendering_queue.js'));
} else {
factory((root.pdfjsWebPDFThumbnailView = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFRenderingQueue);
}
}(this, function (exports, uiUtils, pdfRenderingQueue) {
var mozL10n = uiUtils.mozL10n;
var getOutputScale = uiUtils.getOutputScale;
var RenderingStates = pdfRenderingQueue.RenderingStates;
var THUMBNAIL_WIDTH = 98; // px var THUMBNAIL_WIDTH = 98; // px
var THUMBNAIL_CANVAS_BORDER_WIDTH = 1; // px var THUMBNAIL_CANVAS_BORDER_WIDTH = 1; // px
@ -377,3 +393,6 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
})(); })();
PDFThumbnailView.tempImageCache = null; PDFThumbnailView.tempImageCache = null;
exports.PDFThumbnailView = PDFThumbnailView;
}));

25
web/pdf_thumbnail_viewer.js

@ -12,14 +12,28 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals watchScroll, getVisibleElements, scrollIntoView, PDFThumbnailView,
Promise */
'use strict'; 'use strict';
var THUMBNAIL_SCROLL_MARGIN = -19; (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_thumbnail_viewer', ['exports',
'pdfjs-web/ui_utils', 'pdfjs-web/pdf_thumbnail_view'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'),
require('./pdf_thumbnail_view.js'));
} else {
factory((root.pdfjsWebPDFThumbnailViewer = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFThumbnailView);
}
}(this, function (exports, uiUtils, pdfThumbnailView) {
//#include pdf_thumbnail_view.js var watchScroll = uiUtils.watchScroll;
var getVisibleElements = uiUtils.getVisibleElements;
var scrollIntoView = uiUtils.scrollIntoView;
var PDFThumbnailView = pdfThumbnailView.PDFThumbnailView;
var THUMBNAIL_SCROLL_MARGIN = -19;
/** /**
* @typedef {Object} PDFThumbnailViewerOptions * @typedef {Object} PDFThumbnailViewerOptions
@ -196,3 +210,6 @@ var PDFThumbnailViewer = (function PDFThumbnailViewerClosure() {
return PDFThumbnailViewer; return PDFThumbnailViewer;
})(); })();
exports.PDFThumbnailViewer = PDFThumbnailViewer;
}));

68
web/pdf_viewer.component.js

@ -13,40 +13,46 @@
* limitations under the License. * limitations under the License.
*/ */
/* jshint globalstrict: false */ /* jshint globalstrict: false */
/* globals PDFJS, PDFViewer, PDFPageView, TextLayerBuilder, PDFLinkService, /* umdutils ignore */
DefaultTextLayerFactory, AnnotationLayerBuilder, PDFHistory,
DefaultAnnotationLayerFactory, DownloadManager, ProgressBar */
(function pdfViewerWrapper() { (function (root, factory) {
'use strict'; 'use strict';
if (typeof define === 'function' && define.amd) {
var root = this; define('pdfjs-dist/web/pdf.components', ['exports', 'pdfjs-dist/build/pdf'],
if (!root.pdfjsLib) { factory);
Object.defineProperty(root, 'pdfjsLib', { } else if (typeof exports !== 'undefined') {
get: function () { factory(exports, require('../build/pdf.js'));
return root.pdfjsDistBuildPdf || root.pdfjsDistBuildPdfCombined || } else {
root.pdfjsMainLoader; factory((root.pdfjsDistWebPDFComponents = {}), root.pdfjsDistBuildPdf);
},
enumerable: true,
configurable: true
});
} }
}(this, function (exports, pdfjsLib) {
'use strict';
var pdfViewerLibs = {
pdfjsWebPDFJS: pdfjsLib
};
(function () {
//#expand __BUNDLE__
}).call(pdfViewerLibs);
var PDFJS = pdfjsLib.PDFJS;
//#include ui_utils.js PDFJS.PDFViewer = pdfViewerLibs.pdfjsWebPDFViewer.PDFViewer;
//#include pdf_link_service.js PDFJS.PDFPageView = pdfViewerLibs.pdfjsWebPDFPageView.PDFPageView;
//#include pdf_viewer.js PDFJS.PDFLinkService = pdfViewerLibs.pdfjsWebPDFLinkService.PDFLinkService;
//#include pdf_history.js PDFJS.TextLayerBuilder =
//#include download_manager.js pdfViewerLibs.pdfjsWebTextLayerBuilder.TextLayerBuilder;
PDFJS.DefaultTextLayerFactory =
pdfViewerLibs.pdfjsWebTextLayerBuilder.DefaultTextLayerFactory;
PDFJS.AnnotationLayerBuilder =
pdfViewerLibs.pdfjsWebAnnotationLayerBuilder.AnnotationLayerBuilder;
PDFJS.DefaultAnnotationLayerFactory =
pdfViewerLibs.pdfjsWebAnnotationLayerBuilder.DefaultAnnotationLayerFactory;
PDFJS.PDFHistory = pdfViewerLibs.pdfjsWebPDFHistory.PDFHistory;
PDFJS.PDFViewer = PDFViewer; PDFJS.DownloadManager = pdfViewerLibs.pdfjsWebDownloadManager.DownloadManager;
PDFJS.PDFPageView = PDFPageView; PDFJS.ProgressBar = pdfViewerLibs.pdfjsWebUIUtils.ProgressBar;
PDFJS.PDFLinkService = PDFLinkService;
PDFJS.TextLayerBuilder = TextLayerBuilder;
PDFJS.DefaultTextLayerFactory = DefaultTextLayerFactory;
PDFJS.AnnotationLayerBuilder = AnnotationLayerBuilder;
PDFJS.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
PDFJS.PDFHistory = PDFHistory;
PDFJS.DownloadManager = DownloadManager; exports.PDFJS = PDFJS;
PDFJS.ProgressBar = ProgressBar; }));
}).call((typeof window === 'undefined') ? this : window);

99
web/pdf_viewer.js

@ -12,14 +12,47 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*globals watchScroll, PDFPageView, UNKNOWN_SCALE,
SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS,
DEFAULT_SCALE, scrollIntoView, getVisibleElements, RenderingStates,
pdfjsLib, Promise, TextLayerBuilder, PDFRenderingQueue,
AnnotationLayerBuilder, DEFAULT_SCALE_VALUE */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_viewer', ['exports', 'pdfjs-web/ui_utils',
'pdfjs-web/pdf_page_view', 'pdfjs-web/pdf_rendering_queue',
'pdfjs-web/text_layer_builder', 'pdfjs-web/annotation_layer_builder',
'pdfjs-web/pdf_link_service', 'pdfjs-web/pdfjs'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'), require('./pdf_page_view.js'),
require('./pdf_rendering_queue.js'), require('./text_layer_builder.js'),
require('./annotation_layer_builder.js'),
require('./pdf_link_service.js'), require('./pdfjs.js'));
} else {
factory((root.pdfjsWebPDFViewer = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFPageView, root.pdfjsWebPDFRenderingQueue,
root.pdfjsWebTextLayerBuilder, root.pdfjsWebAnnotationLayerBuilder,
root.pdfjsWebPDFLinkService, root.pdfjsWebPDFJS);
}
}(this, function (exports, uiUtils, pdfPageView, pdfRenderingQueue,
textLayerBuilder, annotationLayerBuilder, pdfLinkService,
pdfjsLib) {
var UNKNOWN_SCALE = uiUtils.UNKNOWN_SCALE;
var SCROLLBAR_PADDING = uiUtils.SCROLLBAR_PADDING;
var VERTICAL_PADDING = uiUtils.VERTICAL_PADDING;
var MAX_AUTO_SCALE = uiUtils.MAX_AUTO_SCALE;
var CSS_UNITS = uiUtils.CSS_UNITS;
var DEFAULT_SCALE = uiUtils.DEFAULT_SCALE;
var DEFAULT_SCALE_VALUE = uiUtils.DEFAULT_SCALE_VALUE;
var scrollIntoView = uiUtils.scrollIntoView;
var watchScroll = uiUtils.watchScroll;
var getVisibleElements = uiUtils.getVisibleElements;
var PDFPageView = pdfPageView.PDFPageView;
var RenderingStates = pdfRenderingQueue.RenderingStates;
var PDFRenderingQueue = pdfRenderingQueue.PDFRenderingQueue;
var TextLayerBuilder = textLayerBuilder.TextLayerBuilder;
var AnnotationLayerBuilder = annotationLayerBuilder.AnnotationLayerBuilder;
var SimpleLinkService = pdfLinkService.SimpleLinkService;
var PresentationModeState = { var PresentationModeState = {
UNKNOWN: 0, UNKNOWN: 0,
NORMAL: 1, NORMAL: 1,
@ -29,11 +62,6 @@ var PresentationModeState = {
var DEFAULT_CACHE_SIZE = 10; var DEFAULT_CACHE_SIZE = 10;
//#include pdf_rendering_queue.js
//#include pdf_page_view.js
//#include text_layer_builder.js
//#include annotation_layer_builder.js
/** /**
* @typedef {Object} PDFViewerOptions * @typedef {Object} PDFViewerOptions
* @property {HTMLDivElement} container - The container for the viewer element. * @property {HTMLDivElement} container - The container for the viewer element.
@ -772,51 +800,6 @@ var PDFViewer = (function pdfViewer() {
return PDFViewer; return PDFViewer;
})(); })();
var SimpleLinkService = (function SimpleLinkServiceClosure() { exports.PresentationModeState = PresentationModeState;
function SimpleLinkService() {} exports.PDFViewer = PDFViewer;
}));
SimpleLinkService.prototype = {
/**
* @returns {number}
*/
get page() {
return 0;
},
/**
* @param {number} value
*/
set page(value) {},
/**
* @param dest - The PDF destination object.
*/
navigateTo: function (dest) {},
/**
* @param dest - The PDF destination object.
* @returns {string} The hyperlink to the PDF object.
*/
getDestinationHash: function (dest) {
return '#';
},
/**
* @param hash - The PDF parameters/hash.
* @returns {string} The hyperlink to the PDF object.
*/
getAnchorUrl: function (hash) {
return '#';
},
/**
* @param {string} hash
*/
setHash: function (hash) {},
/**
* @param {string} action
*/
executeNamedAction: function (action) {},
/**
* @param {number} pageNum - page number.
* @param {Object} pageRef - reference to the page.
*/
cachePageRef: function (pageNum, pageRef) {}
};
return SimpleLinkService;
})();

32
web/platform_integration.js → web/pdfjs.js

@ -12,19 +12,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* umdutils ignore */
//#if !(FIREFOX || MOZCENTRAL) 'use strict';
//#include mozPrintCallback_polyfill.js
//#endif
//#if GENERIC || CHROME (function (root, factory) {
//#include download_manager.js if (typeof define === 'function' && define.amd) {
//#endif define('pdfjs-web/pdfjs', ['exports', 'pdfjs/main_loader'], factory);
} else if (typeof exports !== 'undefined') {
//#if FIREFOX || MOZCENTRAL factory(exports, require('../src/main_loader.js'));
//#include firefoxcom.js } else {
//#endif factory((root.pdfjsWebPDFJS = {}), root.pdfjsMainLoader);
}
//#if CHROME }(this, function (exports, mainLoader) {
//#include chromecom.js // Re-export all mainLoader members.
//#endif for (var i in mainLoader) {
if (Object.prototype.hasOwnProperty.call(mainLoader, i)) {
exports[i] = mainLoader[i];
}
}
}));

17
web/preferences.js

@ -12,11 +12,21 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals DEFAULT_PREFERENCES, Promise */ /* globals DEFAULT_PREFERENCES, chrome */
'use strict'; 'use strict';
//#include default_preferences.js (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/preferences', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebPreferences = {}));
}
}(this, function (exports) {
//#include $ROOT/web/default_preferences.js
/** /**
* Preferences - Utility for storing persistent settings. * Preferences - Utility for storing persistent settings.
@ -209,3 +219,6 @@ Preferences._readFromStorage = function (prefObj) {
}); });
}; };
//#endif //#endif
exports.Preferences = Preferences;
}));

26
web/secondary_toolbar.js

@ -12,10 +12,25 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFViewerApplication, SCROLLBAR_PADDING */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/secondary_toolbar', ['exports', 'pdfjs-web/ui_utils'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'));
} else {
factory((root.pdfjsWebSecondaryToolbar = {}), root.pdfjsWebUIUtils);
}
}(this, function (exports, uiUtils) {
var SCROLLBAR_PADDING = uiUtils.SCROLLBAR_PADDING;
var app; // Avoiding circular reference, see _setApp function below.
var PDFViewerApplication = null; // = app.PDFViewerApplication;
var SecondaryToolbar = { var SecondaryToolbar = {
opened: false, opened: false,
previousContainerHeight: null, previousContainerHeight: null,
@ -158,3 +173,12 @@ var SecondaryToolbar = {
} }
} }
}; };
function _setApp(app_) {
app = app_;
PDFViewerApplication = app.PDFViewerApplication;
}
exports.SecondaryToolbar = SecondaryToolbar;
exports._setApp = _setApp;
}));

16
web/text_layer_builder.js

@ -12,10 +12,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals pdfjsLib */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/text_layer_builder', ['exports', 'pdfjs-web/pdfjs'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./pdfjs.js'));
} else {
factory((root.pdfjsWebTextLayerBuilder = {}), root.pdfjsWebPDFJS);
}
}(this, function (exports, pdfjsLib) {
/** /**
* @typedef {Object} TextLayerBuilderOptions * @typedef {Object} TextLayerBuilderOptions
* @property {HTMLDivElement} textLayerDiv - The text layer container. * @property {HTMLDivElement} textLayerDiv - The text layer container.
@ -346,3 +356,7 @@ DefaultTextLayerFactory.prototype = {
}); });
} }
}; };
exports.TextLayerBuilder = TextLayerBuilder;
exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
}));

36
web/ui_utils.js

@ -12,10 +12,19 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* global PDFJS */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/ui_utils', ['exports', 'pdfjs-web/pdfjs'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./pdfjs.js'));
} else {
factory((root.pdfjsWebUIUtils = {}), root.pdfjsWebPDFJS);
}
}(this, function (exports, pdfjsLib) {
var CSS_UNITS = 96.0 / 72.0; var CSS_UNITS = 96.0 / 72.0;
var DEFAULT_SCALE_VALUE = 'auto'; var DEFAULT_SCALE_VALUE = 'auto';
var DEFAULT_SCALE = 1.0; var DEFAULT_SCALE = 1.0;
@ -26,9 +35,7 @@ var VERTICAL_PADDING = 5;
var mozL10n = document.mozL10n || document.webL10n; var mozL10n = document.mozL10n || document.webL10n;
if (typeof PDFJS === 'undefined') { var PDFJS = pdfjsLib.PDFJS;
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
/** /**
* Disables fullscreen support, and by extension Presentation Mode, * Disables fullscreen support, and by extension Presentation Mode,
@ -458,3 +465,24 @@ var ProgressBar = (function ProgressBarClosure() {
return ProgressBar; return ProgressBar;
})(); })();
exports.CSS_UNITS = CSS_UNITS;
exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
exports.DEFAULT_SCALE = DEFAULT_SCALE;
exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
exports.VERTICAL_PADDING = VERTICAL_PADDING;
exports.mozL10n = mozL10n;
exports.ProgressBar = ProgressBar;
exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
exports.noContextMenuHandler = noContextMenuHandler;
exports.parseQueryString = parseQueryString;
exports.getVisibleElements = getVisibleElements;
exports.roundToDivide = roundToDivide;
exports.approximateFraction = approximateFraction;
exports.getOutputScale = getOutputScale;
exports.scrollIntoView = scrollIntoView;
exports.watchScroll = watchScroll;
exports.binarySearchFirstItem = binarySearchFirstItem;
}));

13
web/view_history.js

@ -15,6 +15,16 @@
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/view_history', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebViewHistory = {}));
}
}(this, function (exports) {
var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20; var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
/** /**
@ -115,3 +125,6 @@ var ViewHistory = (function ViewHistoryClosure() {
return ViewHistory; return ViewHistory;
})(); })();
exports.ViewHistory = ViewHistory;
}));

27
web/viewer.html

@ -61,34 +61,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<!--#endif--> <!--#endif-->
<!--#if !PRODUCTION--> <!--#if !PRODUCTION-->
<script src="ui_utils.js"></script>
<script src="default_preferences.js"></script> <script src="default_preferences.js"></script>
<script src="preferences.js"></script>
<script src="download_manager.js"></script>
<script src="platform_integration.js"></script>
<script src="view_history.js"></script>
<script src="pdf_link_service.js"></script>
<script src="pdf_rendering_queue.js"></script>
<script src="pdf_page_view.js"></script>
<script src="text_layer_builder.js"></script>
<script src="annotation_layer_builder.js"></script>
<script src="pdf_viewer.js"></script>
<script src="pdf_thumbnail_view.js"></script>
<script src="pdf_thumbnail_viewer.js"></script>
<script src="pdf_sidebar.js"></script>
<script src="pdf_outline_viewer.js"></script>
<script src="pdf_attachment_viewer.js"></script>
<script src="pdf_find_bar.js"></script>
<script src="pdf_find_controller.js"></script>
<script src="pdf_history.js"></script>
<script src="secondary_toolbar.js"></script>
<script src="pdf_presentation_mode.js"></script>
<script src="grab_to_pan.js"></script>
<script src="hand_tool.js"></script>
<script src="overlay_manager.js"></script>
<script src="password_prompt.js"></script>
<script src="pdf_document_properties.js"></script>
<script src="app.js"></script>
<!--#endif--> <!--#endif-->
<!--#if !MINIFIED --> <!--#if !MINIFIED -->

33
web/viewer.js

@ -12,21 +12,34 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*globals require, parseQueryString, chrome, PDFViewerApplication */ /*globals require, chrome */
'use strict'; 'use strict';
var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf'; var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
//#include app.js //#if PRODUCTION
//var pdfjsWebLibs = {
// pdfjsWebPDFJS: window.pdfjsDistBuildPdf
//};
//
//(function () {
//#expand __BUNDLE__
//}).call(pdfjsWebLibs);
//#endif
//#if FIREFOX || MOZCENTRAL
//// FIXME the l10n.js file in the Firefox extension needs global FirefoxCom.
//window.FirefoxCom = pdfjsWebLibs.pdfjsWebFirefoxCom.FirefoxCom;
//#endif
//#if CHROME //#if CHROME
//(function rewriteUrlClosure() { //(function rewriteUrlClosure() {
// // Run this code outside DOMContentLoaded to make sure that the URL // // Run this code outside DOMContentLoaded to make sure that the URL
// // is rewritten as soon as possible. // // is rewritten as soon as possible.
// var queryString = document.location.search.slice(1); // var queryString = document.location.search.slice(1);
// var params = parseQueryString(queryString); // var m = /(^|&)file=([^&]*)/.exec(queryString);
// DEFAULT_URL = params.file || ''; // DEFAULT_URL = m ? decodeURIComponent(m[2]) : '';
// //
// // Example: chrome-extension://.../http://example.com/file.pdf // // Example: chrome-extension://.../http://example.com/file.pdf
// var humanReadableUrl = '/' + DEFAULT_URL + location.hash; // var humanReadableUrl = '/' + DEFAULT_URL + location.hash;
@ -39,14 +52,14 @@ var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
function webViewerLoad() { function webViewerLoad() {
//#if !PRODUCTION //#if !PRODUCTION
require.config({paths: {'pdfjs': '../src'}}); require.config({paths: {'pdfjs': '../src', 'pdfjs-web': '.'}});
require(['pdfjs/main_loader'], function (loader) { require(['pdfjs-web/app'], function (web) {
window.pdfjsLib = loader; window.PDFViewerApplication = web.PDFViewerApplication;
PDFViewerApplication.run(); web.PDFViewerApplication.run();
}); });
//#else //#else
//window.pdfjsLib = window.pdfjsDistBuildPdf; //window.PDFViewerApplication = pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication;
//PDFViewerApplication.run(); //pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication.run();
//#endif //#endif
} }

Loading…
Cancel
Save