Add new 'Auto' option for the viewer.

This commit is contained in:
Julian Viereck 2011-12-22 18:24:13 +01:00
parent 78f7354dc7
commit 997e094bdc
2 changed files with 10 additions and 3 deletions

View File

@ -67,10 +67,11 @@
<option value="0.75">75%</option> <option value="0.75">75%</option>
<option value="1">100%</option> <option value="1">100%</option>
<option value="1.25">125%</option> <option value="1.25">125%</option>
<option value="1.5" selected="selected">150%</option> <option value="1.5">150%</option>
<option value="2">200%</option> <option value="2">200%</option>
<option id="pageWidthOption" value="page-width">Page Width</option> <option id="pageWidthOption" value="page-width">Page Width</option>
<option id="pageFitOption" value="page-fit">Page Fit</option> <option id="pageFitOption" value="page-fit">Page Fit</option>
<option id="pageAutoOption" value="auto" selected="selected">Auto</option>
</select> </select>
<div class="separator"></div> <div class="separator"></div>

View File

@ -4,7 +4,7 @@
'use strict'; 'use strict';
var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf'; var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf';
var kDefaultScale = 1.5; var kDefaultScale = 'auto';
var kDefaultScaleDelta = 1.1; var kDefaultScaleDelta = 1.1;
var kCacheSize = 20; var kCacheSize = 20;
var kCssUnits = 96.0 / 72.0; var kCssUnits = 96.0 / 72.0;
@ -187,6 +187,11 @@ var PDFView = {
this.setScale( this.setScale(
Math.min(pageWidthScale, pageHeightScale), resetAutoSettings); Math.min(pageWidthScale, pageHeightScale), resetAutoSettings);
} }
if ('auto' == value) {
this.setScale(Math.min(1.0, pageWidthScale), resetAutoSettings);
}
selectScaleOption(value);
}, },
zoomIn: function pdfViewZoomIn() { zoomIn: function pdfViewZoomIn() {
@ -1000,7 +1005,8 @@ window.addEventListener('webkitTransitionEnd', updateThumbViewArea, true);
window.addEventListener('resize', function webViewerResize(evt) { window.addEventListener('resize', function webViewerResize(evt) {
if (document.getElementById('pageWidthOption').selected || if (document.getElementById('pageWidthOption').selected ||
document.getElementById('pageFitOption').selected) document.getElementById('pageFitOption').selected ||
document.getElementById('pageAutoOption').selected)
PDFView.parseScale(document.getElementById('scaleSelect').value); PDFView.parseScale(document.getElementById('scaleSelect').value);
updateViewarea(); updateViewarea();
}); });