0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-02 10:42:44 +00:00

Code to brew page jumping working

This commit is contained in:
Scott Tolksdorf
2017-01-17 23:32:34 -05:00
parent 6544d63b23
commit 5e04e5dc99
2 changed files with 30 additions and 0 deletions

View File

@@ -66,6 +66,18 @@ const Editor = React.createClass({
})
},
getCurrentPage : function(){
const lines = this.props.value.split('\n').slice(0, this.cursorPosition.line + 1);
return _.reduce(lines, (r, line) => {
if(line.indexOf('\\page') !== -1) r++;
return r;
}, 1);
},
brewJump : function(){
const currentPage = this.getCurrentPage();
window.location.hash = 'p' + currentPage;
},
//Called when there are changes to the editor's dimensions
update : function(){
this.refs.codeEditor.updateSize();
@@ -95,6 +107,10 @@ const Editor = React.createClass({
value={this.props.value}
onChange={this.handleTextChange}
onCursorActivity={this.handleCursorActivty} />
<div className='brewJump' onClick={this.brewJump}>
<i className='fa fa-arrow-right' />
</div>
</div>
);
}

View File

@@ -7,5 +7,19 @@
height : 100%;
}
.brewJump{
position: absolute;
background-color: @teal;
cursor: pointer;
width : 30px;
height : 30px;
display : flex;
align-items : center;
bottom : 20px;
right : 20px;
z-index: 1000000;
justify-content:center;
.tooltipLeft("Jump to brew page");
}
}