[Mobile] AgentService
Replaced name queryService with agentService.
This commit is contained in:
@@ -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" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user