mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 06:31:04 +00:00
Merge pull request #1692 from nasa/timeline-issue-1686
update mct-split-pane to use userPreferenceWidth only when alias is p…
This commit is contained in:
commit
b6a8078634
@ -117,6 +117,10 @@ define(
|
|||||||
|
|
||||||
// Apply styles to child elements
|
// Apply styles to child elements
|
||||||
function updateChildren(children) {
|
function updateChildren(children) {
|
||||||
|
if (alias) {
|
||||||
|
position = userWidthPreference || position;
|
||||||
|
}
|
||||||
|
|
||||||
// Pick out correct elements to update, flowing from
|
// Pick out correct elements to update, flowing from
|
||||||
// selected anchor edge.
|
// selected anchor edge.
|
||||||
var first = children.eq(anchor.reversed ? 2 : 0),
|
var first = children.eq(anchor.reversed ? 2 : 0),
|
||||||
@ -126,7 +130,7 @@ define(
|
|||||||
|
|
||||||
splitterSize = getSize(splitter[0]);
|
splitterSize = getSize(splitter[0]);
|
||||||
first.css(anchor.edge, "0px");
|
first.css(anchor.edge, "0px");
|
||||||
first.css(anchor.dimension, (userWidthPreference || position) + 'px');
|
first.css(anchor.dimension, position + 'px');
|
||||||
|
|
||||||
// Get actual size (to obey min-width etc.)
|
// Get actual size (to obey min-width etc.)
|
||||||
firstSize = getSize(first[0]);
|
firstSize = getSize(first[0]);
|
||||||
@ -135,8 +139,8 @@ define(
|
|||||||
splitter.css(anchor.opposite, "auto");
|
splitter.css(anchor.opposite, "auto");
|
||||||
|
|
||||||
last.css(anchor.edge, firstSize + splitterSize + 'px');
|
last.css(anchor.edge, firstSize + splitterSize + 'px');
|
||||||
last.css(anchor.opposite, "0px");
|
last.css(anchor.opposite, '0px');
|
||||||
position = firstSize + splitterSize;
|
position = firstSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update positioning of contained elements
|
// Update positioning of contained elements
|
||||||
@ -173,17 +177,17 @@ define(
|
|||||||
positionParsed.assign($scope, position);
|
positionParsed.assign($scope, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUserWidthPreference(value) {
|
function setUserWidthPreference(value) {
|
||||||
userWidthPreference = value - splitterSize;
|
userWidthPreference = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function persistToLocalStorage(value) {
|
function persistToLocalStorage(value) {
|
||||||
if (alias) {
|
if (alias) {
|
||||||
userWidthPreference = value - splitterSize;
|
$window.localStorage.setItem(alias, value);
|
||||||
$window.localStorage.setItem(alias, userWidthPreference);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,13 +229,13 @@ define(
|
|||||||
anchor: function () {
|
anchor: function () {
|
||||||
return anchor;
|
return anchor;
|
||||||
},
|
},
|
||||||
position: function (value) {
|
position: function (newPosition) {
|
||||||
if (arguments.length > 0) {
|
if (arguments.length === 0) {
|
||||||
setUserWidthPreference(value);
|
|
||||||
return getSetPosition(value);
|
|
||||||
} else {
|
|
||||||
return getSetPosition();
|
return getSetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setUserWidthPreference(newPosition);
|
||||||
|
return getSetPosition(newPosition);
|
||||||
},
|
},
|
||||||
startResizing: function () {
|
startResizing: function () {
|
||||||
toggleClass('resizing');
|
toggleClass('resizing');
|
||||||
|
@ -57,7 +57,10 @@ define(
|
|||||||
|
|
||||||
// Update the position of this splitter
|
// Update the position of this splitter
|
||||||
newPosition = initialPosition + pixelDelta;
|
newPosition = initialPosition + pixelDelta;
|
||||||
mctSplitPane.position(newPosition);
|
|
||||||
|
if (initialPosition !== newPosition) {
|
||||||
|
mctSplitPane.position(newPosition);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// Grab the event when the user is done moving
|
// Grab the event when the user is done moving
|
||||||
// the splitter and pass it on
|
// the splitter and pass it on
|
||||||
|
@ -140,7 +140,7 @@ define(
|
|||||||
|
|
||||||
it("exposes its splitter's initial position", function () {
|
it("exposes its splitter's initial position", function () {
|
||||||
expect(controller.position()).toEqual(
|
expect(controller.position()).toEqual(
|
||||||
mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth
|
mockFirstPane[0].offsetWidth
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ define(
|
|||||||
controller.position(testValue);
|
controller.position(testValue);
|
||||||
expect(mockFirstPane.css).toHaveBeenCalledWith(
|
expect(mockFirstPane.css).toHaveBeenCalledWith(
|
||||||
'width',
|
'width',
|
||||||
(testValue - mockSplitter[0].offsetWidth) + 'px'
|
(testValue) + 'px'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -200,11 +200,11 @@ define(
|
|||||||
mockFirstPane[0].offsetWidth += 100;
|
mockFirstPane[0].offsetWidth += 100;
|
||||||
// Should not reflect the change yet
|
// Should not reflect the change yet
|
||||||
expect(controller.position()).not.toEqual(
|
expect(controller.position()).not.toEqual(
|
||||||
mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth
|
mockFirstPane[0].offsetWidth
|
||||||
);
|
);
|
||||||
mockInterval.mostRecentCall.args[0]();
|
mockInterval.mostRecentCall.args[0]();
|
||||||
expect(controller.position()).toEqual(
|
expect(controller.position()).toEqual(
|
||||||
mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth
|
mockFirstPane[0].offsetWidth
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ define(
|
|||||||
|
|
||||||
it("saves user preference to localStorage when user is done resizing", function () {
|
it("saves user preference to localStorage when user is done resizing", function () {
|
||||||
controller.endResizing(100);
|
controller.endResizing(100);
|
||||||
expect(Number(mockWindow.localStorage.getItem('mctSplitPane-rightSide'))).toEqual(100 - mockSplitter[0].offsetWidth);
|
expect(Number(mockWindow.localStorage.getItem('mctSplitPane-rightSide'))).toEqual(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user