mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 12:02:44 +00:00
Added a view source button to the share page
This commit is contained in:
@@ -25,6 +25,7 @@ var SharePage = React.createClass({
|
|||||||
return(
|
return(
|
||||||
<div className='sharePage'>
|
<div className='sharePage'>
|
||||||
<Statusbar
|
<Statusbar
|
||||||
|
sourceText={this.props.entry.text}
|
||||||
lastUpdated={this.props.entry.updatedAt}
|
lastUpdated={this.props.entry.updatedAt}
|
||||||
views={this.props.entry.views}
|
views={this.props.entry.views}
|
||||||
printId={this.props.entry.shareId}
|
printId={this.props.entry.shareId}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ var Statusbar = React.createClass({
|
|||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
//editId: null,
|
//editId: null,
|
||||||
|
sourceText : null,
|
||||||
shareId : null,
|
shareId : null,
|
||||||
printId : null,
|
printId : null,
|
||||||
isPending : false,
|
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(){
|
renderInfo : function(){
|
||||||
if(!this.props.lastUpdated) return null;
|
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(){
|
renderNewButton : function(){
|
||||||
if(this.props.editId || this.props.shareId) return null;
|
if(this.props.editId || this.props.shareId) return null;
|
||||||
|
|
||||||
@@ -96,6 +112,7 @@ var Statusbar = React.createClass({
|
|||||||
<div className='controls right'>
|
<div className='controls right'>
|
||||||
{this.renderStatus()}
|
{this.renderStatus()}
|
||||||
{this.renderInfo()}
|
{this.renderInfo()}
|
||||||
|
{this.renderSourceButton()}
|
||||||
{this.renderPrintButton()}
|
{this.renderPrintButton()}
|
||||||
{this.renderShare()}
|
{this.renderShare()}
|
||||||
{this.renderNewButton()}
|
{this.renderNewButton()}
|
||||||
|
|||||||
@@ -90,5 +90,21 @@
|
|||||||
font-size : 12px;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user