From 865a6e663af155eeac34ae575559ab1593c62a5b Mon Sep 17 00:00:00 2001 From: notmasteryet <async.processingjs@yahoo.com> Date: Mon, 5 Sep 2011 09:07:18 -0500 Subject: [PATCH] Fixing #426 comment; add '0' key as a scale reset --- web/images/{list-add.svg => zoom-in.svg} | 0 web/images/{list-remove.svg => zoom-out.svg} | 0 web/viewer.html | 6 ++++-- web/viewer.js | 22 ++++++++++++-------- 4 files changed, 17 insertions(+), 11 deletions(-) rename web/images/{list-add.svg => zoom-in.svg} (100%) rename web/images/{list-remove.svg => zoom-out.svg} (100%) diff --git a/web/images/list-add.svg b/web/images/zoom-in.svg similarity index 100% rename from web/images/list-add.svg rename to web/images/zoom-in.svg diff --git a/web/images/list-remove.svg b/web/images/zoom-out.svg similarity index 100% rename from web/images/list-remove.svg rename to web/images/zoom-out.svg diff --git a/web/viewer.html b/web/viewer.html index a86891796..d37270661 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -34,12 +34,14 @@ <div class="separator"></div> <button id="next" title="Zoom Out" onclick="PDFView.zoomOut();"> - <img src="images/list-remove.svg" align="top" height="32"/> + <img src="images/zoom-out.svg" align="top" height="32"/> </button> <button id="next" title="Zoom In" onclick="PDFView.zoomIn();"> - <img src="images/list-add.svg" align="top" height="32"/> + <img src="images/zoom-in.svg" align="top" height="32"/> </button> + <div class="separator"></div> + <select id="scaleSelect" onchange="PDFView.parseScale(this.value);"> <option id="customScaleOption" value="custom"></option> <option value="0.5">50%</option> diff --git a/web/viewer.js b/web/viewer.js index a29ecf703..811cfcbcc 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -45,13 +45,14 @@ var PDFView = { }, parseScale: function(value) { + if ('custom' == value) + return; + var scale = parseFloat(value); if (scale) { this.setScale(scale, true); return; } - if ('custom' == value) - return; var currentPage = this.pages[this.page - 1]; var scrollbarPadding = 40; @@ -493,7 +494,7 @@ window.addEventListener('scalechange', function scalechange(evt) { var value = '' + evt.scale; for (var i = 0; i < options.length; i++) { var option = options[i]; - if (option.value != evt.scale) { + if (option.value != value) { option.selected = false; continue; } @@ -517,16 +518,19 @@ window.addEventListener('pagechange', function pagechange(evt) { document.getElementById('next').disabled = (page == PDFView.pages.length); }, true); -window.addEventListener('keydown', function (evt) { +window.addEventListener('keydown', function keydown(evt) { switch(evt.keyCode) { - case 61: // '+' and '=' keys - case 107: - case 187: + case 61: // FF/Mac '=' + case 107: // FF '+' and '=' + case 187: // Chrome '+' PDFView.zoomIn(); break; - case 109: // '-' keys - case 189: + case 109: // FF '-' + case 189: // Chrome '-' PDFView.zoomOut(); break; + case 48: // '0' + PDFView.setScale(kDefaultScale, true); + break; } });