Reader.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387
  1. <template>
  2. <div class="column no-wrap">
  3. <div v-show="toolBarActive" ref="header" class="header">
  4. <div ref="buttons" class="row justify-between no-wrap">
  5. <div>
  6. <button ref="loader" v-ripple class="tool-button" :class="buttonActiveClass('loader')" @click="buttonClick('loader')">
  7. <q-icon name="la la-arrow-left" size="32px" />
  8. <q-tooltip :delay="1500" anchor="bottom right" content-style="font-size: 80%">
  9. {{ rstore.readerActions['loader'] }}
  10. </q-tooltip>
  11. </button>
  12. </div>
  13. <div>
  14. <button v-show="showToolButton['undoAction']" ref="undoAction" v-ripple class="tool-button" :class="buttonActiveClass('undoAction')" @click="buttonClick('undoAction')">
  15. <q-icon name="la la-angle-left" size="32px" />
  16. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  17. {{ rstore.readerActions['undoAction'] }}
  18. </q-tooltip>
  19. </button>
  20. <button v-show="showToolButton['redoAction']" ref="redoAction" v-ripple class="tool-button" :class="buttonActiveClass('redoAction')" @click="buttonClick('redoAction')">
  21. <q-icon name="la la-angle-right" size="32px" />
  22. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  23. {{ rstore.readerActions['redoAction'] }}
  24. </q-tooltip>
  25. </button>
  26. <div class="space"></div>
  27. <button v-show="showToolButton['fullScreen']" ref="fullScreen" v-ripple class="tool-button" :class="buttonActiveClass('fullScreen')" @click="buttonClick('fullScreen')">
  28. <q-icon :name="(fullScreenActive ? 'la la-compress-arrows-alt': 'la la-expand-arrows-alt')" size="32px" />
  29. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  30. {{ rstore.readerActions['fullScreen'] }}
  31. </q-tooltip>
  32. </button>
  33. <button v-show="showToolButton['scrolling']" ref="scrolling" v-ripple class="tool-button" :class="buttonActiveClass('scrolling')" @click="buttonClick('scrolling')">
  34. <q-icon name="la la-film" size="32px" />
  35. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  36. {{ rstore.readerActions['scrolling'] }}
  37. </q-tooltip>
  38. </button>
  39. <button v-show="showToolButton['setPosition']" ref="setPosition" v-ripple class="tool-button" :class="buttonActiveClass('setPosition')" @click="buttonClick('setPosition')">
  40. <q-icon name="la la-angle-double-right" size="32px" />
  41. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  42. {{ rstore.readerActions['setPosition'] }}
  43. </q-tooltip>
  44. </button>
  45. <button v-show="showToolButton['search']" ref="search" v-ripple class="tool-button" :class="buttonActiveClass('search')" @click="buttonClick('search')">
  46. <q-icon name="la la-search" size="32px" />
  47. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  48. {{ rstore.readerActions['search'] }}
  49. </q-tooltip>
  50. </button>
  51. <button v-show="showToolButton['copyText']" ref="copyText" v-ripple class="tool-button" :class="buttonActiveClass('copyText')" @click="buttonClick('copyText')">
  52. <q-icon name="la la-copy" size="32px" />
  53. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  54. {{ rstore.readerActions['copyText'] }}
  55. </q-tooltip>
  56. </button>
  57. <button v-show="showToolButton['convOptions']" ref="convOptions" v-ripple class="tool-button" :class="buttonActiveClass('convOptions')" @click="buttonClick('convOptions')">
  58. <q-icon name="la la-magic" size="32px" />
  59. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  60. {{ rstore.readerActions['convOptions'] }}
  61. </q-tooltip>
  62. </button>
  63. <button v-show="showToolButton['refresh']" ref="refresh" v-ripple class="tool-button" :class="buttonActiveClass('refresh')" @click="buttonClick('refresh')">
  64. <q-icon name="la la-sync" size="32px" :class="{clear: !showRefreshIcon}" />
  65. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  66. {{ rstore.readerActions['refresh'] }}
  67. </q-tooltip>
  68. </button>
  69. <div class="space"></div>
  70. <button v-show="showToolButton['contents']" ref="contents" v-ripple class="tool-button" :class="buttonActiveClass('contents')" @click="buttonClick('contents')">
  71. <q-icon name="la la-list" size="32px" />
  72. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  73. {{ rstore.readerActions['contents'] }}
  74. </q-tooltip>
  75. </button>
  76. <button v-show="mode == 'liberama.top' && showToolButton['libs']" ref="libs" v-ripple class="tool-button" :class="buttonActiveClass('libs')" @click="buttonClick('libs')">
  77. <q-icon name="la la-sitemap" size="32px" />
  78. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  79. {{ rstore.readerActions['libs'] }}
  80. </q-tooltip>
  81. </button>
  82. <button v-show="showToolButton['recentBooks']" ref="recentBooks" v-ripple class="tool-button" :class="buttonActiveClass('recentBooks')" @click="buttonClick('recentBooks')">
  83. <q-icon name="la la-book-open" size="32px" />
  84. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  85. {{ rstore.readerActions['recentBooks'] }}
  86. </q-tooltip>
  87. </button>
  88. </div>
  89. <div>
  90. <button v-show="showToolButton['offlineMode']" ref="offlineMode" v-ripple class="tool-button" :class="buttonActiveClass('offlineMode')" @click="buttonClick('offlineMode')">
  91. <q-icon name="la la-unlink" size="32px" />
  92. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  93. {{ rstore.readerActions['offlineMode'] }}
  94. </q-tooltip>
  95. </button>
  96. <button ref="settings" v-ripple class="tool-button" :class="buttonActiveClass('settings')" @click="buttonClick('settings')">
  97. <q-icon name="la la-cog" size="32px" />
  98. <q-tooltip :delay="1500" anchor="bottom left" content-style="font-size: 80%">
  99. {{ rstore.readerActions['settings'] }}
  100. </q-tooltip>
  101. </button>
  102. </div>
  103. </div>
  104. </div>
  105. <div class="main col row relative-position">
  106. <keep-alive>
  107. <component :is="activePage" ref="page" class="col"
  108. @load-book="loadBook"
  109. @load-file="loadFile"
  110. @book-pos-changed="bookPosChanged"
  111. @do-action="doAction"
  112. ></component>
  113. </keep-alive>
  114. <!--SetPositionPage v-if="setPositionActive" ref="setPositionPage" @set-position-toggle="setPositionToggle" @book-pos-changed="bookPosChanged"></SetPositionPage>
  115. <SearchPage v-show="searchActive" ref="searchPage"
  116. @do-action="doAction"
  117. @book-pos-changed="bookPosChanged"
  118. @start-text-search="startTextSearch"
  119. @stop-text-search="stopTextSearch"
  120. ></SearchPage>
  121. <CopyTextPage v-if="copyTextActive" ref="copyTextPage" @do-action="doAction"></CopyTextPage>
  122. <LibsPage v-show="hidden" ref="libsPage" @load-book="loadBook" @libs-close="libsClose" @do-action="doAction"></LibsPage>
  123. <RecentBooksPage v-show="recentBooksActive" ref="recentBooksPage" @load-book="loadBook" @recent-books-close="recentBooksClose"></RecentBooksPage>
  124. <SettingsPage v-show="settingsActive" ref="settingsPage" @do-action="doAction"></SettingsPage>
  125. <HelpPage v-if="helpActive" ref="helpPage" @do-action="doAction"></HelpPage>
  126. <ClickMapPage v-show="clickMapActive" ref="clickMapPage"></ClickMapPage>
  127. <ServerStorage v-show="hidden" ref="serverStorage"></ServerStorage>
  128. <ContentsPage v-show="contentsActive" ref="contentsPage" :book-pos="bookPos" :is-visible="contentsActive" @do-action="doAction" @book-pos-changed="bookPosChanged"></ContentsPage-->
  129. <ReaderDialogs ref="dialogs" @donate-toggle="donateToggle" @version-history-toggle="versionHistoryToggle"></ReaderDialogs>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. //-----------------------------------------------------------------------------
  135. import vueComponent from '../vueComponent.js';
  136. import _ from 'lodash';
  137. import {Buffer} from 'safe-buffer';
  138. import LoaderPage from './LoaderPage/LoaderPage.vue';
  139. import TextPage from './TextPage/TextPage.vue';
  140. import ProgressPage from './ProgressPage/ProgressPage.vue';
  141. /*import SetPositionPage from './SetPositionPage/SetPositionPage.vue';
  142. import SearchPage from './SearchPage/SearchPage.vue';
  143. import CopyTextPage from './CopyTextPage/CopyTextPage.vue';
  144. import LibsPage from './LibsPage/LibsPage.vue';
  145. import RecentBooksPage from './RecentBooksPage/RecentBooksPage.vue';
  146. import SettingsPage from './SettingsPage/SettingsPage.vue';
  147. import HelpPage from './HelpPage/HelpPage.vue';
  148. import ClickMapPage from './ClickMapPage/ClickMapPage.vue';
  149. import ServerStorage from './ServerStorage/ServerStorage.vue';
  150. import ContentsPage from './ContentsPage/ContentsPage.vue';*/
  151. import ReaderDialogs from './ReaderDialogs/ReaderDialogs.vue';
  152. import bookManager from './share/bookManager';
  153. import wallpaperStorage from './share/wallpaperStorage';
  154. import dynamicCss from '../../share/dynamicCss';
  155. import rstore from '../../store/modules/reader';
  156. import readerApi from '../../api/reader';
  157. import miscApi from '../../api/misc';
  158. import {versionHistory} from './versionHistory';
  159. import * as utils from '../../share/utils';
  160. const componentOptions = {
  161. components: {
  162. LoaderPage,
  163. TextPage,
  164. ProgressPage,
  165. /*SetPositionPage,
  166. SearchPage,
  167. CopyTextPage,
  168. LibsPage,
  169. RecentBooksPage,
  170. SettingsPage,
  171. HelpPage,
  172. ClickMapPage,
  173. ServerStorage,
  174. ContentsPage,*/
  175. ReaderDialogs,
  176. },
  177. watch: {
  178. bookPos: function(newValue) {
  179. if (newValue !== undefined && this.activePage == 'TextPage') {
  180. const textPage = this.$refs.page;
  181. if (textPage.bookPos != newValue) {
  182. textPage.bookPos = newValue;
  183. }
  184. if (!this.scrollingActive)
  185. this.debouncedSetRecentBook(newValue);
  186. else
  187. this.scrollingSetRecentBook(newValue);
  188. }
  189. },
  190. routeParamPos: function(newValue) {
  191. if (!this.paramPosIgnore && newValue !== undefined && newValue != this.bookPos) {
  192. this.bookPos = newValue;
  193. }
  194. },
  195. routeParamUrl: function(newValue) {
  196. if (newValue !== '' && newValue !== this.mostRecentBook().url) {
  197. this.loadBook({url: newValue, bookPos: this.routeParamPos});
  198. }
  199. },
  200. settings: function() {
  201. this.loadSettings();
  202. this.updateRoute();
  203. },
  204. loaderActive: function(newValue) {
  205. (async() => {
  206. const recent = this.mostRecentBook();
  207. if (!newValue && !this.loading && recent && !await bookManager.hasBookParsed(recent)) {
  208. this.loadBook(recent);
  209. }
  210. })();
  211. },
  212. dualPageMode(newValue) {
  213. if (newValue)
  214. this.stopScrolling();
  215. },
  216. },
  217. };
  218. class Reader {
  219. _options = componentOptions;
  220. rstore = {};
  221. loaderActive = false;
  222. offlineModeActive = false;
  223. progressActive = false;
  224. fullScreenActive = false;
  225. scrollingActive = false;
  226. setPositionActive = false;
  227. searchActive = false;
  228. copyTextActive = false;
  229. libsActive = false;
  230. recentBooksActive = false;
  231. settingsActive = false;
  232. helpActive = false;
  233. clickMapActive = false;
  234. contentsActive = false;
  235. bookPos = null;
  236. allowUrlParamBookPos = false;
  237. showRefreshIcon = true;
  238. mostRecentBookReactive = null;
  239. showToolButton = {};
  240. actionList = [];
  241. actionCur = -1;
  242. hidden = false;
  243. whatsNewVisible = false;
  244. whatsNewContent = '';
  245. donationVisible = false;
  246. dualPageMode = false;
  247. created() {
  248. this.rstore = rstore;
  249. this.loading = true;
  250. this.commit = this.$store.commit;
  251. this.reader = this.$store.state.reader;
  252. this.config = this.$store.state.config;
  253. this.$root.addKeyHook(this.keyHook);
  254. this.lastActivePage = false;
  255. this.debouncedSetRecentBook = _.debounce(async(newValue) => {
  256. const recent = this.mostRecentBook();
  257. if (recent && (recent.bookPos != newValue || recent.bookPosSeen !== this.bookPosSeen)) {
  258. await bookManager.setRecentBook(Object.assign({}, recent, {bookPos: newValue, bookPosSeen: this.bookPosSeen}));
  259. if (this.actionCur < 0 || (this.actionCur >= 0 && this.actionList[this.actionCur] != newValue))
  260. this.addAction(newValue);
  261. this.paramPosIgnore = true;
  262. this.updateRoute();
  263. await this.$nextTick();
  264. this.paramPosIgnore = false;
  265. }
  266. }, 500, {maxWait: 5000});
  267. this.scrollingSetRecentBook = _.debounce((newValue) => {
  268. this.debouncedSetRecentBook(newValue);
  269. }, 15000, {maxWait: 20000});
  270. document.addEventListener('fullscreenchange', () => {
  271. this.fullScreenActive = (document.fullscreenElement !== null);
  272. });
  273. this.loadSettings();
  274. }
  275. mounted() {
  276. this.updateHeaderMinWidth();
  277. (async() => {
  278. await wallpaperStorage.init();
  279. await bookManager.init(this.settings);
  280. bookManager.addEventListener(this.bookManagerEvent);
  281. if (this.$root.getRootRoute() == '/reader') {
  282. if (this.routeParamUrl) {
  283. await this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos, force: this.routeParamRefresh});
  284. } else {
  285. this.loaderActive = true;
  286. }
  287. }
  288. await this.$refs.serverStorage.init();
  289. this.checkSetStorageAccessKey();
  290. this.checkActivateDonateHelpPage();
  291. this.loading = false;
  292. //проверим состояние Settings, и обновим, если надо
  293. const newSettings = rstore.addDefaultsToSettings(this.settings);
  294. if (newSettings) {
  295. this.commit('reader/setSettings', newSettings);
  296. }
  297. this.updateRoute();
  298. await this.$refs.dialogs.init();
  299. })();
  300. (async() => {
  301. this.isFirstNeedUpdateNotify = true;
  302. //вечный цикл, запрашиваем периодически конфиг для проверки выхода новой версии читалки
  303. while (true) {// eslint-disable-line no-constant-condition
  304. await this.checkNewVersionAvailable();
  305. await utils.sleep(3600*1000); //каждый час
  306. }
  307. //дальше кода нет
  308. })();
  309. }
  310. loadSettings() {
  311. const settings = this.settings;
  312. this.allowUrlParamBookPos = settings.allowUrlParamBookPos;
  313. this.copyFullText = settings.copyFullText;
  314. this.showClickMapPage = settings.showClickMapPage;
  315. this.clickControl = settings.clickControl;
  316. this.blinkCachedLoad = settings.blinkCachedLoad;
  317. this.showToolButton = settings.showToolButton;
  318. this.enableSitesFilter = settings.enableSitesFilter;
  319. this.showNeedUpdateNotify = settings.showNeedUpdateNotify;
  320. this.splitToPara = settings.splitToPara;
  321. this.djvuQuality = settings.djvuQuality;
  322. this.pdfAsText = settings.pdfAsText;
  323. this.pdfQuality = settings.pdfQuality;
  324. this.dualPageMode = settings.dualPageMode;
  325. this.userWallpapers = settings.userWallpapers;
  326. this.readerActionByKeyCode = utils.userHotKeysObjectSwap(settings.userHotKeys);
  327. this.$root.readerActionByKeyEvent = (event) => {
  328. return this.readerActionByKeyCode[utils.keyEventToCode(event)];
  329. }
  330. this.updateHeaderMinWidth();
  331. this.loadWallpapers();//no await
  332. }
  333. //wallpaper css
  334. async loadWallpapers() {
  335. const wallpaperDataLength = await wallpaperStorage.getLength();
  336. if (wallpaperDataLength !== this.wallpaperDataLength) {//оптимизация
  337. this.wallpaperDataLength = wallpaperDataLength;
  338. let newCss = '';
  339. for (const wp of this.userWallpapers) {
  340. const data = await wallpaperStorage.getData(wp.cssClass);
  341. if (!data) {
  342. //здесь будем восстанавливать данные с сервера
  343. }
  344. if (data) {
  345. newCss += `.${wp.cssClass} {background: url(${data}) center; background-size: 100% 100%;}`;
  346. }
  347. }
  348. dynamicCss.replace('wallpapers', newCss);
  349. }
  350. }
  351. async checkNewVersionAvailable() {
  352. if (!this.checkingNewVersion && this.showNeedUpdateNotify) {
  353. this.checkingNewVersion = true;
  354. try {
  355. await utils.sleep(15*1000); //подождем 15 секунд, чтобы прогрузился ServiceWorker при выходе новой версии
  356. const config = await miscApi.loadConfig();
  357. this.commit('config/setConfig', config);
  358. let againMes = '';
  359. if (this.isFirstNeedUpdateNotify) {
  360. againMes = ' еще один раз';
  361. }
  362. if (this.version != this.clientVersion)
  363. this.$root.notify.info(`Вышла новая версия (v${this.version}) читалки.<br>Пожалуйста, обновите страницу${againMes}.`, 'Обновление');
  364. } catch(e) {
  365. console.error(e);
  366. } finally {
  367. this.checkingNewVersion = false;
  368. }
  369. this.isFirstNeedUpdateNotify = false;
  370. }
  371. }
  372. updateHeaderMinWidth() {
  373. const showButtonCount = Object.values(this.showToolButton).reduce((a, b) => a + (b ? 1 : 0), 0);
  374. if (this.$refs.buttons)
  375. this.$refs.buttons.style.minWidth = 65*showButtonCount + 'px';
  376. (async() => {
  377. await utils.sleep(1000);
  378. if (this.$refs.header)
  379. this.$refs.header.style.overflowX = 'auto';
  380. })();
  381. }
  382. checkSetStorageAccessKey() {
  383. const q = this.$route.query;
  384. if (q['setStorageAccessKey']) {
  385. this.$router.replace(`/reader`);
  386. this.settingsToggle();
  387. this.$nextTick(() => {
  388. this.$refs.settingsPage.enterServerStorageKey(
  389. Buffer.from(utils.fromBase58(q['setStorageAccessKey'])).toString()
  390. );
  391. });
  392. }
  393. }
  394. checkActivateDonateHelpPage() {
  395. const q = this.$route.query;
  396. if (q['donate']) {
  397. this.$router.replace(`/reader`);
  398. this.helpToggle();
  399. this.$nextTick(() => {
  400. this.$refs.helpPage.activateDonateHelpPage();
  401. });
  402. }
  403. }
  404. checkBookPosPercent() {
  405. const q = this.$route.query;
  406. if (q['__pp']) {
  407. let pp = q['__pp'];
  408. if (pp) {
  409. pp = parseFloat(pp) || 0;
  410. const recent = this.mostRecentBook();
  411. (async() => {
  412. await utils.sleep(100);
  413. this.bookPos = Math.floor(recent.textLength*pp/100);
  414. })();
  415. }
  416. }
  417. }
  418. get routeParamPos() {
  419. let result = undefined;
  420. const q = this.$route.query;
  421. if (q['__p']) {
  422. result = q['__p'];
  423. if (Array.isArray(result))
  424. result = result[0];
  425. }
  426. return (result ? parseInt(result, 10) || 0 : result);
  427. }
  428. updateRoute(isNewRoute) {
  429. if (this.loading)
  430. return;
  431. const recent = this.mostRecentBook();
  432. const pos = (recent && recent.bookPos && this.allowUrlParamBookPos ? `__p=${recent.bookPos}&` : '');
  433. const url = (recent ? `url=${recent.url}` : '');
  434. if (isNewRoute)
  435. this.$router.push(`/reader?${pos}${url}`).catch(() => {});
  436. else
  437. this.$router.replace(`/reader?${pos}${url}`).catch(() => {});
  438. }
  439. get mode() {
  440. return this.$store.state.config.mode;
  441. }
  442. get version() {
  443. return this.$store.state.config.version;
  444. }
  445. get clientVersion() {
  446. let v = versionHistory[0].header;
  447. v = v.split(' ')[0];
  448. return v;
  449. }
  450. get routeParamUrl() {
  451. let result = '';
  452. const path = this.$route.fullPath;
  453. const i = path.indexOf('url=');
  454. if (i >= 0) {
  455. result = path.substr(i + 4);
  456. }
  457. return decodeURIComponent(result);
  458. }
  459. get routeParamRefresh() {
  460. const q = this.$route.query;
  461. return !!q['__refresh'];
  462. }
  463. bookPosChanged(event) {
  464. if (event.bookPosSeen !== undefined)
  465. this.bookPosSeen = event.bookPosSeen;
  466. this.bookPos = event.bookPos;
  467. }
  468. async bookManagerEvent(eventName, value) {
  469. if (eventName == 'set-recent' || eventName == 'recent-deleted') {
  470. const oldBook = (this.textPage ? this.textPage.lastBook : null);
  471. const oldPos = (this.textPage ? this.textPage.bookPos : null);
  472. const newBook = bookManager.mostRecentBook();
  473. if (!(oldBook && newBook && oldBook.key == newBook.key)) {
  474. this.mostRecentBook();
  475. }
  476. if (oldBook && newBook) {
  477. if (oldBook.key != newBook.key || oldBook.path != newBook.path) {
  478. this.loadingBook = true;
  479. try {
  480. await this.loadBook(newBook);
  481. } finally {
  482. this.loadingBook = false;
  483. }
  484. } else if (oldPos != newBook.bookPos) {
  485. while (this.loadingBook) await utils.sleep(100);
  486. this.bookPosChanged({bookPos: newBook.bookPos});
  487. }
  488. }
  489. }
  490. if (eventName == 'recent-changed') {
  491. if (this.recentBooksActive) {
  492. await this.$refs.recentBooksPage.updateTableData();
  493. }
  494. //сохранение в serverStorage
  495. if (value) {
  496. await utils.sleep(500);
  497. await this.$refs.serverStorage.saveRecent(value);
  498. }
  499. }
  500. }
  501. get toolBarActive() {
  502. return this.reader.toolBarActive;
  503. }
  504. mostRecentBook() {
  505. const result = bookManager.mostRecentBook();
  506. this.mostRecentBookReactive = result;
  507. return result;
  508. }
  509. get settings() {
  510. return this.$store.state.reader.settings;
  511. }
  512. addAction(pos) {
  513. let a = this.actionList;
  514. if (!a.length || a[a.length - 1] != pos) {
  515. a.push(pos);
  516. if (a.length > 20)
  517. a.shift();
  518. this.actionCur = a.length - 1;
  519. }
  520. }
  521. toolBarToggle() {
  522. this.commit('reader/setToolBarActive', !this.toolBarActive);
  523. this.$root.$emit('resize');
  524. }
  525. fullScreenToggle() {
  526. this.fullScreenActive = !this.fullScreenActive;
  527. if (this.fullScreenActive) {
  528. this.$q.fullscreen.request();
  529. } else {
  530. this.$q.fullscreen.exit();
  531. }
  532. }
  533. closeAllWindows() {
  534. this.setPositionActive = false;
  535. this.copyTextActive = false;
  536. this.recentBooksActive = false;
  537. this.settingsActive = false;
  538. this.stopScrolling();
  539. this.stopSearch();
  540. this.helpActive = false;
  541. this.contentsActive = false;
  542. }
  543. loaderToggle() {
  544. this.loaderActive = !this.loaderActive;
  545. if (this.loaderActive) {
  546. this.closeAllWindows();
  547. }
  548. }
  549. setPositionToggle() {
  550. this.setPositionActive = !this.setPositionActive;
  551. const page = this.$refs.page;
  552. if (this.setPositionActive && this.activePage == 'TextPage' && page.parsed) {
  553. this.closeAllWindows();
  554. this.setPositionActive = true;
  555. this.$nextTick(() => {
  556. const recent = this.mostRecentBook();
  557. this.$refs.setPositionPage.init(recent.bookPos, recent.textLength - 1);
  558. });
  559. } else {
  560. this.setPositionActive = false;
  561. }
  562. }
  563. stopScrolling() {
  564. if (this.scrollingActive)
  565. this.scrollingToggle();
  566. }
  567. scrollingToggle() {
  568. this.scrollingActive = !this.scrollingActive;
  569. if (this.activePage == 'TextPage') {
  570. const page = this.$refs.page;
  571. if (this.scrollingActive) {
  572. page.startTextScrolling();
  573. } else {
  574. page.stopTextScrolling();
  575. }
  576. }
  577. if (!this.scrollingActive) {
  578. this.scrollingSetRecentBook.flush();
  579. }
  580. }
  581. stopSearch() {
  582. if (this.searchActive)
  583. this.searchToggle();
  584. }
  585. startTextSearch(opts) {
  586. if (this.activePage == 'TextPage')
  587. this.$refs.page.startSearch(opts.needle);
  588. }
  589. stopTextSearch() {
  590. if (this.activePage == 'TextPage')
  591. this.$refs.page.stopSearch();
  592. }
  593. searchToggle() {
  594. this.searchActive = !this.searchActive;
  595. const page = this.$refs.page;
  596. if (this.searchActive && this.activePage == 'TextPage' && page.parsed) {
  597. this.closeAllWindows();
  598. this.searchActive = true;
  599. this.$nextTick(() => {
  600. this.$refs.searchPage.init(page.parsed);
  601. });
  602. } else {
  603. this.stopTextSearch();
  604. this.searchActive = false;
  605. }
  606. }
  607. copyTextToggle() {
  608. this.copyTextActive = !this.copyTextActive;
  609. const page = this.$refs.page;
  610. if (this.copyTextActive && this.activePage == 'TextPage' && page.parsed) {
  611. this.closeAllWindows();
  612. this.copyTextActive = true;
  613. this.$nextTick(() => {
  614. this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed, this.copyFullText);
  615. });
  616. } else {
  617. this.copyTextActive = false;
  618. }
  619. }
  620. recentBooksClose() {
  621. this.recentBooksActive = false;
  622. }
  623. recentBooksToggle() {
  624. this.recentBooksActive = !this.recentBooksActive;
  625. if (this.recentBooksActive) {
  626. this.closeAllWindows();
  627. this.$refs.recentBooksPage.init();
  628. this.recentBooksActive = true;
  629. } else {
  630. this.recentBooksActive = false;
  631. }
  632. }
  633. contentsPageToggle() {
  634. this.contentsActive = !this.contentsActive;
  635. const page = this.$refs.page;
  636. if (this.contentsActive && this.activePage == 'TextPage' && page.parsed) {
  637. this.closeAllWindows();
  638. this.contentsActive = true;
  639. this.$nextTick(() => {
  640. this.$refs.contentsPage.init(this.mostRecentBook(), page.parsed);
  641. });
  642. } else {
  643. this.contentsActive = false;
  644. }
  645. }
  646. libsClose() {
  647. if (this.libsActive)
  648. this.libsToogle();
  649. }
  650. libsToogle() {
  651. this.libsActive = !this.libsActive;
  652. if (this.libsActive) {
  653. this.$refs.libsPage.init();
  654. } else {
  655. this.$refs.libsPage.done();
  656. }
  657. }
  658. offlineModeToggle() {
  659. this.offlineModeActive = !this.offlineModeActive;
  660. this.$refs.serverStorage.offlineModeActive = this.offlineModeActive;
  661. }
  662. settingsToggle() {
  663. this.settingsActive = !this.settingsActive;
  664. if (this.settingsActive) {
  665. this.closeAllWindows();
  666. this.settingsActive = true;
  667. this.$nextTick(() => {
  668. this.$refs.settingsPage.init();
  669. });
  670. } else {
  671. this.settingsActive = false;
  672. }
  673. }
  674. convOptionsToggle() {
  675. this.settingsToggle();
  676. if (this.settingsActive)
  677. this.$refs.settingsPage.selectedTab = 'convert';
  678. }
  679. helpToggle() {
  680. this.helpActive = !this.helpActive;
  681. if (this.helpActive) {
  682. this.closeAllWindows();
  683. this.helpActive = true;
  684. }
  685. }
  686. donateToggle() {
  687. this.helpToggle();
  688. if (this.helpActive) {
  689. this.$nextTick(() => {
  690. this.$refs.helpPage.activateDonateHelpPage();
  691. });
  692. }
  693. }
  694. versionHistoryToggle() {
  695. this.helpToggle();
  696. if (this.helpActive) {
  697. this.$nextTick(() => {
  698. this.$refs.helpPage.activateVersionHistoryHelpPage();
  699. });
  700. }
  701. }
  702. refreshBook() {
  703. const mrb = this.mostRecentBook();
  704. this.loadBook({url: mrb.url, uploadFileName: mrb.uploadFileName, force: true});
  705. }
  706. undoAction() {
  707. if (this.actionCur > 0) {
  708. this.actionCur--;
  709. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  710. }
  711. }
  712. redoAction() {
  713. if (this.actionCur < this.actionList.length - 1) {
  714. this.actionCur++;
  715. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  716. }
  717. }
  718. buttonClick(action) {
  719. const activeClass = this.buttonActiveClass(action);
  720. this.$refs[action].blur();
  721. if (activeClass['tool-button-disabled'])
  722. return;
  723. this.doAction({action});
  724. }
  725. buttonActiveClass(action) {
  726. const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
  727. const classDisabled = { 'tool-button-disabled': true, 'tool-button-disabled:hover': true };
  728. let classResult = {};
  729. switch (action) {
  730. case 'loader':
  731. case 'fullScreen':
  732. case 'setPosition':
  733. case 'search':
  734. case 'copyText':
  735. case 'convOptions':
  736. case 'refresh':
  737. case 'contents':
  738. case 'libs':
  739. case 'recentBooks':
  740. case 'offlineMode':
  741. case 'settings':
  742. if (this.progressActive) {
  743. classResult = classDisabled;
  744. } else if (this[`${action}Active`]) {
  745. classResult = classActive;
  746. }
  747. break;
  748. case 'scrolling':
  749. if (this.progressActive || this.dualPageMode) {
  750. classResult = classDisabled;
  751. } else if (this[`${action}Active`]) {
  752. classResult = classActive;
  753. }
  754. break;
  755. case 'undoAction':
  756. if (this.actionCur <= 0)
  757. classResult = classDisabled;
  758. break;
  759. case 'redoAction':
  760. if (this.actionCur == this.actionList.length - 1)
  761. classResult = classDisabled;
  762. break;
  763. }
  764. if (this.activePage == 'LoaderPage' || !this.mostRecentBookReactive) {
  765. switch (action) {
  766. case 'undoAction':
  767. case 'redoAction':
  768. case 'setPosition':
  769. case 'scrolling':
  770. case 'search':
  771. case 'copyText':
  772. case 'contents':
  773. classResult = classDisabled;
  774. break;
  775. case 'refresh':
  776. case 'recentBooks':
  777. if (!this.mostRecentBookReactive)
  778. classResult = classDisabled;
  779. break;
  780. }
  781. }
  782. return classResult;
  783. }
  784. async activateClickMapPage() {
  785. if (this.clickControl && this.showClickMapPage && !this.clickMapActive) {
  786. this.clickMapActive = true;
  787. await this.$refs.clickMapPage.slowDisappear();
  788. this.clickMapActive = false;
  789. }
  790. }
  791. get activePage() {
  792. let result = '';
  793. if (this.progressActive)
  794. result = 'ProgressPage';
  795. else if (this.loaderActive)
  796. result = 'LoaderPage';
  797. else if (this.mostRecentBookReactive)
  798. result = 'TextPage';
  799. if (!result && !this.loading) {
  800. this.loaderActive = true;
  801. result = 'LoaderPage';
  802. }
  803. if (result != 'TextPage') {
  804. this.$root.setAppTitle();
  805. }
  806. // на LoaderPage всегда показываем toolBar
  807. if (result == 'LoaderPage' && !this.toolBarActive) {
  808. this.toolBarToggle();
  809. }
  810. if (this.lastActivePage != result && result == 'TextPage') {
  811. //акивируем страницу с текстом
  812. this.$nextTick(async() => {
  813. const last = this.mostRecentBookReactive;
  814. const isParsed = await bookManager.hasBookParsed(last);
  815. if (!isParsed) {
  816. this.$root.setAppTitle();
  817. return;
  818. }
  819. this.updateRoute();
  820. const textPage = this.$refs.page;
  821. if (textPage.showBook) {
  822. this.textPage = textPage;
  823. textPage.lastBook = last;
  824. textPage.bookPos = (last.bookPos !== undefined ? last.bookPos : 0);
  825. textPage.showBook();
  826. }
  827. });
  828. }
  829. this.lastActivePage = result;
  830. return result;
  831. }
  832. async loadBook(opts) {
  833. if (!opts || !opts.url) {
  834. this.mostRecentBook();
  835. return;
  836. }
  837. this.closeAllWindows();
  838. let url = encodeURI(decodeURI(opts.url));
  839. //TODO: убрать конвертирование 'file://' после 06.2021
  840. if (url.length == 71 && url.indexOf('file://') == 0)
  841. url = url.replace(/^file/, 'disk');
  842. if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0) &&
  843. (url.indexOf('disk://') != 0))
  844. url = 'http://' + url;
  845. // уже просматривается сейчас
  846. const lastBook = (this.textPage ? this.textPage.lastBook : null);
  847. if (!opts.force && lastBook && lastBook.url == url &&
  848. (!opts.path || opts.path == lastBook.path) &&
  849. await bookManager.hasBookParsed(lastBook)) {
  850. this.loaderActive = false;
  851. return;
  852. }
  853. this.progressActive = true;
  854. await this.$nextTick();
  855. const progress = this.$refs.page;
  856. this.actionList = [];
  857. this.actionCur = -1;
  858. try {
  859. progress.show();
  860. progress.setState({state: 'parse'});
  861. // есть ли среди недавних
  862. const key = bookManager.keyFromUrl(url);
  863. let wasOpened = await bookManager.getRecentBook({key});
  864. wasOpened = (wasOpened ? wasOpened : {});
  865. const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
  866. const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
  867. const uploadFileName = (opts.uploadFileName ? opts.uploadFileName : '');
  868. let book = null;
  869. if (!opts.force) {
  870. // пытаемся загрузить и распарсить книгу в менеджере из локального кэша
  871. const bookParsed = await bookManager.getBook({url, path: opts.path}, (prog) => {
  872. progress.setState({progress: prog});
  873. });
  874. // если есть в локальном кэше
  875. if (bookParsed) {
  876. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookParsed));
  877. this.mostRecentBook();
  878. this.addAction(bookPos);
  879. this.loaderActive = false;
  880. progress.hide(); this.progressActive = false;
  881. this.blinkCachedLoadMessage();
  882. this.checkBookPosPercent();
  883. await this.activateClickMapPage();
  884. return;
  885. }
  886. // иначе идем на сервер
  887. // пытаемся загрузить готовый файл с сервера
  888. if (wasOpened.path) {
  889. progress.setState({totalSteps: 5});
  890. try {
  891. const resp = await readerApi.loadCachedBook(wasOpened.path, (state) => {
  892. progress.setState(state);
  893. });
  894. book = Object.assign({}, wasOpened, {data: resp.data});
  895. } catch (e) {
  896. //молчим
  897. }
  898. }
  899. }
  900. progress.setState({totalSteps: 5});
  901. // не удалось, скачиваем книгу полностью с конвертацией
  902. let loadCached = true;
  903. if (!book) {
  904. book = await readerApi.loadBook({
  905. url,
  906. uploadFileName,
  907. enableSitesFilter: this.enableSitesFilter,
  908. skipHtmlCheck: (this.splitToPara ? true : false),
  909. isText: (this.splitToPara ? true : false),
  910. djvuQuality: this.djvuQuality,
  911. pdfAsText: this.pdfAsText,
  912. pdfQuality: this.pdfQuality,
  913. },
  914. (state) => {
  915. progress.setState(state);
  916. }
  917. );
  918. loadCached = false;
  919. }
  920. // добавляем в bookManager
  921. progress.setState({state: 'parse', step: 5});
  922. const addedBook = await bookManager.addBook(book, (prog) => {
  923. progress.setState({progress: prog});
  924. });
  925. // добавляем в историю
  926. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen, uploadFileName}, addedBook));
  927. this.mostRecentBook();
  928. this.addAction(bookPos);
  929. this.updateRoute(true);
  930. this.loaderActive = false;
  931. progress.hide(); this.progressActive = false;
  932. if (loadCached) {
  933. this.blinkCachedLoadMessage();
  934. } else
  935. this.stopBlink = true;
  936. this.checkBookPosPercent();
  937. await this.activateClickMapPage();
  938. } catch (e) {
  939. progress.hide(); this.progressActive = false;
  940. this.loaderActive = true;
  941. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  942. } finally {
  943. this.checkNewVersionAvailable();
  944. }
  945. }
  946. async loadFile(opts) {
  947. this.progressActive = true;
  948. await this.$nextTick();
  949. const progress = this.$refs.page;
  950. try {
  951. progress.show();
  952. progress.setState({state: 'upload'});
  953. const url = await readerApi.uploadFile(opts.file, this.config.maxUploadFileSize, (state) => {
  954. progress.setState(state);
  955. });
  956. progress.hide(); this.progressActive = false;
  957. await this.loadBook({url, uploadFileName: opts.file.name, force: true});
  958. } catch (e) {
  959. progress.hide(); this.progressActive = false;
  960. this.loaderActive = true;
  961. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  962. }
  963. }
  964. blinkCachedLoadMessage() {
  965. if (!this.blinkCachedLoad)
  966. return;
  967. this.blinkCount = 30;
  968. if (!this.inBlink) {
  969. this.inBlink = true;
  970. this.stopBlink = false;
  971. this.$nextTick(async() => {
  972. let page = this.$refs.page;
  973. while (this.blinkCount) {
  974. this.showRefreshIcon = !this.showRefreshIcon;
  975. if (page && page.blinkCachedLoadMessage)
  976. page.blinkCachedLoadMessage(this.showRefreshIcon);
  977. await utils.sleep(500);
  978. if (this.stopBlink)
  979. break;
  980. this.blinkCount--;
  981. page = this.$refs.page;
  982. }
  983. this.showRefreshIcon = true;
  984. this.inBlink = false;
  985. if (page && page.blinkCachedLoadMessage)
  986. page.blinkCachedLoadMessage('finish');
  987. });
  988. }
  989. }
  990. doAction(opts) {
  991. let result = true;
  992. let {action = '', event = false} = opts;
  993. switch (action) {
  994. case 'loader':
  995. this.loaderToggle();
  996. break;
  997. case 'help':
  998. this.helpToggle();
  999. break;
  1000. case 'undoAction':
  1001. this.undoAction();
  1002. break;
  1003. case 'redoAction':
  1004. this.redoAction();
  1005. break;
  1006. case 'fullScreen':
  1007. this.fullScreenToggle();
  1008. break;
  1009. case 'scrolling':
  1010. this.scrollingToggle();
  1011. break;
  1012. case 'stopScrolling':
  1013. this.stopScrolling();
  1014. break;
  1015. case 'setPosition':
  1016. this.setPositionToggle();
  1017. break;
  1018. case 'search':
  1019. this.searchToggle();
  1020. break;
  1021. case 'copyText':
  1022. this.copyTextToggle();
  1023. break;
  1024. case 'convOptions':
  1025. this.convOptionsToggle();
  1026. break;
  1027. case 'refresh':
  1028. this.refreshBook();
  1029. break;
  1030. case 'contents':
  1031. this.contentsPageToggle();
  1032. break;
  1033. case 'libs':
  1034. this.libsToogle();
  1035. break;
  1036. case 'recentBooks':
  1037. this.recentBooksToggle();
  1038. break;
  1039. case 'offlineMode':
  1040. this.offlineModeToggle();
  1041. break;
  1042. case 'settings':
  1043. this.settingsToggle();
  1044. break;
  1045. case 'switchToolbar':
  1046. this.toolBarToggle();
  1047. break;
  1048. case 'donate':
  1049. this.donateToggle();
  1050. break;
  1051. default:
  1052. result = false;
  1053. break;
  1054. }
  1055. if (!result && this.activePage == 'TextPage' && this.$refs.page) {
  1056. result = true;
  1057. const textPage = this.$refs.page;
  1058. switch (action) {
  1059. case 'bookBegin':
  1060. textPage.doHome();
  1061. break;
  1062. case 'bookEnd':
  1063. textPage.doEnd();
  1064. break;
  1065. case 'pageBack':
  1066. textPage.doPageUp();
  1067. break;
  1068. case 'pageForward':
  1069. textPage.doPageDown();
  1070. break;
  1071. case 'lineBack':
  1072. textPage.doUp();
  1073. break;
  1074. case 'lineForward':
  1075. textPage.doDown();
  1076. break;
  1077. case 'incFontSize':
  1078. textPage.doFontSizeInc();
  1079. break;
  1080. case 'decFontSize':
  1081. textPage.doFontSizeDec();
  1082. break;
  1083. case 'scrollingSpeedUp':
  1084. textPage.doScrollingSpeedUp();
  1085. break;
  1086. case 'scrollingSpeedDown':
  1087. textPage.doScrollingSpeedDown();
  1088. break;
  1089. default:
  1090. result = false;
  1091. break;
  1092. }
  1093. }
  1094. if (result && event) {
  1095. event.preventDefault();
  1096. event.stopPropagation();
  1097. }
  1098. return result;
  1099. }
  1100. keyHook(event) {
  1101. let result = false;
  1102. if (this.$root.getRootRoute() == '/reader') {
  1103. if (this.$root.stdDialog.active)
  1104. return result;
  1105. if (!result)
  1106. result = this.$refs.dialogs.keyHook(event);
  1107. if (!result && this.helpActive)
  1108. result = this.$refs.helpPage.keyHook(event);
  1109. if (!result && this.settingsActive)
  1110. result = this.$refs.settingsPage.keyHook(event);
  1111. if (!result && this.recentBooksActive)
  1112. result = this.$refs.recentBooksPage.keyHook(event);
  1113. if (!result && this.setPositionActive)
  1114. result = this.$refs.setPositionPage.keyHook(event);
  1115. if (!result && this.searchActive)
  1116. result = this.$refs.searchPage.keyHook(event);
  1117. if (!result && this.copyTextActive)
  1118. result = this.$refs.copyTextPage.keyHook(event);
  1119. if (!result && this.contentsActive)
  1120. result = this.$refs.contentsPage.keyHook(event);
  1121. if (!result && this.$refs.page && this.$refs.page.keyHook)
  1122. result = this.$refs.page.keyHook(event);
  1123. if (!result && event.type == 'keydown') {
  1124. const action = this.$root.readerActionByKeyEvent(event);
  1125. if (action == 'loader') {
  1126. result = this.doAction({action, event});
  1127. }
  1128. if (!result && this.activePage == 'TextPage') {
  1129. result = this.doAction({action, event});
  1130. }
  1131. }
  1132. }
  1133. return result;
  1134. }
  1135. }
  1136. export default vueComponent(Reader);
  1137. //-----------------------------------------------------------------------------
  1138. </script>
  1139. <style scoped>
  1140. .header {
  1141. padding-left: 5px;
  1142. padding-right: 5px;
  1143. background-color: #1B695F;
  1144. color: #000;
  1145. overflow: hidden;
  1146. height: 50px;
  1147. }
  1148. .main {
  1149. background-color: #EBE2C9;
  1150. color: #000;
  1151. }
  1152. .tool-button {
  1153. margin: 0px 2px 0 2px;
  1154. padding: 0;
  1155. color: #3E843E;
  1156. background-color: #E6EDF4;
  1157. margin-top: 5px;
  1158. height: 38px;
  1159. width: 38px;
  1160. border: 0;
  1161. border-radius: 6px;
  1162. box-shadow: 3px 3px 5px black;
  1163. outline: 0;
  1164. }
  1165. .tool-button:hover {
  1166. background-color: white;
  1167. cursor: pointer;
  1168. }
  1169. .tool-button-active {
  1170. box-shadow: 0 0 0;
  1171. color: white;
  1172. background-color: #8AB45F;
  1173. position: relative;
  1174. top: 1px;
  1175. left: 1px;
  1176. }
  1177. .tool-button-active:hover {
  1178. color: white;
  1179. background-color: #81C581;
  1180. cursor: pointer;
  1181. }
  1182. .tool-button-disabled {
  1183. color: lightgray;
  1184. background-color: gray;
  1185. cursor: default;
  1186. }
  1187. .tool-button-disabled:hover {
  1188. color: lightgray;
  1189. background-color: gray;
  1190. cursor: default;
  1191. }
  1192. .space {
  1193. width: 10px;
  1194. display: inline-block;
  1195. }
  1196. .clear {
  1197. color: rgba(0,0,0,0);
  1198. }
  1199. </style>