You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2018/05/17 19:49:53 UTC

[5/7] guacamole-client git commit: GUACAMOLE-152: Handle zoom changes with autoFit correctly.

GUACAMOLE-152: Handle zoom changes with autoFit correctly.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/b34d97f8
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/b34d97f8
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/b34d97f8

Branch: refs/heads/master
Commit: b34d97f82dc5a9b28a89e2072b3ec477fda17464
Parents: b4c8bc8
Author: Nick Couchman <vn...@apache.org>
Authored: Sat May 12 08:13:15 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Sat May 12 08:13:15 2018 -0400

----------------------------------------------------------------------
 .../webapp/app/client/controllers/clientController.js     | 10 ++++++++++
 .../src/main/webapp/app/client/directives/guacZoomCtrl.js |  8 +++++++-
 .../src/main/webapp/app/client/templates/client.html      |  3 ++-
 3 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/b34d97f8/guacamole/src/main/webapp/app/client/controllers/clientController.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/controllers/clientController.js b/guacamole/src/main/webapp/app/client/controllers/clientController.js
index 4fce87b..af1d726 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) {

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/b34d97f8/guacamole/src/main/webapp/app/client/directives/guacZoomCtrl.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/directives/guacZoomCtrl.js b/guacamole/src/main/webapp/app/client/directives/guacZoomCtrl.js
index 5971439..3e5b468 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) {

http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/b34d97f8/guacamole/src/main/webapp/app/client/templates/client.html
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/client/templates/client.html b/guacamole/src/main/webapp/app/client/templates/client.html
index 5abea64..6fda594 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 @@
                             <div class="zoom-ctrl">
                                 <input type="number" class="zoom-ctrl" guac-zoom-ctrl
                                         ng-model="client.clientProperties.scale"
-                                        ng-model-options="{ updateOn: 'blur submit' }" />%
+                                        ng-model-options="{ updateOn: 'blur submit' }"
+                                        ng-change="zoomSet();" />%
                             </div>
                             <div ng-click="zoomIn()" id="zoom-in"><img src="images/settings/zoom-in.png" alt="+"/></div>
                         </div>