mirror of
https://github.com/nasa/openmct.git
synced 2024-12-23 23:12:23 +00:00
updated mctSplitPane to handle all logic regarding persisting userPreferenceWidth to local storage
This commit is contained in:
parent
5a7fdf82ac
commit
593c1adf56
@ -26,7 +26,7 @@
|
|||||||
ng-controller="PaneController as modelPaneTree"
|
ng-controller="PaneController as modelPaneTree"
|
||||||
ng-class="modelPaneTree.visible() ? 'pane-tree-showing' : 'pane-tree-hidden'">
|
ng-class="modelPaneTree.visible() ? 'pane-tree-showing' : 'pane-tree-hidden'">
|
||||||
<mct-split-pane class='abs contents'
|
<mct-split-pane class='abs contents'
|
||||||
anchor='left' saveUserWidthPreference='true'>
|
anchor='left' alias="leftSide">
|
||||||
<div class='split-pane-component treeview pane left'>
|
<div class='split-pane-component treeview pane left'>
|
||||||
<div class="abs holder l-flex-col holder-treeview-elements">
|
<div class="abs holder l-flex-col holder-treeview-elements">
|
||||||
<mct-representation key="'create-button'"
|
<mct-representation key="'create-button'"
|
||||||
@ -60,7 +60,7 @@
|
|||||||
ng-controller="InspectorPaneController as modelPaneInspect"
|
ng-controller="InspectorPaneController as modelPaneInspect"
|
||||||
ng-class="modelPaneInspect.visible() ? 'pane-inspect-showing' : 'pane-inspect-hidden'">
|
ng-class="modelPaneInspect.visible() ? 'pane-inspect-showing' : 'pane-inspect-hidden'">
|
||||||
|
|
||||||
<mct-split-pane class='l-object-and-inspector contents abs' anchor='right' saveUserWidthPreference="true">
|
<mct-split-pane class='l-object-and-inspector contents abs' anchor='right' alias="rightSide">
|
||||||
<div class='split-pane-component t-object pane primary-pane left'>
|
<div class='split-pane-component t-object pane primary-pane left'>
|
||||||
<mct-representation mct-object="navigatedObject"
|
<mct-representation mct-object="navigatedObject"
|
||||||
key="navigatedObject.getCapability('status').get('editing') ? 'edit-object' : 'browse-object'"
|
key="navigatedObject.getCapability('status').get('editing') ? 'edit-object' : 'browse-object'"
|
||||||
|
@ -102,10 +102,6 @@ define(
|
|||||||
positionParsed = $parse($attrs.position),
|
positionParsed = $parse($attrs.position),
|
||||||
position; // Start undefined, until explicitly set
|
position; // Start undefined, until explicitly set
|
||||||
|
|
||||||
// create unique alias for every instance of MCTSplitPane
|
|
||||||
var mctSplitPaneAlias = "mctSplitPaneAlias" + splitPaneNumber;
|
|
||||||
splitPaneNumber += 1;
|
|
||||||
|
|
||||||
// Get relevant size (height or width) of DOM element
|
// Get relevant size (height or width) of DOM element
|
||||||
function getSize(domElement) {
|
function getSize(domElement) {
|
||||||
return (anchor.orientation === 'vertical' ?
|
return (anchor.orientation === 'vertical' ?
|
||||||
@ -154,7 +150,7 @@ define(
|
|||||||
// Enforce minimum/maximum positions
|
// Enforce minimum/maximum positions
|
||||||
function enforceExtrema() {
|
function enforceExtrema() {
|
||||||
// Check for user preference on splitPane width
|
// Check for user preference on splitPane width
|
||||||
var userWidthPreference = window.localStorage[mctSplitPaneAlias];
|
var userWidthPreference = window.localStorage[$attrs.alias];
|
||||||
position = Math.max(position, 0);
|
position = Math.max(position, 0);
|
||||||
position = Math.min(position,(userWidthPreference || getSize($element[0])));
|
position = Math.min(position,(userWidthPreference || getSize($element[0])));
|
||||||
}
|
}
|
||||||
@ -172,7 +168,13 @@ define(
|
|||||||
if (positionParsed.assign && position !== prior) {
|
if (positionParsed.assign && position !== prior) {
|
||||||
positionParsed.assign($scope, position);
|
positionParsed.assign($scope, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($attrs.alias) {
|
||||||
|
var myStorage = window.localStorage;
|
||||||
|
myStorage.setItem($attrs.alias, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,9 +217,7 @@ define(
|
|||||||
toggleClass: toggleClass,
|
toggleClass: toggleClass,
|
||||||
anchor: function () {
|
anchor: function () {
|
||||||
return anchor;
|
return anchor;
|
||||||
},
|
}
|
||||||
saveUserWidthPreference: $attrs.saveuserwidthpreference,
|
|
||||||
mctSplitPaneAlias: mctSplitPaneAlias
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,12 +56,6 @@ define(
|
|||||||
|
|
||||||
// Update the position of this splitter
|
// Update the position of this splitter
|
||||||
mctSplitPane.position(initialPosition + pixelDelta);
|
mctSplitPane.position(initialPosition + pixelDelta);
|
||||||
|
|
||||||
// Save user width preference to local storage if selected
|
|
||||||
if (mctSplitPane.saveUserWidthPreference === 'true') {
|
|
||||||
var myStorage = window.localStorage;
|
|
||||||
myStorage.setItem(mctSplitPane.mctSplitPaneAlias, initialPosition + pixelDelta);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// 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
|
||||||
|
Loading…
Reference in New Issue
Block a user