Добавил логику деактивации кнопок
This commit is contained in:
@@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<el-tooltip content="Действие назад" :open-delay="1000" effect="light">
|
<el-tooltip content="Действие назад" :open-delay="1000" effect="light">
|
||||||
<el-button ref="undoAction" class="tool-button" @click="buttonClick('undoAction')" ><i class="el-icon-arrow-left"></i></el-button>
|
<el-button ref="undoAction" class="tool-button" :class="buttonActiveClass('undoAction')" @click="buttonClick('undoAction')" ><i class="el-icon-arrow-left"></i></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip content="Действие вперед" :open-delay="1000" effect="light">
|
<el-tooltip content="Действие вперед" :open-delay="1000" effect="light">
|
||||||
<el-button ref="redoAction" class="tool-button" @click="buttonClick('redoAction')" ><i class="el-icon-arrow-right"></i></el-button>
|
<el-button ref="redoAction" class="tool-button" :class="buttonActiveClass('redoAction')" @click="buttonClick('redoAction')" ><i class="el-icon-arrow-right"></i></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<div class="space"></div>
|
<div class="space"></div>
|
||||||
<el-tooltip content="На весь экран" :open-delay="1000" effect="light">
|
<el-tooltip content="На весь экран" :open-delay="1000" effect="light">
|
||||||
@@ -21,16 +21,18 @@
|
|||||||
<el-button ref="setPosition" class="tool-button" :class="buttonActiveClass('setPosition')" @click="buttonClick('setPosition')"><i class="el-icon-d-arrow-right"></i></el-button>
|
<el-button ref="setPosition" class="tool-button" :class="buttonActiveClass('setPosition')" @click="buttonClick('setPosition')"><i class="el-icon-d-arrow-right"></i></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip content="Плавный скроллинг" :open-delay="1000" effect="light">
|
<el-tooltip content="Плавный скроллинг" :open-delay="1000" effect="light">
|
||||||
<el-button ref="scrolling" class="tool-button" @click="buttonClick('scrolling')"><i class="el-icon-sort"></i></el-button>
|
<el-button ref="scrolling" class="tool-button" :class="buttonActiveClass('scrolling')" @click="buttonClick('scrolling')"><i class="el-icon-sort"></i></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip content="Найти в тексте" :open-delay="1000" effect="light">
|
<el-tooltip content="Найти в тексте" :open-delay="1000" effect="light">
|
||||||
<el-button ref="search" class="tool-button" @click="buttonClick('search')"><i class="el-icon-search"></i></el-button>
|
<el-button ref="search" class="tool-button" :class="buttonActiveClass('search')" @click="buttonClick('search')"><i class="el-icon-search"></i></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip content="Скопировать текст со страницы" :open-delay="1000" effect="light">
|
<el-tooltip content="Скопировать текст со страницы" :open-delay="1000" effect="light">
|
||||||
<el-button ref="copyText" class="tool-button" @click="buttonClick('copyText')"><i class="el-icon-edit-outline"></i></el-button>
|
<el-button ref="copyText" class="tool-button" :class="buttonActiveClass('copyText')" @click="buttonClick('copyText')"><i class="el-icon-edit-outline"></i></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip content="Принудительно обновить книгу в обход кеша" :open-delay="1000" effect="light">
|
<el-tooltip content="Принудительно обновить книгу в обход кеша" :open-delay="1000" effect="light">
|
||||||
<el-button ref="refresh" class="tool-button" @click="buttonClick('refresh')"><i class="el-icon-refresh" :class="{clear: !showRefreshIcon}"></i></el-button>
|
<el-button ref="refresh" class="tool-button" :class="buttonActiveClass('refresh')" @click="buttonClick('refresh')">
|
||||||
|
<i class="el-icon-refresh" :class="{clear: !showRefreshIcon}"></i>
|
||||||
|
</el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<div class="space"></div>
|
<div class="space"></div>
|
||||||
<el-tooltip content="История" :open-delay="1000" effect="light">
|
<el-tooltip content="История" :open-delay="1000" effect="light">
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
@load-book="loadBook"
|
@load-book="loadBook"
|
||||||
@book-pos-changed="bookPosChanged"
|
@book-pos-changed="bookPosChanged"
|
||||||
@tool-bar-toggle="toolBarToggle"
|
@tool-bar-toggle="toolBarToggle"
|
||||||
|
@full-screen-toogle="fullScreenToggle"
|
||||||
></component>
|
></component>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
|
|
||||||
@@ -112,6 +115,9 @@ class Reader extends Vue {
|
|||||||
progressActive = false;
|
progressActive = false;
|
||||||
fullScreenActive = false;
|
fullScreenActive = false;
|
||||||
|
|
||||||
|
scrollingActive = false;
|
||||||
|
searchActive = false;
|
||||||
|
copyTextActive = false;
|
||||||
historyActive = false;
|
historyActive = false;
|
||||||
setPositionActive = false;
|
setPositionActive = false;
|
||||||
|
|
||||||
@@ -192,7 +198,10 @@ class Reader extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get lastOpenedBook() {
|
get lastOpenedBook() {
|
||||||
return this.$store.getters['reader/lastOpenedBook'];
|
const result = this.$store.getters['reader/lastOpenedBook'];
|
||||||
|
if (!result)
|
||||||
|
this.closeAllTextPages()
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
toolBarToggle() {
|
toolBarToggle() {
|
||||||
@@ -222,21 +231,40 @@ class Reader extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeAllTextPages() {
|
||||||
|
this.historyActive = false;
|
||||||
|
this.setPositionActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
loaderToggle() {
|
loaderToggle() {
|
||||||
this.loaderActive = !this.loaderActive;
|
this.loaderActive = !this.loaderActive;
|
||||||
|
if (this.loaderActive) {
|
||||||
|
this.closeAllTextPages();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
historyToggle() {
|
historyToggle() {
|
||||||
this.historyActive = !this.historyActive;
|
this.historyActive = !this.historyActive;
|
||||||
|
if (this.historyActive && this.activePage == 'TextPage') {
|
||||||
|
this.closeAllTextPages();
|
||||||
|
this.historyActive = true;
|
||||||
|
} else {
|
||||||
|
this.historyActive = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPositionToggle() {
|
setPositionToggle() {
|
||||||
this.setPositionActive = !this.setPositionActive;
|
this.setPositionActive = !this.setPositionActive;
|
||||||
if (this.setPositionActive) {
|
if (this.setPositionActive && this.activePage == 'TextPage' && this.lastOpenedBook) {
|
||||||
|
this.closeAllTextPages();
|
||||||
|
this.setPositionActive = true;
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.setPositionPage.sliderMax = this.lastOpenedBook.textLength - 1;
|
this.$refs.setPositionPage.sliderMax = this.lastOpenedBook.textLength - 1;
|
||||||
this.$refs.setPositionPage.sliderValue = this.lastOpenedBook.bookPos;
|
this.$refs.setPositionPage.sliderValue = this.lastOpenedBook.bookPos;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.setPositionActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,13 +293,41 @@ class Reader extends Vue {
|
|||||||
|
|
||||||
buttonActiveClass(button) {
|
buttonActiveClass(button) {
|
||||||
const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
|
const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
|
||||||
|
const classDisabled = { 'tool-button-disabled': true, 'tool-button-disabled:hover': true };
|
||||||
|
let classResult = {};
|
||||||
|
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case 'loader': return (this.loaderActive ? classActive : {});
|
case 'loader':
|
||||||
case 'fullScreen': return (this.fullScreenActive ? classActive : {});
|
case 'fullScreen':
|
||||||
case 'history': return (this.historyActive ? classActive : {});
|
case 'setPosition':
|
||||||
case 'setPosition': return (this.setPositionActive ? classActive : {});
|
case 'scrolling':
|
||||||
|
case 'search':
|
||||||
|
case 'copyText':
|
||||||
|
case 'history':
|
||||||
|
if (this[`${button}Active`])
|
||||||
|
classResult = classActive;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
|
if (this.activePage == 'LoaderPage' || !this.lastOpenedBook) {
|
||||||
|
switch (button) {
|
||||||
|
case 'undoAction':
|
||||||
|
case 'redoAction':
|
||||||
|
case 'setPosition':
|
||||||
|
case 'scrolling':
|
||||||
|
case 'search':
|
||||||
|
case 'copyText':
|
||||||
|
case 'history':
|
||||||
|
classResult = classDisabled;
|
||||||
|
break;
|
||||||
|
case 'refresh':
|
||||||
|
if (!this.lastOpenedBook)
|
||||||
|
classResult = classDisabled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return classResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
get activePage() {
|
get activePage() {
|
||||||
@@ -315,16 +371,12 @@ class Reader extends Vue {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$nextTick(() => {
|
|
||||||
if (this.$refs.page)
|
|
||||||
this.$refs.page.fullScreenToggle = this.fullScreenToggle;
|
|
||||||
});
|
|
||||||
|
|
||||||
this.lastActivePage = result;
|
this.lastActivePage = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBook(opts) {
|
loadBook(opts) {
|
||||||
|
this.closeAllTextPages();
|
||||||
this.progressActive = true;
|
this.progressActive = true;
|
||||||
this.$nextTick(async() => {
|
this.$nextTick(async() => {
|
||||||
const progress = this.$refs.page;
|
const progress = this.$refs.page;
|
||||||
@@ -525,6 +577,16 @@ class Reader extends Vue {
|
|||||||
background-color: #81C581;
|
background-color: #81C581;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tool-button-disabled {
|
||||||
|
color: lightgray;
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tool-button-disabled:hover {
|
||||||
|
color: lightgray;
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
i {
|
i {
|
||||||
font-size: 200%;
|
font-size: 200%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -632,8 +632,7 @@ class TextPage extends Vue {
|
|||||||
case 'Enter':
|
case 'Enter':
|
||||||
case 'Backquote'://`
|
case 'Backquote'://`
|
||||||
case 'KeyF':
|
case 'KeyF':
|
||||||
if (this.fullScreenToggle)
|
this.$emit('full-screen-toogle');
|
||||||
this.fullScreenToggle();
|
|
||||||
break;
|
break;
|
||||||
case 'Tab':
|
case 'Tab':
|
||||||
this.doToolBarToggle();
|
this.doToolBarToggle();
|
||||||
|
|||||||
Reference in New Issue
Block a user