loleaflet/src/map/Map.js |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit e02516d918ee0aaa9127721b1951957420b740a9
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun May 7 11:37:51 2017 -0400

    loleaflet: configurable dimming timeout and fire event
    
    Two timeout are now configurable.
    idleTimeoutSecs, which controls when to dim because
    of user inactivity, even if the tab is in focus.
    outOfFocusTimeoutSecs, which controls when to dim
    when the tab loses focus.
    
    Currently they are set to 15 minutes and 30 seconds
    respectively by default.
    
    User_Idle event is now fired on dimming.
    
    Change-Id: I894f6df44825b6814872f1c4986fab8dcd4d6cef
    Reviewed-on: https://gerrit.libreoffice.org/37373
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>
    (cherry picked from commit f9ee1c6150854b98e4519cd90c971b4726a0785c)
    Reviewed-on: https://gerrit.libreoffice.org/37413
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 755d99d0..49cb285c 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -18,7 +18,9 @@ L.Map = L.Evented.extend({
                defaultZoom: 10,
                tileWidthTwips: 3840,
                tileHeightTwips: 3840,
-               urlPrefix: 'lool'
+               urlPrefix: 'lool',
+               idleTimeoutSecs: 15 * 60,  // Dim when user is idle.
+               outOfFocusTimeoutSecs: 30, // Dim after switching tabs.
        },
 
        lastActiveTime: Date.now(),
@@ -853,12 +855,13 @@ L.Map = L.Evented.extend({
 
                this._doclayer && this._docLayer._onMessage('textselection:', 
null);
                console.debug('_dim: sending userinactive');
+               map.fire('postMessage', {msgId: 'User_Idle'});
                this._socket.sendMessage('userinactive');
        },
 
        _dimIfInactive: function () {
                console.debug('_dimIfInactive: diff=' + (Date.now() - 
this.lastActiveTime));
-               if ((Date.now() - this.lastActiveTime) >= 10 * 60 * 1000) { // 
Dim 10 minutes after last user activity
+               if ((Date.now() - this.lastActiveTime) >= 
this.options.idleTimeoutSecs * 1000) {
                        this._dim();
                } else {
                        this._startInactiveTimer();
@@ -894,7 +897,7 @@ L.Map = L.Evented.extend({
                var map = this;
                vex.timer = setTimeout(function() {
                        map._dim();
-               }, 30 * 1000); // Dim in 30 seconds.
+               }, this.options.outOfFocusTimeoutSecs * 1000);
        },
 
        _onLostFocus: function () {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to