mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 06:31:04 +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.
|
* The current grid size of the layout.
|
||||||
* @memberof platform/features/layout.ElementProxy#
|
* @memberof platform/features/layout.ElementProxy#
|
||||||
*/
|
*/
|
||||||
this.gridSize = gridSize;
|
this.gridSize = gridSize || [1,1]; //Ensure a reasonable default
|
||||||
|
|
||||||
this.resizeHandles = [new ResizeHandle(
|
this.resizeHandles = [new ResizeHandle(
|
||||||
this.element,
|
this.element,
|
||||||
@ -182,6 +182,10 @@ define(
|
|||||||
*/
|
*/
|
||||||
ElementProxy.prototype.getGridSize = function () {
|
ElementProxy.prototype.getGridSize = function () {
|
||||||
var gridSize;
|
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) {
|
if (this.element.useGrid) {
|
||||||
gridSize = this.gridSize;
|
gridSize = this.gridSize;
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,8 +24,6 @@ define(
|
|||||||
['../../src/elements/ElementProxy'],
|
['../../src/elements/ElementProxy'],
|
||||||
function (ElementProxy) {
|
function (ElementProxy) {
|
||||||
|
|
||||||
var GRID_SIZE = [13,21];
|
|
||||||
|
|
||||||
describe("A fixed position element proxy", function () {
|
describe("A fixed position element proxy", function () {
|
||||||
var testElement,
|
var testElement,
|
||||||
testElements,
|
testElements,
|
||||||
@ -45,7 +43,7 @@ define(
|
|||||||
testElement,
|
testElement,
|
||||||
testElements.indexOf(testElement),
|
testElements.indexOf(testElement),
|
||||||
testElements,
|
testElements,
|
||||||
GRID_SIZE
|
[13,21]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@ define(
|
|||||||
['../../src/elements/LineHandle'],
|
['../../src/elements/LineHandle'],
|
||||||
function (LineHandle) {
|
function (LineHandle) {
|
||||||
|
|
||||||
var GRID_SIZE = [45,21];
|
|
||||||
|
|
||||||
describe("A fixed position drag handle", function () {
|
describe("A fixed position drag handle", function () {
|
||||||
var testElement,
|
var testElement,
|
||||||
handle;
|
handle;
|
||||||
@ -39,7 +37,7 @@ define(
|
|||||||
useGrid: true
|
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 () {
|
it("provides x/y grid coordinates for its corner", function () {
|
||||||
|
@ -28,10 +28,10 @@ define(
|
|||||||
var vertical, horizontal, diagonal, reversed;
|
var vertical, horizontal, diagonal, reversed;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
vertical = { x: 1, y: 4, x2: 1, y2: 8 };
|
vertical = { x: 1, y: 4, x2: 1, y2: 8};
|
||||||
horizontal = { x: 3, y: 3, x2: 12, y2: 3 };
|
horizontal = { x: 3, y: 3, x2: 12, y2: 3};
|
||||||
diagonal = { x: 3, y: 8, x2: 5, y2: 11 };
|
diagonal = { x: 3, y: 8, x2: 5, y2: 11};
|
||||||
reversed = { x2: 3, y2: 8, x: 5, y: 11 };
|
reversed = { x2: 3, y2: 8, x: 5, y: 11};
|
||||||
});
|
});
|
||||||
|
|
||||||
it("ensures visible width for vertical lines", function () {
|
it("ensures visible width for vertical lines", function () {
|
||||||
@ -63,13 +63,13 @@ define(
|
|||||||
it("adjusts both ends when mutating x", function () {
|
it("adjusts both ends when mutating x", function () {
|
||||||
var proxy = new LineProxy(diagonal);
|
var proxy = new LineProxy(diagonal);
|
||||||
proxy.x(6);
|
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 () {
|
it("adjusts both ends when mutating y", function () {
|
||||||
var proxy = new LineProxy(diagonal);
|
var proxy = new LineProxy(diagonal);
|
||||||
proxy.y(6);
|
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 () {
|
it("provides internal positions for SVG lines", function () {
|
||||||
|
@ -24,8 +24,8 @@ define(
|
|||||||
['../../src/elements/ResizeHandle'],
|
['../../src/elements/ResizeHandle'],
|
||||||
function (ResizeHandle) {
|
function (ResizeHandle) {
|
||||||
|
|
||||||
var TEST_MIN_WIDTH = 4, TEST_MIN_HEIGHT = 2,
|
var TEST_MIN_WIDTH = 4,
|
||||||
GRID_SIZE = [34,81];
|
TEST_MIN_HEIGHT = 2;
|
||||||
|
|
||||||
describe("A fixed position drag handle", function () {
|
describe("A fixed position drag handle", function () {
|
||||||
var testElement,
|
var testElement,
|
||||||
@ -44,7 +44,7 @@ define(
|
|||||||
testElement,
|
testElement,
|
||||||
TEST_MIN_WIDTH,
|
TEST_MIN_WIDTH,
|
||||||
TEST_MIN_HEIGHT,
|
TEST_MIN_HEIGHT,
|
||||||
GRID_SIZE
|
[34,81]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user