[Mobile] AgentService

Replaced name queryService with agentService.
This commit is contained in:
Shivam Dave 2015-08-04 10:11:25 -07:00
parent 9b922913a0
commit 3d524d7572
16 changed files with 54 additions and 54 deletions

View File

@ -10,8 +10,8 @@
"depends": [ "$location" ]
},
{
"key": "queryService",
"implementation": "/services/QueryService.js",
"key": "agentService",
"implementation": "/services/AgentService.js",
"depends": [ "$window" ]
}
],
@ -65,7 +65,7 @@
{
"key": "TreeNodeController",
"implementation": "controllers/TreeNodeController.js",
"depends": [ "$scope", "$timeout", "queryService" ]
"depends": [ "$scope", "$timeout", "agentService" ]
},
{
"key": "ActionGroupController",

View File

@ -50,7 +50,7 @@ define(
* expand-to-show-navigated-object behavior.)
* @constructor
*/
function TreeNodeController($scope, $timeout, queryService) {
function TreeNodeController($scope, $timeout, agentService) {
var selectedObject = ($scope.ngModel || {}).selectedObject,
isSelected = false,
hasBeenExpanded = false;
@ -88,7 +88,7 @@ define(
}
function checkMobile() {
return queryService.isMobile(navigator.userAgent);
return agentService.isMobile(navigator.userAgent);
}
// Consider the currently-navigated object and update

View File

@ -22,7 +22,7 @@
/*global define,Promise*/
/**
* Module defining QueryService.
* Module defining AgentService.
*/
define(
@ -35,7 +35,7 @@ define(
* info using a comparison between the userAgent and key
* device names
*/
function QueryService($window) {
function AgentService($window) {
// Gets the UA name if it is one of the following.
// If it is not (a desktop for example) nothing is
@ -97,6 +97,6 @@ define(
};
}
return QueryService;
return AgentService;
}
);

View File

@ -29,7 +29,7 @@ define(
describe("The tree node controller", function () {
var mockScope,
mockTimeout,
mockQueryService,
mockAgentService,
controller;
function TestObject(id, context) {
@ -44,8 +44,8 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", ["$watch", "$on"]);
mockTimeout = jasmine.createSpy("$timeout");
mockQueryService = jasmine.createSpyObj("queryService", ["isMobile"]);
controller = new TreeNodeController(mockScope, mockTimeout, mockQueryService);
mockAgentService = jasmine.createSpyObj("agentService", ["isMobile"]);
controller = new TreeNodeController(mockScope, mockTimeout, mockAgentService);
});
it("allows tracking of expansion state", function () {

View File

@ -25,12 +25,12 @@
* MCTRepresentationSpec. Created by vwoeltje on 11/6/14.
*/
define(
["../../src/services/QueryService"],
function (QueryService) {
["../../src/services/AgentService"],
function (AgentService) {
"use strict";
describe("The url service", function () {
var queryService,
var agentService,
mockWindow,
mockNavigator;
@ -47,24 +47,24 @@ define(
[ "userAgent" ]
);
queryService = new QueryService(mockWindow);
agentService = new AgentService(mockWindow);
});
it("get current device user agent", function () {
mockNavigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36";
queryService.isMobile(mockNavigator.userAgent);
agentService.isMobile(mockNavigator.userAgent);
mockNavigator.userAgent = "Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53";
queryService.isMobile(mockNavigator.userAgent);
agentService.isMobile(mockNavigator.userAgent);
});
it("get orientation of the current device", function () {
mockWindow.outerWidth = 768;
mockWindow.outerHeight = 1024;
queryService.getOrientation();
agentService.getOrientation();
mockWindow.outerWidth = 1024;
mockWindow.outerHeight = 768;
queryService.getOrientation();
agentService.getOrientation();
});
});
}

View File

@ -13,7 +13,7 @@
"directives/MCTDrag",
"directives/MCTResize",
"directives/MCTScroll",
"services/QueryService",
"services/AgentService",
"services/UrlService",
"StyleSheetLoader"
]

View File

@ -24,7 +24,7 @@
"implementation": "gestures/InfoGesture.js",
"depends": [
"$timeout",
"queryService",
"agentService",
"infoService",
"INFO_HOVER_DELAY"
]
@ -34,7 +34,7 @@
"implementation": "gestures/InfoButtonGesture.js",
"depends": [
"$document",
"queryService",
"agentService",
"infoService"
]
}
@ -48,7 +48,7 @@
"$document",
"$window",
"$rootScope",
"queryService"
"agentService"
]
}
],

View File

@ -37,7 +37,7 @@ define(
* @param {DomainObject} domainObject the domain object for which to
* show information
*/
function InfoGestureButton($document, queryService, infoService, element, domainObject) {
function InfoGestureButton($document, agentService, infoService, element, domainObject) {
var dismissBubble,
pendingBubble,
touchPosition,
@ -82,10 +82,10 @@ define(
}
// Checks if you are on a mobile device, if the device is
// mobile (queryService.isMobile() = true), then
// mobile (agentService.isMobile() = true), then
// the a click on something (info button) brings up
// the bubble
if (queryService.isMobile(navigator.userAgent)) {
if (agentService.isMobile(navigator.userAgent)) {
element.on('click', showBubble);
}

View File

@ -38,7 +38,7 @@ define(
* @param {DomainObject} domainObject the domain object for which to
* show information
*/
function InfoGesture($timeout, queryService, infoService, DELAY, element, domainObject) {
function InfoGesture($timeout, agentService, infoService, DELAY, element, domainObject) {
var dismissBubble,
pendingBubble,
mousePosition,
@ -93,9 +93,9 @@ define(
}
// Checks if you are on a mobile device, if the device is
// not mobile (queryService.isMobile() = false), then
// not mobile (agentService.isMobile() = false), then
// the pendingBubble and therefore hovering is allowed
if (!queryService.isMobile(navigator.userAgent)) {
if (!agentService.isMobile(navigator.userAgent)) {
// Show bubble (on a timeout) on mouse over
element.on('mouseenter', showBubble);
}

View File

@ -33,7 +33,7 @@ define(
* Displays informative content ("info bubbles") for the user.
* @constructor
*/
function InfoService($compile, $document, $window, $rootScope, queryService) {
function InfoService($compile, $document, $window, $rootScope, agentService) {
function display(templateKey, title, content, position) {
var body = $document.find('body'),
@ -61,7 +61,7 @@ define(
// info bubble positioned as normal (with triangle pointing
// to where clicked or pressed)
bubble.css('position', 'absolute');
if(queryService.isPhone(navigator.userAgent)) {
if(agentService.isPhone(navigator.userAgent)) {
bubble.css('right', 5 + 'px');
bubble.css('left', 5 + 'px');
bubble.css('top', 40 + 'px');

View File

@ -28,7 +28,7 @@ define(
describe("The info gesture", function () {
var mockTimeout,
mockQueryService,
mockAgentService,
mockInfoService,
testDelay = 12321,
mockElement,
@ -51,7 +51,7 @@ define(
beforeEach(function () {
mockTimeout = jasmine.createSpy('$timeout');
mockTimeout.cancel = jasmine.createSpy('cancel');
mockQueryService = jasmine.createSpyObj('queryService', ['isMobile']);
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile']);
mockInfoService = jasmine.createSpyObj(
'infoService',
[ 'display' ]
@ -81,7 +81,7 @@ define(
gesture = new InfoGesture(
mockTimeout,
mockQueryService,
mockAgentService,
mockInfoService,
testDelay,
mockElement,

View File

@ -26,7 +26,7 @@
{
"key": "menu",
"implementation": "gestures/ContextMenuGesture.js",
"depends": ["$timeout", "queryService"]
"depends": ["$timeout", "agentService"]
}
],
"components": [
@ -54,7 +54,7 @@
{
"key": "menu",
"implementation": "actions/ContextMenuAction.js",
"depends": [ "$compile", "$document", "$window", "$rootScope", "queryService" ]
"depends": [ "$compile", "$document", "$window", "$rootScope", "agentService" ]
}
]
}

View File

@ -47,7 +47,7 @@ define(
* @param actionContexr the context in which the action
* should be performed
*/
function ContextMenuAction($compile, $document, $window, $rootScope, queryService, actionContext) {
function ContextMenuAction($compile, $document, $window, $rootScope, agentService, actionContext) {
function perform() {
var winDim = [$window.innerWidth, $window.innerHeight],
@ -95,11 +95,11 @@ define(
// Stop propagation so that clicks on the menu do not close the menu
// Stop propagation so that touches on the menu do not close the menu
if (!queryService.isMobile(navigator.userAgent)) {
if (!agentService.isMobile(navigator.userAgent)) {
menu.on('mousedown', function (event) {
event.stopPropagation();
});
} else if (queryService.isMobile(navigator.userAgent)) {
} else if (agentService.isMobile(navigator.userAgent)) {
menu.on('touchstart', function (event) {
event.stopPropagation();
});
@ -108,9 +108,9 @@ define(
// 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 (!queryService.isMobile(navigator.userAgent)) {
if (!agentService.isMobile(navigator.userAgent)) {
body.on('mousedown', dismiss);
} else if (queryService.isMobile(navigator.userAgent)) {
} else if (agentService.isMobile(navigator.userAgent)) {
body.on('touchstart', dismiss);
}

View File

@ -39,19 +39,19 @@ define(
* @param {DomainObject} domainObject the object on which actions
* in the context menu will be performed
*/
function ContextMenuGesture($timeout, queryService, element, domainObject) {
function ContextMenuGesture($timeout, agentService, element, domainObject) {
var actionContext,
stop,
isPressing,
longTouchTime = 500;
// When context menu event occurs, show object actions instead
if (!queryService.isMobile(navigator.userAgent)) {
if (!agentService.isMobile(navigator.userAgent)) {
element.on('contextmenu', function (event) {
actionContext = {key: 'menu', domainObject: domainObject, event: event};
stop = domainObject.getCapability('action').perform(actionContext);
});
} else if (queryService.isMobile(navigator.userAgent)) {
} else if (agentService.isMobile(navigator.userAgent)) {
// If on mobile device, then start timeout for the single touch event
// during the timeout 'isPressing' is true.
element.on('touchstart', function (event) {

View File

@ -43,7 +43,7 @@ define(
mockBody,
mockWindow,
mockRootScope,
mockQueryService,
mockAgentService,
mockScope,
mockElement,
mockDomainObject,
@ -61,7 +61,7 @@ define(
mockBody = jasmine.createSpyObj("body", JQLITE_FUNCTIONS);
mockWindow = { innerWidth: MENU_DIMENSIONS[0] * 4, innerHeight: MENU_DIMENSIONS[1] * 4 };
mockRootScope = jasmine.createSpyObj("$rootScope", ["$new"]);
mockQueryService = jasmine.createSpyObj("queryService", ["isMobile"]);
mockAgentService = jasmine.createSpyObj("agentService", ["isMobile"]);
mockScope = {};
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
@ -81,7 +81,7 @@ define(
mockDocument,
mockWindow,
mockRootScope,
mockQueryService,
mockAgentService,
mockActionContext
);
});
@ -160,13 +160,13 @@ define(
});
it("mobile", function () {
mockQueryService.isMobile.andReturn(true);
mockAgentService.isMobile.andReturn(true);
action = new ContextMenuAction(
mockCompile,
mockDocument,
mockWindow,
mockRootScope,
mockQueryService,
mockAgentService,
mockActionContext
);
action.perform();

View File

@ -37,7 +37,7 @@ define(
describe("The 'context menu' gesture", function () {
var mockTimeout,
mockElement,
mockQueryService,
mockAgentService,
mockDomainObject,
mockEvent,
gesture,
@ -46,11 +46,11 @@ define(
beforeEach(function () {
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
mockTimeout = jasmine.createSpy("$timeout");
mockQueryService = jasmine.createSpyObj("queryService", ["isMobile"]);
mockAgentService = jasmine.createSpyObj("agentService", ["isMobile"]);
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
mockEvent = jasmine.createSpyObj("event", ["preventDefault"]);
gesture = new ContextMenuGesture(mockTimeout, mockQueryService, mockElement, mockDomainObject);
gesture = new ContextMenuGesture(mockTimeout, mockAgentService, mockElement, mockDomainObject);
// Capture the contextmenu callback
fireGesture = mockElement.on.mostRecentCall.args[1];
@ -76,8 +76,8 @@ define(
});
it("mobile", function () {
mockQueryService.isMobile.andReturn(true);
gesture = new ContextMenuGesture(mockTimeout, mockQueryService, mockElement, mockDomainObject);
mockAgentService.isMobile.andReturn(true);
gesture = new ContextMenuGesture(mockTimeout, mockAgentService, mockElement, mockDomainObject);
// Capture the contextmenu callback
fireGesture = mockElement.on.mostRecentCall.args[1];