1/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */
2var app = {
3 // Application Constructor
4 initialize: function() {
5 document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
6 },
7
8 // deviceready Event Handler
9 //
10 // Bind any cordova events here. Common events are:
11 // 'pause', 'resume', etc.
12 onDeviceReady: function() {
13 this.receivedEvent('deviceready');
14 },
15
16 onTopLeftButtonPressed: function () {
17 console.log('onTopLeftButtonPressed');
18 },
19
20 // Update DOM on a Received Event
21 receivedEvent: function(id) {
22 var parentElement = document.getElementById(id);
23 var listeningElement = parentElement.querySelector('.listening');
24 var receivedElement = parentElement.querySelector('.received');
25
26 listeningElement.setAttribute('style', 'display:none;');
27 receivedElement.setAttribute('style', 'display:block;');
28
29 console.log('Received Event: ' + id);
30
31 var viewerElement = document.getElementById('viewer');
32 var viewer = new PDFTron.NativeViewer({
33 l: '<your-key-here>',
34 initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/PDFTRON_mobile_about.pdf',
35 disabledElements: [
36 // hide elements as you wish
37 ]
38 }, viewerElement);
39
40 document.addEventListener("topLeftButtonPressed", this.onTopLeftButtonPressed.bind(this), false);
41 }
42};
43
44app.initialize();