From e14d91716186096a418a1cf2b03ccd7a28006aed Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Fri, 17 Jan 2014 12:16:43 +0100 Subject: [PATCH] Close the secondary toolbar when an action is only performed once --- web/hand_tool.js | 5 +++-- web/secondary_toolbar.js | 8 ++++++++ web/viewer.js | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/web/hand_tool.js b/web/hand_tool.js index cd4b3054a..7b8f3eb2f 100644 --- a/web/hand_tool.js +++ b/web/hand_tool.js @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* globals mozL10n, GrabToPan, PDFView */ +/* globals mozL10n, GrabToPan, PDFView, SecondaryToolbar */ 'use strict'; @@ -42,13 +42,14 @@ var HandTool = { } }); if (toggleHandTool) { - toggleHandTool.addEventListener('click', this.handTool.toggle, false); + toggleHandTool.addEventListener('click', this.toggle.bind(this), false); } // TODO: Read global prefs and call this.handTool.activate() if needed. }, toggle: function handToolToggle() { this.handTool.toggle(); + SecondaryToolbar.close(); }, enterPresentationMode: function handToolEnterPresentationMode() { diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js index c9375823d..0d0389bd5 100644 --- a/web/secondary_toolbar.js +++ b/web/secondary_toolbar.js @@ -34,6 +34,7 @@ var SecondaryToolbar = { this.openFile = options.openFile; this.print = options.print; this.download = options.download; + this.viewBookmark = options.viewBookmark; this.firstPage = options.firstPage; this.lastPage = options.lastPage; this.pageRotateCw = options.pageRotateCw; @@ -50,6 +51,7 @@ var SecondaryToolbar = { { element: this.openFile, handler: this.openFileClick }, { element: this.print, handler: this.printClick }, { element: this.download, handler: this.downloadClick }, + { element: this.viewBookmark, handler: this.viewBookmarkClick }, { element: this.firstPage, handler: this.firstPageClick }, { element: this.lastPage, handler: this.lastPageClick }, { element: this.pageRotateCw, handler: this.pageRotateCwClick }, @@ -85,12 +87,18 @@ var SecondaryToolbar = { this.close(evt.target); }, + viewBookmarkClick: function secondaryToolbarViewBookmarkClick(evt) { + this.close(); + }, + firstPageClick: function secondaryToolbarFirstPageClick(evt) { PDFView.page = 1; + this.close(); }, lastPageClick: function secondaryToolbarLastPageClick(evt) { PDFView.page = PDFView.pdfDocument.numPages; + this.close(); }, pageRotateCwClick: function secondaryToolbarPageRotateCwClick(evt) { diff --git a/web/viewer.js b/web/viewer.js index f2ca40c3f..110b9945f 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -158,6 +158,7 @@ var PDFView = { openFile: document.getElementById('secondaryOpenFile'), print: document.getElementById('secondaryPrint'), download: document.getElementById('secondaryDownload'), + viewBookmark: document.getElementById('secondaryViewBookmark'), firstPage: document.getElementById('firstPage'), lastPage: document.getElementById('lastPage'), pageRotateCw: document.getElementById('pageRotateCw'),