remove old unused code

This commit is contained in:
Artur Adib 2012-09-26 16:38:02 -04:00
parent 73b96e0e58
commit 1ec2e2a1a2
3 changed files with 2 additions and 154 deletions

View File

@ -870,8 +870,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
margin-left: 20px;
}
.outlineItem > a,
#findResults > a {
.outlineItem > a {
text-decoration: none;
display: inline-block;
min-width: 95%;
@ -887,8 +886,7 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
white-space: nowrap;
}
.outlineItem > a:hover,
#findResults > a:hover {
.outlineItem > 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;
@ -923,36 +921,6 @@ a:focus > .thumbnail > .thumbnailSelectionRing,
width: 280px;
}
#findToolbar {
padding-left: 0px;
right: 0px;
padding-top: 0px;
padding-bottom: 5px;
}
#findToolbar > input {
margin-left: 4px;
width: 124px;
}
#findToolbar button {
width: auto;
margin: 0;
padding: 0 6px;
height: 22px;
}
#findResults {
overflow: auto;
position: absolute;
top: 30px;
bottom: 0px;
left: 0px;
right: 0;
padding: 4px 4px 0;
font-size: smaller;
}
#sidebarControls {
position:absolute;
width: 180px;

View File

@ -97,13 +97,6 @@ limitations under the License.
</div>
<div id="outlineView" class="hidden">
</div>
<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="findResults"></div>
</div>
</div>
</div> <!-- sidebarContainer -->

View File

@ -244,8 +244,6 @@ var PDFFindController = {
},
calcFindMatch: function(pageContent) {
// TODO: Handle the other find options here as well.
var query = this.state.query;
var caseSensitive = this.state.caseSensitive;
var queryLen = query.length;
@ -1230,72 +1228,6 @@ var PDFView = {
return true;
},
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 (lastFind && (now - lastFind) < FIND_TIMEOUT) {
if (!this.findTimer) {
this.findTimer = setTimeout(function resumeFind() {
PDFView.find();
},
FIND_TIMEOUT - (now - lastFind)
);
}
return;
}
this.FindTimer = null;
this.lastFind = now;
function bindLink(link, pageNumber) {
link.href = '#' + pageNumber;
link.onclick = function findBindLink() {
PDFView.page = pageNumber;
return false;
};
}
var findResults = document.getElementById('findResults');
var findTermsInput = document.getElementById('findTermsInput');
findResults.removeAttribute('hidden');
findResults.textContent = '';
var terms = findTermsInput.value;
if (!terms)
return;
// simple search: removing spaces and hyphens, then scanning every
terms = terms.replace(/\s-/g, '').toLowerCase();
var index = PDFView.pageText;
var pageFound = false;
for (var i = 0, ii = index.length; i < ii; i++) {
var pageText = index[i].replace(/\s-/g, '').toLowerCase();
var j = pageText.indexOf(terms);
if (j < 0)
continue;
var pageNumber = i + 1;
var textSample = index[i].substr(j, 50);
var link = document.createElement('a');
bindLink(link, pageNumber);
link.textContent = 'Page ' + pageNumber + ': ' + textSample;
findResults.appendChild(link);
pageFound = true;
}
if (!pageFound) {
findResults.textContent = '';
var noResults = document.createElement('div');
noResults.classList.add('noResults');
noResults.textContent = mozL10n.get('find_terms_not_found', null,
'(Not found)');
findResults.appendChild(noResults);
}
},
setHash: function pdfViewSetHash(hash) {
if (!hash)
return;
@ -1337,20 +1269,16 @@ var PDFView = {
switchSidebarView: function pdfViewSwitchSidebarView(view) {
var thumbsView = document.getElementById('thumbnailView');
var outlineView = document.getElementById('outlineView');
var findView = document.getElementById('findView');
var thumbsButton = document.getElementById('viewThumbnail');
var outlineButton = document.getElementById('viewOutline');
var findButton = document.getElementById('viewFind');
switch (view) {
case 'thumbs':
thumbsButton.classList.add('toggled');
outlineButton.classList.remove('toggled');
findButton.classList.remove('toggled');
thumbsView.classList.remove('hidden');
outlineView.classList.add('hidden');
findView.classList.add('hidden');
PDFView.renderHighestPriority();
break;
@ -1358,49 +1286,15 @@ var PDFView = {
case 'outline':
thumbsButton.classList.remove('toggled');
outlineButton.classList.add('toggled');
findButton.classList.remove('toggled');
thumbsView.classList.add('hidden');
outlineView.classList.remove('hidden');
findView.classList.add('hidden');
if (outlineButton.getAttribute('disabled'))
return;
break;
case 'find':
thumbsButton.classList.remove('toggled');
outlineButton.classList.remove('toggled');
findButton.classList.add('toggled');
thumbsView.classList.add('hidden');
outlineView.classList.add('hidden');
findView.classList.remove('hidden');
var findTermsInput = document.getElementById('findTermsInput');
findTermsInput.focus();
// Start text extraction as soon as the search gets displayed.
this.extractText();
break;
}
},
extractText: function() {
if (this.startedTextExtraction)
return;
this.startedTextExtraction = true;
var self = this;
function extractPageText(pageIndex) {
self.pages[pageIndex].pdfPage.getTextContent().then(
function textContentResolved(textContent) {
self.pageText[pageIndex] = textContent.join('');
self.find();
if ((pageIndex + 1) < self.pages.length)
extractPageText(pageIndex + 1);
}
);
}
extractPageText(0);
},
getVisiblePages: function pdfViewGetVisiblePages() {
return this.getVisibleElements(this.container,
this.pages, true);
@ -2656,13 +2550,6 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
PDFView.download();
});
document.getElementById('findTermsInput').addEventListener('keydown',
function(event) {
if (event.keyCode == 13) {
PDFView.find();
}
});
document.getElementById('pageNumber').addEventListener('change',
function() {
PDFView.page = this.value;