Reader.vue 47 KB

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