From b34d97f82dc5a9b28a89e2072b3ec477fda17464 Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Sat, 12 May 2018 08:13:15 -0400 Subject: [PATCH] GUACAMOLE-152: Handle zoom changes with autoFit correctly. --- .../webapp/app/client/controllers/clientController.js | 10 ++++++++++ .../main/webapp/app/client/directives/guacZoomCtrl.js | 8 +++++++- .../src/main/webapp/app/client/templates/client.html | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js index 4fce87b3a..af1d72609 100644 --- a/guacamole/src/main/webapp/app/client/controllers/clientController.js +++ b/guacamole/src/main/webapp/app/client/controllers/clientController.js @@ -741,6 +741,16 @@ angular.module('client').controller('clientController', ['$scope', '$routeParams $scope.client.clientProperties.autoFit = false; $scope.client.clientProperties.scale -= 0.1; }; + + /** + * When zoom is manually set by entering a value + * into the controller, this method turns off autoFit, + * both in the menu and the clientProperties. + */ + $scope.zoomSet = function zoomSet() { + $scope.menu.autoFit = false; + $scope.client.clientProperties.autoFit = false; + }; $scope.changeAutoFit = function changeAutoFit() { if ($scope.menu.autoFit && $scope.client.clientProperties.minScale) { diff --git a/guacamole/src/main/webapp/app/client/directives/guacZoomCtrl.js b/guacamole/src/main/webapp/app/client/directives/guacZoomCtrl.js index 597143970..3e5b468da 100644 --- a/guacamole/src/main/webapp/app/client/directives/guacZoomCtrl.js +++ b/guacamole/src/main/webapp/app/client/directives/guacZoomCtrl.js @@ -26,7 +26,13 @@ angular.module('client').directive('guacZoomCtrl', function guacZoomCtrl() { restrict: 'A', require: 'ngModel', priority: 101, - link: function(scope, element, attr, ngModel) { + link: function(scope, element, attrs, ngModel) { + + // Evaluate the ngChange attribute when the model + // changes. + ngModel.$viewChangeListeners.push(function() { + scope.$eval(attrs.ngChange); + }); // When pushing to the menu, mutiply by 100. ngModel.$formatters.push(function(value) { diff --git a/guacamole/src/main/webapp/app/client/templates/client.html b/guacamole/src/main/webapp/app/client/templates/client.html index 5abea643f..6fda594db 100644 --- a/guacamole/src/main/webapp/app/client/templates/client.html +++ b/guacamole/src/main/webapp/app/client/templates/client.html @@ -154,7 +154,8 @@
% + ng-model-options="{ updateOn: 'blur submit' }" + ng-change="zoomSet();" />%
+