diff --git a/js/component/common.js b/js/component/common.js index 13d6544d9..cec8bce3d 100644 --- a/js/component/common.js +++ b/js/component/common.js @@ -27,6 +27,77 @@ var Link = React.createClass({ } }); +var DownloadLink = React.createClass({ + propTypes: { + type: React.PropTypes.string, + streamName: React.PropTypes.string, + label: React.PropTypes.string, + downloadingLabel: React.PropTypes.string, + button: React.PropTypes.string, + style: React.PropTypes.object, + hidden: React.PropTypes.bool, + }, + getDefaultProps: function() { + return { + icon: 'icon-download', + label: 'Download', + downloadingLabel: 'Downloading...', + } + }, + getInitialState: function() { + return { + downloading: false, + } + }, + startDownload: function() { + if (!this.state.downloading) { //@TODO: Continually update this.state.downloading based on actual status of file + this.setState({ + downloading: true + }); + + lbry.getStream(this.props.streamName, (streamInfo) => { + alert('Downloading to ' + streamInfo.path); + console.log(streamInfo); + }); + } + }, + render: function() { + var label = (!this.state.downloading ? this.props.label : this.props.downloadingLabel); + return ; + } +}); + +var WatchLink = React.createClass({ + propTypes: { + type: React.PropTypes.string, + streamName: React.PropTypes.string, + label: React.PropTypes.string, + button: React.PropTypes.string, + style: React.PropTypes.object, + hidden: React.PropTypes.bool, + }, + + getDefaultProps: function() { + return { + icon: 'icon-play', + label: 'Watch', + } + }, + + render: function() { + // No support for lbry:// URLs in Windows or on Chrome yet + if (/windows|win32/i.test(navigator.userAgent) || (window.chrome && window.navigator.vendor == "Google Inc.")) { + var uri = "/?watch=" + this.props.streamName; + } else { + var uri = 'lbry://' + this.props.streamName; + } + + return ; + } +}); + var creditAmountStyle = { color: '#216C2A', fontWeight: 'bold', diff --git a/js/page/home.js b/js/page/home.js index 2dd7b9b41..bf94bf625 100644 --- a/js/page/home.js +++ b/js/page/home.js @@ -92,26 +92,7 @@ var SearchResultRow = React.createClass({ downloading: false } }, - startDownload: function() { - if (!this.state.downloading) { - this.setState({ - downloading: true - }); - lbry.getStream(this.props.name, (streamInfo) => { - alert('Downloading ' + this.props.title + ' to ' + streamInfo.path); - }); - } - }, render: function() { - var displayURI = 'lbry://' + this.props.name; - - // No support for lbry:// URLs in Windows or on Chrome yet - if (/windows|win32/i.test(navigator.userAgent) || (window.chrome && window.navigator.vendor == "Google Inc.")) { - var linkURI = "/?watch=" + this.props.name; - } else { - var linkURI = displayURI; - } - return (
{this.props.description}
{metadata.description}