0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 13:42:38 +00:00

Added a view source button to the share page

This commit is contained in:
Scott Tolksdorf
2016-01-14 12:29:49 -05:00
parent 16264f78fa
commit c92204d99b
3 changed files with 34 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ var SharePage = React.createClass({
return(
<div className='sharePage'>
<Statusbar
sourceText={this.props.entry.text}
lastUpdated={this.props.entry.updatedAt}
views={this.props.entry.views}
printId={this.props.entry.shareId}

View File

@@ -10,6 +10,7 @@ var Statusbar = React.createClass({
getDefaultProps: function() {
return {
//editId: null,
sourceText : null,
shareId : null,
printId : null,
isPending : false,
@@ -33,6 +34,13 @@ var Statusbar = React.createClass({
},
openSourceWindow : function(){
var sourceWindow = window.open();
sourceWindow.document.write('<code><pre>' + this.props.sourceText + '</pre></code>');
},
renderInfo : function(){
if(!this.props.lastUpdated) return null;
@@ -47,6 +55,14 @@ var Statusbar = React.createClass({
},
renderSourceButton : function(){
if(!this.props.sourceText) return null;
return <a className='sourceField' onClick={this.openSourceWindow}>
View Source <i className='fa fa-code' />
</a>
},
renderNewButton : function(){
if(this.props.editId || this.props.shareId) return null;
@@ -96,6 +112,7 @@ var Statusbar = React.createClass({
<div className='controls right'>
{this.renderStatus()}
{this.renderInfo()}
{this.renderSourceButton()}
{this.renderPrintButton()}
{this.renderShare()}
{this.renderNewButton()}

View File

@@ -90,5 +90,21 @@
font-size : 12px;
}
}
.sourceField{
.animate(background-color);
cursor : pointer;
color : white;
text-decoration : none;
&:hover{
background-color : fade(@teal, 70%);
}
span{
margin-right : 5px;
}
input{
width : 100px;
font-size : 12px;
}
}
}
}