mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Open menu on long-press.
This commit is contained in:
		| @@ -158,7 +158,7 @@ var GuacamoleUI = { | |||||||
|     var detectMenuCloseTimeout = null; |     var detectMenuCloseTimeout = null; | ||||||
|  |  | ||||||
|     // Clear detection timeouts |     // Clear detection timeouts | ||||||
|     function resetMenuDetect() { |     GuacamoleUI.resetMenuDetect = function() { | ||||||
|  |  | ||||||
|         if (detectMenuOpenTimeout != null) { |         if (detectMenuOpenTimeout != null) { | ||||||
|             window.clearTimeout(detectMenuOpenTimeout); |             window.clearTimeout(detectMenuOpenTimeout); | ||||||
| @@ -170,54 +170,61 @@ var GuacamoleUI = { | |||||||
|             detectMenuCloseTimeout = null; |             detectMenuCloseTimeout = null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     } |     }; | ||||||
|  |  | ||||||
|     // Initiate detection of menu open action. If not canceled through some |     // Initiate detection of menu open action. If not canceled through some | ||||||
|     // user event, menu will open. |     // user event, menu will open. | ||||||
|     function startMenuOpenDetect() { |     GuacamoleUI.startMenuOpenDetect = function() { | ||||||
|  |  | ||||||
|         // Clear detection state |         if (!detectMenuOpenTimeout) { | ||||||
|         resetMenuDetect(); |  | ||||||
|  |  | ||||||
|         // Wait and then show menu |             // Clear detection state | ||||||
|         detectMenuOpenTimeout = window.setTimeout(function() { |             GuacamoleUI.resetMenuDetect(); | ||||||
|             GuacamoleUI.showMenu(); |  | ||||||
|             detectMenuOpenTimeout = null; |  | ||||||
|         }, 325); |  | ||||||
|  |  | ||||||
|     } |             // Wait and then show menu | ||||||
|  |             detectMenuOpenTimeout = window.setTimeout(function() { | ||||||
|  |                 GuacamoleUI.showMenu(); | ||||||
|  |                 detectMenuOpenTimeout = null; | ||||||
|  |             }, 325); | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |     }; | ||||||
|  |  | ||||||
|     // Initiate detection of menu close action. If not canceled through some |     // Initiate detection of menu close action. If not canceled through some | ||||||
|     // user event, menu will close. |     // user event, menu will close. | ||||||
|     function startMenuCloseDetect() { |     GuacamoleUI.startMenuCloseDetect = function() { | ||||||
|  |  | ||||||
|         // Clear detection state |         if (!detectMenuCloseTimeout) { | ||||||
|         resetMenuDetect(); |  | ||||||
|  |  | ||||||
|         // Wait and then shade menu |             // Clear detection state | ||||||
|         detectMenuCloseTimeout = window.setTimeout(function() { |             GuacamoleUI.resetMenuDetect(); | ||||||
|             GuacamoleUI.shadeMenu(); |  | ||||||
|             detectMenuCloseTimeout = null; |  | ||||||
|         }, 500); |  | ||||||
|  |  | ||||||
|     } |             // Wait and then shade menu | ||||||
|  |             detectMenuCloseTimeout = window.setTimeout(function() { | ||||||
|  |                 GuacamoleUI.shadeMenu(); | ||||||
|  |                 detectMenuCloseTimeout = null; | ||||||
|  |             }, 500); | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |     }; | ||||||
|  |  | ||||||
|     // Show menu if mouseover any part of menu |     // Show menu if mouseover any part of menu | ||||||
|     GuacamoleUI.menu.addEventListener('mouseover', GuacamoleUI.showMenu, true); |     GuacamoleUI.menu.addEventListener('mouseover', GuacamoleUI.showMenu, true); | ||||||
|  |  | ||||||
|     // Stop detecting menu state change intents if mouse is over menu |     // Stop detecting menu state change intents if mouse is over menu | ||||||
|     GuacamoleUI.menu.addEventListener('mouseover', resetMenuDetect, true); |     GuacamoleUI.menu.addEventListener('mouseover', GuacamoleUI.resetMenuDetect, true); | ||||||
|  |  | ||||||
|     // When mouse hovers over top of screen, start detection of intent to open menu |     // When mouse hovers over top of screen, start detection of intent to open menu | ||||||
|     GuacamoleUI.menuControl.addEventListener('mousemove', startMenuOpenDetect, true); |     GuacamoleUI.menuControl.addEventListener('mousemove', GuacamoleUI.startMenuOpenDetect, true); | ||||||
|  |  | ||||||
|     // When mouse enters display, start detection of intent to close menu |     // When mouse enters display, start detection of intent to close menu | ||||||
|     GuacamoleUI.display.addEventListener('mouseover', startMenuCloseDetect, true); |     GuacamoleUI.display.addEventListener('mouseover', GuacamoleUI.startMenuCloseDetect, true); | ||||||
|  |  | ||||||
|     var menuShowLongPressTimeout = null; |     var menuShowLongPressTimeout = null; | ||||||
|  |  | ||||||
|     // Detect long-press at bottom of screen |     GuacamoleUI.startLongPressDetect = function() { | ||||||
|     document.body.addEventListener('touchstart', function(e) { |  | ||||||
|  |  | ||||||
|         if (!menuShowLongPressTimeout) { |         if (!menuShowLongPressTimeout) { | ||||||
|  |  | ||||||
| @@ -229,22 +236,15 @@ var GuacamoleUI = { | |||||||
|             }, 1000); |             }, 1000); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |     }; | ||||||
|  |  | ||||||
|     }, true); |     GuacamoleUI.stopLongPressDetect = function() { | ||||||
|  |  | ||||||
|     // Reset detection when touch stops |  | ||||||
|     document.body.addEventListener('touchend', function() { |  | ||||||
|  |  | ||||||
|         // Reset opacity, stop detection of keyboard show gesture |  | ||||||
|         GuacamoleUI.shadeMenu(); |  | ||||||
|         window.clearTimeout(menuShowLongPressTimeout); |         window.clearTimeout(menuShowLongPressTimeout); | ||||||
|         menuShowLongPressTimeout = null; |         menuShowLongPressTimeout = null; | ||||||
|  |     }; | ||||||
|  |  | ||||||
|     }, false); |     // Detect long-press at bottom of screen | ||||||
|  |     document.body.addEventListener('touchstart', GuacamoleUI.startLongPressDetect, true); | ||||||
|     GuacamoleUI.menu.addEventListener('touchend', function(e) { |  | ||||||
|         e.stopPropagation(); |  | ||||||
|     }, false); |  | ||||||
|  |  | ||||||
|     // Show menu if mouse leaves document |     // Show menu if mouse leaves document | ||||||
|     document.addEventListener('mouseout', function(e) { |     document.addEventListener('mouseout', function(e) { | ||||||
| @@ -261,7 +261,7 @@ var GuacamoleUI = { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Start detection of intent to open menu |         // Start detection of intent to open menu | ||||||
|         startMenuOpenDetect(); |         GuacamoleUI.startMenuOpenDetect(); | ||||||
|   |   | ||||||
|     }, true); |     }, true); | ||||||
|  |  | ||||||
| @@ -327,6 +327,12 @@ GuacamoleUI.attach = function(guac) { | |||||||
|             // Scroll (if necessary) to keep mouse on screen. |             // Scroll (if necessary) to keep mouse on screen. | ||||||
|             window.scrollBy(scroll_amount_x, scroll_amount_y); |             window.scrollBy(scroll_amount_x, scroll_amount_y); | ||||||
|         |         | ||||||
|  |             // Hide menu on movement | ||||||
|  |             GuacamoleUI.startMenuCloseDetect(); | ||||||
|  |  | ||||||
|  |             // Stop detecting long presses if mouse is being used | ||||||
|  |             GuacamoleUI.stopLongPressDetect(); | ||||||
|  |  | ||||||
|             // Send mouse event |             // Send mouse event | ||||||
|             guac.sendMouseState(mouseState); |             guac.sendMouseState(mouseState); | ||||||
|              |              | ||||||
|   | |||||||
| @@ -24,10 +24,20 @@ body { | |||||||
|     margin: 0; |     margin: 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | img { | ||||||
|  |     border: none; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .guac-hide-cursor { | ||||||
|  |     cursor: url('../images/mouse/dot.gif'),url('../images/mouse/blank.cur'),default; | ||||||
|  | } | ||||||
|  |  | ||||||
| * { | * { | ||||||
|     -webkit-tap-highlight-color: rgba(0,0,0,0); |     -webkit-tap-highlight-color: rgba(0,0,0,0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* Dialogs */ | ||||||
|  |  | ||||||
| div.dialogOuter { | div.dialogOuter { | ||||||
|     display: table; |     display: table; | ||||||
|     height: 100%; |     height: 100%; | ||||||
| @@ -37,18 +47,6 @@ div.dialogOuter { | |||||||
|     top: 0; |     top: 0; | ||||||
|  |  | ||||||
|     visibility: hidden; |     visibility: hidden; | ||||||
|     /* |  | ||||||
|     background-image: url('../images/spinner.gif'); |  | ||||||
|     background-position: center; |  | ||||||
|     background-repeat: no-repeat; |  | ||||||
|     */ |  | ||||||
|  |  | ||||||
|     /* |  | ||||||
|     background-image: url('../images/noimage.png'); |  | ||||||
|     background-position: center; |  | ||||||
|     background-repeat: no-repeat; |  | ||||||
|     */ |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| div.dialogMiddle { | div.dialogMiddle { | ||||||
| @@ -88,6 +86,20 @@ div.dialog p { | |||||||
|     margin: 0; |     margin: 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #statusText { | ||||||
|  |     text-shadow: 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black; | ||||||
|  |     font-weight: bold; | ||||||
|  |     font-size: xx-large; | ||||||
|  |     color: white; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .guac-error #statusText { | ||||||
|  |     text-shadow: 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black; | ||||||
|  |     color: #D44; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* Menu */ | ||||||
|  |  | ||||||
| #menu { | #menu { | ||||||
|     position: fixed; |     position: fixed; | ||||||
|     left: 0; |     left: 0; | ||||||
| @@ -103,22 +115,6 @@ div.dialog p { | |||||||
|     background: #D44; |     background: #D44; | ||||||
| } | } | ||||||
|  |  | ||||||
| #statusText { |  | ||||||
|     text-shadow: 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black; |  | ||||||
|     font-weight: bold; |  | ||||||
|     font-size: xx-large; |  | ||||||
|     color: white; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| .guac-error #statusText { |  | ||||||
|     text-shadow: 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black, 0 0 0.25em black; |  | ||||||
|     color: #D44; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| img { |  | ||||||
|     border: none; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| div#display { | div#display { | ||||||
|     position: relative; |     position: relative; | ||||||
|     width: 640px; |     width: 640px; | ||||||
| @@ -165,10 +161,6 @@ div#clipboardDiv textarea { | |||||||
|     width: 100%; |     width: 100%; | ||||||
| } | } | ||||||
|  |  | ||||||
| .guac-hide-cursor { |  | ||||||
|     cursor: url('../images/mouse/dot.gif'),url('../images/mouse/blank.cur'),default; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| div#menuControl { | div#menuControl { | ||||||
|     position: fixed; |     position: fixed; | ||||||
|     top: 0; |     top: 0; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user