Browse Source

Introduces UMD headers to the web/ folder.

Yury Delendik 9 years ago
parent
commit
006e8fb59d
  1. 9
      external/builder/builder.js
  2. 7
      external/umdutils/verifier.js
  3. 182
      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. 119
      web/app.js
  9. 28
      web/chromecom.js
  10. 19
      web/download_manager.js
  11. 23
      web/firefoxcom.js
  12. 14
      web/grab_to_pan.js
  13. 25
      web/hand_tool.js
  14. 16
      web/mozPrintCallback_polyfill.js
  15. 13
      web/overlay_manager.js
  16. 20
      web/password_prompt.js
  17. 13
      web/pdf_attachment_viewer.js
  18. 20
      web/pdf_document_properties.js
  19. 20
      web/pdf_find_bar.js
  20. 20
      web/pdf_find_controller.js
  21. 15
      web/pdf_history.js
  22. 67
      web/pdf_link_service.js
  23. 13
      web/pdf_outline_viewer.js
  24. 26
      web/pdf_page_view.js
  25. 13
      web/pdf_presentation_mode.js
  26. 14
      web/pdf_rendering_queue.js
  27. 18
      web/pdf_sidebar.js
  28. 21
      web/pdf_thumbnail_view.js
  29. 25
      web/pdf_thumbnail_viewer.js
  30. 38
      web/pdf_viewer.component.js
  31. 99
      web/pdf_viewer.js
  32. 30
      web/platform_integration.js
  33. 17
      web/preferences.js
  34. 26
      web/secondary_toolbar.js
  35. 14
      web/text_layer_builder.js
  36. 33
      web/ui_utils.js
  37. 13
      web/view_history.js
  38. 27
      web/viewer.html
  39. 26
      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);
} }

182
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() {
@ -477,6 +498,46 @@ target.cmaps = function () {
compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true); compressCmaps(CMAP_INPUT, VIEWER_CMAP_OUTPUT, true);
}; };
function bundle(filename, outfilename, initFiles, amdName, defines,
isMainFile) {
// 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 umd = require('./external/umdutils/verifier.js');
var files = umd.readDependencies(initFiles).loadOrder.map(
function (name) { return name.replace(/^[\w\-]+\//, '') + '.js'; });
crlfchecker.checkIfCrlfIsPresent(files);
var bundleContent = cat(files),
bundleVersion = VERSION,
bundleBuild = BUILD_COMMIT;
// Prepend a newline because stripCommentHeaders only strips comments that
// follow a line feed. The file where bundleContent is inserted already
// contains a license header, so the header of bundleContent can be removed.
bundleContent = stripCommentHeaders('\n' + bundleContent);
// Removes AMD and CommonJS branches from UMD headers.
bundleContent = stripUMDHeaders(bundleContent);
var jsName = amdName.replace(/[\-_\.\/]\w/g, function (all) {
return all[1].toUpperCase();
});
// This just preprocesses the empty pdf.js file, we don't actually want to
// preprocess everything yet since other build targets use this file.
builder.preprocess(filename, outfilename,
builder.merge(defines, {
BUNDLE: bundleContent,
BUNDLE_VERSION: bundleVersion,
BUNDLE_BUILD: bundleBuild,
BUNDLE_AMD_NAME: amdName,
BUNDLE_JS_NAME: jsName,
MAIN_FILE: isMainFile
}));
}
// //
// make bundle // make bundle
// Bundles all source files into one wrapper 'pdf.js' file, in the given order. // Bundles all source files into one wrapper 'pdf.js' file, in the given order.
@ -491,86 +552,45 @@ target.bundle = function(args) {
echo(); echo();
echo('### Bundling files into ' + BUILD_TARGET); echo('### Bundling files into ' + BUILD_TARGET);
function bundle(filename, outfilename, files, distname, isMainFile) {
var bundleContent = cat(files),
bundleVersion = VERSION,
bundleBuild = exec('git log --format="%h" -n 1',
{silent: true}).output.replace('\n', '');
crlfchecker.checkIfCrlfIsPresent(files);
// Prepend a newline because stripCommentHeaders only strips comments that
// follow a line feed. The file where bundleContent is inserted already
// contains a license header, so the header of bundleContent can be removed.
bundleContent = stripCommentHeaders('\n' + bundleContent);
// Removes AMD and CommonJS branches from UMD headers.
bundleContent = stripUMDHeaders(bundleContent);
var amdName = 'pdfjs-dist/build/' + distname.replace(/\.js$/, '');
var jsName = amdName.replace(/[\-_\.\/]\w/g, function (all) {
return all[1].toUpperCase();
});
// This just preprocesses the empty pdf.js file, we don't actually want to
// preprocess everything yet since other build targets use this file.
builder.preprocess(filename, outfilename, builder.merge(defines,
{BUNDLE: bundleContent,
BUNDLE_VERSION: bundleVersion,
BUNDLE_BUILD: bundleBuild,
BUNDLE_AMD_NAME: amdName,
BUNDLE_JS_NAME: jsName,
MAIN_FILE: isMainFile}));
}
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);
} }
}; };
@ -674,6 +694,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: [
@ -684,6 +711,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: [
@ -694,6 +722,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',
@ -760,6 +789,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', '');
}; };
// //
@ -817,6 +849,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: [
@ -827,6 +867,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],
@ -844,6 +885,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) {
@ -944,6 +986,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: [
@ -952,6 +1001,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],
@ -971,6 +1021,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) {
@ -1076,6 +1127,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: [
@ -1094,6 +1152,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: [
@ -1105,6 +1164,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,
@ -1506,7 +1566,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 */ /*globals pdfjsLib */
'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'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'),
require('./pdf_link_service.js'));
} else {
factory((root.pdfjsWebAnnotationLayerBuilder = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFLinkService);
}
}(this, function (exports, uiUtils, pdfLinkService) {
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;
}));

119
web/app.js

@ -12,18 +12,92 @@
* 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, pdfjsLib, 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'],
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'));
} 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);
}
}(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) {
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 +121,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,
@ -2144,3 +2198,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);
}));

28
web/chromecom.js

@ -13,10 +13,27 @@
* limitations under the License. * limitations under the License.
*/ */
/* globals chrome, pdfjsLib, PDFViewerApplication, OverlayManager */ /* globals chrome, pdfjsLib */
'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'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./app.js'), require('./overlay_manager.js'));
} else {
factory((root.pdfjsWebChromeCom = {}), root.pdfjsWebApp,
root.pdfjsWebOverlayManager);
}
}(this, function (exports, app, overlayManager) {
//#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 +222,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 +321,6 @@ var ChromeCom = (function ChromeComClosure() {
} }
} }
return ChromeCom; exports.ChromeCom = ChromeCom;
})(); //#endif
}));

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 */ /* globals pdfjsLib */
'use strict'; 'use strict';
var DownloadManager = (function DownloadManagerClosure() { (function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/download_manager', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebDownloadManager = {}));
}
}(this, function (exports) {
//#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 */ /* globals pdfjsLib */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/firefoxcom', ['exports', 'pdfjs-web/preferences'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./preferences.js'));
} else {
factory((root.pdfjsWebFirefoxCom = {}), root.pdfjsWebPreferences);
}
}(this, function (exports, preferences) {
//#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;
}));

20
web/password_prompt.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 pdfjsLib, mozL10n, OverlayManager */ /* globals pdfjsLib */
'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'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'), require('./overlay_manager.js'));
} else {
factory((root.pdfjsWebPasswordPrompt = {}), root.pdfjsWebUIUtils,
root.pdfjsWebOverlayManager);
}
}(this, function (exports, uiUtils, overlayManager) {
var mozL10n = uiUtils.mozL10n;
var OverlayManager = overlayManager.OverlayManager;
var PasswordPrompt = { var PasswordPrompt = {
overlayName: null, overlayName: null,
updatePassword: null, updatePassword: null,
@ -79,3 +94,6 @@ var PasswordPrompt = {
} }
} }
}; };
exports.PasswordPrompt = PasswordPrompt;
}));

13
web/pdf_attachment_viewer.js

@ -16,6 +16,16 @@
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_attachment_viewer', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebPDFAttachmentViewer = {}));
}
}(this, function (exports) {
/** /**
* @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;
}));

13
web/pdf_outline_viewer.js

@ -16,6 +16,16 @@
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/pdf_outline_viewer', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebPDFOutlineViewer = {}));
}
}(this, function (exports) {
var DEFAULT_TITLE = '\u2013'; var DEFAULT_TITLE = '\u2013';
/** /**
@ -210,3 +220,6 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() {
return PDFOutlineViewer; return PDFOutlineViewer;
})(); })();
exports.PDFOutlineViewer = PDFOutlineViewer;
}));

26
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, /* globals pdfjsLib */
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'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('./ui_utils.js'),
require('./pdf_rendering_queue.js'));
} else {
factory((root.pdfjsWebPDFPageView = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFRenderingQueue);
}
}(this, function (exports, uiUtils, pdfRenderingQueue) {
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
/** /**
@ -582,3 +601,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;
}));

38
web/pdf_viewer.component.js

@ -13,9 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
/*jshint globalstrict: false */ /*jshint globalstrict: false */
/* globals PDFJS, PDFViewer, PDFPageView, TextLayerBuilder, PDFLinkService,
DefaultTextLayerFactory, AnnotationLayerBuilder, PDFHistory,
DefaultAnnotationLayerFactory, DownloadManager, ProgressBar */
(function pdfViewerWrapper() { (function pdfViewerWrapper() {
'use strict'; 'use strict';
@ -32,21 +29,26 @@
}); });
} }
//#include ui_utils.js var pdfViewerLibs = {};
//#include pdf_link_service.js (function () {
//#include pdf_viewer.js //#expand __BUNDLE__
//#include pdf_history.js }).call(pdfViewerLibs);
//#include download_manager.js
PDFJS.PDFViewer = PDFViewer; var PDFJS = window.PDFJS || (window.PDFJS = {});
PDFJS.PDFPageView = PDFPageView;
PDFJS.PDFLinkService = PDFLinkService;
PDFJS.TextLayerBuilder = TextLayerBuilder;
PDFJS.DefaultTextLayerFactory = DefaultTextLayerFactory;
PDFJS.AnnotationLayerBuilder = AnnotationLayerBuilder;
PDFJS.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
PDFJS.PDFHistory = PDFHistory;
PDFJS.DownloadManager = DownloadManager; PDFJS.PDFViewer = pdfViewerLibs.pdfjsWebPDFViewer.PDFViewer;
PDFJS.ProgressBar = ProgressBar; PDFJS.PDFPageView = pdfViewerLibs.pdfjsWebPDFPageView.PDFPageView;
PDFJS.PDFLinkService = pdfViewerLibs.pdfjsWebPDFLinkService.PDFLinkService;
PDFJS.TextLayerBuilder =
pdfViewerLibs.pdfjsWebTextLayerBuilder.TextLayerBuilder;
PDFJS.DefaultTextLayerFactory =
pdfViewerLibs.pdfjsWebTextLayerBuilder.DefaultTextLayerFactory;
PDFJS.AnnotationLayerBuilder =
pdfViewerLibs.pdfjsWebAnnotationLayerBuilder.AnnotationLayerBuilder;
PDFJS.DefaultAnnotationLayerFactory =
pdfViewerLibs.pdfjsWebAnnotationLayerBuilder.DefaultAnnotationLayerFactory;
PDFJS.PDFHistory = pdfViewerLibs.pdfjsWebPDFHistory.PDFHistory;
PDFJS.DownloadManager = pdfViewerLibs.pdfjsWebDownloadManager.DownloadManager;
PDFJS.ProgressBar = pdfViewerLibs.pdfjsWebUIUtils.ProgressBar;
}).call((typeof window === 'undefined') ? this : window); }).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, /* globals pdfjsLib */
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'], 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'));
} else {
factory((root.pdfjsWebPDFViewer = {}), root.pdfjsWebUIUtils,
root.pdfjsWebPDFPageView, root.pdfjsWebPDFRenderingQueue,
root.pdfjsWebTextLayerBuilder, root.pdfjsWebAnnotationLayerBuilder,
root.pdfjsWebPDFLinkService);
}
}(this, function (exports, uiUtils, pdfPageView, pdfRenderingQueue,
textLayerBuilder, annotationLayerBuilder, pdfLinkService) {
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;
})();

30
web/platform_integration.js

@ -1,30 +0,0 @@
/* Copyright 2016 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//#if !(FIREFOX || MOZCENTRAL)
//#include mozPrintCallback_polyfill.js
//#endif
//#if GENERIC || CHROME
//#include download_manager.js
//#endif
//#if FIREFOX || MOZCENTRAL
//#include firefoxcom.js
//#endif
//#if CHROME
//#include chromecom.js
//#endif

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;
}));

14
web/text_layer_builder.js

@ -16,6 +16,16 @@
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/text_layer_builder', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebTextLayerBuilder = {}));
}
}(this, function (exports) {
/** /**
* @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;
}));

33
web/ui_utils.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.
*/ */
/* global PDFJS */ /* globals PDFJS */
'use strict'; 'use strict';
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/ui_utils', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebUIUtils = {}));
}
}(this, function (exports) {
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;
@ -458,3 +468,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 -->

26
web/viewer.js

@ -12,21 +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 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 var pdfjsWebLibs = {};
(function () {
//#expand __BUNDLE__
}).call(pdfjsWebLibs);
//#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 +47,16 @@ 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/main_loader', 'pdfjs-web/app'], function (loader, web) {
window.pdfjsLib = loader; window.pdfjsLib = loader;
PDFViewerApplication.run(); window.PDFViewerApplication = web.PDFViewerApplication;
web.PDFViewerApplication.run();
}); });
//#else //#else
//window.pdfjsLib = window.pdfjsDistBuildPdf; //window.pdfjsLib = window.pdfjsDistBuildPdf;
//PDFViewerApplication.run(); //window.PDFViewerApplication = pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication;
//pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication.run();
//#endif //#endif
} }

Loading…
Cancel
Save