mirror of
https://github.com/nasa/openmct.git
synced 2025-03-25 13:28:38 +00:00
[Fixed Position] Change default behavior for old elements
For elements created before this change where useGrid is not defined, default it to true to ensure consistent display size Inline constant definitions in unit tests if they are only used once
This commit is contained in:
parent
aa8f780e4e
commit
a4b857a034
@ -69,7 +69,7 @@ define(
|
||||
* The current grid size of the layout.
|
||||
* @memberof platform/features/layout.ElementProxy#
|
||||
*/
|
||||
this.gridSize = gridSize;
|
||||
this.gridSize = gridSize || [1,1]; //Ensure a reasonable default
|
||||
|
||||
this.resizeHandles = [new ResizeHandle(
|
||||
this.element,
|
||||
@ -182,6 +182,10 @@ define(
|
||||
*/
|
||||
ElementProxy.prototype.getGridSize = function () {
|
||||
var gridSize;
|
||||
// Default to using the grid if useGrid was not defined
|
||||
if (typeof this.element.useGrid === 'undefined') {
|
||||
this.element.useGrid = true;
|
||||
}
|
||||
if (this.element.useGrid) {
|
||||
gridSize = this.gridSize;
|
||||
} else {
|
||||
|
@ -24,8 +24,6 @@ define(
|
||||
['../../src/elements/ElementProxy'],
|
||||
function (ElementProxy) {
|
||||
|
||||
var GRID_SIZE = [13,21];
|
||||
|
||||
describe("A fixed position element proxy", function () {
|
||||
var testElement,
|
||||
testElements,
|
||||
@ -45,7 +43,7 @@ define(
|
||||
testElement,
|
||||
testElements.indexOf(testElement),
|
||||
testElements,
|
||||
GRID_SIZE
|
||||
[13,21]
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -24,8 +24,6 @@ define(
|
||||
['../../src/elements/LineHandle'],
|
||||
function (LineHandle) {
|
||||
|
||||
var GRID_SIZE = [45,21];
|
||||
|
||||
describe("A fixed position drag handle", function () {
|
||||
var testElement,
|
||||
handle;
|
||||
@ -39,7 +37,7 @@ define(
|
||||
useGrid: true
|
||||
};
|
||||
|
||||
handle = new LineHandle(testElement, 'x', 'y', 'x2', 'y2', GRID_SIZE);
|
||||
handle = new LineHandle(testElement, 'x', 'y', 'x2', 'y2', [45,21]);
|
||||
});
|
||||
|
||||
it("provides x/y grid coordinates for its corner", function () {
|
||||
|
@ -28,10 +28,10 @@ define(
|
||||
var vertical, horizontal, diagonal, reversed;
|
||||
|
||||
beforeEach(function () {
|
||||
vertical = { x: 1, y: 4, x2: 1, y2: 8 };
|
||||
horizontal = { x: 3, y: 3, x2: 12, y2: 3 };
|
||||
diagonal = { x: 3, y: 8, x2: 5, y2: 11 };
|
||||
reversed = { x2: 3, y2: 8, x: 5, y: 11 };
|
||||
vertical = { x: 1, y: 4, x2: 1, y2: 8};
|
||||
horizontal = { x: 3, y: 3, x2: 12, y2: 3};
|
||||
diagonal = { x: 3, y: 8, x2: 5, y2: 11};
|
||||
reversed = { x2: 3, y2: 8, x: 5, y: 11};
|
||||
});
|
||||
|
||||
it("ensures visible width for vertical lines", function () {
|
||||
@ -63,13 +63,13 @@ define(
|
||||
it("adjusts both ends when mutating x", function () {
|
||||
var proxy = new LineProxy(diagonal);
|
||||
proxy.x(6);
|
||||
expect(diagonal).toEqual({ x: 6, y: 8, x2: 8, y2: 11 });
|
||||
expect(diagonal).toEqual({ x: 6, y: 8, x2: 8, y2: 11, useGrid: true });
|
||||
});
|
||||
|
||||
it("adjusts both ends when mutating y", function () {
|
||||
var proxy = new LineProxy(diagonal);
|
||||
proxy.y(6);
|
||||
expect(diagonal).toEqual({ x: 3, y: 6, x2: 5, y2: 9 });
|
||||
expect(diagonal).toEqual({ x: 3, y: 6, x2: 5, y2: 9, useGrid: true });
|
||||
});
|
||||
|
||||
it("provides internal positions for SVG lines", function () {
|
||||
|
@ -24,8 +24,8 @@ define(
|
||||
['../../src/elements/ResizeHandle'],
|
||||
function (ResizeHandle) {
|
||||
|
||||
var TEST_MIN_WIDTH = 4, TEST_MIN_HEIGHT = 2,
|
||||
GRID_SIZE = [34,81];
|
||||
var TEST_MIN_WIDTH = 4,
|
||||
TEST_MIN_HEIGHT = 2;
|
||||
|
||||
describe("A fixed position drag handle", function () {
|
||||
var testElement,
|
||||
@ -44,7 +44,7 @@ define(
|
||||
testElement,
|
||||
TEST_MIN_WIDTH,
|
||||
TEST_MIN_HEIGHT,
|
||||
GRID_SIZE
|
||||
[34,81]
|
||||
);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user