Reader.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  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 Vue from 'vue';
  136. import Component from 'vue-class-component';
  137. import _ from 'lodash';
  138. import {Buffer} from 'safe-buffer';
  139. import LoaderPage from './LoaderPage/LoaderPage.vue';
  140. import TextPage from './TextPage/TextPage.vue';
  141. import ProgressPage from './ProgressPage/ProgressPage.vue';
  142. import SetPositionPage from './SetPositionPage/SetPositionPage.vue';
  143. import SearchPage from './SearchPage/SearchPage.vue';
  144. import CopyTextPage from './CopyTextPage/CopyTextPage.vue';
  145. import LibsPage from './LibsPage/LibsPage.vue';
  146. import RecentBooksPage from './RecentBooksPage/RecentBooksPage.vue';
  147. import SettingsPage from './SettingsPage/SettingsPage.vue';
  148. import HelpPage from './HelpPage/HelpPage.vue';
  149. import ClickMapPage from './ClickMapPage/ClickMapPage.vue';
  150. import ServerStorage from './ServerStorage/ServerStorage.vue';
  151. import ContentsPage from './ContentsPage/ContentsPage.vue';
  152. import ReaderDialogs from './ReaderDialogs/ReaderDialogs.vue';
  153. import bookManager from './share/bookManager';
  154. import wallpaperStorage from './share/wallpaperStorage';
  155. import dynamicCss from '../../share/dynamicCss';
  156. import rstore from '../../store/modules/reader';
  157. import readerApi from '../../api/reader';
  158. import miscApi from '../../api/misc';
  159. import {versionHistory} from './versionHistory';
  160. import * as utils from '../../share/utils';
  161. export default @Component({
  162. components: {
  163. LoaderPage,
  164. TextPage,
  165. ProgressPage,
  166. SetPositionPage,
  167. SearchPage,
  168. CopyTextPage,
  169. LibsPage,
  170. RecentBooksPage,
  171. SettingsPage,
  172. HelpPage,
  173. ClickMapPage,
  174. ServerStorage,
  175. ContentsPage,
  176. ReaderDialogs,
  177. },
  178. watch: {
  179. bookPos: function(newValue) {
  180. if (newValue !== undefined && this.activePage == 'TextPage') {
  181. const textPage = this.$refs.page;
  182. if (textPage.bookPos != newValue) {
  183. textPage.bookPos = newValue;
  184. }
  185. if (!this.scrollingActive)
  186. this.debouncedSetRecentBook(newValue);
  187. else
  188. this.scrollingSetRecentBook(newValue);
  189. }
  190. },
  191. routeParamPos: function(newValue) {
  192. if (!this.paramPosIgnore && newValue !== undefined && newValue != this.bookPos) {
  193. this.bookPos = newValue;
  194. }
  195. },
  196. routeParamUrl: function(newValue) {
  197. if (newValue !== '' && newValue !== this.mostRecentBook().url) {
  198. this.loadBook({url: newValue, bookPos: this.routeParamPos});
  199. }
  200. },
  201. settings: function() {
  202. this.loadSettings();
  203. this.updateRoute();
  204. },
  205. loaderActive: function(newValue) {
  206. (async() => {
  207. const recent = this.mostRecentBook();
  208. if (!newValue && !this.loading && recent && !await bookManager.hasBookParsed(recent)) {
  209. this.loadBook(recent);
  210. }
  211. })();
  212. },
  213. dualPageMode(newValue) {
  214. if (newValue)
  215. this.stopScrolling();
  216. },
  217. },
  218. })
  219. class Reader extends Vue {
  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.rootRoute() == '/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.$emit('set-app-title');
  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.$emit('set-app-title');
  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.rootRoute() == '/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. //-----------------------------------------------------------------------------
  1137. </script>
  1138. <style scoped>
  1139. .header {
  1140. padding-left: 5px;
  1141. padding-right: 5px;
  1142. background-color: #1B695F;
  1143. color: #000;
  1144. overflow: hidden;
  1145. height: 50px;
  1146. }
  1147. .main {
  1148. background-color: #EBE2C9;
  1149. color: #000;
  1150. }
  1151. .tool-button {
  1152. margin: 0px 2px 0 2px;
  1153. padding: 0;
  1154. color: #3E843E;
  1155. background-color: #E6EDF4;
  1156. margin-top: 5px;
  1157. height: 38px;
  1158. width: 38px;
  1159. border: 0;
  1160. border-radius: 6px;
  1161. box-shadow: 3px 3px 5px black;
  1162. outline: 0;
  1163. }
  1164. .tool-button:hover {
  1165. background-color: white;
  1166. cursor: pointer;
  1167. }
  1168. .tool-button-active {
  1169. box-shadow: 0 0 0;
  1170. color: white;
  1171. background-color: #8AB45F;
  1172. position: relative;
  1173. top: 1px;
  1174. left: 1px;
  1175. }
  1176. .tool-button-active:hover {
  1177. color: white;
  1178. background-color: #81C581;
  1179. cursor: pointer;
  1180. }
  1181. .tool-button-disabled {
  1182. color: lightgray;
  1183. background-color: gray;
  1184. cursor: default;
  1185. }
  1186. .tool-button-disabled:hover {
  1187. color: lightgray;
  1188. background-color: gray;
  1189. cursor: default;
  1190. }
  1191. .space {
  1192. width: 10px;
  1193. display: inline-block;
  1194. }
  1195. .clear {
  1196. color: rgba(0,0,0,0);
  1197. }
  1198. </style>