ExternalLibs.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <Window ref="window" @close="close" margin="2px">
  3. <template slot="header">
  4. {{ header }}
  5. </template>
  6. <template slot="buttons">
  7. <span class="full-screen-button row justify-center items-center" @mousedown.stop @click="fullScreenToggle">
  8. <q-icon :name="(fullScreenActive ? 'la la-compress-arrows-alt': 'la la-expand-arrows-alt')" size="16px"/>
  9. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">На весь экран</q-tooltip>
  10. </span>
  11. </template>
  12. <div v-show="ready" class="col column" style="min-width: 600px">
  13. <div class="row items-center q-px-sm" style="height: 50px">
  14. <q-select class="q-mr-sm" ref="rootLink" v-model="rootLink" :options="rootLinkOptions" @input="rootLinkInput"
  15. @popup-show="onSelectPopupShow" @popup-hide="onSelectPopupHide"
  16. style="width: 230px"
  17. dropdown-icon="la la-angle-down la-sm"
  18. rounded outlined dense emit-value map-options display-value-sanitize options-sanitize
  19. >
  20. <template v-slot:prepend>
  21. <q-btn class="q-mr-xs" round dense color="blue" icon="la la-plus" @click.stop="addBookmark" size="12px">
  22. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Добавить закладку</q-tooltip>
  23. </q-btn>
  24. <q-btn round dense color="blue" icon="la la-bars" @click.stop="bookmarkSettings" size="12px">
  25. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Настроить закладки</q-tooltip>
  26. </q-btn>
  27. </template>
  28. <template v-slot:selected>
  29. <div style="overflow: hidden; white-space: nowrap;">{{ rootLinkWithoutProtocol }}</div>
  30. </template>
  31. </q-select>
  32. <q-select class="q-mr-sm" ref="selectedLink" v-model="selectedLink" :options="selectedLinkOptions" @input="selectedLinkInput" style="width: 50px"
  33. @popup-show="onSelectPopupShow" @popup-hide="onSelectPopupHide"
  34. dropdown-icon="la la-angle-down la-sm"
  35. rounded outlined dense emit-value map-options hide-selected display-value-sanitize options-sanitize
  36. >
  37. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Закладки</q-tooltip>
  38. </q-select>
  39. <q-input class="col q-mr-sm" ref="input" rounded outlined dense bg-color="white" v-model="bookUrl" placeholder="Скопируйте сюда URL книги"
  40. @focus="selectAllOnFocus" @keydown="bookUrlKeyDown"
  41. >
  42. <template v-slot:prepend>
  43. <q-btn class="q-mr-xs" round dense color="blue" icon="la la-home" @click="goToLink(libs.startLink)" size="12px">
  44. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Вернуться на стартовую страницу</q-tooltip>
  45. </q-btn>
  46. <q-btn round dense color="blue" icon="la la-angle-double-down" @click="openBookUrlInFrame" size="12px" :disabled="!bookUrl">
  47. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Загрузить URL во фрейм</q-tooltip>
  48. </q-btn>
  49. </template>
  50. <template v-slot:append>
  51. <q-btn round dense color="blue" icon="la la-cog" @click.stop="openOptions" size="12px">
  52. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Опции</q-tooltip>
  53. </q-btn>
  54. </template>
  55. </q-input>
  56. <q-btn rounded color="green-7" no-caps size="14px" @click="submitUrl">Открыть
  57. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Открыть в читалке</q-tooltip>
  58. </q-btn>
  59. </div>
  60. <div class="separator"></div>
  61. <div class="col fit" style="position: relative;">
  62. <iframe v-if="frameVisible" class="fit" ref="frame" :src="frameSrc" frameborder="0"></iframe>
  63. <div v-show="transparentLayoutVisible" ref="transparentLayout" class="fit transparent-layout" @click="transparentLayoutClick"></div>
  64. </div>
  65. <Dialog ref="dialogAddBookmark" v-model="addBookmarkVisible">
  66. <template slot="header">
  67. <div class="row items-center">
  68. <q-icon class="q-mr-sm" name="la la-bookmark" size="28px"></q-icon>
  69. <div v-if="addBookmarkMode == 'edit'">Редактировать закладку</div>
  70. <div v-else>Добавить закладку</div>
  71. </div>
  72. </template>
  73. <div class="q-mx-md row">
  74. <q-input ref="bookmarkLink" class="col q-mr-sm" outlined dense bg-color="white" v-model="bookmarkLink" @keydown="bookmarkLinkKeyDown"
  75. placeholder="Ссылка для закладки" maxlength="2000" @focus="selectAllOnFocus">
  76. </q-input>
  77. <q-select class="q-mr-sm" ref="defaultRootLink" v-model="defaultRootLink" :options="defaultRootLinkOptions" @input="defaultRootLinkInput" style="width: 50px"
  78. dropdown-icon="la la-angle-down la-sm"
  79. outlined dense emit-value map-options hide-selected display-value-sanitize options-sanitize
  80. >
  81. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Предустановленные ссылки</q-tooltip>
  82. </q-select>
  83. </div>
  84. <div class="q-mx-md q-mt-md">
  85. <q-input class="col q-mr-sm" ref="bookmarkDesc" outlined dense bg-color="white" v-model="bookmarkDesc" @keydown="bookmarkDescKeyDown"
  86. placeholder="Описание" style="width: 400px" maxlength="100" @focus="selectAllOnFocus">
  87. </q-input>
  88. </div>
  89. <template slot="footer">
  90. <q-btn class="q-px-md q-ml-sm" dense no-caps v-close-popup>Отмена</q-btn>
  91. <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okAddBookmark" :disabled="!bookmarkLink">OK</q-btn>
  92. </template>
  93. </Dialog>
  94. </div>
  95. <BookmarkSettings v-if="bookmarkSettingsActive" ref="bookmarkSettings" :libs="libs" :addBookmarkVisible="addBookmarkVisible"
  96. @do-action="doAction" @close="closeBookmarkSettings">
  97. </BookmarkSettings>
  98. </Window>
  99. </template>
  100. <script>
  101. //-----------------------------------------------------------------------------
  102. import Vue from 'vue';
  103. import Component from 'vue-class-component';
  104. import _ from 'lodash';
  105. import Window from '../share/Window.vue';
  106. import Dialog from '../share/Dialog.vue';
  107. import BookmarkSettings from './BookmarkSettings/BookmarkSettings.vue';
  108. import rstore from '../../store/modules/reader';
  109. import * as utils from '../../share/utils';
  110. import * as lu from './linkUtils';
  111. const proxySubst = {
  112. 'http://flibusta.is': 'http://b.liberama.top:23480',
  113. };
  114. export default @Component({
  115. components: {
  116. Window,
  117. Dialog,
  118. BookmarkSettings
  119. },
  120. watch: {
  121. libs: function() {
  122. this.loadLibs();
  123. },
  124. rootLink: function() {
  125. this.updateSelectedLink();
  126. this.updateStartLink();
  127. },
  128. selectedLink: function() {
  129. this.updateStartLink();
  130. },
  131. defaultRootLink: function() {
  132. this.updateBookmarkLink();
  133. }
  134. }
  135. })
  136. class ExternalLibs extends Vue {
  137. ready = false;
  138. frameVisible = false;
  139. startLink = '';
  140. rootLink = '';
  141. selectedLink = '';
  142. frameSrc = '';
  143. bookUrl = '';
  144. libs = {};
  145. fullScreenActive = false;
  146. addBookmarkVisible = false;
  147. transparentLayoutVisible = false;
  148. addBookmarkMode = '';
  149. bookmarkLink = '';
  150. bookmarkDesc = '';
  151. defaultRootLink = '';
  152. bookmarkSettingsActive = false;
  153. created() {
  154. this.$root.addKeyHook(this.keyHook);
  155. document.addEventListener('fullscreenchange', () => {
  156. this.fullScreenActive = (document.fullscreenElement !== null);
  157. });
  158. //this.commit = this.$store.commit;
  159. //this.commit('reader/setLibs', rstore.libsDefaults);
  160. }
  161. mounted() {
  162. //Поправка метода toggleOption компонента select фреймворка quasar, необходимо другое поведение
  163. //$emit('input'.. вызывается всегда
  164. this.toggleOption = function(opt, keepOpen) {
  165. if (this.editable !== true || opt === void 0 || this.isOptionDisabled(opt) === true) {
  166. return;
  167. }
  168. const optValue = this.getOptionValue(opt);
  169. if (this.multiple !== true) {
  170. if (keepOpen !== true) {
  171. this.updateInputValue(this.fillInput === true ? this.getOptionLabel(opt) : '', true, true);
  172. this.hidePopup();
  173. }
  174. this.$refs.target !== void 0 && this.$refs.target.focus();
  175. this.$emit('input', this.emitValue === true ? optValue : opt);
  176. }
  177. };
  178. this.$refs.rootLink.toggleOption = this.toggleOption;
  179. this.$refs.selectedLink.toggleOption = this.toggleOption;
  180. (async() => {
  181. //подождем this.mode
  182. let i = 0;
  183. while(!this.mode && i < 100) {
  184. await utils.sleep(100);
  185. i++;
  186. }
  187. if (this.mode != 'liberama.top') {
  188. this.$router.replace('/404');
  189. return;
  190. }
  191. this.$refs.window.init();
  192. this.opener = null;
  193. const host = window.location.host;
  194. const openerHost = (host.indexOf('b.') == 0 ? host.substring(2) : host);
  195. const openerOrigin1 = `http://${openerHost}`;
  196. const openerOrigin2 = `https://${openerHost}`;
  197. window.addEventListener('message', (event) => {
  198. if (event.origin !== openerOrigin1 && event.origin !== openerOrigin2)
  199. return;
  200. if (!_.isObject(event.data) || event.data.from != 'LibsPage')
  201. return;
  202. if (event.origin == openerOrigin1)
  203. this.opener = window.opener;
  204. else
  205. this.opener = event.source;
  206. this.openerOrigin = event.origin;
  207. //console.log(event);
  208. this.recvMessage(event.data);
  209. });
  210. //Ожидаем родителя
  211. i = 0;
  212. while(!this.opener) {
  213. await utils.sleep(1000);
  214. i++;
  215. if (i >= 5) {
  216. await this.$root.stdDialog.alert('Нет связи с читалкой. Окно будет закрыто', 'Ошибка');
  217. window.close();
  218. }
  219. }
  220. //Проверка закрытия родительского окна
  221. while(this.opener) {
  222. await this.checkOpener();
  223. await utils.sleep(1000);
  224. }
  225. })();
  226. }
  227. recvMessage(d) {
  228. if (d.type == 'mes') {
  229. switch(d.data) {
  230. case 'hello': this.sendMessage({type: 'mes', data: 'ready'}); break;
  231. }
  232. } else if (d.type == 'libs') {
  233. this.ready = true;
  234. this.libs = _.cloneDeep(d.data);
  235. } else if (d.type == 'notify') {
  236. this.$root.notify.success(d.data, '', {position: 'bottom-right'});
  237. }
  238. }
  239. sendMessage(d) {
  240. (async() => {
  241. await this.checkOpener();
  242. if (this.opener && this.openerOrigin)
  243. this.opener.postMessage(Object.assign({}, {from: 'ExternalLibs'}, d), this.openerOrigin);
  244. })();
  245. }
  246. async checkOpener() {
  247. if (this.opener.closed) {
  248. await this.$root.stdDialog.alert('Потеряна связь с читалкой. Окно будет закрыто', 'Ошибка');
  249. window.close();
  250. }
  251. }
  252. commitLibs(libs) {
  253. this.sendMessage({type: 'libs', data: libs});
  254. }
  255. loadLibs() {
  256. const libs = this.libs;
  257. this.startLink = libs.startLink;
  258. this.rootLink = lu.getOrigin(libs.startLink);
  259. this.updateSelectedLink();
  260. }
  261. doAction(event) {
  262. switch (event.action) {
  263. case 'setLibs': this.commitLibs(event.data); break;
  264. case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break;
  265. case 'setSelectedLink': this.selectedLink = event.data; this.selectedLinkInput(); break;
  266. case 'editBookmark': this.addBookmark('edit', event.data.link, event.data.desc); break;
  267. case 'addBookmark': this.addBookmark('add'); break;
  268. }
  269. }
  270. get mode() {
  271. return this.$store.state.config.mode;
  272. }
  273. get header() {
  274. let result = (this.ready ? 'Библиотека' : 'Загрузка...');
  275. if (this.ready && this.startLink) {
  276. result += ` | ${(this.libs.comment ? this.libs.comment + ' ': '') + lu.removeProtocol(this.startLink)}`;
  277. }
  278. this.$root.$emit('set-app-title', result);
  279. return result;
  280. }
  281. get rootLinkWithoutProtocol() {
  282. return lu.removeProtocol(this.rootLink);
  283. }
  284. updateSelectedLink() {
  285. if (!this.ready)
  286. return;
  287. const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink);
  288. if (index >= 0)
  289. this.selectedLink = this.libs.groups[index].s;
  290. else
  291. this.selectedLink = '';
  292. }
  293. updateStartLink() {
  294. if (!this.ready)
  295. return;
  296. const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink);
  297. if (index >= 0) {
  298. let libs = _.cloneDeep(this.libs);
  299. try {
  300. if (lu.getOrigin(libs.groups[index].r) == lu.getOrigin(this.selectedLink)) {
  301. libs.groups[index].s = this.selectedLink;
  302. libs.startLink = this.selectedLink;
  303. libs.comment = this.getCommentByLink(libs.groups[index].list, this.selectedLink);
  304. this.goToLink(this.selectedLink);
  305. this.commitLibs(libs);
  306. } else {
  307. console.error(`${lu.getOrigin(libs.groups[index].r)} != ${lu.getOrigin(this.selectedLink)}`);
  308. }
  309. } catch(e) {
  310. console.log(e);
  311. }
  312. } else {
  313. this.rootLink = '';
  314. this.startLink = '';
  315. this.frameVisible = false;
  316. }
  317. }
  318. get rootLinkOptions() {
  319. let result = [];
  320. if (!this.ready)
  321. return result;
  322. this.libs.groups.forEach(group => {
  323. result.push({label: lu.removeProtocol(group.r), value: group.r});
  324. });
  325. return result;
  326. }
  327. get defaultRootLinkOptions() {
  328. let result = [];
  329. rstore.libsDefaults.groups.forEach(group => {
  330. result.push({label: lu.removeProtocol(group.r), value: group.r});
  331. });
  332. return result;
  333. }
  334. get selectedLinkOptions() {
  335. let result = [];
  336. if (!this.ready)
  337. return result;
  338. const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink);
  339. if (index >= 0) {
  340. this.libs.groups[index].list.forEach(link => {
  341. result.push({label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), value: link.l});
  342. });
  343. }
  344. return result;
  345. }
  346. openBookUrlInFrame() {
  347. if (this.bookUrl) {
  348. this.goToLink(lu.addProtocol(this.bookUrl));
  349. }
  350. }
  351. goToLink(link) {
  352. if (!this.ready || !link)
  353. return;
  354. this.frameSrc = this.makeProxySubst(link);
  355. this.frameVisible = false;
  356. this.$nextTick(() => {
  357. this.frameVisible = true;
  358. this.$nextTick(() => {
  359. this.$refs.frame.contentWindow.focus();
  360. });
  361. });
  362. }
  363. getCommentByLink(list, link) {
  364. const item = lu.getListItemByLink(list, link);
  365. return (item ? item.c : '');
  366. }
  367. makeProxySubst(url, reverse = false) {
  368. for (const [key, value] of Object.entries(proxySubst)) {
  369. if (reverse && value == url.substring(0, value.length)) {
  370. return key + url.substring(value.length);
  371. } else if (key == url.substring(0, key.length)) {
  372. return value + url.substring(key.length);
  373. }
  374. }
  375. return url;
  376. }
  377. selectAllOnFocus(event) {
  378. if (event.target.select)
  379. event.target.select();
  380. }
  381. rootLinkInput() {
  382. this.updateSelectedLink();
  383. this.updateStartLink();
  384. }
  385. selectedLinkInput() {
  386. this.updateStartLink();
  387. }
  388. submitUrl() {
  389. if (this.bookUrl) {
  390. this.sendMessage({type: 'submitUrl', data: {
  391. url: this.makeProxySubst(lu.addProtocol(this.bookUrl), true),
  392. force: true
  393. }});
  394. this.bookUrl = '';
  395. if (this.libs.closeAfterSubmit)
  396. this.close();
  397. }
  398. }
  399. addBookmark(mode = 'add', link = '', desc = '') {
  400. if (mode == 'edit') {
  401. this.editBookmarkLink = this.bookmarkLink = link;
  402. this.editBookmarkDesc = this.bookmarkDesc = desc;
  403. } else {
  404. this.bookmarkLink = (this.bookUrl ? this.makeProxySubst(lu.addProtocol(this.bookUrl), true) : '');
  405. this.bookmarkDesc = '';
  406. }
  407. this.addBookmarkMode = mode;
  408. this.addBookmarkVisible = true;
  409. this.$nextTick(() => {
  410. this.$refs.bookmarkLink.focus();
  411. this.$refs.defaultRootLink.toggleOption = this.toggleOption;
  412. });
  413. }
  414. updateBookmarkLink() {
  415. const index = lu.getSafeRootIndexByUrl(rstore.libsDefaults.groups, this.defaultRootLink);
  416. if (index >= 0) {
  417. this.bookmarkLink = rstore.libsDefaults.groups[index].s;
  418. this.bookmarkDesc = this.getCommentByLink(rstore.libsDefaults.groups[index].list, this.bookmarkLink);
  419. } else {
  420. this.bookmarkLink = '';
  421. this.bookmarkDesc = '';
  422. }
  423. }
  424. defaultRootLinkInput() {
  425. this.updateBookmarkLink();
  426. }
  427. bookmarkLinkKeyDown(event) {
  428. if (event.key == 'Enter') {
  429. this.$refs.bookmarkDesc.focus();
  430. event.preventDefault();
  431. }
  432. }
  433. bookmarkDescKeyDown(event) {
  434. if (event.key == 'Enter') {
  435. event.stopPropagation();
  436. event.preventDefault();
  437. this.okAddBookmark();
  438. }
  439. }
  440. async okAddBookmark() {
  441. if (!this.bookmarkLink)
  442. return;
  443. const link = (this.addBookmarkMode == 'edit' ? lu.addProtocol(this.editBookmarkLink) : lu.addProtocol(this.bookmarkLink));
  444. let index = -1;
  445. try {
  446. index = lu.getRootIndexByUrl(this.libs.groups, link);
  447. } catch (e) {
  448. await this.$root.stdDialog.alert('Неверный формат ссылки', 'Ошибка');
  449. return;
  450. }
  451. let libs = _.cloneDeep(this.libs);
  452. //добавление
  453. //есть группа в закладках
  454. if (index >= 0) {
  455. const item = lu.getListItemByLink(libs.groups[index].list, link);
  456. //редактирование
  457. if (item && this.addBookmarkMode == 'edit') {
  458. if (item) {
  459. //редактируем
  460. item.l = link;
  461. item.c = this.bookmarkDesc;
  462. this.commitLibs(libs);
  463. } else {
  464. await this.$root.stdDialog.alert('Не удалось отредактировать закладку', 'Ошибка');
  465. }
  466. } else if (!item) {
  467. //добавляем
  468. if (libs.groups[index].list.length >= 100) {
  469. await this.$root.stdDialog.alert('Достигнут предел количества закладок для этого сайта', 'Ошибка');
  470. return;
  471. }
  472. libs.groups[index].list.push({l: link, c: this.bookmarkDesc});
  473. this.commitLibs(libs);
  474. } else if (item.c != this.bookmarkDesc) {
  475. if (await this.$root.stdDialog.confirm(`Такая закладка уже существует с другим описанием<br>` +
  476. `Заменить '${this.$sanitize(item.c)}' на '${this.$sanitize(this.bookmarkDesc)}'?`, ' ')) {
  477. item.c = this.bookmarkDesc;
  478. this.commitLibs(libs);
  479. } else
  480. return;
  481. } else {
  482. await this.$root.stdDialog.alert('Такая закладка уже существует', ' ');
  483. return;
  484. }
  485. } else {//нет группы в закладках
  486. if (libs.groups.length >= 100) {
  487. await this.$root.stdDialog.alert('Достигнут предел количества различных сайтов в закладках', 'Ошибка');
  488. return;
  489. }
  490. //добавляем сначала группу
  491. libs.groups.push({r: lu.getOrigin(link), s: link, list: []});
  492. index = lu.getSafeRootIndexByUrl(libs.groups, link);
  493. if (index >= 0)
  494. libs.groups[index].list.push({l: link, c: this.bookmarkDesc});
  495. this.commitLibs(libs);
  496. }
  497. this.addBookmarkVisible = false;
  498. }
  499. fullScreenToggle() {
  500. this.fullScreenActive = !this.fullScreenActive;
  501. if (this.fullScreenActive) {
  502. this.$q.fullscreen.request();
  503. } else {
  504. this.$q.fullscreen.exit();
  505. }
  506. }
  507. transparentLayoutClick() {
  508. this.transparentLayoutVisible = false;
  509. }
  510. onSelectPopupShow() {
  511. this.transparentLayoutVisible = true;
  512. }
  513. onSelectPopupHide() {
  514. this.transparentLayoutVisible = false;
  515. }
  516. close() {
  517. this.sendMessage({type: 'close'});
  518. }
  519. bookUrlKeyDown(event) {
  520. if (event.key == 'Enter') {
  521. this.submitUrl();
  522. event.preventDefault();
  523. }
  524. }
  525. bookmarkSettings() {
  526. this.bookmarkSettingsActive = true;
  527. this.$nextTick(() => {
  528. this.$refs.bookmarkSettings.init();
  529. });
  530. }
  531. closeBookmarkSettings() {
  532. this.bookmarkSettingsActive = false;
  533. }
  534. openOptions() {
  535. }
  536. keyHook(event) {
  537. if (this.$root.rootRoute() == '/external-libs') {
  538. if (this.$root.stdDialog.active)
  539. return false;
  540. if (this.bookmarkSettingsActive && this.$refs.bookmarkSettings.keyHook(event))
  541. return true;
  542. if (this.addBookmarkVisible)
  543. return false;
  544. if (event.type == 'keydown' && event.key == 'F4') {
  545. this.addBookmark();
  546. return true;
  547. }
  548. if (event.type == 'keydown' && event.key == 'Escape' &&
  549. (document.activeElement != this.$refs.rootLink.$refs.target || !this.$refs.rootLink.menu) &&
  550. (document.activeElement != this.$refs.selectedLink.$refs.target || !this.$refs.selectedLink.menu)
  551. ) {
  552. this.close();
  553. return true;
  554. }
  555. }
  556. return false;
  557. }
  558. }
  559. //-----------------------------------------------------------------------------
  560. </script>
  561. <style scoped>
  562. .separator {
  563. height: 1px;
  564. background-color: #A0A0A0;
  565. }
  566. .full-screen-button {
  567. width: 30px;
  568. height: 30px;
  569. cursor: pointer;
  570. }
  571. .full-screen-button:hover {
  572. background-color: #69C05F;
  573. }
  574. .transparent-layout {
  575. top: 0;
  576. left: 0;
  577. position: absolute;
  578. }
  579. </style>