Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UMD header to viewer.js #7916

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"mkdirp": "^0.5.1",
"node-ensure": "^0.0.0",
"requirejs": "^2.1.22",
"requirejs-domready": "^2.0.3",
"rimraf": "^2.4.1",
"run-sequence": "^1.2.2",
"shelljs": "~0.4.0",
Expand Down
7 changes: 6 additions & 1 deletion web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@
<!--#endif-->

<!--#if !MINIFIED -->
<script src="viewer.js"></script>
<script>
require.config({paths: {'pdfjs-web': '.', 'domReady': '../node_modules/requirejs-domready/domReady'}});
require(['pdfjs-web/viewer', 'domReady!'], function (pdfViewer) {
pdfViewer.run();
});
</script>
<!--#else-->
<!--#include viewer-snippet-minified.html-->
<!--#endif-->
Expand Down
18 changes: 16 additions & 2 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,23 @@
* limitations under the License.
*/
/* globals chrome */
/* eslint strict: ["error", "function"] */

var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';

(function (root, factory) {
'use strict';

var DEFAULT_URL = 'compressed.tracemonkey-pldi-09.pdf';
if (typeof define === 'function' && define.amd) {
define('pdfjs-web/viewer', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsWebViewer = {}));
}
}(this, function (exports) {
// Use strict in our context only - users might not want it
'use strict';

if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
(function rewriteUrlClosure() {
Expand Down Expand Up @@ -185,4 +198,5 @@ function webViewerLoad() {
}
}

document.addEventListener('DOMContentLoaded', webViewerLoad, true);
exports.run = webViewerLoad;
}));