From 3d524d7572455fb48d2fd7df5d0d846a743285ca Mon Sep 17 00:00:00 2001 From: Shivam Dave Date: Tue, 4 Aug 2015 10:11:25 -0700 Subject: [PATCH] [Mobile] AgentService Replaced name queryService with agentService. --- platform/commonUI/general/bundle.json | 6 +++--- .../src/controllers/TreeNodeController.js | 4 ++-- .../{QueryService.js => AgentService.js} | 6 +++--- .../test/controllers/TreeNodeControllerSpec.js | 6 +++--- .../{QueryServiceSpec.js => AgentServiceSpec.js} | 16 ++++++++-------- platform/commonUI/general/test/suite.json | 2 +- platform/commonUI/inspect/bundle.json | 6 +++--- .../inspect/src/gestures/InfoButtonGesture.js | 6 +++--- .../commonUI/inspect/src/gestures/InfoGesture.js | 6 +++--- .../commonUI/inspect/src/services/InfoService.js | 4 ++-- .../inspect/test/gestures/InfoGestureSpec.js | 6 +++--- platform/representation/bundle.json | 4 ++-- .../src/actions/ContextMenuAction.js | 10 +++++----- .../src/gestures/ContextMenuGesture.js | 6 +++--- .../test/actions/ContextMenuActionSpec.js | 10 +++++----- .../test/gestures/ContextMenuGestureSpec.js | 10 +++++----- 16 files changed, 54 insertions(+), 54 deletions(-) rename platform/commonUI/general/src/services/{QueryService.js => AgentService.js} (97%) rename platform/commonUI/general/test/services/{QueryServiceSpec.js => AgentServiceSpec.js} (87%) diff --git a/platform/commonUI/general/bundle.json b/platform/commonUI/general/bundle.json index 53486c3f0e..f4ceed6ba1 100644 --- a/platform/commonUI/general/bundle.json +++ b/platform/commonUI/general/bundle.json @@ -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", diff --git a/platform/commonUI/general/src/controllers/TreeNodeController.js b/platform/commonUI/general/src/controllers/TreeNodeController.js index 27ef3bfd49..c55c3e2b6b 100644 --- a/platform/commonUI/general/src/controllers/TreeNodeController.js +++ b/platform/commonUI/general/src/controllers/TreeNodeController.js @@ -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 diff --git a/platform/commonUI/general/src/services/QueryService.js b/platform/commonUI/general/src/services/AgentService.js similarity index 97% rename from platform/commonUI/general/src/services/QueryService.js rename to platform/commonUI/general/src/services/AgentService.js index 18ecea79c4..307446c1dc 100644 --- a/platform/commonUI/general/src/services/QueryService.js +++ b/platform/commonUI/general/src/services/AgentService.js @@ -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; } ); \ No newline at end of file diff --git a/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js b/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js index 2ce5c9f9fc..67e6cf7142 100644 --- a/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js +++ b/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js @@ -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 () { diff --git a/platform/commonUI/general/test/services/QueryServiceSpec.js b/platform/commonUI/general/test/services/AgentServiceSpec.js similarity index 87% rename from platform/commonUI/general/test/services/QueryServiceSpec.js rename to platform/commonUI/general/test/services/AgentServiceSpec.js index 7caf551029..6207267da2 100644 --- a/platform/commonUI/general/test/services/QueryServiceSpec.js +++ b/platform/commonUI/general/test/services/AgentServiceSpec.js @@ -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(); }); }); } diff --git a/platform/commonUI/general/test/suite.json b/platform/commonUI/general/test/suite.json index 08240b6044..085c1795ba 100644 --- a/platform/commonUI/general/test/suite.json +++ b/platform/commonUI/general/test/suite.json @@ -13,7 +13,7 @@ "directives/MCTDrag", "directives/MCTResize", "directives/MCTScroll", - "services/QueryService", + "services/AgentService", "services/UrlService", "StyleSheetLoader" ] \ No newline at end of file diff --git a/platform/commonUI/inspect/bundle.json b/platform/commonUI/inspect/bundle.json index 7168b638e0..bafeb851ef 100644 --- a/platform/commonUI/inspect/bundle.json +++ b/platform/commonUI/inspect/bundle.json @@ -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" ] } ], diff --git a/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js b/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js index 04ab14ebe4..679daabd51 100644 --- a/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js +++ b/platform/commonUI/inspect/src/gestures/InfoButtonGesture.js @@ -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); } diff --git a/platform/commonUI/inspect/src/gestures/InfoGesture.js b/platform/commonUI/inspect/src/gestures/InfoGesture.js index 4792445f6b..6b6d77a3ed 100644 --- a/platform/commonUI/inspect/src/gestures/InfoGesture.js +++ b/platform/commonUI/inspect/src/gestures/InfoGesture.js @@ -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); } diff --git a/platform/commonUI/inspect/src/services/InfoService.js b/platform/commonUI/inspect/src/services/InfoService.js index 4804137544..50d03cb38c 100644 --- a/platform/commonUI/inspect/src/services/InfoService.js +++ b/platform/commonUI/inspect/src/services/InfoService.js @@ -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'); diff --git a/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js b/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js index a9a83eeb5a..28408a2a7c 100644 --- a/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js +++ b/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js @@ -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, diff --git a/platform/representation/bundle.json b/platform/representation/bundle.json index 3eeaf2d258..44656b0f4c 100644 --- a/platform/representation/bundle.json +++ b/platform/representation/bundle.json @@ -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" ] } ] } diff --git a/platform/representation/src/actions/ContextMenuAction.js b/platform/representation/src/actions/ContextMenuAction.js index 244d6a0b0d..65ee0b0d50 100644 --- a/platform/representation/src/actions/ContextMenuAction.js +++ b/platform/representation/src/actions/ContextMenuAction.js @@ -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); } diff --git a/platform/representation/src/gestures/ContextMenuGesture.js b/platform/representation/src/gestures/ContextMenuGesture.js index 576c5eb66f..64449914c4 100644 --- a/platform/representation/src/gestures/ContextMenuGesture.js +++ b/platform/representation/src/gestures/ContextMenuGesture.js @@ -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) { diff --git a/platform/representation/test/actions/ContextMenuActionSpec.js b/platform/representation/test/actions/ContextMenuActionSpec.js index c1c6dc51ca..01ea265f02 100644 --- a/platform/representation/test/actions/ContextMenuActionSpec.js +++ b/platform/representation/test/actions/ContextMenuActionSpec.js @@ -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(); diff --git a/platform/representation/test/gestures/ContextMenuGestureSpec.js b/platform/representation/test/gestures/ContextMenuGestureSpec.js index b3b7e8de8c..031fdfc9e2 100644 --- a/platform/representation/test/gestures/ContextMenuGestureSpec.js +++ b/platform/representation/test/gestures/ContextMenuGestureSpec.js @@ -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];