[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,