123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- function ViewerFindState() {
-
- this.keyword = null;
- this.caseSensitive = false;
- this.wrapAroundSearch = true;
-
- this.matches = null;
- this.focus_index = -1;
- this.matchesFoundInReport = false;
- this.matchesFoundOnServer = false;
- this.pageFirstMatchFound = -1;
- this.matchesUpdateCount = 0;
- this.currentPageNo = -1;
- this.currentPageHasNext = false;
- this.currentPageHasPrev = false;
-
- this.findingOnServerInProgress = false;
- this.searchedOnServer = false;
- }
- ViewerFindState.prototype.setState = function(state) {
- applyJSONProperties(this, state);
-
- };
- ViewerFindState.prototype.getPageNoForFindNext = function() {
- if (!this.isSinglePageReport()) {
- this.currentPageNo++;
- }
- return this.currentPageNo;
- }
- ViewerFindState.prototype.checkServerForNextMatch = function() {
- if (this.isSinglePageReport() ) {
- return false;
- }
-
- if (this.searchedOnServer && (!this.matches || this.matches.length ==0) ) {
- return false;
- }
-
- if (this.currentPageHasNext) {
- return true;
- }
-
- if (this.currentPageHasPrev && this.wrapAroundSearch) {
- return true;
- }
- return false;
- }
- ViewerFindState.prototype.isSinglePageReport = function() {
- return (this.currentPageNo == 1 && !this.currentPageHasNext && !this.currentPageHasPrev);
- }
- ViewerFindState.prototype.findOnServerInProgress = function() {
- return this.findingOnServerInProgress;
- }
- ViewerFindState.prototype.findOnServerStarted = function() {
- this.findingOnServerInProgress = true;
- this.matchesFoundOnServer = false;
- this.searchedOnServer = true;
- }
- ViewerFindState.prototype.findOnServerDone = function() {
- this.findingOnServerInProgress = false
- }
- ViewerFindState.prototype.foundMatchesInReport = function() {
- return this.matchesFoundInReport;
- }
- ViewerFindState.prototype.updatePageInfo = function(matches, currentPage, hasNextPage, hasPrevPage) {
- this.currentPageNo = currentPage;
- this.currentPageHasPrev = hasPrevPage;
- this.currentPageHasNext = hasNextPage;
- this.matches = matches;
- this.focus_index = -1;
-
-
- if (matches && matches.length>0) {
- this.matchesFoundInReport = true;
- this.matchesUpdateCount++;
- if (this.pageFirstMatchFound ==-1) {
- this.pageFirstMatchFound = currentPage;
- }
- }
- }
- ViewerFindState.prototype.resetPageInfo = function() {
- this.updatePageInfo(null, -1, false, false);
- }
- ViewerFindState.prototype.getMatches = function() {
- return this.matches;
- }
- ViewerFindState.prototype.firstMatch = function() {
- if (this.matches && this.matches.length > 0 ) {
- this.focus_index = 0;
- return this.matches[this.focus_index];
- }
- return null;
- }
- ViewerFindState.prototype.nextMatch = function() {
- if (this.matches && this.matches.length > (this.focus_index+1) ) {
- return this.matches[++this.focus_index];
- }
- return null;
- }
- ViewerFindState.prototype.hasNext = function() {
- return (this.matches && this.matches.length > (this.focus_index+1) );
- }
- ViewerFindState.prototype.getFocusedMatch = function() {
- if (this.matches && this.matches.length>0 && this.focus_index >=0) {
- return this.matches[this.focus_index];
- }
- return null;
- }
- ViewerFindState.prototype.getKeyword = function() {
- return this.keyword;
- }
- ViewerFindState.prototype.isCaseSensitive = function() {
- return this.caseSensitive;
- }
- ViewerFindState.prototype.isWrapAroundSearch = function() {
- return this.wrapAroundSearch;
- }
- ViewerFindState.prototype.isRepeating = function() {
-
- if (this.isSinglePageReport()) {
- return this.pageFirstMatchFound == this.currentPageNo;
- } else {
- return (this.pageFirstMatchFound == this.currentPageNo && this.matchesUpdateCount>1);
- }
- };
|