[Pkg-javascript-commits] [pdf.js] 80/119: Re-ordering the PDFPresentationMode code so that the "public" functions are placed towards the top of the file

David Prévot taffit at moszumanska.debian.org
Wed May 13 21:27:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 4edee12e92618c5450baa4531a380d69825a7fe0
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Tue Feb 3 12:17:57 2015 +0100

    Re-ordering the PDFPresentationMode code so that the "public" functions are placed towards the top of the file
---
 web/pdf_presentation_mode.js | 228 +++++++++++++++++++++----------------------
 1 file changed, 114 insertions(+), 114 deletions(-)

diff --git a/web/pdf_presentation_mode.js b/web/pdf_presentation_mode.js
index ca5d46a..5952ce2 100644
--- a/web/pdf_presentation_mode.js
+++ b/web/pdf_presentation_mode.js
@@ -68,6 +68,86 @@ var PDFPresentationMode = {
     }
   },
 
+  /**
+   * Request the browser to enter fullscreen mode.
+   * @returns {boolean} Indicating if the request was successful.
+   */
+  request: function pdfPresentationModeRequest() {
+    if (!this.initialized || this.switchInProgress || this.active ||
+        !this.viewer.hasChildNodes()) {
+      return false;
+    }
+    this._setSwitchInProgress();
+    this._notifyStateChange();
+
+    if (this.container.requestFullscreen) {
+      this.container.requestFullscreen();
+    } else if (this.container.mozRequestFullScreen) {
+      this.container.mozRequestFullScreen();
+    } else if (this.container.webkitRequestFullscreen) {
+      this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
+    } else if (this.container.msRequestFullscreen) {
+      this.container.msRequestFullscreen();
+    } else {
+      return false;
+    }
+
+    this.args = {
+      page: PDFViewerApplication.page,
+      previousScale: PDFViewerApplication.currentScaleValue
+    };
+
+    return true;
+  },
+
+  /**
+   * Switches page when the user scrolls (using a scroll wheel or a touchpad)
+   * with large enough motion, to prevent accidental page switches.
+   * @param {number} delta - The delta value from the mouse event.
+   */
+  mouseScroll: function pdfPresentationModeMouseScroll(delta) {
+    if (!this.initialized && !this.active) {
+      return;
+    }
+    var MOUSE_SCROLL_COOLDOWN_TIME = 50;
+    var PAGE_SWITCH_THRESHOLD = 120;
+    var PageSwitchDirection = {
+      UP: -1,
+      DOWN: 1
+    };
+
+    var currentTime = (new Date()).getTime();
+    var storedTime = this.mouseScrollTimeStamp;
+
+    // If we've already switched page, avoid accidentally switching page again.
+    if (currentTime > storedTime &&
+        currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
+      return;
+    }
+    // If the user changes scroll direction, reset the accumulated scroll delta.
+    if ((this.mouseScrollDelta > 0 && delta < 0) ||
+        (this.mouseScrollDelta < 0 && delta > 0)) {
+      this._resetMouseScrollState();
+    }
+    this.mouseScrollDelta += delta;
+
+    if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
+      var pageSwitchDirection = (this.mouseScrollDelta > 0) ?
+        PageSwitchDirection.UP : PageSwitchDirection.DOWN;
+      var page = PDFViewerApplication.page;
+      this._resetMouseScrollState();
+
+      // If we're already on the first/last page, we don't need to do anything.
+      if ((page === 1 && pageSwitchDirection === PageSwitchDirection.UP) ||
+          (page === PDFViewerApplication.pagesCount &&
+           pageSwitchDirection === PageSwitchDirection.DOWN)) {
+        return;
+      }
+      PDFViewerApplication.page = (page + pageSwitchDirection);
+      this.mouseScrollTimeStamp = currentTime;
+    }
+  },
+
   get isFullscreen() {
     return !!(document.fullscreenElement ||
               document.mozFullScreen ||
@@ -88,6 +168,19 @@ var PDFPresentationMode = {
   },
 
   /**
+   * @private
+   */
+  _notifyStateChange: function pdfPresentationModeNotifyStateChange() {
+    var self = PDFPresentationMode;
+    var event = document.createEvent('CustomEvent');
+    event.initCustomEvent('presentationmodechanged', true, true, {
+      active: self.active,
+      switchInProgress: !!self.switchInProgress
+    });
+    window.dispatchEvent(event);
+  },
+
+  /**
    * Used to initialize a timeout when requesting Presentation Mode,
    * i.e. when the browser is requested to enter fullscreen mode.
    * This timeout is used to prevent the current page from being scrolled
@@ -116,51 +209,6 @@ var PDFPresentationMode = {
   },
 
   /**
-   * Request the browser to enter fullscreen mode.
-   * @returns {boolean} Indicating if the request was successful.
-   */
-  request: function pdfPresentationModeRequest() {
-    if (!this.initialized || this.switchInProgress || this.active ||
-        !this.viewer.hasChildNodes()) {
-      return false;
-    }
-    this._setSwitchInProgress();
-    this._notifyStateChange();
-
-    if (this.container.requestFullscreen) {
-      this.container.requestFullscreen();
-    } else if (this.container.mozRequestFullScreen) {
-      this.container.mozRequestFullScreen();
-    } else if (this.container.webkitRequestFullscreen) {
-      this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
-    } else if (this.container.msRequestFullscreen) {
-      this.container.msRequestFullscreen();
-    } else {
-      return false;
-    }
-
-    this.args = {
-      page: PDFViewerApplication.page,
-      previousScale: PDFViewerApplication.currentScaleValue
-    };
-
-    return true;
-  },
-
-  /**
-   * @private
-   */
-  _notifyStateChange: function pdfPresentationModeNotifyStateChange() {
-    var self = PDFPresentationMode;
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('presentationmodechanged', true, true, {
-      active: self.active,
-      switchInProgress: !!self.switchInProgress
-    });
-    window.dispatchEvent(event);
-  },
-
-  /**
    * @private
    */
   _enter: function pdfPresentationModeEnter() {
@@ -225,35 +273,6 @@ var PDFPresentationMode = {
   /**
    * @private
    */
-  _showControls: function pdfPresentationModeShowControls() {
-    var self = PDFPresentationMode;
-    if (self.controlsTimeout) {
-      clearTimeout(self.controlsTimeout);
-    } else {
-      self.container.classList.add(SELECTOR);
-    }
-    self.controlsTimeout = setTimeout(function showControlsTimeout() {
-      self.container.classList.remove(SELECTOR);
-      delete self.controlsTimeout;
-    }, DELAY_BEFORE_HIDING_CONTROLS);
-  },
-
-  /**
-   * @private
-   */
-  _hideControls: function pdfPresentationModeHideControls() {
-    var self = PDFPresentationMode;
-    if (!self.controlsTimeout) {
-      return;
-    }
-    clearTimeout(self.controlsTimeout);
-    self.container.classList.remove(SELECTOR);
-    delete self.controlsTimeout;
-  },
-
-  /**
-   * @private
-   */
   _mouseDown: function pdfPresentationModeMouseDown(evt) {
     var self = PDFPresentationMode;
     if (self.contextMenuOpen) {
@@ -282,51 +301,32 @@ var PDFPresentationMode = {
   },
 
   /**
-   * Switches page when the user scrolls (using a scroll wheel or a touchpad)
-   * with large enough motion, to prevent accidental page switches.
-   * @param {number} delta - The delta value from the mouse event.
+   * @private
    */
-  mouseScroll: function pdfPresentationModeMouseScroll(delta) {
-    if (!this.initialized && !this.active) {
-      return;
+  _showControls: function pdfPresentationModeShowControls() {
+    var self = PDFPresentationMode;
+    if (self.controlsTimeout) {
+      clearTimeout(self.controlsTimeout);
+    } else {
+      self.container.classList.add(SELECTOR);
     }
-    var MOUSE_SCROLL_COOLDOWN_TIME = 50;
-    var PAGE_SWITCH_THRESHOLD = 120;
-    var PageSwitchDirection = {
-      UP: -1,
-      DOWN: 1
-    };
-
-    var currentTime = (new Date()).getTime();
-    var storedTime = this.mouseScrollTimeStamp;
+    self.controlsTimeout = setTimeout(function showControlsTimeout() {
+      self.container.classList.remove(SELECTOR);
+      delete self.controlsTimeout;
+    }, DELAY_BEFORE_HIDING_CONTROLS);
+  },
 
-    // If we've already switched page, avoid accidentally switching page again.
-    if (currentTime > storedTime &&
-        currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
+  /**
+   * @private
+   */
+  _hideControls: function pdfPresentationModeHideControls() {
+    var self = PDFPresentationMode;
+    if (!self.controlsTimeout) {
       return;
     }
-    // If the user changes scroll direction, reset the accumulated scroll delta.
-    if ((this.mouseScrollDelta > 0 && delta < 0) ||
-        (this.mouseScrollDelta < 0 && delta > 0)) {
-      this._resetMouseScrollState();
-    }
-    this.mouseScrollDelta += delta;
-
-    if (Math.abs(this.mouseScrollDelta) >= PAGE_SWITCH_THRESHOLD) {
-      var pageSwitchDirection = (this.mouseScrollDelta > 0) ?
-        PageSwitchDirection.UP : PageSwitchDirection.DOWN;
-      var page = PDFViewerApplication.page;
-      this._resetMouseScrollState();
-
-      // If we're already on the first/last page, we don't need to do anything.
-      if ((page === 1 && pageSwitchDirection === PageSwitchDirection.UP) ||
-          (page === PDFViewerApplication.pagesCount &&
-           pageSwitchDirection === PageSwitchDirection.DOWN)) {
-        return;
-      }
-      PDFViewerApplication.page = (page + pageSwitchDirection);
-      this.mouseScrollTimeStamp = currentTime;
-    }
+    clearTimeout(self.controlsTimeout);
+    self.container.classList.remove(SELECTOR);
+    delete self.controlsTimeout;
   },
 
   /**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list