Merge pull request #927 from nasa/jscs-rebase-142

[Code Style] Enforce code style
This commit is contained in:
Andrew Henry
2016-05-20 14:03:27 -07:00
467 changed files with 2142 additions and 1924 deletions

View File

@@ -39,7 +39,7 @@ define(
* @param {ActionContext} context the context for this action
*/
function RestartTimerAction(now, context) {
AbstractStartTimerAction.apply(this, [ now, context ]);
AbstractStartTimerAction.apply(this, [now, context]);
}
RestartTimerAction.prototype =

View File

@@ -39,7 +39,7 @@ define(
* @param {ActionContext} context the context for this action
*/
function StartTimerAction(now, context) {
AbstractStartTimerAction.apply(this, [ now, context ]);
AbstractStartTimerAction.apply(this, [now, context]);
}
StartTimerAction.prototype =

View File

@@ -43,7 +43,7 @@ define(
mockNow = jasmine.createSpy('now');
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability', 'useCapability' ]
['getCapability', 'useCapability']
);
mockPersistence = jasmine.createSpyObj(
'persistence',

View File

@@ -44,7 +44,7 @@ define(
mockNow = jasmine.createSpy('now');
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability', 'useCapability', 'getModel' ]
['getCapability', 'useCapability', 'getModel']
);
mockPersistence = jasmine.createSpyObj(
'persistence',

View File

@@ -44,7 +44,7 @@ define(
mockNow = jasmine.createSpy('now');
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability', 'useCapability', 'getModel' ]
['getCapability', 'useCapability', 'getModel']
);
mockPersistence = jasmine.createSpyObj(
'persistence',

View File

@@ -45,11 +45,11 @@ define(
it("refreshes the represented object on every tick", function () {
var mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability' ]
['getCapability']
),
mockPersistence = jasmine.createSpyObj(
'persistence',
[ 'persist', 'refresh' ]
['persist', 'refresh']
);
mockDomainObject.getCapability.andCallFake(function (c) {

View File

@@ -57,7 +57,7 @@ define(
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getCapability', 'useCapability', 'getModel' ]
['getCapability', 'useCapability', 'getModel']
);
mockActionCapability = jasmine.createSpyObj(
'action',

View File

@@ -70,7 +70,7 @@ define(
['getConductor']
);
mockCompile = jasmine.createSpy('$compile');
testViews = [ { someKey: "some value" } ];
testViews = [{ someKey: "some value" }];
mockScope = jasmine.createSpyObj('scope', SCOPE_METHODS);
mockElement = jasmine.createSpyObj('element', ELEMENT_METHODS);
mockElement.parent.andReturn(mockElement);

View File

@@ -36,7 +36,7 @@ define(
beforeEach(function () {
mockTelemetryService = jasmine.createSpyObj(
'telemetryService',
[ 'requestTelemetry', 'subscribe' ]
['requestTelemetry', 'subscribe']
);
mockConductorService = jasmine.createSpyObj(
'conductorService',
@@ -49,7 +49,7 @@ define(
);
mockSeries = jasmine.createSpyObj(
'series',
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
['getPointCount', 'getDomainValue', 'getRangeValue']
);
mockTelemetryService.requestTelemetry.andReturn(mockPromise);

View File

@@ -36,7 +36,7 @@ define(
jasmine.createSpyObj('document', ['createElement'])
];
mockScope = jasmine.createSpyObj('scope', ['$watch']);
mockElement = jasmine.createSpyObj('element', [ 'css' ]);
mockElement = jasmine.createSpyObj('element', ['css']);
testImage = {};
mockDocument[0].createElement.andReturn(testImage);

View File

@@ -51,24 +51,24 @@ define(
});
it("allows the imagery view for domain objects with image telemetry", function () {
testMetadata.ranges = [ { key: "foo", format: "imageUrl" } ];
testMetadata.ranges = [{ key: "foo", format: "imageUrl" }];
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
});
it("disallows the imagery view for domain objects without image telemetry", function () {
testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ];
testMetadata.ranges = [{ key: "foo", format: "somethingElse" }];
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
});
it("disallows the imagery view for domain objects without telemetry", function () {
testMetadata.ranges = [ { key: "foo", format: "imageUrl" } ];
testMetadata.ranges = [{ key: "foo", format: "imageUrl" }];
mockDomainObject.getCapability.andReturn(undefined);
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
});
it("allows other views", function () {
testView.key = "somethingElse";
testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ];
testMetadata.ranges = [{ key: "foo", format: "somethingElse" }];
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
});

View File

@@ -24,7 +24,7 @@ define(
['./FixedProxy', './elements/ElementProxies', './FixedDragHandle'],
function (FixedProxy, ElementProxies, FixedDragHandle) {
var DEFAULT_DIMENSIONS = [ 2, 1 ],
var DEFAULT_DIMENSIONS = [2, 1],
DEFAULT_GRID_SIZE = [64, 16];
/**
@@ -277,7 +277,7 @@ define(
if (e.defaultPrevented) {
return;
}
if (editableDomainObject){
if (editableDomainObject) {
$scope.setEditable(editableDomainObject);
}
e.preventDefault();

View File

@@ -26,7 +26,7 @@ define(
// Drag handle dimensions
var DRAG_HANDLE_SIZE = [ 6, 6 ];
var DRAG_HANDLE_SIZE = [6, 6];
/**
* Template-displayable drag handle for an element in fixed

View File

@@ -29,9 +29,9 @@ define(
['./LayoutDrag'],
function (LayoutDrag) {
var DEFAULT_DIMENSIONS = [ 12, 8 ],
DEFAULT_GRID_SIZE = [ 32, 32 ],
MINIMUM_FRAME_SIZE = [ 320, 180 ];
var DEFAULT_DIMENSIONS = [12, 8],
DEFAULT_GRID_SIZE = [32, 32],
MINIMUM_FRAME_SIZE = [320, 180];
/**
* The LayoutController is responsible for supporting the
@@ -66,7 +66,7 @@ define(
if (e.defaultPrevented) {
return;
}
if (editableDomainObject){
if (editableDomainObject) {
$scope.setEditable(editableDomainObject);
}
// Ensure that configuration field is populated
@@ -103,12 +103,12 @@ define(
//Keep a track of how many composition callbacks have been made
var thisCount = ++callbackCount;
$scope.domainObject.useCapability('composition').then(function(composition){
$scope.domainObject.useCapability('composition').then(function (composition) {
var ids;
//Is this callback for the most recent composition
// request? If not, discard it. Prevents race condition
if (thisCount === callbackCount){
if (thisCount === callbackCount) {
ids = composition.map(function (object) {
return object.getId();
}) || [];

View File

@@ -54,7 +54,7 @@ define(
* @param {Array} elements the full array of elements
*/
function ElementProxy(element, index, elements) {
this.resizeHandles = [ new ResizeHandle(element, 1, 1) ];
this.resizeHandles = [new ResizeHandle(element, 1, 1)];
/**
* The element as stored in the view configuration.

View File

@@ -64,7 +64,7 @@ define(
function makeMockDomainObject(id) {
var mockObject = jasmine.createSpyObj(
'domainObject-' + id,
[ 'getId', 'getModel', 'getCapability' ]
['getId', 'getModel', 'getCapability']
);
mockObject.getId.andReturn(id);
mockObject.getModel.andReturn({ name: "Point " + id});
@@ -74,11 +74,11 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
'$scope',
[ "$on", "$watch", "commit" ]
["$on", "$watch", "commit"]
);
mockHandler = jasmine.createSpyObj(
'telemetryHandler',
[ 'handle' ]
['handle']
);
mockQ = jasmine.createSpyObj('$q', ['when']);
mockDialogService = jasmine.createSpyObj(
@@ -87,11 +87,11 @@ define(
);
mockFormatter = jasmine.createSpyObj(
'telemetryFormatter',
[ 'formatDomainValue', 'formatRangeValue' ]
['formatDomainValue', 'formatRangeValue']
);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getModel', 'getCapability' ]
['getId', 'getModel', 'getCapability']
);
mockHandle = jasmine.createSpyObj(
'subscription',
@@ -106,10 +106,10 @@ define(
);
mockEvent = jasmine.createSpyObj(
'event',
[ 'preventDefault' ]
['preventDefault']
);
testGrid = [ 123, 456 ];
testGrid = [123, 456];
testModel = {
composition: ['a', 'b', 'c'],
layoutGrid: testGrid
@@ -136,7 +136,7 @@ define(
mockScope.configuration = testConfiguration;
mockScope.selection = jasmine.createSpyObj(
'selection',
[ 'select', 'get', 'selected', 'deselect', 'proxy' ]
['select', 'get', 'selected', 'deselect', 'proxy']
);
controller = new FixedController(
@@ -418,7 +418,7 @@ define(
expect(controller.selected().style).toEqual(oldStyle);
// Drag a little
controller.moveHandle().continueDrag([ 1000, 100 ]);
controller.moveHandle().continueDrag([1000, 100]);
// Style should have been updated
expect(controller.selected().style).not.toEqual(oldStyle);

View File

@@ -24,7 +24,7 @@ define(
['../src/FixedDragHandle'],
function (FixedDragHandle) {
var TEST_GRID_SIZE = [ 13, 33 ];
var TEST_GRID_SIZE = [13, 33];
describe("A fixed position drag handle", function () {
var mockElementHandle,
@@ -35,7 +35,7 @@ define(
beforeEach(function () {
mockElementHandle = jasmine.createSpyObj(
'elementHandle',
[ 'x', 'y' ]
['x', 'y']
);
mockUpdate = jasmine.createSpy('update');
mockCommit = jasmine.createSpy('commit');
@@ -61,13 +61,13 @@ define(
it("allows handles to be dragged", function () {
handle.startDrag();
handle.continueDrag([ 16, 8 ]);
handle.continueDrag([16, 8]);
// Should update x/y, snapped to grid
expect(mockElementHandle.x).toHaveBeenCalledWith(7);
expect(mockElementHandle.y).toHaveBeenCalledWith(8);
handle.continueDrag([ -16, -35 ]);
handle.continueDrag([-16, -35]);
// Should have interpreted relative to initial state
expect(mockElementHandle.x).toHaveBeenCalledWith(5);
@@ -84,4 +84,4 @@ define(
});
}
);
);

View File

@@ -34,7 +34,7 @@ define(
mockComposition,
mockCompositionObjects;
function mockPromise(value){
function mockPromise(value) {
return {
then: function (thenFunc) {
return mockPromise(thenFunc(value));
@@ -42,12 +42,12 @@ define(
};
}
function mockDomainObject(id){
function mockDomainObject(id) {
return {
getId: function() {
getId: function () {
return id;
},
useCapability: function() {
useCapability: function () {
return mockCompositionCapability;
}
};
@@ -56,11 +56,11 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$watch", "$watchCollection", "$on", "commit" ]
["$watch", "$watchCollection", "$on", "commit"]
);
mockEvent = jasmine.createSpyObj(
'event',
[ 'preventDefault' ]
['preventDefault']
);
testModel = {};
@@ -238,7 +238,7 @@ define(
var styleB;
// Start with a very small frame size
testModel.layoutGrid = [ 1, 1 ];
testModel.layoutGrid = [1, 1];
// White-boxy; we know which watch is which
mockScope.$watch.calls[0].args[1](testModel.layoutGrid);
@@ -255,7 +255,7 @@ define(
var style;
// Start with a very small frame size
testModel.layoutGrid = [ 1, 1 ];
testModel.layoutGrid = [1, 1];
mockScope.$watch.calls[0].args[1](testModel.layoutGrid);
// Notify that a drop occurred

View File

@@ -26,56 +26,56 @@ define(
describe("A Layout drag handler", function () {
var testPosition = {
position: [ 8, 11 ],
dimensions: [ 3, 2 ]
position: [8, 11],
dimensions: [3, 2]
};
it("changes position by a supplied factor, rounding by grid size", function () {
var handler = new LayoutDrag(
testPosition,
[ 1, 1 ],
[ 0, 0 ],
[ 10, 20 ]
[1, 1],
[0, 0],
[10, 20]
);
expect(handler.getAdjustedPosition([ 37, 84 ])).toEqual({
position: [ 12, 15 ],
dimensions: [ 3, 2 ]
expect(handler.getAdjustedPosition([37, 84])).toEqual({
position: [12, 15],
dimensions: [3, 2]
});
expect(handler.getAdjustedPosition([ -37, 84 ])).toEqual({
position: [ 4, 15 ],
dimensions: [ 3, 2 ]
expect(handler.getAdjustedPosition([-37, 84])).toEqual({
position: [4, 15],
dimensions: [3, 2]
});
});
it("changes dimensions by a supplied factor, rounding by grid size", function () {
var handler = new LayoutDrag(
testPosition,
[ 0, 0 ],
[ 1, 1 ],
[ 10, 20 ]
[0, 0],
[1, 1],
[10, 20]
);
expect(handler.getAdjustedPosition([ 37, 84 ])).toEqual({
position: [ 8, 11 ],
dimensions: [ 7, 6 ]
expect(handler.getAdjustedPosition([37, 84])).toEqual({
position: [8, 11],
dimensions: [7, 6]
});
});
it("allows mixing dimension and position factors", function () {
var handler = new LayoutDrag(
testPosition,
[ 0, 1 ],
[ -1, 0 ],
[ 10, 20 ]
[0, 1],
[-1, 0],
[10, 20]
);
expect(handler.getAdjustedPosition([ 11, 84 ])).toEqual({
position: [ 8, 15 ],
dimensions: [ 2, 2 ]
expect(handler.getAdjustedPosition([11, 84])).toEqual({
position: [8, 15],
dimensions: [2, 2]
});
});
});
}
);
);

View File

@@ -37,7 +37,7 @@ define(
height: 24,
fill: "transparent"
};
testElements = [ {}, {}, testElement, {} ];
testElements = [{}, {}, testElement, {}];
proxy = new BoxProxy(
testElement,
testElements.indexOf(testElement),

View File

@@ -24,8 +24,8 @@ define(
['../../src/elements/ElementFactory'],
function (ElementFactory) {
var DIALOG_ELEMENTS = [ 'image', 'text' ],
NON_DIALOG_ELEMENTS = [ 'box', 'line' ];
var DIALOG_ELEMENTS = ['image', 'text'],
NON_DIALOG_ELEMENTS = ['box', 'line'];
describe("The fixed position element factory", function () {
var mockDialogService,
@@ -35,11 +35,11 @@ define(
beforeEach(function () {
mockDialogService = jasmine.createSpyObj(
'dialogService',
[ 'getUserInput' ]
['getUserInput']
);
mockPromise = jasmine.createSpyObj(
'promise',
[ 'then' ]
['then']
);
mockDialogService.getUserInput.andReturn(mockPromise);
@@ -66,4 +66,4 @@ define(
});
});
}
);
);

View File

@@ -37,7 +37,7 @@ define(
width: 42,
height: 24
};
testElements = [ {}, {}, testElement, {} ];
testElements = [{}, {}, testElement, {}];
proxy = new ElementProxy(
testElement,
testElements.indexOf(testElement),

View File

@@ -37,7 +37,7 @@ define(
height: 24,
url: "http://www.nasa.gov"
};
testElements = [ {}, {}, testElement, {} ];
testElements = [{}, {}, testElement, {}];
proxy = new ImageProxy(
testElement,
testElements.indexOf(testElement),

View File

@@ -70,4 +70,4 @@ define(
});
}
);
);

View File

@@ -92,4 +92,4 @@ define(
});
}
);
);

View File

@@ -75,4 +75,4 @@ define(
});
}
);
);

View File

@@ -38,7 +38,7 @@ define(
height: 24,
id: "test-id"
};
testElements = [ {}, {}, testElement, {} ];
testElements = [{}, {}, testElement, {}];
proxy = new TelemetryProxy(
testElement,
testElements.indexOf(testElement),

View File

@@ -37,7 +37,7 @@ define(
height: 24,
fill: "transparent"
};
testElements = [ {}, {}, testElement, {} ];
testElements = [{}, {}, testElement, {}];
proxy = new TextProxy(
testElement,
testElements.indexOf(testElement),

View File

@@ -38,8 +38,8 @@ define(
this.c2d = canvas.getContext('2d');
this.width = canvas.width;
this.height = canvas.height;
this.dimensions = [ this.width, this.height ];
this.origin = [ 0, 0 ];
this.dimensions = [this.width, this.height];
this.origin = [0, 0];
if (!this.c2d) {
throw new Error("Canvas 2d API unavailable.");

View File

@@ -57,7 +57,7 @@ define(
Listen for changes to the domain object and update the object's
children.
*/
this.mutationListener = this.domainObject.getCapability('mutation').listen(function(model) {
this.mutationListener = this.domainObject.getCapability('mutation').listen(function (model) {
if (self.hasCompositionChanged(self.composition, model.composition)) {
self.updateChildren();
}
@@ -70,7 +70,7 @@ define(
$scope.xAxisForm = this.plotOptionsForm.xAxisForm;
$scope.yAxisForm = this.plotOptionsForm.yAxisForm;
$scope.$on("$destroy", function() {
$scope.$on("$destroy", function () {
//Clean up any listeners on destruction of controller
self.mutationListener();
});
@@ -82,10 +82,10 @@ define(
* Setup a number of watches for changes to form values. On
* change, update the model configuration via mutation
*/
$scope.$watchCollection('configuration.plot.yAxis', function(newValue, oldValue){
$scope.$watchCollection('configuration.plot.yAxis', function (newValue, oldValue) {
self.updateConfiguration(newValue, oldValue);
});
$scope.$watchCollection('configuration.plot.xAxis', function(newValue, oldValue){
$scope.$watchCollection('configuration.plot.xAxis', function (newValue, oldValue) {
self.updateConfiguration(newValue, oldValue);
});
@@ -98,8 +98,8 @@ define(
* child objects)
* @private
*/
PlotOptionsController.prototype.clearSeriesWatches = function() {
this.watches.forEach(function(watch) {
PlotOptionsController.prototype.clearSeriesWatches = function () {
this.watches.forEach(function (watch) {
watch();
});
this.watches = [];
@@ -109,16 +109,16 @@ define(
* Attach watches for each object in the plot's composition
* @private
*/
PlotOptionsController.prototype.watchSeries = function() {
PlotOptionsController.prototype.watchSeries = function () {
var self = this;
this.clearSeriesWatches();
(self.$scope.children || []).forEach(function(child, index){
(self.$scope.children || []).forEach(function (child, index) {
self.watches.push(
self.$scope.$watchCollection(
'configuration.plot.series[' + index + ']',
function(newValue, oldValue){
function (newValue, oldValue) {
self.updateConfiguration(newValue, oldValue);
}
)
@@ -132,13 +132,13 @@ define(
*
* @private
*/
PlotOptionsController.prototype.hasCompositionChanged = function(oldComposition, newComposition){
PlotOptionsController.prototype.hasCompositionChanged = function (oldComposition, newComposition) {
// Framed slightly strangely, but the boolean logic is
// easier to follow for the unchanged case.
var isUnchanged = oldComposition === newComposition ||
(
oldComposition.length === newComposition.length &&
oldComposition.every( function (currentValue, index) {
oldComposition.every(function (currentValue, index) {
return newComposition[index] && currentValue === newComposition[index];
})
);
@@ -163,12 +163,12 @@ define(
* plot options model
* @private
*/
PlotOptionsController.prototype.updateChildren = function() {
PlotOptionsController.prototype.updateChildren = function () {
var self = this;
this.domainObject.useCapability('composition').then(function(children){
this.domainObject.useCapability('composition').then(function (children) {
self.$scope.children = children;
self.composition = self.domainObject.getModel().composition;
children.forEach(function(child, index){
children.forEach(function (child, index) {
self.configuration.plot.series[index] =
self.configuration.plot.series[index] || {'id': child.getId()};
});
@@ -181,9 +181,9 @@ define(
* object
* @private
*/
PlotOptionsController.prototype.updateConfiguration = function() {
PlotOptionsController.prototype.updateConfiguration = function () {
var self = this;
this.domainObject.useCapability('mutation', function(model){
this.domainObject.useCapability('mutation', function (model) {
model.configuration = model.configuration || {};
model.configuration.plot = self.configuration.plot;
});

View File

@@ -37,7 +37,7 @@ define(
Defined below are the form structures for the plot options.
*/
this.xAxisForm = {
'name':'x-axis',
'name': 'x-axis',
'sections': [{
'name': 'x-axis',
'rows': [
@@ -46,30 +46,30 @@ define(
'control': 'select',
'key': 'key',
'options': [
{'name':'SCET', 'value': 'scet'},
{'name':'SCLK', 'value': 'sclk'},
{'name':'LST', 'value': 'lst'}
{'name': 'SCET', 'value': 'scet'},
{'name': 'SCLK', 'value': 'sclk'},
{'name': 'LST', 'value': 'lst'}
]
}
]
}]};
}]};
this.yAxisForm = {
'name':'y-axis',
'sections': [{
// Will need to be repeated for each y-axis, with a
// distinct name for each. Ideally the name of the axis
// itself.
'name': 'y-axis',
'rows': [
'sections': [{
// Will need to be repeated for each y-axis, with a
// distinct name for each. Ideally the name of the axis
// itself.
'name': 'y-axis',
'rows': [
{
'name': 'Range',
'control': 'select',
'key': 'key',
'options': [
{'name':'EU', 'value': 'eu'},
{'name':'DN', 'value': 'dn'},
{'name':'Status', 'value': 'status'}
{'name': 'EU', 'value': 'eu'},
{'name': 'DN', 'value': 'dn'},
{'name': 'Status', 'value': 'status'}
]
},
{
@@ -95,7 +95,7 @@ define(
}]
};
this.plotSeriesForm = {
'name':'Series Options',
'name': 'Series Options',
'sections': [
{
rows: [
@@ -106,7 +106,7 @@ define(
}]
},
{
'rows':[
'rows': [
{
'name': 'Markers',
'control': 'checkbox',
@@ -116,7 +116,7 @@ define(
]
},
{
'rows':[
'rows': [
{
'name': 'No Line',
'control': 'radio',

View File

@@ -67,7 +67,7 @@ define(
* implies that there is no range data displayed either
* @returns {boolean} true if domain data exists for the current pan/zoom level
*/
SubPlot.prototype.hasDomainData = function() {
SubPlot.prototype.hasDomainData = function () {
return this.panZoomStack &&
this.panZoomStack.getDimensions()[0] > 0;
};
@@ -109,7 +109,7 @@ define(
// associated with conversion to a 32-bit floating point
// format (which is needed in the chart area itself, by WebGL.)
SubPlot.prototype.toDisplayable = function (position) {
return [ position[0] - this.domainOffset, position[1] ];
return [position[0] - this.domainOffset, position[1]];
};
// Update the current hover coordinates
@@ -145,7 +145,7 @@ define(
end: this.toDisplayable(
this.mousePositionToDomainRange(this.mousePosition)
),
color: [1, 1, 1, 0.5 ]
color: [1, 1, 1, 0.5]
}] : undefined;
};
@@ -189,7 +189,7 @@ define(
this.panZoomStack
);
delta = [ current[0] - start[0], current[1] - start[1] ];
delta = [current[0] - start[0], current[1] - start[1]];
nextOrigin = [
this.panStartBounds.origin[0] - delta[0],
this.panStartBounds.origin[1] - delta[1]

View File

@@ -35,7 +35,7 @@ define(
function PlotLineBuffer(domainOffset, initialSize, maxSize) {
this.buffer = new Float32Array(initialSize * 2);
this.rangeExtrema =
[ Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY ];
[Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY];
this.length = 0;
this.domainOffset = domainOffset;
this.initialSize = initialSize;

View File

@@ -30,36 +30,36 @@ define(
// describe colors in several ways (as RGB 0-255, as
// RGB 0.0-1.0, or as stylesheet-appropriate #-prefixed colors).
var integerPalette = [
[ 0x20, 0xB2, 0xAA ],
[ 0x9A, 0xCD, 0x32 ],
[ 0xFF, 0x8C, 0x00 ],
[ 0xD2, 0xB4, 0x8C ],
[ 0x40, 0xE0, 0xD0 ],
[ 0x41, 0x69, 0xFF ],
[ 0xFF, 0xD7, 0x00 ],
[ 0x6A, 0x5A, 0xCD ],
[ 0xEE, 0x82, 0xEE ],
[ 0xCC, 0x99, 0x66 ],
[ 0x99, 0xCC, 0xCC ],
[ 0x66, 0xCC, 0x33 ],
[ 0xFF, 0xCC, 0x00 ],
[ 0xFF, 0x66, 0x33 ],
[ 0xCC, 0x66, 0xFF ],
[ 0xFF, 0x00, 0x66 ],
[ 0xFF, 0xFF, 0x00 ],
[ 0x80, 0x00, 0x80 ],
[ 0x00, 0x86, 0x8B ],
[ 0x00, 0x8A, 0x00 ],
[ 0xFF, 0x00, 0x00 ],
[ 0x00, 0x00, 0xFF ],
[ 0xF5, 0xDE, 0xB3 ],
[ 0xBC, 0x8F, 0x8F ],
[ 0x46, 0x82, 0xB4 ],
[ 0xFF, 0xAF, 0xAF ],
[ 0x43, 0xCD, 0x80 ],
[ 0xCD, 0xC1, 0xC5 ],
[ 0xA0, 0x52, 0x2D ],
[ 0x64, 0x95, 0xED ]
[0x20, 0xB2, 0xAA],
[0x9A, 0xCD, 0x32],
[0xFF, 0x8C, 0x00],
[0xD2, 0xB4, 0x8C],
[0x40, 0xE0, 0xD0],
[0x41, 0x69, 0xFF],
[0xFF, 0xD7, 0x00],
[0x6A, 0x5A, 0xCD],
[0xEE, 0x82, 0xEE],
[0xCC, 0x99, 0x66],
[0x99, 0xCC, 0xCC],
[0x66, 0xCC, 0x33],
[0xFF, 0xCC, 0x00],
[0xFF, 0x66, 0x33],
[0xCC, 0x66, 0xFF],
[0xFF, 0x00, 0x66],
[0xFF, 0xFF, 0x00],
[0x80, 0x00, 0x80],
[0x00, 0x86, 0x8B],
[0x00, 0x8A, 0x00],
[0xFF, 0x00, 0x00],
[0x00, 0x00, 0xFF],
[0xF5, 0xDE, 0xB3],
[0xBC, 0x8F, 0x8F],
[0x46, 0x82, 0xB4],
[0xFF, 0xAF, 0xAF],
[0x43, 0xCD, 0x80],
[0xCD, 0xC1, 0xC5],
[0xA0, 0x52, 0x2D],
[0x64, 0x95, 0xED]
], stringPalette = integerPalette.map(function (arr) {
// Convert to # notation for use in styles
return '#' + arr.map(function (c) {

View File

@@ -50,8 +50,8 @@ define(
// For other stacks, do a push, but repeat
// their current range axis bounds.
stack.pushPanZoom(
[ origin[0], stack.getOrigin()[1] ],
[ dimensions[0], stack.getDimensions()[1] ]
[origin[0], stack.getOrigin()[1]],
[dimensions[0], stack.getDimensions()[1]]
);
}
});

View File

@@ -60,7 +60,7 @@ define(
// Note that range is reversed from the y-axis in pixel space
//(positive range points up, positive pixel-y points down)
this.position =
[ x / width, (height - y) / height ].map(convert);
[x / width, (height - y) / height].map(convert);
}
}

View File

@@ -27,7 +27,9 @@
define(
function () {
function identity(x) { return x; }
function identity(x) {
return x;
}
/**
* The PlotPreparer is responsible for handling data sets and

View File

@@ -71,7 +71,7 @@ define(
// Used in the reduce step of updateExtrema
function reduceExtrema(a, b) {
return [ Math.min(a[0], b[0]), Math.max(a[1], b[1]) ];
return [Math.min(a[0], b[0]), Math.max(a[1], b[1])];
}
// Convert a domain/range extrema to plot dimensions
@@ -173,9 +173,9 @@ define(
}).reduce(reduceExtrema);
// Calculate best-fit dimensions
this.dimensions = [ this.domainExtrema, this.rangeExtrema ]
this.dimensions = [this.domainExtrema, this.rangeExtrema]
.map(dimensionsOf);
this.origin = [ this.domainExtrema, this.rangeExtrema ]
this.origin = [this.domainExtrema, this.rangeExtrema]
.map(originOf);
// Enforce some minimum visible area

View File

@@ -89,7 +89,7 @@ define(
*/
function PlotModeOptions(telemetryObjects, subPlotFactory) {
this.options = telemetryObjects.length > 1 ?
[ OVERLAID, STACKED ] : [ OVERLAID ];
[OVERLAID, STACKED] : [OVERLAID];
this.mode = this.options[0]; // Initial selection (overlaid)
this.telemetryObjects = telemetryObjects;
this.subPlotFactory = subPlotFactory;

View File

@@ -38,7 +38,7 @@ define(
telemetryObjects,
this.panZoomStack
);
this.subplots = [ this.subplot ];
this.subplots = [this.subplot];
}
PlotOverlayMode.prototype.plotTelemetry = function (updater) {

View File

@@ -33,7 +33,7 @@ define(
chart;
beforeEach(function () {
mockCanvas = jasmine.createSpyObj("canvas", [ "getContext" ]);
mockCanvas = jasmine.createSpyObj("canvas", ["getContext"]);
mock2d = jasmine.createSpyObj(
"2d",
[
@@ -72,8 +72,8 @@ define(
});
it("allows lines to be drawn", function () {
var testBuffer = [ 0, 1, 3, 8 ],
testColor = [ 0.25, 0.33, 0.66, 1.0 ],
var testBuffer = [0, 1, 3, 8],
testColor = [0.25, 0.33, 0.66, 1.0],
testPoints = 2;
chart.drawLine(testBuffer, testColor, testPoints);
expect(mock2d.beginPath).toHaveBeenCalled();
@@ -84,7 +84,7 @@ define(
it("allows squares to be drawn", function () {
var testMin = [0, 1],
testMax = [10, 10],
testColor = [ 0.25, 0.33, 0.66, 1.0 ];
testColor = [0.25, 0.33, 0.66, 1.0];
chart.drawSquare(testMin, testMax, testColor);
expect(mock2d.fillRect).toHaveBeenCalled();
@@ -92,4 +92,4 @@ define(
});
}
);
);

View File

@@ -33,7 +33,7 @@ define(
glChart;
beforeEach(function () {
mockCanvas = jasmine.createSpyObj("canvas", [ "getContext" ]);
mockCanvas = jasmine.createSpyObj("canvas", ["getContext"]);
mockGL = jasmine.createSpyObj(
"gl",
[
@@ -98,8 +98,8 @@ define(
});
it("allows lines to be drawn", function () {
var testBuffer = [ 0, 1, 3, 8 ],
testColor = [ 0.25, 0.33, 0.66, 1.0 ],
var testBuffer = [0, 1, 3, 8],
testColor = [0.25, 0.33, 0.66, 1.0],
testPoints = 2;
glChart.drawLine(testBuffer, testColor, testPoints);
expect(mockGL.bufferData).toHaveBeenCalledWith(
@@ -116,7 +116,7 @@ define(
it("allows squares to be drawn", function () {
var testMin = [0, 1],
testMax = [10, 10],
testColor = [ 0.25, 0.33, 0.66, 1.0 ];
testColor = [0.25, 0.33, 0.66, 1.0];
glChart.drawSquare(testMin, testMax, testColor);
@@ -140,4 +140,4 @@ define(
});
});
}
);
);

View File

@@ -55,7 +55,7 @@ define(
// mct-chart uses GLChart, so it needs WebGL API
mockCanvas =
jasmine.createSpyObj("canvas", [ "getContext", "addEventListener" ]);
jasmine.createSpyObj("canvas", ["getContext", "addEventListener"]);
mockGL = jasmine.createSpyObj(
"gl",
[
@@ -122,7 +122,7 @@ define(
it("issues one draw call per line", function () {
mctChart.link(mockScope, mockElement);
mockScope.$watchCollection.mostRecentCall.args[1]({
lines: [ {}, {}, {} ]
lines: [{}, {}, {}]
});
expect(mockGL.drawArrays.calls.length).toEqual(3);
});

View File

@@ -63,15 +63,15 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$watch", "$on", "$emit" ]
["$watch", "$on", "$emit"]
);
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
mockHandler = jasmine.createSpyObj(
"telemetrySubscriber",
@@ -96,7 +96,9 @@ define(
);
mockHandler.handle.andReturn(mockHandle);
mockThrottle.andCallFake(function (fn) { return fn; });
mockThrottle.andCallFake(function (fn) {
return fn;
});
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
mockHandle.getMetadata.andReturn([{}]);
mockHandle.getDomainValue.andReturn(123);

View File

@@ -58,7 +58,7 @@ define(
mockComposition = [
mockChildOne
];
mockCompositionCapability.then.andCallFake(function (callback){
mockCompositionCapability.then.andCallFake(function (callback) {
callback(mockComposition);
});
@@ -79,7 +79,7 @@ define(
'useCapability',
'getCapability'
]);
mockDomainObject.useCapability.andCallFake(function(capability){
mockDomainObject.useCapability.andCallFake(function (capability) {
return mockUseCapabilities[capability]();
});
mockDomainObject.getCapability.andReturn(mockMutationCapability);
@@ -120,7 +120,7 @@ define(
it("on changes in form values, updates the object model", function () {
var scopeConfiguration = mockScope.configuration,
model = mockDomainObject.getModel();
objModel = mockDomainObject.getModel();
scopeConfiguration.plot.yAxis.autoScale = true;
scopeConfiguration.plot.yAxis.key = 'eu';
@@ -130,10 +130,10 @@ define(
mockScope.$watchCollection.calls[0].args[1]();
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
mockDomainObject.useCapability.mostRecentCall.args[1](model);
expect(model.configuration.plot.yAxis.autoScale).toBe(true);
expect(model.configuration.plot.yAxis.key).toBe('eu');
expect(model.configuration.plot.xAxis.key).toBe('lst');
mockDomainObject.useCapability.mostRecentCall.args[1](objModel);
expect(objModel.configuration.plot.yAxis.autoScale).toBe(true);
expect(objModel.configuration.plot.yAxis.key).toBe('eu');
expect(objModel.configuration.plot.xAxis.key).toBe('lst');
});

View File

@@ -36,20 +36,20 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
mockPanZoomStack = jasmine.createSpyObj(
"panZoomStack",
[ "getPanZoom" ]
["getPanZoom"]
);
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
mockPanZoomStack.getPanZoom.andReturn({
origin: [ 0, 0 ],
dimensions: [ 100, 100 ]
origin: [0, 0],
dimensions: [100, 100]
});
factory = new SubPlotFactory(mockFormatter);
@@ -63,4 +63,4 @@ define(
});
});
}
);
);

View File

@@ -40,7 +40,7 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
mockPanZoomStack = jasmine.createSpyObj(
"panZoomStack",
@@ -57,16 +57,16 @@ define(
);
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
mockElement = jasmine.createSpyObj(
"element",
[ "getBoundingClientRect" ]
["getBoundingClientRect"]
);
testOrigin = [ 5, 10 ];
testDimensions = [ 3000, 1000 ];
testDomainObjects = [ mockDomainObject, mockDomainObject ];
testOrigin = [5, 10];
testDimensions = [3000, 1000];
testDomainObjects = [mockDomainObject, mockDomainObject];
mockPanZoomStack.getOrigin.andReturn(testOrigin);
mockPanZoomStack.getDimensions.andReturn(testDimensions);
@@ -163,7 +163,7 @@ define(
mockPanZoomStack.getDimensions.andReturn([0,0]);
expect(subplot.hasDomainData()).toEqual(false);
});
it("disallows marquee zoom when start and end Marquee is at the same position", function () {
expect(mockPanZoomStack.pushPanZoom).not.toHaveBeenCalled();

View File

@@ -88,7 +88,7 @@ define(
});
it("reflects changes to applicable metadata", function () {
axis.updateMetadata([ testMetadatas[1] ]);
axis.updateMetadata([testMetadatas[1]]);
expect(axis.options).toEqual([
{ key: "t0", name: "T0" },
{ key: "t2", name: "T2" }

View File

@@ -41,11 +41,11 @@ define(
mockTelemetryObjects = ['a', 'b', 'c'].map(function (id, i) {
var mockTelemetryObject = jasmine.createSpyObj(
'object-' + id,
[ 'getId', 'getCapability', 'getModel' ]
['getId', 'getCapability', 'getModel']
),
mockLimitCapability = jasmine.createSpyObj(
'limit-' + id,
[ 'evaluate' ]
['evaluate']
);
testData[id] = { id: id, value: i };
mockTelemetryObject.getId.andReturn(id);

View File

@@ -38,8 +38,8 @@ define(
buffer;
beforeEach(function () {
testDomainValues = [ 1, 3, 7, 9, 14, 15 ];
testRangeValues = [ 8, 0, 3, 9, 8, 11 ];
testDomainValues = [1, 3, 7, 9, 14, 15];
testRangeValues = [8, 0, 3, 9, 8, 11];
mockSeries = jasmine.createSpyObj(
"series",
['getPointCount', 'getDomainValue', 'getRangeValue']
@@ -70,7 +70,7 @@ define(
// that domain offset was adjusted for.
expect(
Array.prototype.slice.call(buffer.getBuffer()).slice(0, 12)
).toEqual([ -41, 8, -39, 0, -35, 3, -33, 9, -28, 8, -27, 11]);
).toEqual([-41, 8, -39, 0, -35, 3, -33, 9, -28, 8, -27, 11]);
expect(buffer.getLength()).toEqual(6);
});
@@ -84,8 +84,8 @@ define(
});
it("allows insertion in the middle", function () {
var head = [ -41, 8, -39, 0, -35, 3 ],
tail = [ -33, 9, -28, 8, -27, 11];
var head = [-41, 8, -39, 0, -35, 3],
tail = [-33, 9, -28, 8, -27, 11];
buffer.insert(mockSeries, 3);
expect(
Array.prototype.slice.call(buffer.getBuffer()).slice(0, 24)
@@ -98,7 +98,7 @@ define(
expect(buffer.getLength()).toEqual(4);
expect(
Array.prototype.slice.call(buffer.getBuffer()).slice(0, 8)
).toEqual([ -35, 3, -33, 9, -28, 8, -27, 11]);
).toEqual([-35, 3, -33, 9, -28, 8, -27, 11]);
});
it("expands buffer when needed to accommodate more data", function () {

View File

@@ -101,7 +101,7 @@ define(
});
it("allows series insertion", function () {
testSeries = [ [ 50, 42 ], [ 100, 200 ], [ 150, 12321 ] ];
testSeries = [[50, 42], [100, 200], [150, 12321]];
line.addSeries(mockSeries);
// Should have managed insertion index choices to get to...
expect(testDomainBuffer).toEqual([50, 100, 150]);
@@ -109,7 +109,7 @@ define(
});
it("splits series insertion when necessary", function () {
testSeries = [ [ 50, 42 ], [ 100, 200 ], [ 150, 12321 ] ];
testSeries = [[50, 42], [100, 200], [150, 12321]];
line.addPoint(75, 1);
line.addSeries(mockSeries);
// Should have managed insertion index choices to get to...
@@ -130,4 +130,4 @@ define(
});
}
);
);

View File

@@ -120,4 +120,4 @@ define(
});
});
}
);
);

View File

@@ -49,7 +49,7 @@ define(
it("synchronizes pan-zoom stack depth", function () {
expect(group.getDepth()).toEqual(1);
group.getPanZoomStack(1).pushPanZoom([ 10, 20 ], [ 30, 40 ]);
group.getPanZoomStack(1).pushPanZoom([10, 20], [30, 40]);
stacks.forEach(function (stack) {
expect(stack.getDepth()).toEqual(2);
});
@@ -58,11 +58,11 @@ define(
it("synchronizes domain but not range", function () {
// Set up different initial states
stacks.forEach(function (stack, i) {
stack.pushPanZoom([ i, i ], [ i, i ]);
stack.pushPanZoom([i, i], [i, i]);
});
// Push a new pan-zoom state onto one of the stacks
group.getPanZoomStack(1).pushPanZoom([ 99, 99 ], [ 42, 42 ]);
group.getPanZoomStack(1).pushPanZoom([99, 99], [42, 42]);
// Should changed domain values for all stacks, but
// only changed range values for stack 1
@@ -85,7 +85,7 @@ define(
it("clears pan-zoom on request", function () {
// Set up different initial states
stacks.forEach(function (stack, i) {
stack.pushPanZoom([ i, i ], [ i, i ]);
stack.pushPanZoom([i, i], [i, i]);
});
// Verify that we have a greater depth
@@ -104,7 +104,7 @@ define(
it("pops pan-zoom on request", function () {
// Set up different initial states
stacks.forEach(function (stack, i) {
stack.pushPanZoom([ i, i ], [ i, i ]);
stack.pushPanZoom([i, i], [i, i]);
});
// Verify that we have a greater depth
@@ -123,4 +123,4 @@ define(
});
}
);
);

View File

@@ -46,10 +46,10 @@ define(
}
beforeEach(function () {
initialOrigin = [ 4, 2 ];
initialDimensions = [ 600, 400 ];
otherOrigins = [ [8, 6], [12, 9] ];
otherDimensions = [ [400, 300], [200, 300] ];
initialOrigin = [4, 2];
initialDimensions = [600, 400];
otherOrigins = [[8, 6], [12, 9]];
otherDimensions = [[400, 300], [200, 300]];
panZoomStack =
new PlotPanZoomStack(initialOrigin, initialDimensions);
});
@@ -96,4 +96,4 @@ define(
});
});
}
);
);

View File

@@ -29,13 +29,13 @@ define(
describe("A plot position", function () {
var mockPanZoom,
testOrigin = [ 10, 20 ],
testDimensions = [ 800, 10 ];
testOrigin = [10, 20],
testDimensions = [800, 10];
beforeEach(function () {
mockPanZoom = jasmine.createSpyObj(
"panZoomStack",
[ "getPanZoom" ]
["getPanZoom"]
);
mockPanZoom.getPanZoom.andReturn({
origin: testOrigin,
@@ -64,4 +64,4 @@ define(
});
});
}
);
);

View File

@@ -34,7 +34,7 @@ define(
function makeMockData(scale) {
var mockData = jasmine.createSpyObj(
"data" + scale,
[ "getPointCount", "getDomainValue", "getRangeValue" ]
["getPointCount", "getDomainValue", "getRangeValue"]
);
mockData.getPointCount.andReturn(1000);
mockData.getDomainValue.andCallFake(function (i) {
@@ -90,4 +90,4 @@ define(
});
}
);
);

View File

@@ -31,11 +31,11 @@ define(
beforeEach(function () {
testSeries = [
[ 0, 42 ],
[ 10, 1 ],
[ 20, 4 ],
[ 30, 9 ],
[ 40, 3 ]
[0, 42],
[10, 1],
[20, 4],
[30, 9],
[40, 3]
];
mockSeries = jasmine.createSpyObj(
@@ -90,4 +90,4 @@ define(
});
}
);
);

View File

@@ -35,16 +35,16 @@ define(
beforeEach(function () {
mockPanZoomStack = jasmine.createSpyObj(
"panZoomStack",
[ "getPanZoom" ]
["getPanZoom"]
);
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
mockPanZoomStack.getPanZoom.andReturn({
origin: [ 0, 0 ],
dimensions: [ 100, 100 ]
origin: [0, 0],
dimensions: [100, 100]
});
generator =
@@ -70,4 +70,4 @@ define(
});
}
);
);

View File

@@ -39,19 +39,19 @@ define(
function makeMockDomainObject(id) {
var mockDomainObject = jasmine.createSpyObj(
"object-" + id,
[ "getId", "getCapability", "getModel" ]
["getId", "getCapability", "getModel"]
);
mockDomainObject.getId.andReturn(id);
return mockDomainObject;
}
beforeEach(function () {
var ids = [ 'a', 'b', 'c' ],
var ids = ['a', 'b', 'c'],
mockObjects = ids.map(makeMockDomainObject);
mockSubscription = jasmine.createSpyObj(
"subscription",
[ "getDomainValue", "getRangeValue", "getTelemetryObjects" ]
["getDomainValue", "getRangeValue", "getTelemetryObjects"]
);
mockSeries = jasmine.createSpyObj(
'series',

View File

@@ -34,11 +34,11 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
mockSubPlotFactory = jasmine.createSpyObj(
"subPlotFactory",
[ "createSubPlot" ]
["createSubPlot"]
);
});
@@ -84,4 +84,4 @@ define(
});
});
}
);
);

View File

@@ -58,11 +58,11 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
mockSubPlotFactory = jasmine.createSpyObj(
"subPlotFactory",
[ "createSubPlot" ]
["createSubPlot"]
);
// Prepared telemetry data
mockPrepared = jasmine.createSpyObj(
@@ -181,4 +181,4 @@ define(
});
});
}
);
);

View File

@@ -58,16 +58,16 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability" ]
["getId", "getModel", "getCapability"]
);
mockSubPlotFactory = jasmine.createSpyObj(
"subPlotFactory",
[ "createSubPlot" ]
["createSubPlot"]
);
// Prepared telemetry data
mockPrepared = jasmine.createSpyObj(
"prepared",
[ "getDomainOffset", "getOrigin", "getDimensions", "getLineBuffers" ]
["getDomainOffset", "getOrigin", "getDimensions", "getLineBuffers"]
);
mockSubPlotFactory.createSubPlot.andCallFake(createMockSubPlot);
@@ -176,4 +176,4 @@ define(
});
}
);
);

View File

@@ -51,23 +51,23 @@ define(
});
it("allows the imagery view for domain objects with numeric telemetry", function () {
testMetadata.ranges = [ { key: "foo", format: "number" } ];
testMetadata.ranges = [{ key: "foo", format: "number" }];
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
});
it("allows the imagery view for domain objects with unspecified telemetry", function () {
testMetadata.ranges = [ { key: "foo" } ];
testMetadata.ranges = [{ key: "foo" }];
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
});
it("disallows the imagery view for domain objects without image telemetry", function () {
testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ];
testMetadata.ranges = [{ key: "foo", format: "somethingElse" }];
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
});
it("allows other views", function () {
testView.key = "somethingElse";
testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ];
testMetadata.ranges = [{ key: "foo", format: "somethingElse" }];
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
});

View File

@@ -21,11 +21,11 @@
*****************************************************************************/
define([
"text!./res/markup.html",
'legacyRegistry'
], function (
markupTemplate,
legacyRegistry
) {

View File

@@ -56,7 +56,7 @@ define(
return {
cssClass: alarm && alarm.cssClass,
text: typeof(value) === 'undefined' ? undefined : this.telemetryFormatter.formatRangeValue(value)
text: typeof (value) === 'undefined' ? undefined : this.telemetryFormatter.formatRangeValue(value)
};
};

View File

@@ -64,7 +64,7 @@ define(
});
});
if (this.columns.length > 0){
if (this.columns.length > 0) {
self.addColumn(new NameColumn(), 0);
}
}
@@ -91,7 +91,7 @@ define(
* @returns {*|string}
*/
TableConfiguration.prototype.getColumnTitle = function (column) {
return column.getTitle();
return column.getTitle();
};
/**
@@ -100,7 +100,7 @@ define(
*/
TableConfiguration.prototype.getHeaders = function () {
var self = this;
return this.columns.map(function (column, i){
return this.columns.map(function (column, i) {
return self.getColumnTitle(column) || 'Column ' + (i + 1);
});
};
@@ -115,11 +115,11 @@ define(
*/
TableConfiguration.prototype.getRowValues = function (telemetryObject, datum) {
var self = this;
return this.columns.reduce(function (rowObject, column, i){
return this.columns.reduce(function (rowObject, column, i) {
var columnTitle = self.getColumnTitle(column) || 'Column ' + (i + 1),
columnValue = column.getValue(telemetryObject, datum);
if (columnValue !== undefined && columnValue.text === undefined){
if (columnValue !== undefined && columnValue.text === undefined) {
columnValue.text = '';
}
// Don't replace something with nothing.
@@ -158,7 +158,7 @@ define(
config2Keys = Object.keys(config2);
return (config1Keys.length !== config2Keys.length) ||
config1Keys.some(function(key){
config1Keys.some(function (key) {
return config1[key] !== config2[key];
});
}

View File

@@ -49,7 +49,7 @@ define(
var rowData = [],
self = this;
this.handle.getTelemetryObjects().forEach(function (telemetryObject){
this.handle.getTelemetryObjects().forEach(function (telemetryObject) {
var series = self.handle.getSeries(telemetryObject) || {},
pointCount = series.getPointCount ? series.getPointCount() : 0,
i = 0;

View File

@@ -32,15 +32,15 @@ define(
/**
* Set default values for optional parameters on a given scope
*/
function setDefaults($scope) {
if (typeof $scope.enableFilter === 'undefined') {
$scope.enableFilter = true;
$scope.filters = {};
function setDefaults(scope) {
if (typeof scope.enableFilter === 'undefined') {
scope.enableFilter = true;
scope.filters = {};
}
if (typeof $scope.enableSort === 'undefined') {
$scope.enableSort = true;
$scope.sortColumn = undefined;
$scope.sortDirection = undefined;
if (typeof scope.enableSort === 'undefined') {
scope.enableSort = true;
scope.sortColumn = undefined;
scope.sortDirection = undefined;
}
}
@@ -89,8 +89,8 @@ define(
//Use timeout to defer execution until next digest when any
// pending UI changes have completed, eg. a new row in the table.
if (this.$scope.autoScroll) {
this.$timeout(function (){
self.scrollable[0].scrollTop = self.scrollable[0].scrollHeight;
this.$timeout(function () {
self.scrollable[0].scrollTop = self.scrollable[0].scrollHeight;
});
}
};
@@ -125,10 +125,10 @@ define(
// Do a sequential search here. Only way of finding row is by
// object equality, so array is in effect unsorted.
indexInDisplayRows = this.$scope.displayRows.indexOf(row);
if (indexInDisplayRows !== -1) {
this.$scope.displayRows.splice(indexInDisplayRows, 1);
this.setVisibleRows();
}
if (indexInDisplayRows !== -1) {
this.$scope.displayRows.splice(indexInDisplayRows, 1);
this.setVisibleRows();
}
};
/**
@@ -222,7 +222,7 @@ define(
* sorting.
*/
MCTTableController.prototype.setHeaders = function (newHeaders) {
if (!newHeaders){
if (!newHeaders) {
return;
}
@@ -234,8 +234,8 @@ define(
// contain the column currently sorted on.
if (this.$scope.enableSort &&
newHeaders.indexOf(this.$scope.sortColumn) === -1) {
this.$scope.sortColumn = undefined;
this.$scope.sortDirection = undefined;
this.$scope.sortColumn = undefined;
this.$scope.sortDirection = undefined;
}
this.setRows(this.$scope.rows);
};
@@ -283,14 +283,14 @@ define(
self = this,
sortKey = this.$scope.sortColumn;
function binarySearch(searchArray, searchElement, min, max){
function binarySearch(searchArray, searchElement, min, max) {
var sampleAt = Math.floor((max - min) / 2) + min;
if (max < min) {
return min; // Element is not in array, min gives direction
}
switch(self.sortComparator(searchElement[sortKey].text,
switch (self.sortComparator(searchElement[sortKey].text,
searchArray[sampleAt][sortKey].text)) {
case -1:
return binarySearch(searchArray, searchElement, min,
@@ -310,9 +310,9 @@ define(
//Sort is enabled, perform binary search to find insertion point
index = binarySearch(array, element, 0, array.length - 1);
}
if (index === -1){
if (index === -1) {
array.unshift(element);
} else if (index === array.length){
} else if (index === array.length) {
array.push(element);
} else {
array.splice(index, 0, element);
@@ -342,7 +342,7 @@ define(
* @returns {*} The value cast to a Number, or the original value if
* a Number representation is not possible.
*/
function toNumber (value){
function toNumber(value) {
var val = !isNaN(Number(value)) && !isNaN(parseFloat(value)) ? Number(value) : value;
return val;
}
@@ -410,7 +410,7 @@ define(
currentColumnLength,
largestColumn,
largestColumnLength;
if (row[key]){
if (row[key]) {
currentColumn = (row[key]).text;
currentColumnLength =
(currentColumn && currentColumn.length) ?
@@ -485,13 +485,13 @@ define(
/**
* Returns true if row matches all filters.
*/
function matchRow(filters, row) {
return Object.keys(filters).every(function (key) {
function matchRow(filterMap, row) {
return Object.keys(filterMap).every(function (key) {
if (!row[key]) {
return false;
}
var testVal = String(row[key].text).toLowerCase();
return testVal.indexOf(filters[key]) !== -1;
return testVal.indexOf(filterMap[key]) !== -1;
});
}

View File

@@ -58,7 +58,7 @@ define(
$scope.$watch('domainObject', function (domainObject) {
//When a domain object becomes available, check whether the
// view should auto-scroll to the bottom.
if (domainObject && hasStringTelemetry(domainObject)){
if (domainObject && hasStringTelemetry(domainObject)) {
$scope.autoScroll = true;
}
});
@@ -70,11 +70,11 @@ define(
* Overrides method on TelemetryTableController providing handling
* for realtime data.
*/
RealtimeTableController.prototype.addRealtimeData = function() {
RealtimeTableController.prototype.addRealtimeData = function () {
var self = this,
datum,
row;
this.handle.getTelemetryObjects().forEach(function (telemetryObject){
this.handle.getTelemetryObjects().forEach(function (telemetryObject) {
datum = self.handle.getDatum(telemetryObject);
if (datum) {
//Populate row values from telemetry datum

View File

@@ -59,7 +59,7 @@ define(
});
}
$scope.$watch('domainObject', function(domainObject) {
$scope.$watch('domainObject', function (domainObject) {
unlisten();
self.populateForm(domainObject.getModel());
@@ -72,10 +72,10 @@ define(
* Maintain a configuration object on scope that stores column
* configuration. On change, synchronize with object model.
*/
$scope.$watchCollection('configuration.table.columns', function (columns){
if (columns){
$scope.$watchCollection('configuration.table.columns', function (columns) {
if (columns) {
self.domainObject.useCapability('mutation', function (model) {
model.configuration.table.columns = columns;
model.configuration.table.columns = columns;
});
self.domainObject.getCapability('persistence').persist();
}
@@ -92,13 +92,13 @@ define(
var columnsDefinition = (((model.configuration || {}).table || {}).columns || {}),
rows = [];
this.$scope.columnsForm = {
'name':'Columns',
'name': 'Columns',
'sections': [{
'name': 'Columns',
'rows': rows
}]};
Object.keys(columnsDefinition).forEach(function (key){
Object.keys(columnsDefinition).forEach(function (key) {
rows.push({
'name': key,
'control': 'checkbox',

View File

@@ -58,7 +58,7 @@ define(
$scope.rows = [];
// Subscribe to telemetry when a domain object becomes available
this.$scope.$watch('domainObject', function(){
this.$scope.$watch('domainObject', function () {
self.subscribe();
self.registerChangeListeners();
});

View File

@@ -88,7 +88,7 @@ define(
enableFilter: "=?",
enableSort: "=?",
autoScroll: "=?"
},
}
};
}

View File

@@ -38,11 +38,11 @@ define(
beforeEach(function () {
mockDataSet = jasmine.createSpyObj(
"data",
[ "getDomainValue" ]
["getDomainValue"]
);
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
testMetadata = {
key: "testKey",

View File

@@ -34,7 +34,7 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getModel" ]
["getModel"]
);
mockDomainObject.getModel.andReturn({
name: "Test object name"

View File

@@ -40,7 +40,7 @@ define(
testDatum = { testKey: 123, otherKey: 456 };
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
testMetadata = {
key: "testKey",
@@ -48,7 +48,7 @@ define(
};
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getModel", "getCapability" ]
["getModel", "getCapability"]
);
mockFormatter.formatRangeValue.andReturn(TEST_RANGE_VALUE);

View File

@@ -44,10 +44,10 @@ define(
'formatDomainValue',
'formatRangeValue'
]);
mockTelemetryFormatter.formatDomainValue.andCallFake(function(valueIn){
mockTelemetryFormatter.formatDomainValue.andCallFake(function (valueIn) {
return valueIn;
});
mockTelemetryFormatter.formatRangeValue.andCallFake(function(valueIn){
mockTelemetryFormatter.formatRangeValue.andCallFake(function (valueIn) {
return valueIn;
});
@@ -87,7 +87,7 @@ define(
expect(table.columns[2]).toBe(thirdColumn);
});
describe("Building columns from telemetry metadata", function() {
describe("Building columns from telemetry metadata", function () {
var metadata = [{
ranges: [
{
@@ -113,21 +113,21 @@ define(
]
}];
beforeEach(function() {
beforeEach(function () {
table.populateColumns(metadata);
});
it("populates columns", function() {
it("populates columns", function () {
expect(table.columns.length).toBe(5);
});
it("Build columns populates columns with domains to the left", function() {
it("Build columns populates columns with domains to the left", function () {
expect(table.columns[1] instanceof DomainColumn).toBeTruthy();
expect(table.columns[2] instanceof DomainColumn).toBeTruthy();
expect(table.columns[3] instanceof DomainColumn).toBeFalsy();
});
it("Produces headers for each column based on title", function() {
it("Produces headers for each column based on title", function () {
var headers,
firstColumn = table.columns[0];
@@ -138,16 +138,16 @@ define(
});
it("Provides a default configuration with all columns" +
" visible", function() {
" visible", function () {
var configuration = table.buildColumnConfiguration();
expect(configuration).toBeDefined();
expect(Object.keys(configuration).every(function(key){
expect(Object.keys(configuration).every(function (key) {
return configuration[key];
}));
});
it("Column configuration exposes persisted configuration", function() {
it("Column configuration exposes persisted configuration", function () {
var tableConfig,
modelConfig = {
table: {
@@ -168,7 +168,7 @@ define(
var datum,
rowValues;
beforeEach(function() {
beforeEach(function () {
datum = {
'range1': 'range 1 value',
'range2': 'range 2 value',
@@ -178,14 +178,14 @@ define(
rowValues = table.getRowValues(mockDomainObject, datum);
});
it("Returns a value for every column", function() {
it("Returns a value for every column", function () {
expect(rowValues['Range 1'].text).toBeDefined();
expect(rowValues['Range 1'].text).toEqual('range 1' +
' value');
});
it("Uses the telemetry formatter to appropriately format" +
" telemetry values", function() {
" telemetry values", function () {
expect(mockTelemetryFormatter.formatRangeValue).toHaveBeenCalled();
});
});

View File

@@ -39,7 +39,7 @@ define(
function promise(value) {
return {
then: function (callback){
then: function (callback) {
return promise(callback(value));
}
};
@@ -53,13 +53,13 @@ define(
'$watchCollection'
]);
mockScope.$on.andCallFake(function (expression, callback){
mockScope.$on.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watch.andCallFake(function (expression, callback){
watches[expression] = callback;
mockScope.$watch.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watchCollection.andCallFake(function (expression, callback){
mockScope.$watchCollection.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
@@ -80,7 +80,7 @@ define(
mockTable.columns = [];
mockTable.buildColumnConfiguration.andReturn(mockConfiguration);
mockDomainObject= jasmine.createSpyObj('domainObject', [
mockDomainObject = jasmine.createSpyObj('domainObject', [
'getCapability',
'useCapability',
'getModel'
@@ -118,7 +118,7 @@ define(
expect(mockTelemetryHandle.request).toHaveBeenCalled();
});
it('Unsubscribes from telemetry when scope is destroyed',function () {
it('Unsubscribes from telemetry when scope is destroyed', function () {
controller.handle = mockTelemetryHandle;
watches.$destroy();
expect(mockTelemetryHandle.unsubscribe).toHaveBeenCalled();
@@ -139,7 +139,7 @@ define(
});
});
it('updates the rows on scope when historical telemetry is received', function (){
it('updates the rows on scope when historical telemetry is received', function () {
var mockSeries = {
getPointCount: function () {
return 5;
@@ -154,7 +154,7 @@ define(
mockRow = {'domain': 'Domain Value', 'range': 'Range' +
' Value'};
mockTelemetryHandle.makeDatum.andCallFake(function (){
mockTelemetryHandle.makeDatum.andCallFake(function () {
return mockRow;
});
mockTable.getRowValues.andReturn(mockRow);
@@ -167,7 +167,7 @@ define(
expect(controller.$scope.rows[0]).toBe(mockRow);
});
it('filters the visible columns based on configuration', function (){
it('filters the visible columns based on configuration', function () {
controller.filterColumns();
expect(controller.$scope.headers.length).toBe(3);
expect(controller.$scope.headers[2]).toEqual('domain1');
@@ -178,9 +178,9 @@ define(
expect(controller.$scope.headers[2]).toBeUndefined();
});
describe('creates event listeners', function (){
describe('creates event listeners', function () {
beforeEach(function () {
spyOn(controller,'subscribe');
spyOn(controller, 'subscribe');
spyOn(controller, 'filterColumns');
});

View File

@@ -26,7 +26,7 @@ define(
],
function (MCTTableController) {
describe('The MCTTable Controller', function() {
describe('The MCTTable Controller', function () {
var controller,
mockScope,
@@ -42,7 +42,7 @@ define(
};
}
beforeEach(function() {
beforeEach(function () {
watches = {};
mockScope = jasmine.createSpyObj('scope', [
@@ -50,7 +50,7 @@ define(
'$on',
'$watchCollection'
]);
mockScope.$watchCollection.andCallFake(function(event, callback) {
mockScope.$watchCollection.andCallFake(function (event, callback) {
watches[event] = callback;
});
@@ -75,15 +75,15 @@ define(
spyOn(controller, 'setVisibleRows').andCallThrough();
});
it('Reacts to changes to filters, headers, and rows', function() {
it('Reacts to changes to filters, headers, and rows', function () {
expect(mockScope.$watchCollection).toHaveBeenCalledWith('filters', jasmine.any(Function));
expect(mockScope.$watch).toHaveBeenCalledWith('headers', jasmine.any(Function));
expect(mockScope.$watch).toHaveBeenCalledWith('rows', jasmine.any(Function));
});
describe('rows', function() {
describe('rows', function () {
var testRows = [];
beforeEach(function() {
beforeEach(function () {
testRows = [
{
'col1': {'text': 'row1 col1 match'},
@@ -104,30 +104,30 @@ define(
mockScope.rows = testRows;
});
it('Filters results based on filter input', function() {
var filters = {},
filteredRows;
it('Filters results based on filter input', function () {
var filters = {},
filteredRows;
mockScope.filters = filters;
mockScope.filters = filters;
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(3);
filters.col1 = 'row1';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(1);
filters.col1 = 'match';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(2);
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(3);
filters.col1 = 'row1';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(1);
filters.col1 = 'match';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(2);
});
it('Sets rows on scope when rows change', function() {
it('Sets rows on scope when rows change', function () {
controller.setRows(testRows);
expect(mockScope.displayRows.length).toBe(3);
expect(mockScope.displayRows).toEqual(testRows);
});
it('Supports adding rows individually', function() {
var addRowFunc = mockScope.$on.calls[mockScope.$on.calls.length-2].args[1],
it('Supports adding rows individually', function () {
var addRowFunc = mockScope.$on.calls[mockScope.$on.calls.length - 2].args[1],
row4 = {
'col1': {'text': 'row3 col1'},
'col2': {'text': 'ghi'},
@@ -140,8 +140,8 @@ define(
expect(mockScope.displayRows.length).toBe(4);
});
it('Supports removing rows individually', function() {
var removeRowFunc = mockScope.$on.calls[mockScope.$on.calls.length-1].args[1];
it('Supports removing rows individually', function () {
var removeRowFunc = mockScope.$on.calls[mockScope.$on.calls.length - 1].args[1];
controller.setRows(testRows);
expect(mockScope.displayRows.length).toBe(3);
removeRowFunc(undefined, 2);
@@ -149,10 +149,10 @@ define(
expect(controller.setVisibleRows).toHaveBeenCalled();
});
describe('sorting', function() {
describe('sorting', function () {
var sortedRows;
it('Sorts rows ascending', function() {
it('Sorts rows ascending', function () {
mockScope.sortColumn = 'col1';
mockScope.sortDirection = 'asc';
@@ -164,7 +164,7 @@ define(
});
it('Sorts rows descending', function() {
it('Sorts rows descending', function () {
mockScope.sortColumn = 'col1';
mockScope.sortDirection = 'desc';
@@ -173,7 +173,7 @@ define(
expect(sortedRows[1].col1.text).toEqual('row2 col1 match');
expect(sortedRows[2].col1.text).toEqual('row1 col1 match');
});
it('Sorts rows descending based on selected sort column', function() {
it('Sorts rows descending based on selected sort column', function () {
mockScope.sortColumn = 'col2';
mockScope.sortDirection = 'desc';
@@ -218,9 +218,9 @@ define(
expect(sortedRows[1].col2.text).toEqual('def');
expect(sortedRows[2].col2.text).toEqual('abc');
expect(sortedRows[sortedRows.length-3].col2.text).toEqual('456');
expect(sortedRows[sortedRows.length-2].col2.text).toEqual('123');
expect(sortedRows[sortedRows.length-1].col2.text).toEqual('');
expect(sortedRows[sortedRows.length - 3].col2.text).toEqual('456');
expect(sortedRows[sortedRows.length - 2].col2.text).toEqual('123');
expect(sortedRows[sortedRows.length - 1].col2.text).toEqual('');
});
describe('The sort comparator', function () {
@@ -245,7 +245,7 @@ define(
row5,
row6;
beforeEach(function() {
beforeEach(function () {
row4 = {
'col1': {'text': 'row5 col1'},
'col2': {'text': 'xyz'},
@@ -264,33 +264,33 @@ define(
});
it('Adds new rows at the correct sort position when' +
' sorted ', function() {
' sorted ', function () {
mockScope.sortColumn = 'col2';
mockScope.sortDirection = 'desc';
mockScope.displayRows = controller.sortRows(testRows.slice(0));
mockScope.rows.push(row4);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[0].col2.text).toEqual('xyz');
mockScope.rows.push(row5);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[4].col2.text).toEqual('aaa');
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[2].col2.text).toEqual('ggg');
//Add a duplicate row
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[2].col2.text).toEqual('ggg');
expect(mockScope.displayRows[3].col2.text).toEqual('ggg');
});
it('Adds new rows at the correct sort position when' +
' sorted and filtered', function() {
' sorted and filtered', function () {
mockScope.sortColumn = 'col2';
mockScope.sortDirection = 'desc';
mockScope.filters = {'col2': 'a'};//Include only
@@ -300,12 +300,12 @@ define(
mockScope.displayRows = controller.filterRows(testRows);
mockScope.rows.push(row5);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows.length).toBe(2);
expect(mockScope.displayRows[1].col2.text).toEqual('aaa');
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows.length).toBe(2);
//Row was not added because does not match filter
});
@@ -319,16 +319,16 @@ define(
mockScope.displayRows = testRows.slice(0);
mockScope.rows.push(row5);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[3].col2.text).toEqual('aaa');
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[4].col2.text).toEqual('ggg');
});
it('Resizes columns if length of any columns in new' +
' row exceeds corresponding existing column', function() {
' row exceeds corresponding existing column', function () {
var row7 = {
'col1': {'text': 'row6 col1'},
'col2': {'text': 'some longer string'},
@@ -342,7 +342,7 @@ define(
mockScope.displayRows = testRows.slice(0);
mockScope.rows.push(row7);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(controller.$scope.sizingRow.col2).toEqual({text: 'some longer string'});
});

View File

@@ -40,7 +40,7 @@ define(
function promise(value) {
return {
then: function (callback){
then: function (callback) {
return promise(callback(value));
}
};
@@ -57,13 +57,13 @@ define(
'$digest',
'$broadcast'
]);
mockScope.$on.andCallFake(function (expression, callback){
mockScope.$on.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watch.andCallFake(function (expression, callback){
watches[expression] = callback;
mockScope.$watch.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watchCollection.andCallFake(function (expression, callback){
mockScope.$watchCollection.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
@@ -85,7 +85,7 @@ define(
mockTable.buildColumnConfiguration.andReturn(mockConfiguration);
mockTable.getRowValues.andReturn(mockTableRow);
mockDomainObject= jasmine.createSpyObj('domainObject', [
mockDomainObject = jasmine.createSpyObj('domainObject', [
'getCapability',
'useCapability',
'getModel'
@@ -93,7 +93,7 @@ define(
mockDomainObject.getModel.andReturn({});
mockDomainObject.getCapability.andReturn(
{
getMetadata: function (){
getMetadata: function () {
return {ranges: [{format: 'string'}]};
}
});
@@ -132,7 +132,7 @@ define(
});
describe('receives new telemetry', function () {
beforeEach(function() {
beforeEach(function () {
controller.subscribe();
mockScope.rows = [];
});
@@ -151,7 +151,7 @@ define(
}
mockTelemetryHandler.handle.mostRecentCall.args[1]();
expect(mockScope.rows.length).toBe(controller.maxRows);
expect(mockScope.rows[mockScope.rows.length-1]).toBe(mockTableRow);
expect(mockScope.rows[mockScope.rows.length - 1]).toBe(mockTableRow);
expect(mockScope.rows[0].row).toBe(1);
});
});

View File

@@ -26,13 +26,13 @@ define(
],
function (TableOptionsController) {
describe('The Table Options Controller', function() {
describe('The Table Options Controller', function () {
var mockDomainObject,
mockCapability,
controller,
mockScope;
beforeEach(function() {
beforeEach(function () {
mockCapability = jasmine.createSpyObj('mutationCapability', [
'listen'
]);
@@ -53,11 +53,11 @@ define(
controller = new TableOptionsController(mockScope);
});
it('Listens for changing domain object', function() {
it('Listens for changing domain object', function () {
expect(mockScope.$watch).toHaveBeenCalledWith('domainObject', jasmine.any(Function));
});
it('On destruction of controller, destroys listeners', function() {
it('On destruction of controller, destroys listeners', function () {
var unlistenFunc = jasmine.createSpy("unlisten");
controller.listeners.push(unlistenFunc);
expect(mockScope.$on).toHaveBeenCalledWith('$destroy', jasmine.any(Function));
@@ -65,21 +65,21 @@ define(
expect(unlistenFunc).toHaveBeenCalled();
});
it('Registers a listener for mutation events on the object', function() {
it('Registers a listener for mutation events on the object', function () {
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
expect(mockCapability.listen).toHaveBeenCalled();
});
it('Listens for changes to object composition and updates' +
' options accordingly', function() {
' options accordingly', function () {
expect(mockScope.$watchCollection).toHaveBeenCalledWith('configuration.table.columns', jasmine.any(Function));
});
describe('Populates scope with a form definition based on provided' +
' column configuration', function() {
' column configuration', function () {
var mockModel;
beforeEach(function() {
beforeEach(function () {
mockModel = {
configuration: {
table: {
@@ -87,7 +87,7 @@ define(
'column1': true,
'column2': true,
'column3': false,
'column4': true,
'column4': true
}
}
}
@@ -95,19 +95,19 @@ define(
controller.populateForm(mockModel);
});
it('creates form on scope', function() {
it('creates form on scope', function () {
expect(mockScope.columnsForm).toBeDefined();
expect(mockScope.columnsForm.sections[0]).toBeDefined();
expect(mockScope.columnsForm.sections[0].rows).toBeDefined();
expect(mockScope.columnsForm.sections[0].rows.length).toBe(4);
});
it('presents columns as checkboxes', function() {
expect(mockScope.columnsForm.sections[0].rows.every(function(row){
it('presents columns as checkboxes', function () {
expect(mockScope.columnsForm.sections[0].rows.every(function (row) {
return row.control === 'checkbox';
})).toBe(true);
});
});
});
});
});

View File

@@ -91,7 +91,7 @@ define([
"name": "Export Timeline as CSV",
"category": "contextual",
"implementation": ExportTimelineAsCSVAction,
"depends": [ "exportService", "notificationService" ]
"depends": ["exportService", "notificationService"]
}
],
"constants": [

View File

@@ -28,4 +28,4 @@ define({
HANDLE_WIDTH: 32,
// Pixel tolerance for snapping behavior
SNAP_WIDTH: 16
});
});

View File

@@ -73,4 +73,4 @@ define(
return TimelineFormatter;
}
);
);

View File

@@ -65,4 +65,4 @@ define(["./ExportTimelineAsCSVTask"], function (ExportTimelineAsCSVTask) {
};
return ExportTimelineAsCSVAction;
});
});

View File

@@ -80,4 +80,4 @@ define([], function () {
return TimelineTraverser;
});
});

View File

@@ -52,25 +52,25 @@ define(
// Set the start time associated with this object
function setStart(value) {
var end = getEnd();
mutation.mutate(function (model) {
model.start.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.start.timestamp = Math.max(value, 0);
// Update duration to keep end time
model.duration.timestamp = Math.max(end - value, 0);
m.duration.timestamp = Math.max(end - value, 0);
}, model.modified);
}
// Set the duration associated with this object
function setDuration(value) {
mutation.mutate(function (model) {
model.duration.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.duration.timestamp = Math.max(value, 0);
}, model.modified);
}
// Set the end time associated with this object
function setEnd(value) {
var start = getStart();
mutation.mutate(function (model) {
model.duration.timestamp = Math.max(value - start, 0);
mutation.mutate(function (m) {
m.duration.timestamp = Math.max(value - start, 0);
}, model.modified);
}
@@ -116,4 +116,4 @@ define(
return ActivityTimespan;
}
);
);

View File

@@ -47,4 +47,4 @@ define(
return ActivityUtilization;
}
);
);

View File

@@ -53,21 +53,21 @@ define(
// Initialize the data values
function initializeValues() {
var values = [],
var vals = [],
slope = 0,
i;
// Add a point (or points, if needed) reaching to the provided
// domain and/or range value
function addPoint(domain, range) {
var previous = values[values.length - 1],
var previous = vals[vals.length - 1],
delta = domain - previous.domain, // time delta
change = delta * slope * rate, // change
next = previous.range + change;
// Crop to minimum boundary...
if (next < minimum) {
values.push({
vals.push({
domain: intercept(
previous.domain,
previous.range,
@@ -81,7 +81,7 @@ define(
// ...and maximum boundary
if (next > maximum) {
values.push({
vals.push({
domain: intercept(
previous.domain,
previous.range,
@@ -95,19 +95,19 @@ define(
// Add the new data value
if (delta > 0) {
values.push({ domain: domain, range: next });
vals.push({ domain: domain, range: next });
}
slope = range;
}
values.push({ domain: 0, range: initial });
vals.push({ domain: 0, range: initial });
for (i = 0; i < graph.getPointCount(); i += 1) {
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
}
return values;
return vals;
}
function convertToPercent(point) {
@@ -149,4 +149,4 @@ define(
return CumulativeGraph;
}
);
);

View File

@@ -72,13 +72,13 @@ define(
// If there are sequences of points with the same timestamp,
// allow only the first and last.
function filterPoint(value, index, values) {
function filterPoint(value, index, vals) {
// Allow the first or last point as a base case; aside from
// that, allow only points that have different timestamps
// from their predecessor or successor.
return (index === 0) || (index === values.length - 1) ||
(value.domain !== values[index - 1].domain) ||
(value.domain !== values[index + 1].domain);
return (index === 0) || (index === vals.length - 1) ||
(value.domain !== vals[index - 1].domain) ||
(value.domain !== vals[index + 1].domain);
}
// Add a step up or down (Step 3c above)
@@ -144,4 +144,4 @@ define(
return ResourceGraph;
}
);
);

View File

@@ -57,8 +57,8 @@ define(
// Set the start time associated with this object
function setStart(value) {
mutation.mutate(function (model) {
model.start.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.start.timestamp = Math.max(value, 0);
}, model.modified);
}
@@ -121,4 +121,4 @@ define(
return TimelineTimespan;
}
);
);

View File

@@ -47,4 +47,4 @@ define(
return TimelineUtilization;
}
);
);

View File

@@ -120,13 +120,13 @@ define(
}
// Look up a specific object's resource utilization
function lookupUtilization(domainObject) {
return domainObject.useCapability('utilization');
function lookupUtilization(object) {
return object.useCapability('utilization');
}
// Look up a specific object's resource utilization keys
function lookupUtilizationResources(domainObject) {
var utilization = domainObject.getCapability('utilization');
function lookupUtilizationResources(object) {
var utilization = object.getCapability('utilization');
return utilization && utilization.resources();
}

View File

@@ -96,7 +96,7 @@ define(
});
}
}
// Recalculate swimlane state on changes
$scope.$watch("domainObject", swimlanePopulator.populate);

View File

@@ -88,4 +88,4 @@ define(
return DateTimeController;
}
);
);

View File

@@ -83,4 +83,4 @@ define(
return TimelineGanttController;
}
);
);

View File

@@ -92,4 +92,4 @@ define(
return TimelineGraphController;
}
);
);

View File

@@ -113,4 +113,4 @@ define(
return TimelineTickController;
}
);
);

View File

@@ -29,7 +29,7 @@ define(
*/
function TimelineZoomController($scope, ZOOM_CONFIGURATION) {
// Prefer to start with the middle index
var zoomLevels = ZOOM_CONFIGURATION.levels || [ 1000 ],
var zoomLevels = ZOOM_CONFIGURATION.levels || [1000],
zoomIndex = Math.floor(zoomLevels.length / 2),
tickWidth = ZOOM_CONFIGURATION.width || 200,
duration = 86400000; // Default duration in view

View File

@@ -47,19 +47,19 @@ define(
}
// Get the timespan associated with this domain object
function populateCapabilityMaps(domainObject) {
var id = domainObject.getId(),
timespanPromise = domainObject.useCapability('timespan');
function populateCapabilityMaps(object) {
var id = object.getId(),
timespanPromise = object.useCapability('timespan');
if (timespanPromise) {
timespanPromise.then(function (timespan) {
// Cache that timespan
timespans[id] = timespan;
// And its mutation capability
mutations[id] = domainObject.getCapability('mutation');
mutations[id] = object.getCapability('mutation');
// Also cache the persistence capability for later
persists[id] = domainObject.getCapability('persistence');
persists[id] = object.getCapability('persistence');
// And the composition, for bulk moves
compositions[id] = domainObject.getModel().composition || [];
compositions[id] = object.getModel().composition || [];
});
}
}
@@ -199,8 +199,8 @@ define(
minStart;
// Update start & end, in that order
function updateStartEnd(id) {
var timespan = timespans[id], start, end;
function updateStartEnd(spanId) {
var timespan = timespans[spanId], start, end;
if (timespan) {
// Get start/end so we don't get fooled by our
// own adjustments
@@ -210,7 +210,7 @@ define(
timespan.setStart(start + delta);
timespan.setEnd(end + delta);
// Mark as dirty for subsequent persistence
dirty[toId(id)] = true;
dirty[toId(spanId)] = true;
}
}
@@ -228,12 +228,12 @@ define(
}
// Find the minimum start time
minStart = Object.keys(ids).map(function (id) {
minStart = Object.keys(ids).map(function (spanId) {
// Get the start time; default to +Inf if not
// found, since this will not survive a min
// test if any real timespans are present
return timespans[id] ?
timespans[id].getStart() :
return timespans[spanId] ?
timespans[spanId].getStart() :
Number.POSITIVE_INFINITY;
}).reduce(function (a, b) {
// Reduce with a minimum test
@@ -253,4 +253,4 @@ define(
return TimelineDragHandler;
}
);
);

View File

@@ -92,4 +92,4 @@ define(
return TimelineDragPopulator;
}
);
);

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