File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,23 +66,28 @@ BookReader.prototype.setup = (function (super_) {
6666 /** @type { {[pageIndex: number]: SearchInsideMatchBox[]} } */
6767 this . _searchBoxesByIndex = { } ;
6868
69- this . searchView = undefined ;
69+ if ( this . enableSearch ) {
70+ this . searchView = new SearchView ( {
71+ br : this ,
72+ searchCancelledCallback : ( ) => {
73+ this . _cancelSearch ( ) ;
74+ this . trigger ( 'SearchCanceled' , { term : this . searchTerm , instance : this } ) ;
75+ }
76+ } ) ;
77+ } else {
78+ this . searchView = null ;
79+ }
7080 } ;
7181} ) ( BookReader . prototype . setup ) ;
7282
7383/** @override */
7484BookReader . prototype . init = ( function ( super_ ) {
7585 return function ( ) {
7686 super_ . call ( this ) ;
77- // give SearchView the most complete bookreader state
78- this . searchView = new SearchView ( {
79- br : this ,
80- searchCancelledCallback : ( ) => {
81- this . _cancelSearch ( ) ;
82- this . trigger ( 'SearchCanceled' , { term : this . searchTerm , instance : this } ) ;
83- }
84- } ) ;
85- if ( this . options . enableSearch && this . options . initialSearchTerm ) {
87+ if ( ! this . enableSearch ) return ;
88+
89+ this . searchView . init ( ) ;
90+ if ( this . options . initialSearchTerm ) {
8691 /**
8792 * this.search() take two parameter
8893 * 1. this.options.initialSearchTerm - search term
Original file line number Diff line number Diff line change @@ -11,10 +11,13 @@ class SearchView {
1111 this . br = br ;
1212 this . matches = [ ] ;
1313 this . cacheDOMElements ( ) ;
14- this . bindEvents ( ) ;
1514 this . cancelSearch = searchCancelledCallback ;
1615 }
1716
17+ init ( ) {
18+ this . bindEvents ( ) ;
19+ }
20+
1821 cacheDOMElements ( ) {
1922 this . dom = { } ;
2023 // Search input within the top toolbar. Will be removed once the mobile menu is replaced.
You can’t perform that action at this time.
0 commit comments