diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue
index dbff37ee..d73cba8c 100644
--- a/client/components/Reader/Reader.vue
+++ b/client/components/Reader/Reader.vue
@@ -59,7 +59,7 @@
-
+
diff --git a/client/components/Reader/SearchPage/SearchPage.vue b/client/components/Reader/SearchPage/SearchPage.vue
index 2d3e84f1..a5d9e89b 100644
--- a/client/components/Reader/SearchPage/SearchPage.vue
+++ b/client/components/Reader/SearchPage/SearchPage.vue
@@ -16,8 +16,8 @@
{{ foundText }}
-
-
+
+
@@ -43,7 +43,7 @@ export default @Component({
},
foundText: function(newValue) {
- this.$refs.input.style.paddingRight = newValue.length*12 + 'px';
+ this.$refs.input.style.paddingRight = (10 + newValue.length*12) + 'px';
},
},
})
@@ -87,7 +87,7 @@ class SearchPage extends Vue {
prevPerc = perc;
}
}
- this.text = text;
+ this.text = text.toLowerCase();
this.initStep = false;
this.header = 'Найти';
@@ -98,26 +98,46 @@ class SearchPage extends Vue {
get foundText() {
if (this.foundList.length && this.foundCur >= 0)
- return `${this.foundCur}/${this.foundList.length}`;
+ return `${this.foundCur + 1}/${this.foundList.length}`;
else
return '';
}
find() {
let foundList = [];
- let i = 0;
- while (i < this.text.length) {
- i++;
+ if (this.needle) {
+ const needle = this.needle.toLowerCase();
+ let i = 0;
+ while (i < this.text.length) {
+ const found = this.text.indexOf(needle, i);
+ if (found >= 0)
+ foundList.push(found);
+ i = (found >= 0 ? found + 1 : this.text.length);
+ }
}
this.foundList = foundList;
+ this.foundCur = -1;
+ this.showNext();
}
- findNext() {
- console.log('1');
+ showNext() {
+ const next = this.foundCur + 1;
+ if (next < this.foundList.length)
+ this.foundCur = next;
+ else
+ this.foundCur = (this.foundList.length ? 0 : -1);
+ this.$emit('book-pos-changed', {bookPos: this.foundList[this.foundCur]});
+ this.$refs.input.focus();
}
- findPrev() {
- console.log('2');
+ showPrev() {
+ const prev = this.foundCur - 1;
+ if (prev >= 0)
+ this.foundCur = prev;
+ else
+ this.foundCur = this.foundList.length - 1;
+ this.$emit('book-pos-changed', {bookPos: this.foundList[this.foundCur]});
+ this.$refs.input.focus();
}
close() {
@@ -128,7 +148,7 @@ class SearchPage extends Vue {
keyHook(event) {
//недостатки сторонних ui
if (document.activeElement === this.$refs.input && event.type == 'keydown' && event.key == 'Enter') {
- this.find();
+ this.showNext();
}
if (event.type == 'keydown' && (event.code == 'Escape')) {