mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 07:08:08 +02:00
Use "find" instead of both find & search
This commit is contained in:
parent
d94bbad575
commit
6864a07221
13 changed files with 101 additions and 101 deletions
|
@ -728,7 +728,7 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
|||
content: url(images/toolbarButton-viewOutline.png);
|
||||
}
|
||||
|
||||
#viewSearch.toolbarButton::before {
|
||||
#viewFind.toolbarButton::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-search.png);
|
||||
}
|
||||
|
@ -871,7 +871,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
|||
}
|
||||
|
||||
.outlineItem > a,
|
||||
#searchResults > a {
|
||||
#findResults > a {
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
min-width: 95%;
|
||||
|
@ -888,7 +888,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
|||
}
|
||||
|
||||
.outlineItem > a:hover,
|
||||
#searchResults > a:hover {
|
||||
#findResults > a:hover {
|
||||
background-color: hsla(0,0%,100%,.02);
|
||||
background-image: -moz-linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-clip: padding-box;
|
||||
|
@ -915,7 +915,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
|||
font-style: italic;
|
||||
}
|
||||
|
||||
#searchScrollView {
|
||||
#findScrollView {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
bottom: 10px;
|
||||
|
@ -923,26 +923,26 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
|
|||
width: 280px;
|
||||
}
|
||||
|
||||
#searchToolbar {
|
||||
#findToolbar {
|
||||
padding-left: 0px;
|
||||
right: 0px;
|
||||
padding-top: 0px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
#searchToolbar > input {
|
||||
#findToolbar > input {
|
||||
margin-left: 4px;
|
||||
width: 124px;
|
||||
}
|
||||
|
||||
#searchToolbar button {
|
||||
#findToolbar button {
|
||||
width: auto;
|
||||
margin: 0;
|
||||
padding: 0 6px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
#searchResults {
|
||||
#findResults {
|
||||
overflow: auto;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
|
|
|
@ -88,8 +88,8 @@ limitations under the License.
|
|||
<button id="viewOutline" class="toolbarButton group" title="Show Document Outline" tabindex="2" data-l10n-id="outline">
|
||||
<span data-l10n-id="outline_label">Document Outline</span>
|
||||
</button>
|
||||
<button id="viewSearch" class="toolbarButton group hidden" title="Search Document" tabindex="3" data-l10n-id="search_panel">
|
||||
<span data-l10n-id="search_panel_label">Search Document</span>
|
||||
<button id="viewFind" class="toolbarButton group" title="Find in Document" tabindex="3" data-l10n-id="find_panel">
|
||||
<span data-l10n-id="find_panel_label">Find in Document</span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="sidebarContent">
|
||||
|
@ -97,12 +97,12 @@ limitations under the License.
|
|||
</div>
|
||||
<div id="outlineView" class="hidden">
|
||||
</div>
|
||||
<div id="searchView" class="hidden">
|
||||
<div id="searchToolbar">
|
||||
<input id="searchTermsInput" class="toolbarField">
|
||||
<button id="searchButton" class="textButton toolbarButton" data-l10n-id="search">Find</button>
|
||||
<div id="findView" class="hidden">
|
||||
<div id="findToolbar">
|
||||
<input id="findTermsInput" class="toolbarField">
|
||||
<button id="findButton" class="textButton toolbarButton" data-l10n-id="find">Find</button>
|
||||
</div>
|
||||
<div id="searchResults"></div>
|
||||
<div id="findResults"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- sidebarContainer -->
|
||||
|
|
|
@ -211,7 +211,7 @@ var currentPageNumber = 1;
|
|||
var PDFFindController = {
|
||||
startedTextExtraction: false,
|
||||
|
||||
// If active, search resulsts will be highlighted.
|
||||
// If active, find results will be highlighted.
|
||||
active: false,
|
||||
|
||||
// Stores the text for each page.
|
||||
|
@ -244,7 +244,7 @@ var PDFFindController = {
|
|||
},
|
||||
|
||||
calcFindMatch: function(pageContent) {
|
||||
// TODO: Handle the other search options here as well.
|
||||
// TODO: Handle the other find options here as well.
|
||||
|
||||
var query = this.state.query;
|
||||
var queryLen = query.length;
|
||||
|
@ -274,7 +274,7 @@ var PDFFindController = {
|
|||
function extractPageText(pageIndex) {
|
||||
PDFView.pages[pageIndex].getTextContent().then(
|
||||
function textContentResolved(data) {
|
||||
// Bulid the search string.
|
||||
// Build the find string.
|
||||
var bidiTexts = data.bidiTexts;
|
||||
var str = '';
|
||||
|
||||
|
@ -434,7 +434,7 @@ var PDFFindBar = {
|
|||
|
||||
initialize: function() {
|
||||
this.bar = document.getElementById('findbar');
|
||||
this.toggleButton = document.getElementById('viewSearch');
|
||||
this.toggleButton = document.getElementById('viewFind');
|
||||
this.findField = document.getElementById('findInput');
|
||||
this.highlightAll = document.getElementById('findHighlightAll');
|
||||
this.caseSensitive = document.getElementById('findMatchCase');
|
||||
|
@ -1224,39 +1224,39 @@ var PDFView = {
|
|||
return true;
|
||||
},
|
||||
|
||||
search: function pdfViewStartSearch() {
|
||||
// Limit this function to run every <SEARCH_TIMEOUT>ms.
|
||||
var SEARCH_TIMEOUT = 250;
|
||||
var lastSearch = this.lastSearch;
|
||||
find: function pdfViewStartFind() {
|
||||
// Limit this function to run every <FIND_TIMEOUT>ms.
|
||||
var FIND_TIMEOUT = 250;
|
||||
var lastFind = this.lastFind;
|
||||
var now = Date.now();
|
||||
if (lastSearch && (now - lastSearch) < SEARCH_TIMEOUT) {
|
||||
if (!this.searchTimer) {
|
||||
this.searchTimer = setTimeout(function resumeSearch() {
|
||||
PDFView.search();
|
||||
if (lastFind && (now - lastFind) < FIND_TIMEOUT) {
|
||||
if (!this.findTimer) {
|
||||
this.findTimer = setTimeout(function resumeFind() {
|
||||
PDFView.find();
|
||||
},
|
||||
SEARCH_TIMEOUT - (now - lastSearch)
|
||||
FIND_TIMEOUT - (now - lastFind)
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.searchTimer = null;
|
||||
this.lastSearch = now;
|
||||
this.FindTimer = null;
|
||||
this.lastFind = now;
|
||||
|
||||
function bindLink(link, pageNumber) {
|
||||
link.href = '#' + pageNumber;
|
||||
link.onclick = function searchBindLink() {
|
||||
link.onclick = function findBindLink() {
|
||||
PDFView.page = pageNumber;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
var searchResults = document.getElementById('searchResults');
|
||||
var findResults = document.getElementById('findResults');
|
||||
|
||||
var searchTermsInput = document.getElementById('searchTermsInput');
|
||||
searchResults.removeAttribute('hidden');
|
||||
searchResults.textContent = '';
|
||||
var findTermsInput = document.getElementById('findTermsInput');
|
||||
findResults.removeAttribute('hidden');
|
||||
findResults.textContent = '';
|
||||
|
||||
var terms = searchTermsInput.value;
|
||||
var terms = findTermsInput.value;
|
||||
|
||||
if (!terms)
|
||||
return;
|
||||
|
@ -1276,17 +1276,17 @@ var PDFView = {
|
|||
var link = document.createElement('a');
|
||||
bindLink(link, pageNumber);
|
||||
link.textContent = 'Page ' + pageNumber + ': ' + textSample;
|
||||
searchResults.appendChild(link);
|
||||
findResults.appendChild(link);
|
||||
|
||||
pageFound = true;
|
||||
}
|
||||
if (!pageFound) {
|
||||
searchResults.textContent = '';
|
||||
findResults.textContent = '';
|
||||
var noResults = document.createElement('div');
|
||||
noResults.classList.add('noResults');
|
||||
noResults.textContent = mozL10n.get('search_terms_not_found', null,
|
||||
noResults.textContent = mozL10n.get('find_terms_not_found', null,
|
||||
'(Not found)');
|
||||
searchResults.appendChild(noResults);
|
||||
findResults.appendChild(noResults);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1331,20 +1331,20 @@ var PDFView = {
|
|||
switchSidebarView: function pdfViewSwitchSidebarView(view) {
|
||||
var thumbsView = document.getElementById('thumbnailView');
|
||||
var outlineView = document.getElementById('outlineView');
|
||||
var searchView = document.getElementById('searchView');
|
||||
var findView = document.getElementById('findView');
|
||||
|
||||
var thumbsButton = document.getElementById('viewThumbnail');
|
||||
var outlineButton = document.getElementById('viewOutline');
|
||||
var searchButton = document.getElementById('viewSearch');
|
||||
var findButton = document.getElementById('viewFind');
|
||||
|
||||
switch (view) {
|
||||
case 'thumbs':
|
||||
thumbsButton.classList.add('toggled');
|
||||
outlineButton.classList.remove('toggled');
|
||||
searchButton.classList.remove('toggled');
|
||||
findButton.classList.remove('toggled');
|
||||
thumbsView.classList.remove('hidden');
|
||||
outlineView.classList.add('hidden');
|
||||
searchView.classList.add('hidden');
|
||||
findView.classList.add('hidden');
|
||||
|
||||
PDFView.renderHighestPriority();
|
||||
break;
|
||||
|
@ -1352,25 +1352,25 @@ var PDFView = {
|
|||
case 'outline':
|
||||
thumbsButton.classList.remove('toggled');
|
||||
outlineButton.classList.add('toggled');
|
||||
searchButton.classList.remove('toggled');
|
||||
findButton.classList.remove('toggled');
|
||||
thumbsView.classList.add('hidden');
|
||||
outlineView.classList.remove('hidden');
|
||||
searchView.classList.add('hidden');
|
||||
findView.classList.add('hidden');
|
||||
|
||||
if (outlineButton.getAttribute('disabled'))
|
||||
return;
|
||||
break;
|
||||
|
||||
case 'search':
|
||||
case 'find':
|
||||
thumbsButton.classList.remove('toggled');
|
||||
outlineButton.classList.remove('toggled');
|
||||
searchButton.classList.add('toggled');
|
||||
findButton.classList.add('toggled');
|
||||
thumbsView.classList.add('hidden');
|
||||
outlineView.classList.add('hidden');
|
||||
searchView.classList.remove('hidden');
|
||||
findView.classList.remove('hidden');
|
||||
|
||||
var searchTermsInput = document.getElementById('searchTermsInput');
|
||||
searchTermsInput.focus();
|
||||
var findTermsInput = document.getElementById('findTermsInput');
|
||||
findTermsInput.focus();
|
||||
// Start text extraction as soon as the search gets displayed.
|
||||
this.extractText();
|
||||
break;
|
||||
|
@ -1386,7 +1386,7 @@ var PDFView = {
|
|||
self.pages[pageIndex].pdfPage.getTextContent().then(
|
||||
function textContentResolved(textContent) {
|
||||
self.pageText[pageIndex] = textContent.join('');
|
||||
self.search();
|
||||
self.find();
|
||||
if ((pageIndex + 1) < self.pages.length)
|
||||
extractPageText(pageIndex + 1);
|
||||
}
|
||||
|
@ -2545,8 +2545,8 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||
|
||||
//#if !(FIREFOX || MOZCENTRAL)
|
||||
//#else
|
||||
//if (FirefoxCom.requestSync('searchEnabled')) {
|
||||
// document.querySelector('#viewSearch').classList.remove('hidden');
|
||||
//if (FirefoxCom.requestSync('findEnabled')) {
|
||||
// document.querySelector('#viewFind').classList.remove('hidden');
|
||||
//}
|
||||
//#endif
|
||||
|
||||
|
@ -2636,10 +2636,10 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||
PDFView.download();
|
||||
});
|
||||
|
||||
document.getElementById('searchTermsInput').addEventListener('keydown',
|
||||
document.getElementById('findTermsInput').addEventListener('keydown',
|
||||
function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
PDFView.search();
|
||||
PDFView.find();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue