Skip to content

Commit

Permalink
Merge pull request #146 from owncloud/close-145
Browse files Browse the repository at this point in the history
Update pdfjs to the most recent stable  1.9.426
  • Loading branch information
Vincent Petry committed Jun 25, 2018
2 parents 5e12dd6 + 9bf1805 commit 83cebef
Show file tree
Hide file tree
Showing 391 changed files with 14,491 additions and 64,716 deletions.
4 changes: 4 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "vendor"
}

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
build
build
vendor/
!js/vendor/
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ endif
clean:
rm -rf ./build/artifacts

.PHONY: rebuild-pdfjs
rebuild-pdfjs:
rm -rf js/vendor/pdfjs
rm -rf vendor/pdfjs
bower install
cd vendor/pdfjs && npm install
cd vendor/pdfjs && gulp generic
mkdir -p js/vendor
mv vendor/pdfjs/build/generic js/vendor/pdfjs


# Builds the source and appstore package
.PHONY: dist
dist:
Expand Down Expand Up @@ -59,7 +70,6 @@ appstore:
templates \
css \
img \
vendor \
js \
$(appstore_package_name)

Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ This application integrates the [PDF.js](https://mozilla.github.io/pdf.js/) libr
[![Code Coverage](https://scrutinizer-ci.com/g/owncloud/files_pdfviewer/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/owncloud/files_pdfviewer/?branch=master)
[![Build Status](https://travis-ci.org/owncloud/files_pdfviewer.svg)](https://travis-ci.org/owncloud/files_pdfviewer)


Instructions to update pdfjs
===========
1. Prerequisites
- Install npm
- Install bower
- Install gulp

2. Update pdfjs version in bower.json

3. Run `make rebuild-pdfjs`

4. New version of the library will be in `js/vendor/pdfjs`

5. Check if `templates/viewer.php` needs to be updated to match `js/vendor/pdfjs/web/viewer.html`

6. Test the app ;)


Maintainers
===========
- [Lukas Reschke](https://github.com/LukasReschke)
24 changes: 24 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "files_pdfviewer",
"homepage": "https://github.com/owncloud/files_pdfviewer",
"authors": [
"Victor Dubiniuk <dubiniuk@owncloud.com>"
],
"description": "ownCloud pdf viewer app",
"main": "",
"license": "AGPL",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"pdfjs": "~1.9.x"
},
"resolutions": {
"pdfjs": "~1.9.x"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
80 changes: 41 additions & 39 deletions vendor/pdfjs/web/debugger.js → js/vendor/pdfjs/web/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFJS */

'use strict';

Expand Down Expand Up @@ -65,7 +64,7 @@ var FontInspector = (function FontInspectorClosure() {
name: 'Font Inspector',
panel: null,
manager: null,
init: function init() {
init: function init(pdfjsLib) {
var panel = this.panel;
panel.setAttribute('style', 'padding: 5px;');
var tmp = document.createElement('button');
Expand Down Expand Up @@ -120,7 +119,7 @@ var FontInspector = (function FontInspectorClosure() {
download.href = url[1];
} else if (fontObj.data) {
url = URL.createObjectURL(new Blob([fontObj.data], {
type: fontObj.mimeType
type: fontObj.mimeType,
}));
download.href = url;
}
Expand Down Expand Up @@ -150,29 +149,31 @@ var FontInspector = (function FontInspectorClosure() {
fonts.appendChild(font);
// Somewhat of a hack, should probably add a hook for when the text layer
// is done rendering.
setTimeout(function() {
setTimeout(() => {
if (this.active) {
resetSelection();
}
}.bind(this), 2000);
}
}, 2000);
},
};
})();

var opMap;

// Manages all the page steppers.
var StepperManager = (function StepperManagerClosure() {
var steppers = [];
var stepperDiv = null;
var stepperControls = null;
var stepperChooser = null;
var breakPoints = {};
var breakPoints = Object.create(null);
return {
// Properties/functions needed by PDFBug.
id: 'Stepper',
name: 'Stepper',
panel: null,
manager: null,
init: function init() {
init: function init(pdfjsLib) {
var self = this;
this.panel.setAttribute('style', 'padding: 5px;');
stepperControls = document.createElement('div');
Expand All @@ -187,6 +188,11 @@ var StepperManager = (function StepperManagerClosure() {
if (sessionStorage.getItem('pdfjsBreakPoints')) {
breakPoints = JSON.parse(sessionStorage.getItem('pdfjsBreakPoints'));
}

opMap = Object.create(null);
for (var key in pdfjsLib.OPS) {
opMap[pdfjsLib.OPS[key]] = key;
}
},
cleanup: function cleanup() {
stepperChooser.textContent = '';
Expand Down Expand Up @@ -237,7 +243,7 @@ var StepperManager = (function StepperManagerClosure() {
saveBreakPoints: function saveBreakPoints(pageIndex, bps) {
breakPoints[pageIndex] = bps;
sessionStorage.setItem('pdfjsBreakPoints', JSON.stringify(breakPoints));
}
},
};
})();

Expand All @@ -252,8 +258,6 @@ var Stepper = (function StepperClosure() {
return d;
}

var opMap = null;

function simplifyArgs(args) {
if (typeof args === 'string') {
var MAX_STRING_LENGTH = 75;
Expand Down Expand Up @@ -291,7 +295,7 @@ var Stepper = (function StepperClosure() {
this.operatorListIdx = 0;
}
Stepper.prototype = {
init: function init() {
init: function init(operatorList) {
var panel = this.panel;
var content = c('div', 'c=continue, s=step');
var table = c('table');
Expand All @@ -305,12 +309,7 @@ var Stepper = (function StepperClosure() {
headerRow.appendChild(c('th', 'args'));
panel.appendChild(content);
this.table = table;
if (!opMap) {
opMap = Object.create(null);
for (var key in PDFJS.OPS) {
opMap[PDFJS.OPS[key]] = key;
}
}
this.updateOperatorList(operatorList);
},
updateOperatorList: function updateOperatorList(operatorList) {
var self = this;
Expand Down Expand Up @@ -388,7 +387,9 @@ var Stepper = (function StepperClosure() {
this.table.appendChild(chunk);
},
getNextBreakPoint: function getNextBreakPoint() {
this.breakPoints.sort(function(a, b) { return a - b; });
this.breakPoints.sort(function(a, b) {
return a - b;
});
for (var i = 0; i < this.breakPoints.length; i++) {
if (this.breakPoints[i] > this.currentIdx) {
return this.breakPoints[i];
Expand All @@ -404,21 +405,21 @@ var Stepper = (function StepperClosure() {
var listener = function(e) {
switch (e.keyCode) {
case 83: // step
dom.removeEventListener('keydown', listener, false);
dom.removeEventListener('keydown', listener);
self.nextBreakPoint = self.currentIdx + 1;
self.goTo(-1);
callback();
break;
case 67: // continue
dom.removeEventListener('keydown', listener, false);
dom.removeEventListener('keydown', listener);
var breakPoint = self.getNextBreakPoint();
self.nextBreakPoint = breakPoint;
self.goTo(-1);
callback();
break;
}
};
dom.addEventListener('keydown', listener, false);
dom.addEventListener('keydown', listener);
self.goTo(idx);
},
goTo: function goTo(idx) {
Expand All @@ -432,7 +433,7 @@ var Stepper = (function StepperClosure() {
row.style.backgroundColor = null;
}
}
}
},
};
return Stepper;
})();
Expand All @@ -458,14 +459,14 @@ var Stats = (function Stats() {
name: 'Stats',
panel: null,
manager: null,
init: function init() {
init(pdfjsLib) {
this.panel.setAttribute('style', 'padding: 5px;');
PDFJS.enableStats = true;
pdfjsLib.PDFJS.enableStats = true;
},
enabled: false,
active: false,
// Stats specific functions.
add: function(pageNumber, stat) {
add(pageNumber, stat) {
if (!stat) {
return;
}
Expand All @@ -484,22 +485,24 @@ var Stats = (function Stats() {
statsDiv.textContent = stat.toString();
wrapper.appendChild(title);
wrapper.appendChild(statsDiv);
stats.push({ pageNumber: pageNumber, div: wrapper });
stats.sort(function(a, b) { return a.pageNumber - b.pageNumber; });
stats.push({ pageNumber, div: wrapper, });
stats.sort(function(a, b) {
return a.pageNumber - b.pageNumber;
});
clear(this.panel);
for (var i = 0, ii = stats.length; i < ii; ++i) {
this.panel.appendChild(stats[i].div);
}
},
cleanup: function () {
cleanup() {
stats = [];
clear(this.panel);
}
},
};
})();

// Manages all the debugging tools.
var PDFBug = (function PDFBugClosure() {
window.PDFBug = (function PDFBugClosure() {
var panelWidth = 300;
var buttons = [];
var activePanel = null;
Expand All @@ -510,7 +513,7 @@ var PDFBug = (function PDFBugClosure() {
StepperManager,
Stats
],
enable: function(ids) {
enable(ids) {
var all = false, tools = this.tools;
if (ids.length === 1 && ids[0] === 'all') {
all = true;
Expand All @@ -532,7 +535,7 @@ var PDFBug = (function PDFBugClosure() {
});
}
},
init: function init() {
init(pdfjsLib, container) {
/*
* Basic Layout:
* PDFBug
Expand All @@ -553,7 +556,6 @@ var PDFBug = (function PDFBugClosure() {
panels.setAttribute('class', 'panels');
ui.appendChild(panels);

var container = document.getElementById('viewerContainer');
container.appendChild(ui);
container.style.right = panelWidth + 'px';

Expand All @@ -576,24 +578,24 @@ var PDFBug = (function PDFBugClosure() {
tool.panel = panel;
tool.manager = this;
if (tool.enabled) {
tool.init();
tool.init(pdfjsLib);
} else {
panel.textContent = tool.name + ' is disabled. To enable add ' +
' "' + tool.id + '" to the pdfBug parameter ' +
'and refresh (seperate multiple by commas).';
'and refresh (separate multiple by commas).';
}
buttons.push(panelButton);
}
this.selectPanel(0);
},
cleanup: function cleanup() {
cleanup() {
for (var i = 0, ii = this.tools.length; i < ii; i++) {
if (this.tools[i].enabled) {
this.tools[i].cleanup();
}
}
},
selectPanel: function selectPanel(index) {
selectPanel(index) {
if (typeof index !== 'number') {
index = this.tools.indexOf(index);
}
Expand All @@ -613,6 +615,6 @@ var PDFBug = (function PDFBugClosure() {
tools[j].panel.setAttribute('hidden', 'true');
}
}
}
},
};
})();
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added js/vendor/pdfjs/web/images/texture.png

0 comments on commit 83cebef

Please sign in to comment.