diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index c61260a400..65ac4467b8 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -187,6 +187,12 @@ define( navigationService.removeListener(setNavigation); }); + // If the user has selected an object (and is portrait + // on a phone), then hide the tree menu + $scope.$on("select-obj", function () { + $scope.treeSlide(); + }); + $scope.backArrow = navigateToParent; $scope.checkRoot = checkRoot; diff --git a/platform/commonUI/general/bundle.json b/platform/commonUI/general/bundle.json index f4ceed6ba1..7f5e2bfb86 100644 --- a/platform/commonUI/general/bundle.json +++ b/platform/commonUI/general/bundle.json @@ -11,8 +11,7 @@ }, { "key": "agentService", - "implementation": "/services/AgentService.js", - "depends": [ "$window" ] + "implementation": "/services/AgentService.js" } ], "runs": [ diff --git a/platform/commonUI/general/res/templates/tree-node.html b/platform/commonUI/general/res/templates/tree-node.html index 7f54b97180..9b094fe81d 100644 --- a/platform/commonUI/general/res/templates/tree-node.html +++ b/platform/commonUI/general/res/templates/tree-node.html @@ -29,15 +29,14 @@ key="'label'" mct-object="domainObject" ng-model="ngModel" - ng-click="!treeNode.checkMobile() ? ngModel.selectedObject = domainObject : - toggle.toggle(); treeNode.trackExpansion()" + ng-click="!treeNode.checkMobile() ? treeNode.setObject(ngModel, domainObject) : toggle.toggle(); treeNode.trackExpansion()" > diff --git a/platform/commonUI/general/src/controllers/TreeNodeController.js b/platform/commonUI/general/src/controllers/TreeNodeController.js index c55c3e2b6b..8d6becdfad 100644 --- a/platform/commonUI/general/src/controllers/TreeNodeController.js +++ b/platform/commonUI/general/src/controllers/TreeNodeController.js @@ -87,6 +87,17 @@ define( } } + // Sets the selected object in the tree, to be the + // currently represented object. If the user is on phone + // and in portrait mode, than, hide the tree menu + function setObject(ngModel, domainObject) { + ngModel.selectedObject = domainObject; + if (agentService.getOrientation() === "portrait" && + agentService.isPhone(navigator.userAgent)) { + $scope.$emit('select-obj'); + } + } + function checkMobile() { return agentService.isMobile(navigator.userAgent); } @@ -157,6 +168,8 @@ define( checkMobile: checkMobile, + setObject: setObject, + /** * Check if this not has ever been expanded. * @returns true if it has been expanded diff --git a/platform/commonUI/general/src/services/AgentService.js b/platform/commonUI/general/src/services/AgentService.js index 0d43cfdfa6..fa790e966f 100644 --- a/platform/commonUI/general/src/services/AgentService.js +++ b/platform/commonUI/general/src/services/AgentService.js @@ -35,7 +35,7 @@ define( * info using a comparison between the userAgent and key * device names */ - function AgentService($window) { + function AgentService() { // Gets the UA name if it is one of the following. // If it is not (a desktop for example) nothing is @@ -69,9 +69,9 @@ define( // Returns the orientation of the device based on the // device's window dimensions function getOrientation() { - if ($window.outerWidth > $window.outerHeight) { + if (window.innerWidth > window.innerHeight) { return "landscape"; - } else if ($window.outerWidth < $window.outerHeight) { + } else if (window.innerWidth < window.innerHeight) { return "portrait"; } }