Работа над ExternalLibs
This commit is contained in:
@@ -19,10 +19,10 @@
|
|||||||
rounded outlined dense emit-value map-options display-value-sanitize options-sanitize
|
rounded outlined dense emit-value map-options display-value-sanitize options-sanitize
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-btn class="q-mr-xs" round dense color="blue" icon="la la-plus" @click="addBookmark" size="12px">
|
<q-btn class="q-mr-xs" round dense color="blue" icon="la la-plus" @click.stop="addBookmark" size="12px">
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Добавить закладку</q-tooltip>
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Добавить закладку</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-btn round dense color="blue" icon="la la-bars" size="12px" disabled>
|
<q-btn round dense color="blue" icon="la la-bars" @click.stop="bookmarkSettings" size="12px" disabled>
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Настроить закладки (пока недоступно)</q-tooltip>
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Настроить закладки (пока недоступно)</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</template>
|
</template>
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
dropdown-icon="la la-angle-down la-sm"
|
dropdown-icon="la la-angle-down la-sm"
|
||||||
rounded outlined dense emit-value map-options hide-selected display-value-sanitize options-sanitize
|
rounded outlined dense emit-value map-options hide-selected display-value-sanitize options-sanitize
|
||||||
>
|
>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Закладки</q-tooltip>
|
||||||
</q-select>
|
</q-select>
|
||||||
<q-input class="col q-mr-sm" ref="input" rounded outlined dense bg-color="white" v-model="bookUrl" placeholder="Скопируйте сюда URL книги" @focus="onInputFocus">
|
<q-input class="col q-mr-sm" ref="input" rounded outlined dense bg-color="white" v-model="bookUrl" placeholder="Скопируйте сюда URL книги" @focus="onInputFocus">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
@@ -50,7 +51,41 @@
|
|||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
<div class="separator"></div>
|
<div class="separator"></div>
|
||||||
|
|
||||||
<iframe v-if="frameVisible" class="col fit" ref="frame" :src="frameSrc" frameborder="0"></iframe>
|
<iframe v-if="frameVisible" class="col fit" ref="frame" :src="frameSrc" frameborder="0"></iframe>
|
||||||
|
|
||||||
|
<Dialog ref="dialogAddBookmark" v-model="addBookmarkVisible">
|
||||||
|
<template slot="header">
|
||||||
|
<div class="row items-center">
|
||||||
|
<q-icon class="q-mr-sm" name="la la-bookmark" size="28px"></q-icon>
|
||||||
|
Добавить закладку
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="q-mx-md row">
|
||||||
|
<q-input ref="bookmarkLink" class="col q-mr-sm" outlined dense bg-color="white" v-model="bookmarkLink"
|
||||||
|
placeholder="Ссылка на закладку" maxlength="2000" @focus="onInputFocus">
|
||||||
|
</q-input>
|
||||||
|
|
||||||
|
<q-select class="q-mr-sm" v-model="defaultRootLink" :options="defaultRootLinkOptions" style="width: 50px"
|
||||||
|
dropdown-icon="la la-angle-down la-sm"
|
||||||
|
outlined dense emit-value map-options hide-selected display-value-sanitize options-sanitize
|
||||||
|
>
|
||||||
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Предустановленные ссылки</q-tooltip>
|
||||||
|
</q-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="q-mx-md q-mt-md">
|
||||||
|
<q-input class="col q-mr-sm" outlined dense bg-color="white" v-model="bookmarkDesc"
|
||||||
|
placeholder="Описание" style="width: 400px" maxlength="100" @focus="onInputFocus">
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template slot="footer">
|
||||||
|
<q-btn class="q-px-md q-ml-sm" dense no-caps v-close-popup>Отмена</q-btn>
|
||||||
|
<q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okAddBookmark" :disabled="!bookmarkLink">OK</q-btn>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
</Window>
|
</Window>
|
||||||
</template>
|
</template>
|
||||||
@@ -62,6 +97,8 @@ import Component from 'vue-class-component';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
import Window from '../share/Window.vue';
|
import Window from '../share/Window.vue';
|
||||||
|
import Dialog from '../share/Dialog.vue';
|
||||||
|
import rstore from '../../store/modules/reader';
|
||||||
import * as utils from '../../share/utils';
|
import * as utils from '../../share/utils';
|
||||||
|
|
||||||
const proxySubst = {
|
const proxySubst = {
|
||||||
@@ -70,7 +107,8 @@ const proxySubst = {
|
|||||||
|
|
||||||
export default @Component({
|
export default @Component({
|
||||||
components: {
|
components: {
|
||||||
Window
|
Window,
|
||||||
|
Dialog
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
libs: function() {
|
libs: function() {
|
||||||
@@ -82,6 +120,9 @@ export default @Component({
|
|||||||
},
|
},
|
||||||
selectedLink: function() {
|
selectedLink: function() {
|
||||||
this.updateStartLink();
|
this.updateStartLink();
|
||||||
|
},
|
||||||
|
defaultRootLink: function() {
|
||||||
|
this.updateBookmarkLink();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -95,6 +136,11 @@ class ExternalLibs extends Vue {
|
|||||||
bookUrl = '';
|
bookUrl = '';
|
||||||
libs = {};
|
libs = {};
|
||||||
fullScreenActive = false;
|
fullScreenActive = false;
|
||||||
|
addBookmarkVisible = false;
|
||||||
|
|
||||||
|
bookmarkLink = '';
|
||||||
|
bookmarkDesc = '';
|
||||||
|
defaultRootLink = '';
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.$root.addKeyHook(this.keyHook);
|
this.$root.addKeyHook(this.keyHook);
|
||||||
@@ -199,7 +245,7 @@ class ExternalLibs extends Vue {
|
|||||||
updateSelectedLink() {
|
updateSelectedLink() {
|
||||||
if (!this.ready)
|
if (!this.ready)
|
||||||
return;
|
return;
|
||||||
const index = this.getRootIndexByUrl(this.rootLink);
|
const index = this.getRootIndexByUrl(this.libs.groups, this.rootLink);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
this.selectedLink = this.libs.groups[index].s;
|
this.selectedLink = this.libs.groups[index].s;
|
||||||
}
|
}
|
||||||
@@ -207,7 +253,7 @@ class ExternalLibs extends Vue {
|
|||||||
updateStartLink() {
|
updateStartLink() {
|
||||||
if (!this.ready)
|
if (!this.ready)
|
||||||
return;
|
return;
|
||||||
const index = this.getRootIndexByUrl(this.rootLink);
|
const index = this.getRootIndexByUrl(this.libs.groups, this.rootLink);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
let libs = _.cloneDeep(this.libs);
|
let libs = _.cloneDeep(this.libs);
|
||||||
libs.groups[index].s = this.selectedLink;
|
libs.groups[index].s = this.selectedLink;
|
||||||
@@ -230,12 +276,22 @@ class ExternalLibs extends Vue {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get defaultRootLinkOptions() {
|
||||||
|
let result = [];
|
||||||
|
|
||||||
|
rstore.libsDefaults.groups.forEach(group => {
|
||||||
|
result.push({label: this.removeProtocol(group.r), value: group.r});
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
get selectedLinkOptions() {
|
get selectedLinkOptions() {
|
||||||
let result = [];
|
let result = [];
|
||||||
if (!this.ready)
|
if (!this.ready)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
const index = this.getRootIndexByUrl(this.rootLink);
|
const index = this.getRootIndexByUrl(this.libs.groups, this.rootLink);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
this.libs.groups[index].list.forEach(link => {
|
this.libs.groups[index].list.forEach(link => {
|
||||||
result.push({label: (link.c ? link.c + ' ': '') + this.removeOrigin(link.l), value: link.l});
|
result.push({label: (link.c ? link.c + ' ': '') + this.removeOrigin(link.l), value: link.l});
|
||||||
@@ -282,11 +338,10 @@ class ExternalLibs extends Vue {
|
|||||||
return (result ? result : '/');
|
return (result ? result : '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
getRootIndexByUrl(url) {
|
getRootIndexByUrl(groups, url) {
|
||||||
if (!this.ready)
|
if (!this.ready)
|
||||||
return -1;
|
return -1;
|
||||||
const origin = this.getOrigin(url);
|
const origin = this.getOrigin(url);
|
||||||
const groups = this.libs.groups;
|
|
||||||
for (let i = 0; i < groups.length; i++) {
|
for (let i = 0; i < groups.length; i++) {
|
||||||
if (groups[i].r == origin)
|
if (groups[i].r == origin)
|
||||||
return i;
|
return i;
|
||||||
@@ -314,8 +369,8 @@ class ExternalLibs extends Vue {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
onInputFocus() {
|
onInputFocus(event) {
|
||||||
this.$refs.input.select();
|
event.target.select();
|
||||||
}
|
}
|
||||||
|
|
||||||
submitUrl() {
|
submitUrl() {
|
||||||
@@ -331,6 +386,26 @@ class ExternalLibs extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addBookmark() {
|
addBookmark() {
|
||||||
|
this.addBookmarkVisible = true;
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs.bookmarkLink.focus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateBookmarkLink() {
|
||||||
|
this.bookmarkLink = this.defaultRootLink;
|
||||||
|
const index = this.getRootIndexByUrl(rstore.libsDefaults.groups, this.bookmarkLink);
|
||||||
|
if (index >= 0) {
|
||||||
|
this.bookmarkDesc = this.getCommentByLink(rstore.libsDefaults.groups[index].list, this.bookmarkLink);
|
||||||
|
} else {
|
||||||
|
this.bookmarkDesc = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
okAddBookmark() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bookmarkSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fullScreenToggle() {
|
fullScreenToggle() {
|
||||||
@@ -347,17 +422,23 @@ class ExternalLibs extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyHook() {
|
keyHook() {
|
||||||
//недостатки сторонних ui
|
if (this.$root.rootRoute() == '/external-libs') {
|
||||||
const input = this.$refs.input.$refs.input;
|
if (this.$refs.dialogAddBookmark.active)
|
||||||
if (document.activeElement === input && event.type == 'keydown' && event.code == 'Enter') {
|
return false;
|
||||||
this.submitUrl();
|
|
||||||
|
//недостатки сторонних ui
|
||||||
|
const input = this.$refs.input.$refs.input;
|
||||||
|
if (document.activeElement === input && event.type == 'keydown' && event.code == 'Enter') {
|
||||||
|
this.submitUrl();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.type == 'keydown' && (event.code == 'Escape')) {
|
||||||
|
this.close();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
if (event.type == 'keydown' && (event.code == 'Escape')) {
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,7 +266,11 @@ const libsDefaults = {
|
|||||||
]},
|
]},
|
||||||
{r: 'http://lib.ru', s: 'http://lib.ru', list: [
|
{r: 'http://lib.ru', s: 'http://lib.ru', list: [
|
||||||
{l: 'http://lib.ru', c: 'Библиотека Максима Мошкова'},
|
{l: 'http://lib.ru', c: 'Библиотека Максима Мошкова'},
|
||||||
]},
|
]},
|
||||||
|
{r: 'https://aldebaran.ru', s: 'https://aldebaran.ru', list: [
|
||||||
|
{l: 'https://aldebaran.ru', c: 'АЛЬДЕБАРАН | Электронная библиотека книг'},
|
||||||
|
]},
|
||||||
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user