[Code Style] Run gulp fixstyle

...to apply code style settings from #142.
This commit is contained in:
Victor Woeltjen 2016-05-19 11:29:13 -07:00
parent f12b9704d9
commit fa77139077
440 changed files with 1885 additions and 1662 deletions

View File

@ -41,10 +41,10 @@ requirejs.config({
"exports": "angular"
},
"angular-route": {
"deps": [ "angular" ]
"deps": ["angular"]
},
"moment-duration-format": {
"deps": [ "moment" ]
"deps": ["moment"]
},
"screenfull": {
"exports": "screenfull"

View File

@ -80,12 +80,12 @@ define(
function setNavigation(domainObject) {
var navigationAllowed = true;
if (domainObject === $scope.navigatedObject){
if (domainObject === $scope.navigatedObject) {
//do nothing;
return;
}
policyService.allow("navigation", $scope.navigatedObject, domainObject, function(message){
policyService.allow("navigation", $scope.navigatedObject, domainObject, function (message) {
navigationAllowed = $window.confirm(message + "\r\n\r\n" +
" Are you sure you want to continue?");
});

View File

@ -70,7 +70,7 @@ define(
$scope.$watch('domainObject', setViewForDomainObject);
$scope.$watch('representation.selected.key', updateQueryParam);
$scope.doAction = function (action){
$scope.doAction = function (action) {
return $scope[action] && $scope[action]();
};

View File

@ -45,7 +45,7 @@ define(
/**
* @private
*/
InspectorRegion.prototype.buildRegion = function() {
InspectorRegion.prototype.buildRegion = function () {
var metadataRegion = {
name: 'metadata',
title: 'Metadata Region',

View File

@ -81,13 +81,13 @@ define(
newModel.type = this.type.getKey();
newObject = parentObject.getCapability('instantiation').instantiate(newModel);
newObject.useCapability('mutation', function(model){
newObject.useCapability('mutation', function (model) {
model.location = parentObject.getId();
});
wizard = new CreateWizard(newObject, this.parent, this.policyService);
function populateObjectFromInput (formValue) {
function populateObjectFromInput(formValue) {
return wizard.populateObjectFromInput(formValue, newObject);
}
@ -99,7 +99,7 @@ define(
});
}
function addToParent (populatedObject) {
function addToParent(populatedObject) {
parentObject.getCapability('composition').add(populatedObject);
return persistAndReturn(parentObject);
}
@ -125,7 +125,7 @@ define(
* @returns {AddActionMetadata} metadata about this action
*/
AddAction.prototype.getMetadata = function () {
return this.metadata;
return this.metadata;
};
return AddAction;

View File

@ -101,7 +101,7 @@ define(
return editorCapability.save();
}, function () {
return editorCapability.cancel();
});
});
}
};
@ -118,7 +118,7 @@ define(
* @returns {CreateActionMetadata} metadata about this action
*/
CreateAction.prototype.getMetadata = function () {
return this.metadata;
return this.metadata;
};
return CreateAction;

View File

@ -111,12 +111,12 @@ define(
* @param formValue
* @returns {DomainObject}
*/
CreateWizard.prototype.populateObjectFromInput = function(formValue) {
CreateWizard.prototype.populateObjectFromInput = function (formValue) {
var parent = this.getLocation(formValue),
formModel = this.createModel(formValue);
formModel.location = parent.getId();
this.domainObject.useCapability("mutation", function(){
this.domainObject.useCapability("mutation", function () {
return formModel;
});
return this.domainObject;

View File

@ -50,14 +50,14 @@ define(
$scope.rootObject =
(context && context.getRoot()) || $scope.rootObject;
}, 0);
} else if (!contextRoot){
} else if (!contextRoot) {
//If no context root is available, default to the root
// object
$scope.rootObject = undefined;
// Update the displayed tree on a timeout to avoid
// an infinite digest exception.
objectService.getObjects(['ROOT'])
.then(function(objects){
.then(function (objects) {
$timeout(function () {
$scope.rootObject = objects.ROOT;
}, 0);

View File

@ -78,12 +78,12 @@ define(
mockScope = jasmine.createSpyObj(
"$scope",
[ "$on", "$watch" ]
["$on", "$watch"]
);
mockRoute = { current: { params: {} } };
mockLocation = jasmine.createSpyObj(
"$location",
[ "path" ]
["path"]
);
mockUrlService = jasmine.createSpyObj(
"urlService",
@ -91,7 +91,7 @@ define(
);
mockObjectService = jasmine.createSpyObj(
"objectService",
[ "getObjects" ]
["getObjects"]
);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
@ -104,15 +104,15 @@ define(
);
mockRootObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
["getId", "getCapability", "getModel", "useCapability"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
["getId", "getCapability", "getModel", "useCapability"]
);
mockNextObject = jasmine.createSpyObj(
"nextObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
["getId", "getCapability", "getModel", "useCapability"]
);
mockObjectService.getObjects.andReturn(mockPromise({
@ -255,7 +255,7 @@ define(
" object", function () {
mockScope.navigatedObject = mockDomainObject;
mockWindow.confirm.andReturn(false);
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
mockPolicyService.allow.andCallFake(function (category, object, context, callback) {
callback("unsaved changes");
return false;
});

View File

@ -44,12 +44,12 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$on", "$watch" ]
["$on", "$watch"]
);
mockRoute = { current: { params: {} } };
mockLocation = jasmine.createSpyObj(
"$location",
[ "path", "search" ]
["path", "search"]
);
mockUnlisten = jasmine.createSpy("unlisten");

View File

@ -38,23 +38,23 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "" ]
[""]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability" ]
["getCapability"]
);
mockEvent = jasmine.createSpyObj(
"event",
[ "preventDefault" ]
["preventDefault"]
);
mockContextMenuAction = jasmine.createSpyObj(
"action",
[ "perform", "getActions" ]
["perform", "getActions"]
);
mockActionContext = jasmine.createSpyObj(
"actionContext",
[ "" ]
[""]
);
mockActionContext.domainObject = mockDomainObject;

View File

@ -42,11 +42,11 @@ define(
}
beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", [ "$on" ]);
mockScope = jasmine.createSpyObj("$scope", ["$on"]);
mockDomainObjects = ['a', 'b'].map(function (id) {
var mockDomainObject = jasmine.createSpyObj(
'domainObject-' + id,
[ 'getId', 'getModel', 'getCapability' ]
['getId', 'getModel', 'getCapability']
);
mockDomainObject.getId.andReturn(id);
@ -56,7 +56,7 @@ define(
});
mockAgentService = jasmine.createSpyObj(
"agentService",
[ "isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape" ]
["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"]
);
mockWindow = jasmine.createSpyObj("$window", ["open"]);
});

View File

@ -60,37 +60,37 @@ define(
beforeEach(function () {
mockTypeService = jasmine.createSpyObj(
"typeService",
[ "listTypes" ]
["listTypes"]
);
mockDialogService = jasmine.createSpyObj(
"dialogService",
[ "getUserInput" ]
["getUserInput"]
);
mockPolicyService = jasmine.createSpyObj(
"policyService",
[ "allow" ]
["allow"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability" ]
["getCapability"]
);
//Mocking getCapability because AddActionProvider uses the
// type capability of the destination object.
mockDomainObject.getCapability.andReturn({});
mockTypes = [ "A", "B", "C" ].map(createMockType);
mockTypes = ["A", "B", "C"].map(createMockType);
mockTypes.forEach(function(type){
mockTypes.forEach(function (type) {
mockPolicyMap[type.getName()] = true;
});
mockCreationPolicy = function(type){
mockCreationPolicy = function (type) {
return mockPolicyMap[type.getName()];
};
mockCompositionPolicy = function(){
mockCompositionPolicy = function () {
return true;
};

View File

@ -59,32 +59,32 @@ define(
beforeEach(function () {
mockTypeService = jasmine.createSpyObj(
"typeService",
[ "listTypes" ]
["listTypes"]
);
mockDialogService = jasmine.createSpyObj(
"dialogService",
[ "getUserInput" ]
["getUserInput"]
);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[ "setNavigation" ]
["setNavigation"]
);
mockPolicyService = jasmine.createSpyObj(
"policyService",
[ "allow" ]
["allow"]
);
mockTypes = [ "A", "B", "C" ].map(createMockType);
mockTypes = ["A", "B", "C"].map(createMockType);
mockTypes.forEach(function(type){
mockTypes.forEach(function (type) {
mockPolicyMap[type.getName()] = true;
});
mockCreationPolicy = function(type){
mockCreationPolicy = function (type) {
return mockPolicyMap[type.getName()];
};
mockPolicyService.allow.andCallFake(function(category, type){
mockPolicyService.allow.andCallFake(function (category, type) {
return category === "creation" && mockCreationPolicy(type) ? true : false;
});

View File

@ -68,11 +68,11 @@ define(
};
mockDialogService = jasmine.createSpyObj(
"dialogService",
[ "getUserInput" ]
["getUserInput"]
);
mockCreationService = jasmine.createSpyObj(
"creationService",
[ "createObject" ]
["createObject"]
);
mockType.getKey.andReturn("test");

View File

@ -39,7 +39,7 @@ define(
function createMockProperty(name) {
var mockProperty = jasmine.createSpyObj(
"property" + name,
[ "getDefinition", "getValue", "setValue" ]
["getDefinition", "getValue", "setValue"]
);
mockProperty.getDefinition.andReturn({
control: "textfield"
@ -68,7 +68,7 @@ define(
"getCapability"
]
);
mockProperties = [ "A", "B", "C" ].map(createMockProperty);
mockProperties = ["A", "B", "C"].map(createMockProperty);
mockPolicyService = jasmine.createSpyObj('policyService', ['allow']);
testModel = { someKey: "some value" };
@ -144,8 +144,8 @@ define(
"A": "ValueA",
"B": "ValueB",
"C": "ValueC"
},
compareModel = wizard.createModel(formValue);
},
compareModel = wizard.createModel(formValue);
wizard.populateObjectFromInput(formValue);
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
expect(mockDomainObject.useCapability.mostRecentCall.args[1]()).toEqual(compareModel);
@ -179,7 +179,7 @@ define(
});
it("creates a form model without a location if not requested", function () {
expect(wizard.getFormStructure(false).sections.some(function(section){
expect(wizard.getFormStructure(false).sections.some(function (section) {
return section.name === 'Location';
})).toEqual(false);
});

View File

@ -61,23 +61,23 @@ define(
mockQ = { when: mockPromise, reject: mockReject };
mockLog = jasmine.createSpyObj(
"$log",
[ "error", "warn", "info", "debug" ]
["error", "warn", "info", "debug"]
);
mockParentObject = jasmine.createSpyObj(
"parentObject",
[ "getId", "getCapability", "useCapability" ]
["getId", "getCapability", "useCapability"]
);
mockNewObject = jasmine.createSpyObj(
"newObject",
[ "getId", "getCapability", "useCapability" ]
["getId", "getCapability", "useCapability"]
);
mockMutationCapability = jasmine.createSpyObj(
"mutation",
[ "invoke" ]
["invoke"]
);
mockPersistenceCapability = jasmine.createSpyObj(
"persistence",
[ "persist", "getSpace" ]
["persist", "getSpace"]
);
mockCompositionCapability = jasmine.createSpyObj(
"composition",
@ -100,7 +100,7 @@ define(
};
mockNewPersistenceCapability = jasmine.createSpyObj(
"new-persistence",
[ "persist", "getSpace" ]
["persist", "getSpace"]
);
mockParentObject.getCapability.andCallFake(function (key) {

View File

@ -40,20 +40,20 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$watch" ]
["$watch"]
);
mockTimeout = jasmine.createSpy("$timeout");
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability" ]
["getCapability"]
);
mockRootObject = jasmine.createSpyObj(
"rootObject",
[ "getCapability" ]
["getCapability"]
);
mockContext = jasmine.createSpyObj(
"context",
[ "getRoot" ]
["getRoot"]
);
mockObjectService = jasmine.createSpyObj(
"objectService",
@ -73,18 +73,18 @@ define(
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
});
describe("when context is available", function () {
describe("when context is available", function () {
beforeEach(function () {
beforeEach(function () {
mockContext.getRoot.andReturn(mockRootObject);
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
});
it("adds a treeModel to scope", function () {
it("adds a treeModel to scope", function () {
expect(mockScope.treeModel).toBeDefined();
});
it("watches for changes to treeModel", function () {
it("watches for changes to treeModel", function () {
// This is what the embedded tree representation
// will be modifying.
expect(mockScope.$watch).toHaveBeenCalledWith(
@ -93,7 +93,7 @@ define(
);
});
it("changes its own model on embedded model updates", function () {
it("changes its own model on embedded model updates", function () {
// Need to pass on selection changes as updates to
// the control's value
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
@ -107,7 +107,7 @@ define(
.toHaveBeenCalledWith("context");
});
it("rejects changes which fail validation", function () {
it("rejects changes which fail validation", function () {
mockScope.structure = { validate: jasmine.createSpy('validate') };
mockScope.structure.validate.andReturn(false);
@ -120,10 +120,10 @@ define(
expect(mockScope.ngModel.someField).not.toEqual(mockDomainObject);
});
it("treats a lack of a selection as invalid", function () {
it("treats a lack of a selection as invalid", function () {
mockScope.ngModelController = jasmine.createSpyObj(
'ngModelController',
[ '$setValidity' ]
['$setValidity']
);
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
@ -136,14 +136,14 @@ define(
expect(mockScope.ngModelController.$setValidity)
.toHaveBeenCalledWith(jasmine.any(String), false);
});
});
describe("when no context is available", function () {
});
describe("when no context is available", function () {
var defaultRoot = "DEFAULT_ROOT";
beforeEach(function () {
mockContext.getRoot.andReturn(undefined);
getObjectsPromise.then.andCallFake(function(callback){
callback({'ROOT':defaultRoot});
getObjectsPromise.then.andCallFake(function (callback) {
callback({'ROOT': defaultRoot});
});
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
});

View File

@ -44,12 +44,12 @@ define(
beforeEach(function () {
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[ "setNavigation" ]
["setNavigation"]
);
mockQ = { when: mockPromise };
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
action = new NavigateAction(

View File

@ -37,11 +37,11 @@ define(
beforeEach(function () {
mockNavigationService = jasmine.createSpyObj(
'navigationService',
[ 'getNavigation' ]
['getNavigation']
);
mockRootScope = jasmine.createSpyObj(
'$rootScope',
[ '$watch' ]
['$watch']
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',

View File

@ -155,8 +155,8 @@ define(
* @returns {boolean} true if dialog is currently visible, false
* otherwise
*/
DialogService.prototype.canShowDialog = function(dialogModel){
if (this.dialogVisible){
DialogService.prototype.canShowDialog = function (dialogModel) {
if (this.dialogVisible) {
// Only one dialog should be shown at a time.
// The application design should be such that
// we never even try to do this.
@ -224,7 +224,7 @@ define(
* @param {typeClass} string tells overlayService that this overlay should use appropriate CSS class
* @returns {boolean}
*/
DialogService.prototype.showBlockingMessage = function(dialogModel) {
DialogService.prototype.showBlockingMessage = function (dialogModel) {
if (this.canShowDialog(dialogModel)) {
// Add the overlay using the OverlayService, which
// will handle actual insertion into the DOM

View File

@ -38,23 +38,23 @@ define(
beforeEach(function () {
mockOverlayService = jasmine.createSpyObj(
"overlayService",
[ "createOverlay" ]
["createOverlay"]
);
mockQ = jasmine.createSpyObj(
"$q",
[ "defer" ]
["defer"]
);
mockLog = jasmine.createSpyObj(
"$log",
[ "warn", "info", "debug" ]
["warn", "info", "debug"]
);
mockOverlay = jasmine.createSpyObj(
"overlay",
[ "dismiss" ]
["dismiss"]
);
mockDeferred = jasmine.createSpyObj(
"deferred",
[ "resolve", "reject"]
["resolve", "reject"]
);
mockDeferred.promise = "mock promise";
@ -120,7 +120,7 @@ define(
});
it("invokes the overlay service with the correct parameters when" +
" a blocking dialog is requested", function() {
" a blocking dialog is requested", function () {
var dialogModel = {};
expect(dialogService.showBlockingMessage(dialogModel)).toBe(true);
expect(mockOverlayService.createOverlay).toHaveBeenCalledWith(

View File

@ -38,13 +38,13 @@ define(
overlayService;
beforeEach(function () {
mockDocument = jasmine.createSpyObj("$document", [ "find" ]);
mockDocument = jasmine.createSpyObj("$document", ["find"]);
mockCompile = jasmine.createSpy("$compile");
mockRootScope = jasmine.createSpyObj("$rootScope", [ "$new" ]);
mockBody = jasmine.createSpyObj("body", [ "prepend" ]);
mockRootScope = jasmine.createSpyObj("$rootScope", ["$new"]);
mockBody = jasmine.createSpyObj("body", ["prepend"]);
mockTemplate = jasmine.createSpy("template");
mockElement = jasmine.createSpyObj("element", [ "remove" ]);
mockScope = jasmine.createSpyObj("scope", [ "$destroy" ]);
mockElement = jasmine.createSpyObj("element", ["remove"]);
mockScope = jasmine.createSpyObj("scope", ["$destroy"]);
mockDocument.find.andReturn(mockBody);
mockCompile.andReturn(mockTemplate);

View File

@ -298,7 +298,7 @@ define([
],
"constants": [
{
"key":"editModeBlacklist",
"key": "editModeBlacklist",
"value": ["copy", "follow", "window", "link", "locate"]
},
{
@ -316,7 +316,7 @@ define([
"transactionService"
]
}
],
]
}
});
});

View File

@ -44,7 +44,7 @@ define(
CancelAction.prototype.perform = function () {
var domainObject = this.domainObject;
function returnToBrowse () {
function returnToBrowse() {
var parent;
//If the object existed already, navigate to refresh view

View File

@ -70,7 +70,7 @@ define(
*/
EditAction.prototype.perform = function () {
var self = this;
function cancelEditing(){
function cancelEditing() {
self.domainObject.getCapability('editor').cancel();
self.navigationService.removeListener(cancelEditing);
}

View File

@ -48,7 +48,7 @@ define(
SaveAction.prototype.perform = function () {
var domainObject = this.domainObject;
function resolveWith(object){
function resolveWith(object) {
return function () {
return object;
};

View File

@ -42,7 +42,7 @@ define(
context
) {
this.domainObject = (context || {}).domainObject;
this.injectObjectService = function(){
this.injectObjectService = function () {
this.objectService = $injector.get("objectService");
};
this.policyService = policyService;
@ -65,7 +65,7 @@ define(
/**
* @private
*/
SaveAsAction.prototype.getObjectService = function(){
SaveAsAction.prototype.getObjectService = function () {
// Lazily acquire object service (avoids cyclical dependency)
if (!this.objectService) {
this.injectObjectService();
@ -73,7 +73,7 @@ define(
return this.objectService;
};
function resolveWith(object){
function resolveWith(object) {
return function () {
return object;
};
@ -116,13 +116,13 @@ define(
).then(wizard.populateObjectFromInput.bind(wizard));
}
function fetchObject(objectId){
return self.getObjectService().getObjects([objectId]).then(function(objects){
function fetchObject(objectId) {
return self.getObjectService().getObjects([objectId]).then(function (objects) {
return objects[objectId];
});
}
function getParent(object){
function getParent(object) {
return fetchObject(object.getModel().location);
}

View File

@ -52,11 +52,11 @@ define(
this.domainObject.getCapability('status').set('editing', true);
};
function isEditContextRoot (domainObject) {
function isEditContextRoot(domainObject) {
return domainObject.getCapability('status').get('editing');
}
function isEditing (domainObject) {
function isEditing(domainObject) {
return isEditContextRoot(domainObject) ||
domainObject.hasCapability('context') &&
isEditing(domainObject.getCapability('context').getParent());
@ -87,7 +87,7 @@ define(
*/
EditorCapability.prototype.save = function () {
var domainObject = this.domainObject;
return this.transactionService.commit().then(function() {
return this.transactionService.commit().then(function () {
domainObject.getCapability('status').set('editing', false);
});
};
@ -101,7 +101,7 @@ define(
*/
EditorCapability.prototype.cancel = function () {
var domainObject = this.domainObject;
return this.transactionService.cancel().then(function(){
return this.transactionService.cancel().then(function () {
domainObject.getCapability("status").set("editing", false);
return domainObject;
});

View File

@ -60,14 +60,14 @@ define(
var self = this;
function onCommit() {
return self.persistenceCapability.persist().then(function(result) {
return self.persistenceCapability.persist().then(function (result) {
self.persistPending = false;
return result;
});
}
function onCancel() {
return self.persistenceCapability.refresh().then(function(result) {
return self.persistenceCapability.refresh().then(function (result) {
self.persistPending = false;
return result;
});

View File

@ -59,7 +59,7 @@ define(
$scope.$watch('domainObject', setViewForDomainObject);
$scope.doAction = function (action){
$scope.doAction = function (action) {
return $scope[action] && $scope[action]();
};
}
@ -74,8 +74,8 @@ define(
var navigatedObject = this.scope.domainObject,
policyMessage;
this.policyService.allow("navigation", navigatedObject, undefined, function(message) {
policyMessage = message;
this.policyService.allow("navigation", navigatedObject, undefined, function (message) {
policyMessage = message;
});
return policyMessage;

View File

@ -30,7 +30,7 @@ define(
* @constructor
*/
function ElementsController($scope) {
function filterBy(text){
function filterBy(text) {
if (typeof text === 'undefined') {
return $scope.searchText;
} else {

View File

@ -45,7 +45,7 @@ define(
count = 0,
type, views;
if (!domainObject){
if (!domainObject) {
return count;
}

View File

@ -56,7 +56,7 @@ define(
actionMetadata = action.getMetadata ? action.getMetadata() : {};
if (navigatedObject.hasCapability("editor") && navigatedObject.getCapability("editor").isEditContextRoot()) {
if (selectedObject.hasCapability("editor") && selectedObject.getCapability("editor").inEditContext()){
if (selectedObject.hasCapability("editor") && selectedObject.getCapability("editor").inEditContext()) {
return this.editModeBlacklist.indexOf(actionMetadata.key) === -1;
} else {
//Target is in the context menu

View File

@ -38,7 +38,7 @@ define(
/**
* @private
*/
EditNavigationPolicy.prototype.isDirty = function(domainObject) {
EditNavigationPolicy.prototype.isDirty = function (domainObject) {
var navigatedObject = domainObject,
editorCapability = navigatedObject &&
navigatedObject.getCapability("editor");

View File

@ -119,7 +119,7 @@ define(
// Ensure existing watches are released
this.destroy();
function setEditing(){
function setEditing() {
scope.viewObjectTemplate = 'edit-object';
}
@ -128,15 +128,15 @@ define(
* editable then change the view and inspector regions
* object representation accordingly
*/
this.listenHandle = this.domainObject.getCapability('status').listen(function(statuses){
if (statuses.indexOf('editing') !== -1){
this.listenHandle = this.domainObject.getCapability('status').listen(function (statuses) {
if (statuses.indexOf('editing') !== -1) {
setEditing();
} else {
delete scope.viewObjectTemplate;
}
});
if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()){
if (representedObject.hasCapability('editor') && representedObject.getCapability('editor').isEditContextRoot()) {
setEditing();
}
};

View File

@ -24,8 +24,12 @@ define(
function () {
// Utility functions for reducing truth arrays
function and(a, b) { return a && b; }
function or(a, b) { return a || b; }
function and(a, b) {
return a && b;
}
function or(a, b) {
return a || b;
}
/**

View File

@ -22,7 +22,7 @@
/*global define*/
define(
[],
function() {
function () {
/**
* Implements an application-wide transaction state. Once a
* transaction is started, calls to
@ -103,7 +103,7 @@ define(
this.$log.error("Error committing transaction.");
}
}
return this.$q.all(promises).then( function () {
return this.$q.all(promises).then(function () {
self.transaction = false;
self.onCommits = [];
@ -145,4 +145,4 @@ define(
};
return TransactionService;
});
});

View File

@ -44,15 +44,15 @@ define(
beforeEach(function () {
mockLocation = jasmine.createSpyObj(
"$location",
[ "path" ]
["path"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability", "hasCapability" ]
["getCapability", "hasCapability"]
);
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel" ]
["save", "cancel"]
);
mockUrlService = jasmine.createSpyObj(
"urlService",

View File

@ -38,23 +38,23 @@ define(
beforeEach(function () {
mockLocation = jasmine.createSpyObj(
"$location",
[ "path" ]
["path"]
);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[ "setNavigation", "getNavigation", "addListener", "removeListener" ]
["setNavigation", "getNavigation", "addListener", "removeListener"]
);
mockLog = jasmine.createSpyObj(
"$log",
[ "error", "warn", "info", "debug" ]
["error", "warn", "info", "debug"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
);
mockType = jasmine.createSpyObj(
"type",
[ "hasFeature" ]
["hasFeature"]
);
mockEditor = jasmine.createSpyObj(
"editorCapability",
@ -66,7 +66,7 @@ define(
editor: mockEditor
};
mockDomainObject.getCapability.andCallFake( function (name) {
mockDomainObject.getCapability.andCallFake(function (name) {
return capabilities[name];
});
mockDomainObject.hasCapability.andReturn(true);

View File

@ -50,7 +50,7 @@ define(
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockQ = { when: mockPromise };
mockParent = {
@ -64,10 +64,10 @@ define(
return capabilities[k].invoke(v);
}
};
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockComposition = jasmine.createSpyObj("composition", [ "invoke", "add" ]);
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
mockContext = jasmine.createSpyObj("context", ["getParent"]);
mockComposition = jasmine.createSpyObj("composition", ["invoke", "add"]);
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
mockType = jasmine.createSpyObj("type", ["hasFeature"]);
mockDomainObject.getId.andReturn("test");
mockDomainObject.getCapability.andReturn(mockContext);
@ -82,7 +82,7 @@ define(
type: mockType
};
model = {
composition: [ "a", "b", "c" ]
composition: ["a", "b", "c"]
};
actionContext = {

View File

@ -38,7 +38,9 @@ define(
beforeEach(function () {
capabilities = {
type: {
getProperties: function () { return []; },
getProperties: function () {
return [];
},
hasFeature: jasmine.createSpy('hasFeature')
},
persistence: jasmine.createSpyObj("persistence", ["persist"]),
@ -47,11 +49,21 @@ define(
model = {};
input = {};
object = {
getId: function () { return 'test-id'; },
getCapability: function (k) { return capabilities[k]; },
getModel: function () { return model; },
useCapability: function (k, v) { return capabilities[k](v); },
hasCapability: function () { return true; }
getId: function () {
return 'test-id';
},
getCapability: function (k) {
return capabilities[k];
},
getModel: function () {
return model;
},
useCapability: function (k, v) {
return capabilities[k](v);
},
hasCapability: function () {
return true;
}
};
context = { someKey: "some value", domainObject: object };
dialogService = {

View File

@ -30,14 +30,22 @@ define(
beforeEach(function () {
type = {
getProperties: function () { return properties; }
getProperties: function () {
return properties;
}
};
model = { x: "initial value" };
properties = ["x", "y", "z"].map(function (k) {
return {
getValue: function (model) { return model[k]; },
setValue: function (model, v) { model[k] = v; },
getDefinition: function () { return { control: 'textfield '}; }
getValue: function (model) {
return model[k];
},
setValue: function (model, v) {
model[k] = v;
},
getDefinition: function () {
return { control: 'textfield '};
}
};
});

View File

@ -57,19 +57,19 @@ define(
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockChildObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockGrandchildObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockRootObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockQ = { when: mockPromise };
mockParent = {
@ -83,13 +83,13 @@ define(
return capabilities[k].invoke(v);
}
};
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockRootContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
mockContext = jasmine.createSpyObj("context", ["getParent"]);
mockChildContext = jasmine.createSpyObj("context", ["getParent"]);
mockGrandchildContext = jasmine.createSpyObj("context", ["getParent"]);
mockRootContext = jasmine.createSpyObj("context", ["getParent"]);
mockMutation = jasmine.createSpyObj("mutation", ["invoke"]);
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
mockType = jasmine.createSpyObj("type", ["hasFeature"]);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[
@ -113,7 +113,7 @@ define(
type: mockType
};
model = {
composition: [ "a", "test", "b" ]
composition: ["a", "test", "b"]
};
actionContext = { domainObject: mockDomainObject };

View File

@ -52,11 +52,11 @@ define(
);
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel", "isEditContextRoot" ]
["save", "cancel", "isEditContextRoot"]
);
mockActionCapability = jasmine.createSpyObj(
"actionCapability",
[ "perform"]
["perform"]
);
capabilities.editor = mockEditorCapability;
capabilities.action = mockActionCapability;
@ -90,7 +90,7 @@ define(
function () {
mockDomainObject.getModel.andReturn({persisted: undefined});
expect(SaveAction.appliesTo(actionContext)).toBe(false);
});
});
it("uses the editor capability to save the object",
function () {

View File

@ -38,7 +38,7 @@ define(
capabilities = {},
action;
function noop () {}
function noop() {}
function mockPromise(value) {
return (value || {}).then ? value :
@ -49,7 +49,7 @@ define(
catch: function (callback) {
return mockPromise(callback(value));
}
} ;
} ;
}
beforeEach(function () {
@ -78,7 +78,7 @@ define(
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel", "isEditContextRoot" ]
["save", "cancel", "isEditContextRoot"]
);
mockEditorCapability.cancel.andReturn(mockPromise(undefined));
mockEditorCapability.save.andReturn(mockPromise(true));
@ -130,7 +130,7 @@ define(
action.createWizard.andReturn({
getFormStructure: noop,
getInitialFormValue: noop,
populateObjectFromInput: function() {
populateObjectFromInput: function () {
return mockDomainObject;
}
});

View File

@ -82,7 +82,7 @@ define(
status: mockStatusCapability
};
mockDomainObject.hasCapability.andCallFake(function(name) {
mockDomainObject.hasCapability.andCallFake(function (name) {
return capabilities[name] !== undefined;
});
@ -126,8 +126,8 @@ define(
expect(capability.inEditContext()).toBe(true);
});
describe("save", function() {
beforeEach(function() {
describe("save", function () {
beforeEach(function () {
capability.edit();
capability.save();
});
@ -139,8 +139,8 @@ define(
});
});
describe("cancel", function() {
beforeEach(function() {
describe("cancel", function () {
beforeEach(function () {
capability.edit();
capability.cancel();
});
@ -152,10 +152,10 @@ define(
});
});
describe("dirty", function() {
describe("dirty", function () {
var model = {};
beforeEach(function() {
beforeEach(function () {
mockDomainObject.getModel.andReturn(model);
capability.edit();
capability.cancel();

View File

@ -33,18 +33,18 @@ define(
mockCapabilityService,
provider;
beforeEach(function() {
beforeEach(function () {
mockQ = {};
mockTransactionService = {};
mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]);
mockCapabilityService.getCapabilities.andReturn({
persistence: function() {}
persistence: function () {}
});
provider = new TransactionCapabilityDecorator(mockQ, mockTransactionService, mockCapabilityService);
});
it("decorates the persistence capability", function() {
it("decorates the persistence capability", function () {
var capabilities = provider.getCapabilities();
expect(capabilities.persistence({}) instanceof TransactionalPersistenceCapability).toBe(true);
});

View File

@ -29,7 +29,7 @@ define(
function fastPromise(val) {
return {
then: function(callback) {
then: function (callback) {
return callback(val);
}
};
@ -42,7 +42,7 @@ define(
mockDomainObject,
capability;
beforeEach(function() {
beforeEach(function () {
mockQ = jasmine.createSpyObj("$q", ["when"]);
mockQ.when.andCallFake(function (val) {
return fastPromise(val);
@ -61,14 +61,14 @@ define(
});
it("if no transaction is active, passes through to persistence" +
" provider", function() {
" provider", function () {
mockTransactionService.isActive.andReturn(false);
capability.persist();
expect(mockPersistence.persist).toHaveBeenCalled();
});
it("if transaction is active, persist and cancel calls are" +
" queued", function() {
" queued", function () {
mockTransactionService.isActive.andReturn(true);
capability.persist();
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
@ -78,7 +78,7 @@ define(
expect(mockPersistence.refresh).toHaveBeenCalled();
});
it("persist call is only added to transaction once", function() {
it("persist call is only added to transaction once", function () {
mockTransactionService.isActive.andReturn(true);
capability.persist();
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();

View File

@ -52,15 +52,15 @@ define(
);
mockScope = jasmine.createSpyObj(
"$scope",
[ "$on", "$watch" ]
["$on", "$watch"]
);
mockObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
);
mockType = jasmine.createSpyObj(
"type",
[ "hasFeature" ]
["hasFeature"]
);
mockStatusCapability = jasmine.createSpyObj('statusCapability',
["get"]
@ -99,8 +99,8 @@ define(
expect(controller.getUnloadWarning()).toBeUndefined();
// Override the policy service to prevent navigation
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
callback(errorMessage);
mockPolicyService.allow.andCallFake(function (category, object, context, callback) {
callback(errorMessage);
});
// Should have some warning message here now

View File

@ -34,11 +34,11 @@ define(
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getCapability' ]
['getId', 'getCapability']
);
mockContext = jasmine.createSpyObj(
'context',
[ 'getTrueRoot' ]
['getTrueRoot']
);
mockDomainObject.getId.andReturn('test-id');

View File

@ -34,8 +34,8 @@ define(
controller = new ElementsController(mockScope);
});
function getModel (model) {
return function() {
function getModel(model) {
return function () {
return model;
};
}

View File

@ -58,10 +58,10 @@ define(
mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']);
mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']);
mockDomainObject.getCapability.andCallFake(function(capability){
mockDomainObject.getCapability.andCallFake(function (capability) {
return capabilities[capability];
});
mockDomainObject.hasCapability.andCallFake(function(capability){
mockDomainObject.hasCapability.andCallFake(function (capability) {
return !!capabilities[capability];
});
@ -88,42 +88,42 @@ define(
});
it("allows the edit action when there are editable views", function () {
testViews = [ editableView ];
testViews = [editableView];
expect(policy.allow(mockEditAction, testContext)).toBe(true);
});
it("allows the edit properties action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
testViews = [nonEditableView, nonEditableView];
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
});
it("disallows the edit action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
testViews = [nonEditableView, nonEditableView];
expect(policy.allow(mockEditAction, testContext)).toBe(false);
});
it("disallows the edit properties action when there are" +
" editable views", function () {
testViews = [ editableView ];
testViews = [editableView];
expect(policy.allow(mockPropertiesAction, testContext)).toBe(false);
});
it("disallows the edit action when object is already being" +
" edited", function () {
testViews = [ editableView ];
testViews = [editableView];
mockEditorCapability.isEditContextRoot.andReturn(true);
expect(policy.allow(mockEditAction, testContext)).toBe(false);
});
it("allows editing of panels in plot view", function () {
testViews = [ plotView ];
testViews = [plotView];
mockTypeCapability.getKey.andReturn('telemetry.panel');
expect(policy.allow(mockEditAction, testContext)).toBe(true);
});
it("disallows editing of plot view when object not a panel type", function () {
testViews = [ plotView ];
testViews = [plotView];
mockTypeCapability.getKey.andReturn('something.else');
expect(policy.allow(mockEditAction, testContext)).toBe(false);
@ -131,7 +131,7 @@ define(
it("allows the edit properties outside of the 'view-control' category", function () {
testViews = [ nonEditableView ];
testViews = [nonEditableView];
testContext.category = "something-else";
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
});

View File

@ -61,12 +61,12 @@ define(
policy = new EditContextualActionPolicy(navigationService, editModeBlacklist, nonEditContextBlacklist);
});
it('Allows all actions when navigated object not in edit mode', function() {
it('Allows all actions when navigated object not in edit mode', function () {
expect(policy.allow(mockAction, context)).toBe(true);
});
it('Allows "window" action when navigated object in edit mode,' +
' but selected object not in edit mode ', function() {
' but selected object not in edit mode ', function () {
navigatedObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);
metadata.key = "window";
@ -75,7 +75,7 @@ define(
it('Allows "remove" action when navigated object in edit mode,' +
' and selected object not editable, but its parent is.',
function() {
function () {
var mockParent = jasmine.createSpyObj("parentObject", ["hasCapability"]),
mockContextCapability = jasmine.createSpyObj("contextCapability", ["getParent"]);
@ -93,10 +93,10 @@ define(
metadata.key = "remove";
expect(policy.allow(mockAction, context)).toBe(true);
});
});
it('Disallows "move" action when navigated object in edit mode,' +
' but selected object not in edit mode ', function() {
' but selected object not in edit mode ', function () {
navigatedObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);
mockEditorCapability.inEditContext.andReturn(false);
@ -105,7 +105,7 @@ define(
});
it('Disallows copy action when navigated object and' +
' selected object in edit mode', function() {
' selected object in edit mode', function () {
navigatedObject.hasCapability.andReturn(true);
mockDomainObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);

View File

@ -36,7 +36,7 @@ define(
['hasCapability', 'getCapability']
);
mockDomainObject.getCapability.andReturn({
inEditContext: function () {
inEditContext: function () {
return true;
}
});

View File

@ -72,7 +72,7 @@ define(
mockDomainObject.getModel.andReturn({});
mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.useCapability.andReturn(true);
mockDomainObject.getCapability.andCallFake(function(capability){
mockDomainObject.getCapability.andCallFake(function (capability) {
return mockCapabilities[capability];
});

View File

@ -34,13 +34,13 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
'$scope',
[ '$on', '$watch', '$watchCollection', "commit" ]
['$on', '$watch', '$watchCollection', "commit"]
);
mockElement = {};
testAttrs = { toolbar: 'testToolbar' };
mockScope.$parent = jasmine.createSpyObj(
'$parent',
[ '$watch', '$watchCollection' ]
['$watch', '$watchCollection']
);
mockUnwatch = jasmine.createSpy('unwatch');
@ -92,7 +92,7 @@ define(
// Provide a view which has a toolbar
representer.represent({
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
});
// Update the selection
@ -120,7 +120,7 @@ define(
// Provide a view which has a toolbar
representer.represent({
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
});
// Update the selection

View File

@ -76,7 +76,7 @@ define(
it("provides properties from the original structure", function () {
expect(
new EditToolbar(testStructure, [ testABC ])
new EditToolbar(testStructure, [testABC])
.getStructure()
.sections[0]
.items[1]
@ -87,7 +87,7 @@ define(
// This is needed by mct-toolbar
it("adds keys to form structure", function () {
expect(
new EditToolbar(testStructure, [ testABC ])
new EditToolbar(testStructure, [testABC])
.getStructure()
.sections[0]
.items[1]
@ -97,20 +97,20 @@ define(
it("marks empty sections as hidden", function () {
// Verify that all sections are included when applicable...
toolbar.setSelection([ testABCXYZ ]);
toolbar.setSelection([testABCXYZ]);
expect(toolbar.getStructure().sections.map(getVisibility))
.toEqual([ true, true, false ]);
.toEqual([true, true, false]);
// ...but omitted when only some are applicable
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
expect(toolbar.getStructure().sections.map(getVisibility))
.toEqual([ true, false, false ]);
.toEqual([true, false, false]);
});
it("reads properties from selections", function () {
var structure, state;
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
state = toolbar.getState();
@ -126,9 +126,11 @@ define(
it("reads properties from getters", function () {
var structure, state;
testABC.a = function () { return "from a getter!"; };
testABC.a = function () {
return "from a getter!";
};
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
state = toolbar.getState();
@ -137,7 +139,7 @@ define(
});
it("sets properties on update", function () {
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
toolbar.updateState(
toolbar.getStructure().sections[0].items[0].key,
"new value"
@ -151,7 +153,7 @@ define(
testABC.a = jasmine.createSpy('a');
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
toolbar.updateState(
@ -165,7 +167,7 @@ define(
it("provides a return value describing update status", function () {
// Should return true if actually updated, otherwise false
var key;
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
key = toolbar.getStructure().sections[0].items[0].key;
expect(toolbar.updateState(key, testABC.a)).toBeFalsy();
expect(toolbar.updateState(key, "new value")).toBeTruthy();
@ -173,35 +175,35 @@ define(
it("removes inapplicable items", function () {
// First, verify with all items
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ true, true, true ]);
.toEqual([true, true, true]);
// Then, try with some items omitted
toolbar.setSelection([ testABC, testAB ]);
toolbar.setSelection([testABC, testAB]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ true, true, false ]);
.toEqual([true, true, false]);
});
it("removes inconsistent states", function () {
// Only two of three values match among these selections
toolbar.setSelection([ testABC, testABC2 ]);
toolbar.setSelection([testABC, testABC2]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ false, true, true ]);
.toEqual([false, true, true]);
});
it("allows inclusive items", function () {
// One inclusive item is in the set, property 'x' of the
// second section; make sure items are pruned down
// when only some of the selection has x,y,z properties
toolbar.setSelection([ testABC, testABCXYZ ]);
toolbar.setSelection([testABC, testABCXYZ]);
expect(toolbar.getStructure().sections[1].items.map(getVisibility))
.toEqual([ true, false, false ]);
.toEqual([true, false, false]);
});
it("removes inclusive items when there are no matches", function () {
toolbar.setSelection([ testABCYZ ]);
toolbar.setSelection([testABCYZ]);
expect(toolbar.getStructure().sections[1].items.map(getVisibility))
.toEqual([ false, true, true ]);
.toEqual([false, true, true]);
});
it("adds click functions when a method is specified", function () {

View File

@ -30,7 +30,7 @@ define(
mockLog,
transactionService;
function fastPromise (val) {
function fastPromise(val) {
return {
then: function (callback) {
return fastPromise(callback(val));
@ -75,8 +75,8 @@ define(
describe("commit", function () {
var onCommits;
beforeEach(function() {
onCommits = [0, 1, 2].map(function(val) {
beforeEach(function () {
onCommits = [0, 1, 2].map(function (val) {
return jasmine.createSpy("onCommit" + val);
});
@ -87,7 +87,7 @@ define(
it("commit calls all queued commit functions", function () {
expect(transactionService.onCommits.length).toBe(3);
transactionService.commit();
onCommits.forEach( function (spy) {
onCommits.forEach(function (spy) {
expect(spy).toHaveBeenCalled();
});
});
@ -104,8 +104,8 @@ define(
describe("cancel", function () {
var onCancels;
beforeEach(function() {
onCancels = [0, 1, 2].map(function(val) {
beforeEach(function () {
onCancels = [0, 1, 2].map(function (val) {
return jasmine.createSpy("onCancel" + val);
});
@ -118,7 +118,7 @@ define(
it("cancel calls all queued cancel functions", function () {
expect(transactionService.onCancels.length).toBe(3);
transactionService.cancel();
onCancels.forEach( function (spy) {
onCancels.forEach(function (spy) {
expect(spy).toHaveBeenCalled();
});
});

View File

@ -24,7 +24,7 @@ define(
['../src/FormatProvider'],
function (FormatProvider) {
var KEYS = [ 'a', 'b', 'c' ];
var KEYS = ['a', 'b', 'c'];
describe("The FormatProvider", function () {
var mockFormats,
@ -35,12 +35,14 @@ define(
mockFormatInstances = KEYS.map(function (k) {
return jasmine.createSpyObj(
'format-' + k,
[ 'parse', 'validate', 'format' ]
['parse', 'validate', 'format']
);
});
// Return constructors
mockFormats = KEYS.map(function (k, i) {
function MockFormat() { return mockFormatInstances[i]; }
function MockFormat() {
return mockFormatInstances[i];
}
MockFormat.key = k;
return MockFormat;
});

View File

@ -380,7 +380,7 @@ define([
{
"key": "mctTree",
"implementation": MCTTree,
"depends": [ '$parse', 'gestureService' ]
"depends": ['$parse', 'gestureService']
}
],
"constants": [

View File

@ -40,7 +40,7 @@ define(
function BannerController($scope, notificationService, dialogService) {
$scope.active = notificationService.active;
$scope.action = function (action, $event){
$scope.action = function (action, $event) {
/*
Prevents default 'maximize' behaviour when clicking on
notification button
@ -48,19 +48,19 @@ define(
$event.stopPropagation();
return action();
};
$scope.dismiss = function(notification, $event) {
$scope.dismiss = function (notification, $event) {
$event.stopPropagation();
notification.dismissOrMinimize();
};
$scope.maximize = function(notification) {
if (notification.model.severity !== "info"){
$scope.maximize = function (notification) {
if (notification.model.severity !== "info") {
notification.model.cancel = function(){
notification.model.cancel = function () {
dialogService.dismiss();
};
//If the notification is dismissed by the user, close
// the dialog.
notification.onDismiss(function(){
notification.onDismiss(function () {
dialogService.dismiss();
});

View File

@ -65,7 +65,7 @@ define(
* Get the current state of the toggle.
* @return {boolean} true if active
*/
ClickAwayController.prototype.isActive =function () {
ClickAwayController.prototype.isActive = function () {
return this.state;
};

View File

@ -21,7 +21,7 @@
*****************************************************************************/
define(
[ 'moment' ],
['moment'],
function (moment) {
var TIME_NAMES = {

View File

@ -69,7 +69,9 @@ define(
function updateList(ids) {
function updateSelectedObjects(objects) {
// Look up from the
function getObject(id) { return objects[id]; }
function getObject(id) {
return objects[id];
}
self.selectedObjects =
ids.filter(getObject).map(getObject);
}

View File

@ -76,7 +76,7 @@ define(
// based on a new mouse event object.
function updatePosition(event) {
// Get the current position, as an array
var currentPosition = [ event.pageX, event.pageY ];
var currentPosition = [event.pageX, event.pageY];
// Track the initial position, if one hasn't been observed
initialPosition = initialPosition || currentPosition;

View File

@ -46,7 +46,7 @@ define(
function link(scope, element, attrs, ctrl, transclude) {
var div = $compile(TEMPLATE)(scope),
rect = element.parent()[0].getBoundingClientRect(),
position = [ rect.left, rect.top ],
position = [rect.left, rect.top],
popup = popupService.display(div, position);
// TODO: Handle in CSS;

View File

@ -59,7 +59,7 @@ define(
},
// Grab the event when the user is done moving
// the splitter and pass it on
endMove: function() {
endMove: function () {
mctSplitPane.toggleClass('resizing');
}
};

View File

@ -78,7 +78,7 @@ define(
var $document = this.$document,
$window = this.$window,
body = $document.find('body'),
winDim = [ $window.innerWidth, $window.innerHeight ],
winDim = [$window.innerWidth, $window.innerHeight],
styles = { position: 'absolute' },
margin,
offset;
@ -93,7 +93,7 @@ define(
options.offsetX !== undefined ? options.offsetX : 0,
options.offsetY !== undefined ? options.offsetY : 0
];
margin = [ options.marginX, options.marginY ].map(function (m, i) {
margin = [options.marginX, options.marginY].map(function (m, i) {
return m === undefined ? (winDim[i] / 2) : m;
}).map(adjustNegatives);

View File

@ -75,7 +75,7 @@ define([
this.activeGestures = this.gestureService.attachGestures(
this.elements(),
domainObject,
[ 'info', 'menu', 'drag' ]
['info', 'menu', 'drag']
);
}
};

View File

@ -47,7 +47,7 @@ define(
mockPlainDocument =
jasmine.createSpyObj("document", ["createElement"]);
mockDocument = [ mockPlainDocument ];
mockDocument = [mockPlainDocument];
mockDocument.find = jasmine.createSpy("$document.find");
mockHead = jasmine.createSpyObj("head", ["append"]);
mockElement = jasmine.createSpyObj("link", ["setAttribute"]);

View File

@ -35,11 +35,13 @@ define(
beforeEach(function () {
mockIndicator = jasmine.createSpyObj(
"indicator",
[ "getGlyph", "getText" ]
["getGlyph", "getText"]
);
testIndicatorA = {};
testIndicatorB = function () { return mockIndicator; };
testIndicatorB = function () {
return mockIndicator;
};
testIndicatorC = { template: "someTemplate" };
testIndicators = [

View File

@ -32,7 +32,7 @@ define(
beforeEach(function () {
mockDocument = jasmine.createSpyObj(
"$document",
[ "on", "off" ]
["on", "off"]
);
mockTimeout = jasmine.createSpy('timeout');
controller = new ClickAwayController(

View File

@ -48,7 +48,7 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$apply", "$watch", "$watchCollection" ]
["$apply", "$watch", "$watchCollection"]
);
mockScope.ngModel = {};
mockScope.field = "testField";

View File

@ -39,35 +39,35 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$watch" ]
["$watch"]
);
mockScope.ngModel = {};
mockScope.ngModel.selectedObject = 'mock selected object';
mockObjectService = jasmine.createSpyObj(
"objectService",
[ "getObjects" ]
["getObjects"]
);
mockPromise = jasmine.createSpyObj(
"promise",
[ "then" ]
["then"]
);
mockObjectService.getObjects.andReturn(mockPromise);
mockDomainObject = jasmine.createSpyObj(
"selectedObject",
[ "hasCapability", "getCapability", "useCapability", "getModel" ]
["hasCapability", "getCapability", "useCapability", "getModel"]
);
mockDomainObject.getModel.andReturn({location: 'somewhere'});
mockDomainObject.hasCapability.andReturn(true);
mockContextCapability = jasmine.createSpyObj(
"context capability",
[ "getParent" ]
["getParent"]
);
mockLocationCapability = jasmine.createSpyObj(
"location capability",
[ "isLink" ]
["isLink"]
);
mockDomainObject.getCapability.andCallFake(function (param) {
if (param === 'location') {

View File

@ -43,7 +43,7 @@ define(
function makeMockObject(id) {
var mockObject = jasmine.createSpyObj(
'object-' + id,
[ 'getId' ]
['getId']
);
mockObject.getId.andReturn(id);
return mockObject;
@ -60,15 +60,15 @@ define(
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability', 'hasCapability' ]
['getCapability', 'hasCapability']
);
mockType = jasmine.createSpyObj(
'type',
[ 'instanceOf' ]
['instanceOf']
);
mockDomainObjects = {};
[ "ROOT", "abc", "def", "xyz" ].forEach(function (id) {
["ROOT", "abc", "def", "xyz"].forEach(function (id) {
mockDomainObjects[id] = makeMockObject(id);
});
@ -98,7 +98,7 @@ define(
});
it("watches for changes in controlled property", function () {
var testValue = [ "a", "b", 1, 2 ];
var testValue = ["a", "b", 1, 2];
// This test is sensitive to ordering of watch calls
expect(mockScope.$watchCollection.calls.length).toEqual(1);
// Make sure we're watching the correct object
@ -131,7 +131,7 @@ define(
});
it("loads objects when the underlying list changes", function () {
var testIds = [ "abc", "def", "xyz" ];
var testIds = ["abc", "def", "xyz"];
// This test is sensitive to ordering of watch calls
expect(mockScope.$watchCollection.calls.length).toEqual(1);
// Make sure we're watching the correct object

View File

@ -56,16 +56,16 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$apply", "$watch", "$watchCollection" ]
["$apply", "$watch", "$watchCollection"]
);
mockFormatService = jasmine.createSpyObj(
"formatService",
[ "getFormat" ]
["getFormat"]
);
testDefaultFormat = 'utc';
mockFormat = jasmine.createSpyObj(
"format",
[ "validate", "format", "parse" ]
["validate", "format", "parse"]
);
mockFormatService.getFormat.andReturn(mockFormat);

View File

@ -32,7 +32,9 @@ define(
function TestObject(id, context) {
return {
getId: function () { return id; },
getId: function () {
return id;
},
getCapability: function (key) {
return key === 'context' ? context : undefined;
}
@ -44,7 +46,7 @@ define(
mockTimeout = jasmine.createSpy("$timeout");
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
["getId", "getCapability", "getModel", "useCapability"]
);
controller = new TreeNodeController(mockScope, mockTimeout);
@ -71,7 +73,7 @@ define(
// This is needed to highlight the current selection
var mockContext = jasmine.createSpyObj(
"context",
[ "getParent", "getPath", "getRoot" ]
["getParent", "getPath", "getRoot"]
),
obj = new TestObject("test-object", mockContext);
@ -92,11 +94,11 @@ define(
it("expands a node if it is on the navigation path", function () {
var mockParentContext = jasmine.createSpyObj(
"parentContext",
[ "getParent", "getPath", "getRoot" ]
["getParent", "getPath", "getRoot"]
),
mockChildContext = jasmine.createSpyObj(
"childContext",
[ "getParent", "getPath", "getRoot" ]
["getParent", "getPath", "getRoot"]
),
parent = new TestObject("parent", mockParentContext),
child = new TestObject("child", mockChildContext);
@ -128,11 +130,11 @@ define(
it("does not expand a node if it is not on the navigation path", function () {
var mockParentContext = jasmine.createSpyObj(
"parentContext",
[ "getParent", "getPath", "getRoot" ]
["getParent", "getPath", "getRoot"]
),
mockChildContext = jasmine.createSpyObj(
"childContext",
[ "getParent", "getPath", "getRoot" ]
["getParent", "getPath", "getRoot"]
),
parent = new TestObject("parent", mockParentContext),
child = new TestObject("child", mockChildContext);
@ -161,11 +163,11 @@ define(
it("does not expand a node if no context is available", function () {
var mockParentContext = jasmine.createSpyObj(
"parentContext",
[ "getParent", "getPath", "getRoot" ]
["getParent", "getPath", "getRoot"]
),
mockChildContext = jasmine.createSpyObj(
"childContext",
[ "getParent", "getPath", "getRoot" ]
["getParent", "getPath", "getRoot"]
),
parent = new TestObject("parent", mockParentContext),
child = new TestObject("child", undefined);

View File

@ -33,9 +33,11 @@ define(
controller;
beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", [ "$watch" ]);
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
mockTimeout = jasmine.createSpy("$timeout");
mockTimeout.andCallFake(function (cb) { cb(); });
mockTimeout.andCallFake(function (cb) {
cb();
});
mockScope.ngModel = {};
controller = new ViewSwitcherController(mockScope, mockTimeout);
});

View File

@ -24,7 +24,7 @@ define(
["../../src/directives/MCTClickElsewhere"],
function (MCTClickElsewhere) {
var JQLITE_METHODS = [ "on", "off", "find", "parent" ];
var JQLITE_METHODS = ["on", "off", "find", "parent"];
describe("The mct-click-elsewhere directive", function () {
var mockDocument,
@ -48,7 +48,7 @@ define(
mockDocument =
jasmine.createSpyObj("$document", JQLITE_METHODS);
mockScope =
jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]);
jasmine.createSpyObj("$scope", ["$eval", "$apply", "$on"]);
mockElement =
jasmine.createSpyObj("element", JQLITE_METHODS);
mockBody =

View File

@ -35,7 +35,7 @@ define(
bundle: { path: "x", resources: "y" },
template: "<span>bar</span>",
key: "xyz",
attributes: [ "someAttr", "someOtherAttr" ]
attributes: ["someAttr", "someOtherAttr"]
}
],
mctContainer;

View File

@ -24,7 +24,7 @@ define(
["../../src/directives/MCTDrag"],
function (MCTDrag) {
var JQLITE_METHODS = [ "on", "off", "find" ];
var JQLITE_METHODS = ["on", "off", "find"];
describe("The mct-drag directive", function () {
var mockDocument,
@ -46,7 +46,7 @@ define(
mockDocument =
jasmine.createSpyObj("$document", JQLITE_METHODS);
mockScope =
jasmine.createSpyObj("$scope", [ "$eval", "$apply" ]);
jasmine.createSpyObj("$scope", ["$eval", "$apply"]);
mockElement =
jasmine.createSpyObj("element", JQLITE_METHODS);
mockBody =

View File

@ -24,7 +24,7 @@ define(
["../../src/directives/MCTPopup"],
function (MCTPopup) {
var JQLITE_METHODS = [ "on", "off", "find", "parent", "css", "append" ];
var JQLITE_METHODS = ["on", "off", "find", "parent", "css", "append"];
describe("The mct-popup directive", function () {
var mockCompile,
@ -48,7 +48,7 @@ define(
mockPopup =
jasmine.createSpyObj("popup", ["dismiss"]);
mockScope =
jasmine.createSpyObj("$scope", [ "$eval", "$apply", "$on" ]);
jasmine.createSpyObj("$scope", ["$eval", "$apply", "$on"]);
mockElement =
jasmine.createSpyObj("element", JQLITE_METHODS);
mockBody =
@ -98,7 +98,7 @@ define(
it("displays as a popup", function () {
expect(mockPopupService.display).toHaveBeenCalledWith(
mockNewElement,
[ testRect.left, testRect.top ]
[testRect.left, testRect.top]
);
});

View File

@ -48,16 +48,16 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
'$scope',
[ '$on', '$watch' ]
['$on', '$watch']
);
mockElement = jasmine.createSpyObj(
'element',
[ 'addClass' ]
['addClass']
);
testAttrs = {};
mockSplitPane = jasmine.createSpyObj(
'mctSplitPane',
[ 'position', 'toggleClass', 'anchor' ]
['position', 'toggleClass', 'anchor']
);
mctSplitter.link(
@ -92,7 +92,7 @@ define(
});
it("repositions during drag", function () {
mockScope.splitter.move([ 10, 0 ]);
mockScope.splitter.move([10, 0]);
expect(mockSplitPane.position)
.toHaveBeenCalledWith(testPosition + 10);
});

View File

@ -32,7 +32,7 @@ define([
beforeEach(function () {
mockGestureService = jasmine.createSpyObj(
'gestureService',
[ 'attachGestures' ]
['attachGestures']
);
mockParse = jasmine.createSpy('$parse');
mockExpr = jasmine.createSpy('expr');

View File

@ -33,9 +33,9 @@ define(
popupService;
beforeEach(function () {
mockDocument = jasmine.createSpyObj('$document', [ 'find' ]);
mockDocument = jasmine.createSpyObj('$document', ['find']);
testWindow = { innerWidth: 1000, innerHeight: 800 };
mockBody = jasmine.createSpyObj('body', [ 'append' ]);
mockBody = jasmine.createSpyObj('body', ['append']);
mockElement = jasmine.createSpyObj('element', [
'css',
'remove'
@ -49,13 +49,13 @@ define(
});
it("adds elements to the body of the document", function () {
popupService.display(mockElement, [ 0, 0 ]);
popupService.display(mockElement, [0, 0]);
expect(mockBody.append).toHaveBeenCalledWith(mockElement);
});
describe("when positioned in appropriate quadrants", function () {
it("orients elements relative to the top-left", function () {
popupService.display(mockElement, [ 25, 50 ]);
popupService.display(mockElement, [25, 50]);
expect(mockElement.css).toHaveBeenCalledWith({
position: 'absolute',
left: '25px',
@ -64,7 +64,7 @@ define(
});
it("orients elements relative to the top-right", function () {
popupService.display(mockElement, [ 800, 50 ]);
popupService.display(mockElement, [800, 50]);
expect(mockElement.css).toHaveBeenCalledWith({
position: 'absolute',
right: '200px',
@ -73,7 +73,7 @@ define(
});
it("orients elements relative to the bottom-right", function () {
popupService.display(mockElement, [ 800, 650 ]);
popupService.display(mockElement, [800, 650]);
expect(mockElement.css).toHaveBeenCalledWith({
position: 'absolute',
right: '200px',
@ -82,7 +82,7 @@ define(
});
it("orients elements relative to the bottom-left", function () {
popupService.display(mockElement, [ 120, 650 ]);
popupService.display(mockElement, [120, 650]);
expect(mockElement.css).toHaveBeenCalledWith({
position: 'absolute',
left: '120px',

View File

@ -32,7 +32,7 @@ define(
beforeEach(function () {
mockElement =
jasmine.createSpyObj('element', [ 'css', 'remove' ]);
jasmine.createSpyObj('element', ['css', 'remove']);
testStyles = { left: '12px', top: '14px' };
popup = new Popup(mockElement, testStyles);
});

View File

@ -40,15 +40,15 @@ define(
// do the view search
mockLocation = jasmine.createSpyObj(
"$location",
[ "path", "search" ]
["path", "search"]
);
// The mockDomainObject is initialized as a
// The mockDomainObject is initialized as a
// spy object to ultimately be passed into the
// urlService urlFor function
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
["getId", "getCapability", "getModel", "useCapability"]
);
mockContext = jasmine.createSpyObj('context', ['getPath']);
testViews = [

View File

@ -63,7 +63,7 @@ define([
beforeEach(function () {
mockGestureService = jasmine.createSpyObj(
'gestureService',
[ 'attachGestures' ]
['attachGestures']
);
mockGestureHandle = jasmine.createSpyObj('gestures', ['destroy']);
@ -100,15 +100,15 @@ define([
function makeGenericCapabilities() {
var mockContext =
jasmine.createSpyObj('context', [ 'getPath' ]),
jasmine.createSpyObj('context', ['getPath']),
mockType =
jasmine.createSpyObj('type', [ 'getGlyph' ]),
jasmine.createSpyObj('type', ['getGlyph']),
mockLocation =
jasmine.createSpyObj('location', [ 'isLink' ]),
jasmine.createSpyObj('location', ['isLink']),
mockMutation =
jasmine.createSpyObj('mutation', [ 'listen' ]),
jasmine.createSpyObj('mutation', ['listen']),
mockStatus =
jasmine.createSpyObj('status', [ 'listen', 'list' ]);
jasmine.createSpyObj('status', ['listen', 'list']);
mockStatus.list.andReturn([]);
@ -231,7 +231,7 @@ define([
calledBackInner = false;
newCapabilities.composition =
jasmine.createSpyObj('composition', [ 'invoke' ]);
jasmine.createSpyObj('composition', ['invoke']);
newCapabilities.composition.invoke
.andReturn(Promise.resolve([mockGrandchild]));
mockComposition.push(mockNewChild);
@ -274,7 +274,7 @@ define([
beforeEach(function () {
var mockStatus = mockComposition[1].getCapability('status');
testStatuses = [ 'foo' ];
testStatuses = ['foo'];
mockStatus.list.andReturn(testStatuses);
mockStatus.listen.mostRecentCall.args[0](testStatuses);

View File

@ -40,7 +40,7 @@ define({
offsetX: 0,
offsetY: -26
},
BUBBLE_MOBILE_POSITION: [ 0, -25 ],
BUBBLE_MOBILE_POSITION: [0, -25],
// Max width and margins allowed for bubbles;
// defined in /platform/commonUI/general/res/sass/_constants.scss
BUBBLE_MARGIN_LR: 10,

View File

@ -45,7 +45,7 @@ define(
// Record touch position, so bubble can be shown at latest
// touch position, also offset by 22px to left (accounts for
// a finger-sized touch on the info button)
touchPosition = [ event.clientX - 22, event.clientY ];
touchPosition = [event.clientX - 22, event.clientY];
}
// Hides the bubble and detaches the

View File

@ -71,7 +71,7 @@ define(
InfoGesture.prototype.trackPosition = function (event) {
// Record mouse position, so bubble can be shown at latest
// mouse position (not just where the mouse entered)
this.mousePosition = [ event.clientX, event.clientY ];
this.mousePosition = [event.clientX, event.clientY];
};
InfoGesture.prototype.hideBubble = function () {

View File

@ -44,28 +44,28 @@ define(
beforeEach(function () {
mockTimeout = jasmine.createSpy('$timeout');
mockDocument = jasmine.createSpyObj('$document', ['find']);
mockBody = jasmine.createSpyObj('body', [ 'on', 'off', 'scope', 'css', 'unbind' ]);
mockBody = jasmine.createSpyObj('body', ['on', 'off', 'scope', 'css', 'unbind']);
mockDocument.find.andReturn(mockBody);
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']);
mockInfoService = jasmine.createSpyObj(
'infoService',
[ 'display' ]
['display']
);
mockElement = jasmine.createSpyObj(
'element',
[ 'on', 'off', 'scope', 'css' ]
['on', 'off', 'scope', 'css']
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getCapability', 'useCapability', 'getModel' ]
['getId', 'getCapability', 'useCapability', 'getModel']
);
mockEvent = jasmine.createSpyObj("event", ["preventDefault", "stopPropagation"]);
mockEvent.pageX = 0;
mockEvent.pageY = 0;
mockScope = jasmine.createSpyObj('$scope', [ '$on' ]);
mockScope = jasmine.createSpyObj('$scope', ['$on']);
mockOff = jasmine.createSpy('$off');
testMetadata = [ { name: "Test name", value: "Test value" } ];
testMetadata = [{ name: "Test name", value: "Test value" }];
mockHide = jasmine.createSpy('hide');
mockDomainObject.getModel.andReturn({ name: "Test Object" });

View File

@ -52,19 +52,19 @@ define(
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile']);
mockInfoService = jasmine.createSpyObj(
'infoService',
[ 'display' ]
['display']
);
mockElement = jasmine.createSpyObj(
'element',
[ 'on', 'off', 'scope', 'css' ]
['on', 'off', 'scope', 'css']
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getCapability', 'useCapability', 'getModel' ]
['getId', 'getCapability', 'useCapability', 'getModel']
);
mockScope = jasmine.createSpyObj('$scope', [ '$on' ]);
mockScope = jasmine.createSpyObj('$scope', ['$on']);
mockOff = jasmine.createSpy('$off');
testMetadata = [ { name: "Test name", value: "Test value" } ];
testMetadata = [{ name: "Test name", value: "Test value" }];
mockPromise = jasmine.createSpyObj('promise', ['then']);
mockHide = jasmine.createSpy('hide');
@ -101,7 +101,7 @@ define(
jasmine.any(String),
"Test Object",
testMetadata,
[ 1977, 42 ]
[1977, 42]
);
});
@ -130,7 +130,7 @@ define(
jasmine.any(String),
"Test Object",
testMetadata,
[ 1984, 11 ]
[1984, 11]
);
});

View File

@ -79,7 +79,7 @@ define(
service.display('', '', {}, [123, 456]);
expect(mockPopupService.display).toHaveBeenCalledWith(
mockElements[0],
[ 123, 456 ],
[123, 456],
jasmine.any(Object)
);
});
@ -102,16 +102,16 @@ define(
service.display('', '', {}, [123, 456]);
expect(mockPopupService.display).toHaveBeenCalledWith(
mockElements[0],
[ 0, -25 ],
[0, -25],
jasmine.any(Object)
);
});
[ false, true ].forEach(function (goesLeft) {
[ false, true].forEach(function (goesUp) {
[false, true].forEach(function (goesLeft) {
[false, true].forEach(function (goesUp) {
var vertical = goesUp ? "up" : "down",
horizontal = goesLeft ? "left" : "right",
location = [ vertical, horizontal].join('-');
location = [vertical, horizontal].join('-');
describe("when bubble goes " + location, function () {
var expectedLocation = [
goesUp ? "bottom" : "top",
@ -123,7 +123,7 @@ define(
mockPopup.goesDown.andReturn(!goesUp);
mockPopup.goesLeft.andReturn(goesLeft);
mockPopup.goesRight.andReturn(!goesLeft);
service.display('', '', {}, [ 10, 10 ]);
service.display('', '', {}, [10, 10]);
});
it("positions the arrow in the " + expectedLocation, function () {

View File

@ -34,11 +34,11 @@ define(
'isTouch'
],
TEST_PERMUTATIONS = [
[ 'isMobile', 'isPhone', 'isTouch', 'isPortrait' ],
[ 'isMobile', 'isPhone', 'isTouch', 'isLandscape' ],
[ 'isMobile', 'isTablet', 'isTouch', 'isPortrait' ],
[ 'isMobile', 'isTablet', 'isTouch', 'isLandscape' ],
[ 'isTouch' ],
['isMobile', 'isPhone', 'isTouch', 'isPortrait'],
['isMobile', 'isPhone', 'isTouch', 'isLandscape'],
['isMobile', 'isTablet', 'isTouch', 'isPortrait'],
['isMobile', 'isTablet', 'isTouch', 'isLandscape'],
['isTouch'],
[]
];
@ -54,11 +54,11 @@ define(
);
mockDocument = jasmine.createSpyObj(
'$document',
[ 'find' ]
['find']
);
mockBody = jasmine.createSpyObj(
'body',
[ 'addClass' ]
['addClass']
);
mockDocument.find.andCallFake(function (sel) {
return sel === 'body' && mockBody;

View File

@ -24,7 +24,7 @@ define(
['../src/MCTDevice'],
function (MCTDevice) {
var JQLITE_METHODS = [ 'replaceWith' ];
var JQLITE_METHODS = ['replaceWith'];
describe("The mct-device directive", function () {
var mockAgentService,
@ -41,7 +41,7 @@ define(
beforeEach(function () {
mockAgentService = jasmine.createSpyObj(
"agentService",
[ "isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape" ]
["isMobile", "isPhone", "isTablet", "isPortrait", "isLandscape"]
);
mockTransclude = jasmine.createSpy("$transclude");
mockElement = jasmine.createSpyObj(name, JQLITE_METHODS);

View File

@ -42,7 +42,7 @@ define(
/**
* Launch a dialog showing a list of current notifications.
*/
$scope.showNotificationsList = function(){
$scope.showNotificationsList = function () {
dialogService.getDialogResponse('overlay-message-list', {
dialog: {
title: "Messages",
@ -50,7 +50,7 @@ define(
// from the notifications
messages: notificationService.notifications
},
cancel: function(){
cancel: function () {
dialogService.dismiss();
}
});

View File

@ -118,7 +118,7 @@ define(
function NotificationService($timeout, topic, DEFAULT_AUTO_DISMISS, MINIMIZE_TIMEOUT) {
this.notifications = [];
this.$timeout = $timeout;
this.highest ={ severity: "info" };
this.highest = { severity: "info" };
this.DEFAULT_AUTO_DISMISS = DEFAULT_AUTO_DISMISS;
this.MINIMIZE_TIMEOUT = MINIMIZE_TIMEOUT;
this.topic = topic;
@ -143,7 +143,7 @@ define(
//Check this is a known notification
var index = service.notifications.indexOf(notification);
if (service.active.timeout){
if (service.active.timeout) {
/*
Method can be called manually (clicking dismiss) or
automatically from an auto-timeout. this.active.timeout
@ -157,10 +157,10 @@ define(
}
if (index >= 0) {
notification.model.minimized=true;
notification.model.minimized = true;
//Add a brief timeout before showing the next notification
// in order to allow the minimize animation to run through.
service.$timeout(function() {
service.$timeout(function () {
service.setActiveNotification(service.selectNextNotification());
}, service.MINIMIZE_TIMEOUT);
}
@ -180,7 +180,7 @@ define(
//Check this is a known notification
var index = service.notifications.indexOf(notification);
if (service.active.timeout){
if (service.active.timeout) {
/* Method can be called manually (clicking dismiss) or
* automatically from an auto-timeout. this.active.timeout
* acts as a semaphore to prevent race conditions. Cancel any
@ -219,7 +219,7 @@ define(
* Returns the notification that is currently visible in the banner area
* @returns {Notification}
*/
NotificationService.prototype.getActiveNotification = function (){
NotificationService.prototype.getActiveNotification = function () {
return this.active.notification;
};
@ -281,8 +281,8 @@ define(
"alert": 2,
"error": 3
};
this.highest.severity = this.notifications.reduce(function(previous, notification){
if (severity[notification.model.severity] > severity[previous]){
this.highest.severity = this.notifications.reduce(function (previous, notification) {
if (severity[notification.model.severity] > severity[previous]) {
return notification.model.severity;
} else {
return previous;
@ -308,23 +308,23 @@ define(
notification = {
model: notificationModel,
minimize: function() {
minimize: function () {
self.minimize(self, notification);
},
dismiss: function(){
dismiss: function () {
self.dismiss(self, notification);
topic.notify();
},
dismissOrMinimize: function(){
dismissOrMinimize: function () {
self.dismissOrMinimize(notification);
},
onDismiss: function(callback) {
onDismiss: function (callback) {
topic.listen(callback);
}
};
notificationModel.severity = notificationModel.severity || "info";
if (notificationModel.autoDismiss === true){
if (notificationModel.autoDismiss === true) {
notificationModel.autoDismiss = this.DEFAULT_AUTO_DISMISS;
}
@ -337,7 +337,7 @@ define(
notificationModel.options = notificationModel.options || [];
notificationModel.options.unshift({
label: "Dismiss",
callback: function() {
callback: function () {
notification.dismiss();
}
});
@ -350,10 +350,10 @@ define(
/*
Check if there is already an active (ie. visible) notification
*/
if (!this.active.notification){
if (!this.active.notification) {
this.setActiveNotification(notification);
} else if (!this.active.timeout){
} else if (!this.active.timeout) {
/*
If there is already an active notification, time it out. If it's
already got a timeout in progress (either because it has had
@ -397,7 +397,7 @@ define(
} else {
delete this.active.timeout;
}
};
};
/**
* Used internally by the NotificationService
@ -406,17 +406,17 @@ define(
*/
NotificationService.prototype.selectNextNotification = function () {
var notification,
i=0;
i = 0;
/*
Loop through the notifications queue and find the first one that
has not already been minimized (manually or otherwise).
*/
for (; i< this.notifications.length; i++) {
for (; i < this.notifications.length; i++) {
notification = this.notifications[i];
if (!notification.model.minimized &&
notification!== this.active.notification) {
notification !== this.active.notification) {
return notification;
}

View File

@ -30,7 +30,7 @@ define(
mockDialogService,
controller;
beforeEach(function(){
beforeEach(function () {
mockNotificationService = jasmine.createSpy("notificationService");
mockScope = jasmine.createSpy("$scope");
mockDialogService = jasmine.createSpyObj(
@ -43,12 +43,12 @@ define(
controller = new NotificationIndicatorController(mockScope, mockNotificationService, mockDialogService);
});
it("exposes the highest notification severity to the template", function() {
it("exposes the highest notification severity to the template", function () {
expect(mockScope.highest).toBeTruthy();
expect(mockScope.highest.severity).toBe("error");
});
it("invokes the dialog service to show list of messages", function() {
it("invokes the dialog service to show list of messages", function () {
expect(mockScope.showNotificationsList).toBeDefined();
mockScope.showNotificationsList();
expect(mockDialogService.getDialogResponse).toHaveBeenCalled();
@ -60,7 +60,7 @@ define(
expect(mockDialogService.dismiss).toHaveBeenCalled();
});
it("provides a means of dismissing the message list", function() {
it("provides a means of dismissing the message list", function () {
expect(mockScope.showNotificationsList).toBeDefined();
mockScope.showNotificationsList();
expect(mockDialogService.getDialogResponse).toHaveBeenCalled();

Some files were not shown because too many files have changed in this diff Show More