0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-08 14:02:41 +00:00

Removing unneeded code

This commit is contained in:
Scott Tolksdorf
2016-05-10 21:45:58 -04:00
parent c07c9911ec
commit c9bfd08bb3
10 changed files with 10 additions and 594 deletions

View File

@@ -21,20 +21,16 @@ var BrewRenderer = React.createClass({
totalPages : 0,
height : 0,
componentDidMount: function() {
this.setState({
height : this.refs.main.parentNode.clientHeight
});
},
handleScroll : function(e){
this.setState({
viewablePageNumber : Math.floor(e.target.scrollTop / PAGE_HEIGHT)
});
},
//Implement later
scrollToPage : function(pageNumber){
},

View File

@@ -6,7 +6,7 @@ var Nav = require('naturalcrit/nav/nav.jsx');
const MAX_TITLE_LENGTH = 50;
var RedditShare = React.createClass({
var EditTitle = React.createClass({
getDefaultProps: function() {
return {
title : '',
@@ -30,4 +30,4 @@ var RedditShare = React.createClass({
});
module.exports = RedditShare;
module.exports = EditTitle;

View File

@@ -19,11 +19,7 @@ var Navbar = React.createClass({
<Nav.item>v1.5.0</Nav.item>
</Nav.section>
{this.props.children}
{this.props.children}
</Nav.base>
}
});

View File

@@ -1,53 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Markdown = require('marked');
var PAGE_HEIGHT = 1056 + 30;
var PageContainer = React.createClass({
getDefaultProps: function() {
return {
text : ""
};
},
getInitialState: function() {
return {
viewablePageIndex: 0
};
},
handleScroll : function(e){
this.setState({
viewablePageIndex : Math.floor(e.target.scrollTop / PAGE_HEIGHT)
});
},
renderDummyPage : function(key){
return <div className='phb' key={key}>
<i className='fa fa-spinner fa-spin' />
</div>
},
renderPages : function(){
var currentIndex = this.state.viewablePageIndex;
return _.map(this.props.text.split('\\page'), (pageText, index) => {
if(currentIndex - 1 == index || currentIndex == index || currentIndex + 1 == index){
return <div className='phb' dangerouslySetInnerHTML={{__html:Markdown(pageText)}} key={index} />
}else{
return this.renderDummyPage(index);
}
})
},
render : function(){
return <div className="pageContainer" onScroll={this.handleScroll}>
<div className='pages'>
{this.renderPages()}
</div>
</div>;
}
});
module.exports = PageContainer;

View File

@@ -1,14 +0,0 @@
@import (less) './client/homebrew/phbStyle/phb.style.less';
.pageContainer{
background-color : @steel;
.pages{
padding : 30px 0px;
&>.phb{
margin-right : auto;
margin-bottom : 30px;
margin-left : auto;
box-shadow : 1px 4px 14px #000;
}
}
}

View File

@@ -1,173 +0,0 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var Moment = require('moment');
var request = require('superagent')
var Logo = require('naturalcrit/logo/logo.jsx');
var replaceAll = function(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
var Statusbar = React.createClass({
getDefaultProps: function() {
return {
editId: null,
sourceText : null,
shareId : null,
printId : null,
isPending : false,
lastUpdated : null,
info : null,
views : 0
};
},
componentDidMount: function() {
//Updates the last updated text every 10 seconds
if(this.props.lastUpdated){
this.refreshTimer = setInterval(()=>{
this.forceUpdate();
}, 10000)
}
},
componentWillUnmount: function() {
clearInterval(this.refreshTimer);
},
deleteBrew : function(){
if(!confirm("are you sure you want to delete this brew?")) return;
if(!confirm("are you REALLY sure? You will not be able to recover it")) return;
request.get('/homebrew/api/remove/' + this.props.editId)
.send()
.end(function(err, res){
window.location.href = '/homebrew';
});
},
openSourceWindow : function(){
var sourceWindow = window.open();
var content = replaceAll(this.props.sourceText, '<', '&lt;');
content = replaceAll(content, '>', '&gt;');
sourceWindow.document.write('<code><pre>' + content + '</pre></code>');
},
renderInfo : function(){
if(!this.props.lastUpdated) return null;
return [
<div className='views' key='views'>
Views: {this.props.views}
</div>,
<div className='lastUpdated' key='lastUpdated'>
Last updated: {Moment(this.props.lastUpdated).fromNow()}
</div>
];
},
renderChromeTip : function(){
if(typeof window !== 'undefined' && window.chrome) return;
return <div
className='chromeField'
data-tooltip="If you are noticing rendering issues, try using Chrome instead.">
<i className='fa fa-exclamation-triangle' />
Optimized for Chrome
</div>
},
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;
return <a className='newButton' target='_blank' href='/homebrew/new'>
New Brew <i className='fa fa-external-link' />
</a>
},
renderChangelogButton : function(){
if(this.props.editId || this.props.shareId) return null;
return <a className='changelogButton' target='_blank' href='/homebrew/changelog'>
Changelog <i className='fa fa-file-text-o' />
</a>
},
renderShare : function(){
if(!this.props.shareId) return null;
return <a className='shareField' key='share' href={'/homebrew/share/' + this.props.shareId} target="_blank">
Share Link <i className='fa fa-external-link' />
</a>
},
renderPrintButton : function(){
if(!this.props.printId) return null;
return <a className='printField' key='print' href={'/homebrew/print/' + this.props.printId} target="_blank">
Print View <i className='fa fa-print' />
</a>
},
renderDeleteButton : function(){
if(!this.props.editId) return null;
return <div className='deleteButton' onClick={this.deleteBrew}>
Delete <i className='fa fa-trash' />
</div>
},
renderStatus : function(){
if(!this.props.editId) return null;
var text = 'Saved.'
if(this.props.isPending){
text = 'Saving...'
}
return <div className='savingStatus'>
{text}
</div>
},
render : function(){
return <div className='statusbar'>
<Logo
hoverSlide={true}
/>
<div className='left'>
<a href='/homebrew' className='toolName'>
The Home<small>Brewery</small>
</a>
</div>
<div className='controls right'>
{this.renderChromeTip()}
{this.renderChangelogButton()}
{this.renderStatus()}
{this.renderInfo()}
{this.renderSourceButton()}
{this.renderDeleteButton()}
{this.renderPrintButton()}
{this.renderShare()}
{this.renderNewButton()}
</div>
</div>
}
});
module.exports = Statusbar;

View File

@@ -1,135 +0,0 @@
.statusbar{
position : fixed;
z-index : 1000;
height : 25px;
width : 100%;
background-color : black;
font-size : 24px;
color : white;
line-height : 1.0em;
border-bottom : 1px solid @grey;
.logo{
display : inline-block;
vertical-align : middle;
margin-top : -5px;
margin-right : 20px;
svg{
margin-top : -6px;
}
}
.left{
display : inline-block;
vertical-align : top;
}
.right{
float : right;
}
.toolName{
display : block;
vertical-align : middle;
font-family : CodeBold;
font-size : 16px;
color : white;
line-height : 30px;
text-decoration : none;
small{
font-family : CodeBold;
}
}
.controls{
font-size : 12px;
>*{
display : inline-block;
height : 100%;
padding : 0px 10px;
border-left : 1px solid @grey;
}
.savingStatus{
width : 56px;
color : @grey;
text-align : center;
}
.newButton{
.animate(background-color);
color : white;
text-decoration : none;
&:hover{
background-color : fade(@green, 70%);
}
}
.chromeField{
background-color: @orange;
color : white;
text-decoration : none;
i{
margin-right: 10px;
}
}
.changelogButton{
.animate(background-color);
color : white;
text-decoration : none;
&:hover{
background-color : fade(@purple, 70%);
}
}
.deleteButton{
.animate(background-color);
color : white;
text-decoration : none;
cursor: pointer;
&:hover{
background-color : fade(@red, 70%);
}
}
.shareField{
.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;
}
}
.printField{
.animate(background-color);
cursor : pointer;
color : white;
text-decoration : none;
&:hover{
background-color : fade(@orange, 70%);
}
span{
margin-right : 5px;
}
input{
width : 100px;
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;
}
}
}
}