-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4176667
commit 6f9fe7b
Showing
4 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module PdfViewerHelper | ||
def viewer_url(path) | ||
"/web/viewer.html?file=#{path}##{query_param}" | ||
end | ||
|
||
def query_param | ||
return unless search_query | ||
"search=#{search_query}&phrase=true" | ||
end | ||
|
||
private | ||
|
||
def search_query | ||
search && search.respond_to?(:query_params) && search.query_params[:q] | ||
end | ||
|
||
def search | ||
current_search_session | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// fills in the findInput search box with the | ||
// provided query term (when present), only on load | ||
document.addEventListener('pagerendered', function (ev) { | ||
var findInput = document.getElementById('findInput') | ||
var app = PDFViewerApplication | ||
|
||
app.eventBus.on('pagesloaded', function () { | ||
var findController = app.findController || {} | ||
var state = findController.state || {} | ||
var query = state.query || null | ||
|
||
if (!query) { | ||
return | ||
} | ||
|
||
findInput.value = query | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters