Skip to content

Commit

Permalink
Merge pull request #607 from amcgee/update-pane-logic
Browse files Browse the repository at this point in the history
Update pane initialization and display logic
  • Loading branch information
tmcgee authored Oct 2, 2016
2 parents c92372d + 830f6eb commit e7c3f88
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions viewer/js/viewer/_LayoutMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ define([
aspect.after(splitter, '_stopDrag', lang.hitch(this, '_splitterStopDrag', key));
}
}
if (panes[key].open !== undefined) {
this.togglePane(key, panes[key].open);
}
}
if (panes[key].open !== undefined) {
this.togglePane(key, panes[key].open, true);
}
if (key !== 'center' && this.panes[key]._splitterWidget) {
domClass.add(this.map.root.parentNode, 'pane' + key);
Expand All @@ -213,20 +213,46 @@ define([
this.resizeLayout();
},

togglePane: function (id, show) {
togglePane: function (id, show, suppressEvent) {
if (!this.panes[id]) {
return;
}
var domNode = this.panes[id].domNode;
if (domNode) {
var disp = (show && typeof (show) === 'string') ? show : (domStyle.get(domNode, 'display') === 'none') ? 'block' : 'none';
domStyle.set(domNode, 'display', disp);
if (this.panes[id]._splitterWidget) { // show/hide the splitter, if found
domStyle.set(this.panes[id]._splitterWidget.domNode, 'display', disp);
var oldDisp = domStyle.get(domNode, 'display');
var newDisp;

if (typeof(show) === 'string' && (show === 'none' || show === 'block')) {
// Set (CSS Display Property)
newDisp = show;
} else if (typeof(show) === 'boolean') {
// Set (boolean)
newDisp = (show) ? 'block' : 'none';
} else if (show === undefined) {
// Toggle
newDisp = (oldDisp === 'none') ? 'block' : 'none';
} else {
this.handleError({
source: '_LayoutMixin',
error: 'Invalid type passed as "show" property of "togglePane" function : ' + typeof(show)
});
return;
}
this.positionSideBarToggle(id);
if (this.panes.outer) {
this.panes.outer.resize();
show = (newDisp === 'block');

if (newDisp !== oldDisp) {
domStyle.set(domNode, 'display', newDisp);
if (this.panes[id]._splitterWidget) { // show/hide the splitter, if found
domStyle.set(this.panes[id]._splitterWidget.domNode, 'display', newDisp);
}
this.positionSideBarToggle(id);
if (this.panes.outer) {
this.panes.outer.resize();
}

if (!suppressEvent) {
topic.publish('viewer/onTogglePane', {pane: id, show: show});
}
}
}
},
Expand Down

0 comments on commit e7c3f88

Please sign in to comment.