Merge pull request #676 from vingtetun/oncontextmenu

Fix issue 581 by adding oncontextmenu='return false;' to buttons
This commit is contained in:
notmasteryet 2011-10-17 19:15:19 -07:00
commit 7323e670b6
5 changed files with 32 additions and 17 deletions

View File

@ -710,7 +710,13 @@ var Font = (function Font() {
}; };
function createOS2Table(properties, override) { function createOS2Table(properties, override) {
var override = override || {}; override = override || {
unitsPerEm: 0,
yMax: 0,
yMin: 0,
ascent: 0,
descent: 0
};
var ulUnicodeRange1 = 0; var ulUnicodeRange1 = 0;
var ulUnicodeRange2 = 0; var ulUnicodeRange2 = 0;
@ -1322,7 +1328,8 @@ var Font = (function Font() {
'OS/2': stringToArray(createOS2Table(properties)), 'OS/2': stringToArray(createOS2Table(properties)),
// Character to glyphs mapping // Character to glyphs mapping
'cmap': createCMapTable(charstrings.slice(), font.glyphIds), 'cmap': createCMapTable(charstrings.slice(),
('glyphIds' in font) ? font.glyphIds: null),
// Font header // Font header
'head': (function fontFieldsHead() { 'head': (function fontFieldsHead() {
@ -2612,7 +2619,8 @@ var Type2CFF = (function type2CFF() {
if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255)) if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
unicode += kCmapGlyphOffset; unicode += kCmapGlyphOffset;
var width = isNum(mapping.width) ? mapping.width : defaultWidth; var width = ('width' in mapping) && isNum(mapping.width) ? mapping.width
: defaultWidth;
properties.encoding[code] = { properties.encoding[code] = {
unicode: unicode, unicode: unicode,
width: width width: width

12
pdf.js
View File

@ -5136,7 +5136,8 @@ var CanvasGraphics = (function canvasGraphics() {
stroke: function canvasGraphicsStroke() { stroke: function canvasGraphicsStroke() {
var ctx = this.ctx; var ctx = this.ctx;
var strokeColor = this.current.strokeColor; var strokeColor = this.current.strokeColor;
if (strokeColor && strokeColor.type === 'Pattern') { if (strokeColor && strokeColor.hasOwnProperty('type') &&
strokeColor.type === 'Pattern') {
// for patterns, we transform to pattern space, calculate // for patterns, we transform to pattern space, calculate
// the pattern, call stroke, and restore to user space // the pattern, call stroke, and restore to user space
ctx.save(); ctx.save();
@ -5157,7 +5158,8 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx; var ctx = this.ctx;
var fillColor = this.current.fillColor; var fillColor = this.current.fillColor;
if (fillColor && fillColor.type === 'Pattern') { if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
ctx.save(); ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx); ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill(); ctx.fill();
@ -5177,7 +5179,8 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx; var ctx = this.ctx;
var fillColor = this.current.fillColor; var fillColor = this.current.fillColor;
if (fillColor && fillColor.type === 'Pattern') { if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
ctx.save(); ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx); ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill(); ctx.fill();
@ -5187,7 +5190,8 @@ var CanvasGraphics = (function canvasGraphics() {
} }
var strokeColor = this.current.strokeColor; var strokeColor = this.current.strokeColor;
if (strokeColor && strokeColor.type === 'Pattern') { if (strokeColor && strokeColor.hasOwnProperty('type') &&
strokeColor.type === 'Pattern') {
ctx.save(); ctx.save();
ctx.strokeStyle = strokeColor.getPattern(ctx); ctx.strokeStyle = strokeColor.getPattern(ctx);
ctx.stroke(); ctx.stroke();

View File

@ -163,7 +163,7 @@
// IE9 text/html data URI // IE9 text/html data URI
(function checkDocumentDocumentModeCompatibility() { (function checkDocumentDocumentModeCompatibility() {
if (document.documentMode !== 9) if (!('documentMode' in document) || document.documentMode !== 9)
return; return;
// overriding the src property // overriding the src property
var originalSrcDescriptor = Object.getOwnPropertyDescriptor( var originalSrcDescriptor = Object.getOwnPropertyDescriptor(

View File

@ -17,12 +17,12 @@
<body> <body>
<div id="controls"> <div id="controls">
<button id="previous" onclick="PDFView.page--;"> <button id="previous" onclick="PDFView.page--;" oncontextmenu="return false;">
<img src="images/go-up.svg" align="top" height="32"/> <img src="images/go-up.svg" align="top" height="32"/>
Previous Previous
</button> </button>
<button id="next" onclick="PDFView.page++;"> <button id="next" onclick="PDFView.page++;" oncontextmenu="return false;">
<img src="images/go-down.svg" align="top" height="32"/> <img src="images/go-down.svg" align="top" height="32"/>
Next Next
</button> </button>
@ -36,16 +36,16 @@
<div class="separator"></div> <div class="separator"></div>
<button id="next" title="Zoom Out" onclick="PDFView.zoomOut();"> <button id="zoomOut" title="Zoom Out" onclick="PDFView.zoomOut();" oncontextmenu="return false;">
<img src="images/zoom-out.svg" align="top" height="32"/> <img src="images/zoom-out.svg" align="top" height="32"/>
</button> </button>
<button id="next" title="Zoom In" onclick="PDFView.zoomIn();"> <button id="zoomIn" title="Zoom In" onclick="PDFView.zoomIn();" oncontextmenu="return false;">
<img src="images/zoom-in.svg" align="top" height="32"/> <img src="images/zoom-in.svg" align="top" height="32"/>
</button> </button>
<div class="separator"></div> <div class="separator"></div>
<select id="scaleSelect" onchange="PDFView.parseScale(this.value);"> <select id="scaleSelect" onchange="PDFView.parseScale(this.value);" oncontextmenu="return false;">
<option id="customScaleOption" value="custom"></option> <option id="customScaleOption" value="custom"></option>
<option value="0.5">50%</option> <option value="0.5">50%</option>
<option value="0.75">75%</option> <option value="0.75">75%</option>
@ -59,14 +59,14 @@
<div class="separator"></div> <div class="separator"></div>
<button id="print" onclick="window.print();"> <button id="print" onclick="window.print();" oncontextmenu="return false;">
<img src="images/document-print.svg" align="top" height="32"/> <img src="images/document-print.svg" align="top" height="32"/>
Print Print
</button> </button>
<div class="separator"></div> <div class="separator"></div>
<input id="fileInput" type="file"/> <input id="fileInput" type="file" oncontextmenu="return false;"/>
<div class="separator"></div> <div class="separator"></div>

View File

@ -178,7 +178,9 @@ var PDFView = {
while (sidebar.hasChildNodes()) while (sidebar.hasChildNodes())
sidebar.removeChild(sidebar.lastChild); sidebar.removeChild(sidebar.lastChild);
clearInterval(sidebar._loadingInterval);
if ('_loadingInterval' in sidebar)
clearInterval(sidebar._loadingInterval);
var container = document.getElementById('viewer'); var container = document.getElementById('viewer');
while (container.hasChildNodes()) while (container.hasChildNodes())
@ -544,7 +546,8 @@ window.addEventListener('load', function webViewerLoad(evt) {
params[unescape(param[0])] = unescape(param[1]); params[unescape(param[0])] = unescape(param[1]);
} }
PDFView.open(params.file || kDefaultURL, parseFloat(params.scale)); var scale = ('scale' in params) ? params.scale : kDefaultScale;
PDFView.open(params.file || kDefaultURL, parseFloat(scale));
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) if (!window.File || !window.FileReader || !window.FileList || !window.Blob)
document.getElementById('fileInput').style.display = 'none'; document.getElementById('fileInput').style.display = 'none';