Skip to content

Commit

Permalink
fixed menu
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyalSix committed Jan 20, 2017
1 parent 8e1e3ea commit e22c3ae
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/js/components/core/SideBar/SideBarContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class SideBarContainer extends React.Component {
<MenuHeaders ref='menuheaders' subMenuProps={this.props.subMenuProps} currentToolNamespace={this.props.currentToolNamespace} currentGroupObjects={this.props.currentGroupObjects}
isCurrentHeader={this.props.isCurrentHeader} currentCheckIndex={this.props.currentCheckIndex}
currentGroupIndex={this.props.currentGroupIndex} menuClick={this.props.menuClick} currentBookName={this.props.currentBookName}
currentSubGroupObjects={this.props.currentSubGroupObjects} isCurrentSubMenu={this.props.currentCheckIndex} />
currentSubGroupObjects={this.props.currentSubGroupObjects} isCurrentSubMenu={this.props.currentCheckIndex}
isOpen={this.props.isOpen}/>
</Col>
</Grid>);
}
Expand Down
1 change: 1 addition & 0 deletions src/js/components/core/navigation_menu/MenuHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MenuHeaders extends React.Component {
const menuItem = this.props.currentGroupObjects[i];
menuItem.isCurrentItem = this.props.isCurrentHeader == i;
menuItem.currentGroupprogress = menuItem.currentGroupprogress || 0;
menuItem.open = this.props.isOpen;
groupsName.push(
<MenuHeadersItems onClick={this.props.menuClick} subMenuProps={this.props.subMenuProps}
{...menuItem} id={i} key={i} ref={menuItem.group.toString()}
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/core/navigation_menu/MenuHeadersItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class MenuHeadersItems extends React.Component {
{this.props.checks[0].groupName}
</td>
<td>
{this.props.isCurrentItem ? <Glyphicon glyph="chevron-right" style={{ position: "absolute", right: "5px", top: "auto" }} /> :
{this.props.isCurrentItem && this.props.open ? <Glyphicon glyph="chevron-right" style={{ position: "absolute", right: "5px", top: "auto" }} /> :
<Glyphicon glyph="chevron-down" style={{ position: "absolute", right: "5px", top: "auto" }} />}
</td>
</tr>
{this.props.isCurrentItem ?
{this.props.isCurrentItem && this.props.open ?
<tr>
<td>
<SubMenu ref='submenu' checkClicked={this.props.subMenuProps.checkClicked} currentBookName={this.props.currentBookName}
Expand Down
20 changes: 14 additions & 6 deletions src/js/pages/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ var Main = React.createClass({
goToPreviousCheck() {
var lastCheck = this.state.currentCheckIndex - 1 < 0;
if (lastCheck) {
this.state.menuHeadersProps.menuClick(this.state.currentGroupIndex - 1);
this.state.menuHeadersProps.menuClick(this.state.currentGroupIndex - 1, true);
}
else this.state.subMenuProps.checkClicked(this.state.currentCheckIndex - 1);
},

goToNextCheck() {
var lastCheck = this.state.currentCheckIndex + 1 >= this.state.currentSubGroupObjects.length;
if (lastCheck) {
this.state.menuHeadersProps.menuClick(this.state.currentGroupIndex + 1);
this.state.menuHeadersProps.menuClick(this.state.currentGroupIndex + 1, true);
}
else this.state.subMenuProps.checkClicked(this.state.currentCheckIndex + 1);
},
Expand Down Expand Up @@ -303,6 +303,7 @@ var Main = React.createClass({
const user = CoreStore.getLoggedInUser();
this.state =
Object.assign({}, this.state, {
subMenuOpen:true,
mainViewVisible: this.props.coreStoreReducer.mainViewVisible,
currentToolNamespace: null,
currentGroupName: null,
Expand Down Expand Up @@ -499,7 +500,12 @@ var Main = React.createClass({
console.log("Its possible the tools data structure doesnt follow the groups and checks pattern");
}
},
menuClick: (id) => {
menuClick: (id, menuOpen) => {
if (id != this.state.currentGroupIndex) {
menuOpen = true;
} else {
menuOpen = menuOpen || !this.state.subMenuOpen;
}
id = id >= 0 ? id : 0;
id = id <= this.state.currentGroupObjects.length - 1 ? id : this.state.currentGroupObjects.length - 1;
this.state.menuHeadersProps.setIsCurrentCheck(true, id, () => {
Expand All @@ -508,15 +514,16 @@ var Main = React.createClass({
chapterNumber: currentCheck.chapter,
verseNumber: currentCheck.verse
});
});
}, menuOpen);
},
setIsCurrentCheck: (status, id, callback) => {
setIsCurrentCheck: (status, id, callback, menuOpen) => {
const newObj = this.state.currentGroupObjects.slice(0);
const currentSubGroupObjects = newObj[id].checks;
this.setState({
currentGroupIndex: parseInt(id),
currentSubGroupObjects: currentSubGroupObjects,
currentCheckIndex: 0,
subMenuOpen:menuOpen
}, callback);
},
},
Expand Down Expand Up @@ -1027,7 +1034,8 @@ var Main = React.createClass({
<SideBarContainer ref='sidebar' currentToolNamespace={this.state.currentToolNamespace} currentGroupObjects={this.state.currentGroupObjects}
subMenuProps={this.state.subMenuProps} isCurrentHeader={this.state.currentGroupIndex} {...this.state.sideBarContainerProps} menuClick={this.state.menuHeadersProps.menuClick} {...this.state.sideNavBarProps}
currentBookName={this.state.currentBookName} isCurrentSubMenu={this.state.currentCheckIndex} currentCheckIndex={this.state.currentCheckIndex}
currentGroupIndex={this.state.currentGroupIndex} currentSubGroupObjects={this.state.currentSubGroupObjects} />
currentGroupIndex={this.state.currentGroupIndex} currentSubGroupObjects={this.state.currentSubGroupObjects}
isOpen={this.state.subMenuOpen}/>
</Col>
<Col style={RootStyles.ScrollableSection} md={9}>
<Loader {...this.state.loaderModalProps} />
Expand Down
2 changes: 1 addition & 1 deletion tC_apps/translationWords

0 comments on commit e22c3ae

Please sign in to comment.