diff --git a/src/pyj/read_book/iframe.pyj b/src/pyj/read_book/iframe.pyj
index 062f18883c..4df110db3a 100644
--- a/src/pyj/read_book/iframe.pyj
+++ b/src/pyj/read_book/iframe.pyj
@@ -145,7 +145,6 @@ class IframeBoss:
'number_of_columns_changed': self.number_of_columns_changed,
'change_scroll_speed': self.change_scroll_speed,
'display': self.display,
- 'find': self.find,
'gesture_from_margin': self.gesture_from_margin,
'get_current_cfi': self.get_current_cfi,
'initialize':self.initialize,
@@ -464,8 +463,6 @@ class IframeBoss:
self.jump_to_cfi(ipos.cfi)
elif ipos.type is 'search_result':
self.show_search_result(ipos, True)
- elif ipos.type is 'search':
- self.find(ipos.search_data, True)
elif ipos.type is 'edit_annotation':
window.setTimeout(def():
self.annotations_msg_received({'type': 'edit-highlight', 'uuid': ipos.uuid})
@@ -752,29 +749,6 @@ class IframeBoss:
if refnum?:
self.scroll_to_ref(refnum)
- def find(self, data, from_load):
- self.last_search_at = window.performance.now()
- if data.searched_in_spine:
- window.getSelection().removeAllRanges()
- wrap_search = from_load and data.backwards
- found = window.find(data.text, False, data.backwards, wrap_search)
- if not found and wrap_search:
- # wrapping is not implemented on Firefox
- prev_range = None
- while window.find(data.text, False):
- prev_range = window.getSelection().getRangeAt(0)
- if prev_range:
- sel = window.getSelection()
- sel.removeAllRanges()
- sel.addRange(prev_range)
- found = window.find(data.text, False, True)
- if found:
- if current_layout_mode() is not 'flow':
- snap_to_selection()
- else:
- msg_type = 'invisible_text' if from_load else 'find_in_spine'
- self.send_message(msg_type, text=data.text, backwards=data.backwards, searched_in_spine=data.searched_in_spine)
-
def show_search_result(self, data, from_load):
sr = data.search_result
if sr.on_discovery:
diff --git a/src/pyj/read_book/search.pyj b/src/pyj/read_book/search.pyj
index 58ff457a8f..221c474825 100644
--- a/src/pyj/read_book/search.pyj
+++ b/src/pyj/read_book/search.pyj
@@ -11,7 +11,6 @@ from complete import create_search_bar
from gettext import gettext as _
from modals import error_dialog
from read_book.globals import current_book, ui_operations
-from read_book.resources import text_from_serialized_html
from read_book.search_worker import (
CONNECT_FAILED, DB_ERROR, GET_SPINE_FAILED, UNHANDLED_ERROR, worker_main
)
@@ -180,16 +179,12 @@ class SearchOverlay:
def container(self):
return document.getElementById(self.CONTAINER_ID)
- @property
- def search_text(self):
- return self.container.querySelector('input').value
-
@property
def is_visible(self):
return self.container.style.display is not 'none'
def set_text(self, text):
- self.container.querySelector('input').value = text or ''
+ self.container.querySelector('input[type=search]').value = text or ''
def hide(self):
self.container.style.display = 'none'
@@ -204,7 +199,6 @@ class SearchOverlay:
def find(self, text, backwards):
if not text:
return
- self.view.find(text, backwards)
def find_next(self):
self.find(self.search_text, False)
@@ -213,28 +207,4 @@ class SearchOverlay:
self.find(self.search_text, True)
-def find_in_serialized_html(data, text):
- haystack = text_from_serialized_html(data)
- return haystack.toLowerCase().indexOf(text) > -1
-
-
-def find_in_spine(names, book, text, proceed):
- text = text.toLowerCase()
-
- def got_one(data, name, mimetype):
- if find_in_serialized_html(data, text):
- proceed(name)
- else:
- do_one()
-
- def do_one():
- name = names.shift()
- if name:
- ui_operations.get_file(book, name, got_one)
- else:
- proceed(None)
-
- do_one()
-
-
main = worker_main
diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj
index d6e6a03aae..adff820d80 100644
--- a/src/pyj/read_book/view.pyj
+++ b/src/pyj/read_book/view.pyj
@@ -35,7 +35,7 @@ from read_book.prefs.scrolling import (
from read_book.read_aloud import ReadAloud
from read_book.resources import load_resources
from read_book.scrollbar import BookScrollbar
-from read_book.search import SearchOverlay, find_in_spine
+from read_book.search import SearchOverlay
from read_book.selection_bar import SelectionBar
from read_book.shortcuts import create_shortcut_map
from read_book.timers import Timers
@@ -238,7 +238,6 @@ class View:
'bump_font_size': self.bump_font_size,
'content_loaded': self.on_content_loaded,
'error': self.on_iframe_error,
- 'find_in_spine': self.on_find_in_spine,
'invisible_text': self.on_invisible_text,
'goto_doc_boundary': def(data): self.goto_doc_boundary(data.start);,
'handle_keypress': self.on_handle_keypress,
@@ -655,9 +654,6 @@ class View:
misc.show_actions_toolbar = v'!misc.show_actions_toolbar'
sd.set('standalone_misc_settings', misc)
- def find(self, text, backwards):
- self.iframe_wrapper.send_message('find', text=text, backwards=backwards, searched_in_spine=False)
-
def on_invisible_text(self, data):
warning_dialog(
_('Not found'), _('The text: {} is present on this page but not visible').format(html_escape(data.text)),
@@ -665,35 +661,6 @@ class View:
self.search_overlay.show()
)
- def on_find_in_spine(self, data):
- if data.searched_in_spine:
- warning_dialog(
- _('Not found'), _('The text: {} was not found in this book').format(html_escape(data.text)),
- on_close=def():
- self.search_overlay.show()
- )
- return
- spine = self.book.manifest.spine
- idx = spine.indexOf(self.currently_showing.name)
- if idx < 0:
- error_dialog(_('Missing file'), _(
- 'Could not search as the spine item {} is missing from the book').format(self.currently_showing.name),
- on_close=def():
- self.search_overlay.show()
- )
- return
- names = v'[]'
- item_groups = [range(idx-1, -1, -1), range(spine.length-1, idx, -1)] if data.backwards else [range(idx + 1, spine.length), range(idx)]
- for items in item_groups:
- for i in items:
- names.push(spine[i])
- find_in_spine(names, self.book, data.text, def(found_in):
- if found_in:
- self.show_name(found_in, initial_position={'type':'search', 'search_data':data, 'replace_history':True})
- else:
- self.iframe_wrapper.send_message('find', text=data.text, backwards=data.backwards, searched_in_spine=True)
- )
-
def bump_font_size(self, data):
mult = 1 if data.increase else -1
frac = 0.2