Clarify comments and variable names for viewDrag

This commit is contained in:
samhed 2016-04-26 23:21:32 +02:00
parent cd611a5326
commit e00698fef8
1 changed files with 19 additions and 21 deletions

View File

@ -984,38 +984,36 @@ var UI;
} }
}, },
// Update the viewport drag/move button // Update the viewport drag state
updateViewDrag: function(drag) { updateViewDrag: function(drag) {
if (!UI.rfb) return; if (!UI.rfb) return;
var vmb = $D('noVNC_view_drag_button'); var viewDragButton = $D('noVNC_view_drag_button');
// Check if viewport drag is possible // Check if viewport drag is possible. It is only possible
// if the remote display is clipping the client display.
if (UI.rfb_state === 'normal' && if (UI.rfb_state === 'normal' &&
UI.rfb.get_display().get_viewport() && UI.rfb.get_display().get_viewport() &&
UI.rfb.get_display().clippingDisplay()) { UI.rfb.get_display().clippingDisplay()) {
// Show and enable the drag button viewDragButton.style.display = "inline";
vmb.style.display = "inline"; viewDragButton.disabled = false;
vmb.disabled = false;
} else { } else {
// The VNC content is the same size as // The size of the remote display is the same or smaller
// or smaller than the display // than the client display. Make sure viewport drag isn't
// active when it can't be used.
if (UI.rfb.get_viewportDrag) { if (UI.rfb.get_viewportDrag) {
// Turn off viewport drag when it's viewDragButton.className = "noVNC_status_button";
// active since it can't be used here
vmb.className = "noVNC_status_button";
UI.rfb.set_viewportDrag(false); UI.rfb.set_viewportDrag(false);
} }
// Disable or hide the drag button // The button is disabled instead of hidden on touch devices
if (UI.rfb_state === 'normal' && UI.isTouchDevice) { if (UI.rfb_state === 'normal' && UI.isTouchDevice) {
vmb.style.display = "inline"; viewDragButton.style.display = "inline";
vmb.disabled = true; viewDragButton.disabled = true;
} else { } else {
vmb.style.display = "none"; viewDragButton.style.display = "none";
} }
return; return;
} }
@ -1023,10 +1021,10 @@ var UI;
if (typeof(drag) !== "undefined" && if (typeof(drag) !== "undefined" &&
typeof(drag) !== "object") { typeof(drag) !== "object") {
if (drag) { if (drag) {
vmb.className = "noVNC_status_button_selected"; viewDragButton.className = "noVNC_status_button_selected";
UI.rfb.set_viewportDrag(true); UI.rfb.set_viewportDrag(true);
} else { } else {
vmb.className = "noVNC_status_button"; viewDragButton.className = "noVNC_status_button";
UI.rfb.set_viewportDrag(false); UI.rfb.set_viewportDrag(false);
} }
} }
@ -1035,12 +1033,12 @@ var UI;
toggleViewDrag: function() { toggleViewDrag: function() {
if (!UI.rfb) return; if (!UI.rfb) return;
var vmb = $D('noVNC_view_drag_button'); var viewDragButton = $D('noVNC_view_drag_button');
if (UI.rfb.get_viewportDrag()) { if (UI.rfb.get_viewportDrag()) {
vmb.className = "noVNC_status_button"; viewDragButton.className = "noVNC_status_button";
UI.rfb.set_viewportDrag(false); UI.rfb.set_viewportDrag(false);
} else { } else {
vmb.className = "noVNC_status_button_selected"; viewDragButton.className = "noVNC_status_button_selected";
UI.rfb.set_viewportDrag(true); UI.rfb.set_viewportDrag(true);
} }
}, },