[Mobile] Hide Tree

On selecting a node in the tree, if the
user is on phone and in portrait, than
emit up to the browse controller to call
treeSlide(), which will hide the tree menu.
Also adjusted the agent service to properly
check for orientation using window.innerHeight/
Width. Also created function for the selection
of an object in BrowseController.
This commit is contained in:
Shivam Dave 2015-08-24 16:17:58 -07:00
parent c4dd4f5c45
commit 6a2bdd103b
5 changed files with 25 additions and 8 deletions

View File

@ -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;

View File

@ -11,8 +11,7 @@
},
{
"key": "agentService",
"implementation": "/services/AgentService.js",
"depends": [ "$window" ]
"implementation": "/services/AgentService.js"
}
],
"runs": [

View File

@ -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()"
>
</mct-representation>
<span
class='ui-symbol view-control'
mct-object="domainObject"
ng-model="ngModel"
ng-click="treeNode.checkMobile() ? ngModel.selectedObject = domainObject :
ng-click="treeNode.checkMobile() ? treeNode.setObject(ngModel, domainObject) :
toggle.toggle(); treeNode.trackExpansion()"
ng-if="model.composition !== undefined || treeNode.checkMobile()"
>

View File

@ -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

View File

@ -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";
}
}