[Mobile] Update agentService usages

This commit is contained in:
Victor Woeltjen 2015-09-18 10:07:27 -07:00
parent 0b4f44f00d
commit fa186a1556
6 changed files with 40 additions and 48 deletions

View File

@ -19,7 +19,7 @@
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define,Promise,window*/
/*global define,Promise*/
/**
* Module defining TreeNodeController. Created by vwoeltje on 11/10/14.
@ -182,14 +182,13 @@ define(
// and in portrait mode, than, hide the tree menu
TreeNodeController.prototype.setObject = function (ngModel, domainObject) {
ngModel.selectedObject = domainObject;
if (this.agentService.getOrientation(window.innerWidth, window.innerHeight) === "portrait" &&
this.agentService.isPhone(navigator.userAgent)) {
if (this.agentService.isPhone() && this.agentService.isPortrait()) {
this.$scope.$emit('select-obj');
}
};
TreeNodeController.prototype.checkMobile = function () {
return this.agentService.isMobile(navigator.userAgent);
return this.agentService.isMobile();
};
return TreeNodeController;

View File

@ -92,7 +92,7 @@ define(
// mobile (agentService.isMobile() = true), then
// the a click on something (info button) brings up
// the bubble
if (agentService.isMobile(navigator.userAgent)) {
if (agentService.isMobile()) {
element.on('click', showBubble);
}

View File

@ -69,7 +69,7 @@ define(
// Checks if you are on a mobile device, if the device is
// not mobile (agentService.isMobile() = false), then
// the pendingBubble and therefore hovering is allowed
if (!agentService.isMobile(navigator.userAgent)) {
if (!agentService.isMobile()) {
// Show bubble (on a timeout) on mouse over
element.on('mouseenter', this.showBubbleCallback);
}

View File

@ -31,17 +31,20 @@ define(
"use strict";
function MobileBrowseTreeController($scope, navigationService, agentService) {
var object = navigationService.getNavigation();
var object = navigationService.getNavigation(),
self = this;
// Collapse tree when navigation changes
function changeObject(newObject) {
if (newObject !== object) {
if (newObject !== object && agentService.isPortrait()) {
object = newObject;
this.state = false;
self.state = false;
}
}
if (agentService.isMobile()) {
navigationService.listen(changeObject);
}
this.state = true;
}

View File

@ -71,6 +71,7 @@ define(
scope = $rootScope.$new(),
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
goUp = eventCoors[1] + menuDim[1] > winDim[1],
initiatingEvent = this.agentService.isMobile() ? 'touchstart' : 'mousedown',
menu;
// Remove the context menu
@ -107,27 +108,16 @@ define(
body.append(menu);
// Stop propagation so that clicks or touches on the menu do not close the menu
if (!(this.agentService.isMobile(navigator.userAgent))) {
menu.on('mousedown', function (event) {
menu.on(initiatingEvent, function (event) {
event.stopPropagation();
});
} else if ((this.agentService.isMobile(navigator.userAgent))) {
menu.on('touchstart', function (event) {
event.stopPropagation();
});
}
// Dismiss the menu when body is clicked/touched elsewhere
// ('mousedown' because 'click' breaks left-click context menus)
// ('touchstart' because 'touch' breaks context menus up)
if (!(this.agentService.isMobile(navigator.userAgent))) {
body.on('mousedown', dismiss);
body.on(initiatingEvent, dismiss);
// NOTE: Apply to mobile?
menu.on('click', dismiss);
} else if (this.agentService.isMobile(navigator.userAgent)) {
body.on('touchstart', dismiss);
}
// Don't launch browser's context menu
actionContext.event.preventDefault();

View File

@ -54,11 +54,11 @@ define(
}
// When context menu event occurs, show object actions instead
if (!agentService.isMobile(navigator.userAgent)) {
if (!agentService.isMobile()) {
// When context menu event occurs, show object actions instead
element.on('contextmenu', showMenu);
} else if (agentService.isMobile(navigator.userAgent)) {
} else if (agentService.isMobile()) {
// If on mobile device, then start timeout for the single touch event
// during the timeout 'isPressing' is true.