mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 13:17:53 +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
|
||||
function updateChildren(children) {
|
||||
if (alias) {
|
||||
position = userWidthPreference || position;
|
||||
}
|
||||
|
||||
// Pick out correct elements to update, flowing from
|
||||
// selected anchor edge.
|
||||
var first = children.eq(anchor.reversed ? 2 : 0),
|
||||
@ -126,7 +130,7 @@ define(
|
||||
|
||||
splitterSize = getSize(splitter[0]);
|
||||
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.)
|
||||
firstSize = getSize(first[0]);
|
||||
@ -135,8 +139,8 @@ define(
|
||||
splitter.css(anchor.opposite, "auto");
|
||||
|
||||
last.css(anchor.edge, firstSize + splitterSize + 'px');
|
||||
last.css(anchor.opposite, "0px");
|
||||
position = firstSize + splitterSize;
|
||||
last.css(anchor.opposite, '0px');
|
||||
position = firstSize;
|
||||
}
|
||||
|
||||
// Update positioning of contained elements
|
||||
@ -173,17 +177,17 @@ define(
|
||||
positionParsed.assign($scope, position);
|
||||
}
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
function setUserWidthPreference(value) {
|
||||
userWidthPreference = value - splitterSize;
|
||||
userWidthPreference = value;
|
||||
}
|
||||
|
||||
function persistToLocalStorage(value) {
|
||||
if (alias) {
|
||||
userWidthPreference = value - splitterSize;
|
||||
$window.localStorage.setItem(alias, userWidthPreference);
|
||||
$window.localStorage.setItem(alias, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,13 +229,13 @@ define(
|
||||
anchor: function () {
|
||||
return anchor;
|
||||
},
|
||||
position: function (value) {
|
||||
if (arguments.length > 0) {
|
||||
setUserWidthPreference(value);
|
||||
return getSetPosition(value);
|
||||
} else {
|
||||
position: function (newPosition) {
|
||||
if (arguments.length === 0) {
|
||||
return getSetPosition();
|
||||
}
|
||||
|
||||
setUserWidthPreference(newPosition);
|
||||
return getSetPosition(newPosition);
|
||||
},
|
||||
startResizing: function () {
|
||||
toggleClass('resizing');
|
||||
|
@ -57,7 +57,10 @@ define(
|
||||
|
||||
// Update the position of this splitter
|
||||
newPosition = initialPosition + pixelDelta;
|
||||
mctSplitPane.position(newPosition);
|
||||
|
||||
if (initialPosition !== newPosition) {
|
||||
mctSplitPane.position(newPosition);
|
||||
}
|
||||
},
|
||||
// Grab the event when the user is done moving
|
||||
// the splitter and pass it on
|
||||
|
@ -140,7 +140,7 @@ define(
|
||||
|
||||
it("exposes its splitter's initial position", function () {
|
||||
expect(controller.position()).toEqual(
|
||||
mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth
|
||||
mockFirstPane[0].offsetWidth
|
||||
);
|
||||
});
|
||||
|
||||
@ -168,7 +168,7 @@ define(
|
||||
controller.position(testValue);
|
||||
expect(mockFirstPane.css).toHaveBeenCalledWith(
|
||||
'width',
|
||||
(testValue - mockSplitter[0].offsetWidth) + 'px'
|
||||
(testValue) + 'px'
|
||||
);
|
||||
});
|
||||
|
||||
@ -200,11 +200,11 @@ define(
|
||||
mockFirstPane[0].offsetWidth += 100;
|
||||
// Should not reflect the change yet
|
||||
expect(controller.position()).not.toEqual(
|
||||
mockFirstPane[0].offsetWidth + mockSplitter[0].offsetWidth
|
||||
mockFirstPane[0].offsetWidth
|
||||
);
|
||||
mockInterval.mostRecentCall.args[0]();
|
||||
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 () {
|
||||
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…
Reference in New Issue
Block a user