From 545f772918e08f31bf089fb66f8784a9af14b84c Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Wed, 27 Jun 2018 22:01:29 +0300 Subject: [PATCH] feat(downloading): tooltips on torrent element --- src/app/app.css | 10 ++- src/app/tooltip.js | 5 +- src/app/torrent.js | 181 +++++++++++++++++++++++-------------------- translations/en.json | 7 +- translations/ru.json | 7 +- translations/ua.json | 7 +- 6 files changed, 129 insertions(+), 88 deletions(-) diff --git a/src/app/app.css b/src/app/app.css index 629ce0e..f10c380 100644 --- a/src/app/app.css +++ b/src/app/app.css @@ -61,6 +61,10 @@ font-size: 0.9em; } +.tooltip .tooltiptext.right { + margin-left: -100px; +} + .tooltip .tooltiptext::after { content: ""; position: absolute; @@ -72,6 +76,10 @@ border-color: transparent transparent black transparent; } +.tooltip .tooltiptext.right::after { + left: 80%; +} + .tooltip:hover .tooltiptext { visibility: visible; } @@ -82,7 +90,7 @@ height: 24px; position: relative; top: 0; - left: -15px; + left: -26px; right: 0; bottom: 0; } diff --git a/src/app/tooltip.js b/src/app/tooltip.js index a8cff36..5fb7c88 100644 --- a/src/app/tooltip.js +++ b/src/app/tooltip.js @@ -1,10 +1,13 @@ import React from 'react'; export default (props) => { + let className = 'tooltiptext' + if(props.right) + className += ' right' return (
{props.children} - {props.hint} + {props.hint}
) } \ No newline at end of file diff --git a/src/app/torrent.js b/src/app/torrent.js index edbe73d..f7779f9 100644 --- a/src/app/torrent.js +++ b/src/app/torrent.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import formatBytes from './format-bytes' import {ListItem} from 'material-ui/List'; import Divider from 'material-ui/Divider'; +import ToolTip from './tooltip'; import PagesPie from './pages-pie.js'; import TorrentPage from './torrent-page' @@ -358,18 +359,19 @@ export default class Torrent extends Component { // mark delete after finish canDeleteDownloadAfterFinish && - - { - e.preventDefault(); - e.stopPropagation(); - window.torrentSocket.emit('downloadUpdate', torrent.hash, {removeOnDone: 'switch'}) - }} viewBox="0 0 512 512"> - - + + - - - - - - + + + + } { !this.state.startingDownloading && !this.state.downloading && !this.state.downloaded ? - - { - e.preventDefault(); - e.stopPropagation(); - window.torrentSocket.emit('download', torrent, null, (added) => { - if(added) - this.setState({startingDownloading: true}) - }) - }} viewBox="0 0 56 56"> - - - - - - - + + + { + e.preventDefault(); + e.stopPropagation(); + window.torrentSocket.emit('download', torrent, null, (added) => { + if(added) + this.setState({startingDownloading: true}) + }) + }} viewBox="0 0 56 56"> + + + + + + + + : this.state.startingDownloading && !this.state.downloading - ? + ? +
{ e.preventDefault(); e.stopPropagation(); @@ -448,45 +454,53 @@ export default class Torrent extends Component {
+
: this.state.downloaded ? - - { - e.preventDefault(); - e.stopPropagation(); + + + { + e.preventDefault(); + e.stopPropagation(); - window.torrentSocket.emit('downloadCancel', torrent.hash) - }} viewBox="0 0 18 18"> - + window.torrentSocket.emit('downloadCancel', torrent.hash) + }} viewBox="0 0 18 18"> + + : this.state.downloading && - - { - e.preventDefault(); - e.stopPropagation(); + + + { + e.preventDefault(); + e.stopPropagation(); - window.torrentSocket.emit('downloadCancel', torrent.hash) - }} viewBox="0 0 18 18"> - + window.torrentSocket.emit('downloadCancel', torrent.hash) + }} viewBox="0 0 18 18"> + + } - - { - e.preventDefault(); - e.stopPropagation(); - var win = window.open(`magnet:?xt=urn:btih:${torrent.hash}`, '_self'); - }} viewBox="0 0 24 24"> - + - + + } /> diff --git a/translations/en.json b/translations/en.json index e8f7ce2..9165d81 100644 --- a/translations/en.json +++ b/translations/en.json @@ -169,6 +169,11 @@ "filters settings": "filters settings", "enable/disable safe search (adult filter)": "enable/disable safe search (adult filter)", "advanced search": "advanced search", - "display search results for current search request": "display search results for current search request" + "display search results for current search request": "display search results for current search request", + "Download using built-in client": "Download using built-in client", + "Open torrent in external torrent client": "Open torrent in external torrent client", + "Dont start to seed torrent after download finish": "Dont start to seed torrent after download finish", + "Delete download (files saved)": "Delete download (files saved)", + "Serching metadata in progress... Click will delete this torrent.": "Serching metadata in progress... Click will delete this torrent." } } \ No newline at end of file diff --git a/translations/ru.json b/translations/ru.json index 7396368..c1c0fda 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -169,6 +169,11 @@ "filters settings": "настройки фильтров", "enable/disable safe search (adult filter)": "включить/выключить безопасный поиск (фильтр для взрослых)", "advanced search": "расширенный поиск", - "display search results for current search request": "отобразить поисковые результаты для текущего поиского запроса" + "display search results for current search request": "отобразить поисковые результаты для текущего поиского запроса", + "Download using built-in client": "Скачать используя встроенный клиент", + "Open torrent in external torrent client": "Открыть торрент во внешнем торрент-клиенте", + "Dont start to seed torrent after download finish": "Не начинать сидировать торрент после окончания загрузки", + "Delete download (files saved)": "Удалить закачку (сохранив файлы)", + "Serching metadata in progress... Click will delete this torrent.": "Поиск методанных в процессе... Клик удалит этот торрент." } } \ No newline at end of file diff --git a/translations/ua.json b/translations/ua.json index 6e02de1..8fdba95 100644 --- a/translations/ua.json +++ b/translations/ua.json @@ -169,6 +169,11 @@ "filters settings": "filters settings", "enable/disable safe search (adult filter)": "enable/disable safe search (adult filter)", "advanced search": "advanced search", - "display search results for current search request": "display search results for current search request" + "display search results for current search request": "display search results for current search request", + "Download using built-in client": "Download using built-in client", + "Open torrent in external torrent client": "Open torrent in external torrent client", + "Dont start to seed torrent after download finish": "Dont start to seed torrent after download finish", + "Delete download (files saved)": "Delete download (files saved)", + "Serching metadata in progress... Click will delete this torrent.": "Serching metadata in progress... Click will delete this torrent." } } \ No newline at end of file