Merge pull request #5325 from fzembow/findcontrollerfix
Update findbar to wrap on initial search
This commit is contained in:
		
						commit
						c8d729ff39
					
				@ -44,6 +44,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
 | 
				
			|||||||
      pageIdx: null,
 | 
					      pageIdx: null,
 | 
				
			||||||
      matchIdx: null
 | 
					      matchIdx: null
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					    this.pagesToSearch = null;
 | 
				
			||||||
    this.resumePageIdx = null;
 | 
					    this.resumePageIdx = null;
 | 
				
			||||||
    this.state = null;
 | 
					    this.state = null;
 | 
				
			||||||
    this.dirtyMatch = false;
 | 
					    this.dirtyMatch = false;
 | 
				
			||||||
@ -255,6 +256,8 @@ var PDFFindController = (function PDFFindControllerClosure() {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      var offset = this.offset;
 | 
					      var offset = this.offset;
 | 
				
			||||||
 | 
					      // Keep track of how many pages we should maximally iterate through.
 | 
				
			||||||
 | 
					      this.pagesToSearch = numPages;
 | 
				
			||||||
      // If there's already a matchIdx that means we are iterating through a
 | 
					      // If there's already a matchIdx that means we are iterating through a
 | 
				
			||||||
      // page's matches.
 | 
					      // page's matches.
 | 
				
			||||||
      if (offset.matchIdx !== null) {
 | 
					      if (offset.matchIdx !== null) {
 | 
				
			||||||
@ -293,8 +296,8 @@ var PDFFindController = (function PDFFindControllerClosure() {
 | 
				
			|||||||
        this.advanceOffsetPage(previous);
 | 
					        this.advanceOffsetPage(previous);
 | 
				
			||||||
        if (offset.wrapped) {
 | 
					        if (offset.wrapped) {
 | 
				
			||||||
          offset.matchIdx = null;
 | 
					          offset.matchIdx = null;
 | 
				
			||||||
          if (!this.hadMatch) {
 | 
					          if (this.pagesToSearch < 0) {
 | 
				
			||||||
            // No point in wrapping, there were no matches.
 | 
					            // No point in wrapping again, there were no matches.
 | 
				
			||||||
            this.updateMatch(false);
 | 
					            this.updateMatch(false);
 | 
				
			||||||
            // while matches were not found, searching for a page 
 | 
					            // while matches were not found, searching for a page 
 | 
				
			||||||
            // with matches should nevertheless halt.
 | 
					            // with matches should nevertheless halt.
 | 
				
			||||||
@ -328,10 +331,11 @@ var PDFFindController = (function PDFFindControllerClosure() {
 | 
				
			|||||||
      offset.pageIdx = (previous ? offset.pageIdx - 1 : offset.pageIdx + 1);
 | 
					      offset.pageIdx = (previous ? offset.pageIdx - 1 : offset.pageIdx + 1);
 | 
				
			||||||
      offset.matchIdx = null;
 | 
					      offset.matchIdx = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      this.pagesToSearch--;
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
      if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
 | 
					      if (offset.pageIdx >= numPages || offset.pageIdx < 0) {
 | 
				
			||||||
        offset.pageIdx = (previous ? numPages - 1 : 0);
 | 
					        offset.pageIdx = (previous ? numPages - 1 : 0);
 | 
				
			||||||
        offset.wrapped = true;
 | 
					        offset.wrapped = true;
 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user