[DE PE SSE] Fix search
This commit is contained in:
		
							parent
							
								
									aa91f6263c
								
							
						
					
					
						commit
						f1744a3737
					
				| 
						 | 
				
			
			@ -165,7 +165,7 @@ define([
 | 
			
		|||
 | 
			
		||||
        onLayoutChanged: function () {
 | 
			
		||||
            var top = $('#app-title').height() + $('#toolbar').height() + 2,
 | 
			
		||||
                left = Common.Utils.innerWidth() - $('#right-menu').width() - this.options.width - 32;
 | 
			
		||||
                left = Common.Utils.innerWidth() - ($('#right-menu').is(':visible') ? $('#right-menu').width() : 0) - this.options.width - 32;
 | 
			
		||||
            this.$window.css({left: left, top: top});
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -208,12 +208,7 @@ define([
 | 
			
		|||
                searchSettings.put_MatchCase(this._state.matchCase);
 | 
			
		||||
                searchSettings.put_WholeWords(this._state.matchWord);
 | 
			
		||||
                if (!this.api.asc_replaceText(searchSettings, textReplace, false)) {
 | 
			
		||||
                    this.resultItems = [];
 | 
			
		||||
                    this.view.updateResultsNumber(undefined, 0);
 | 
			
		||||
                    this.view.disableReplaceButtons(true);
 | 
			
		||||
                    this._state.currentResult = 0;
 | 
			
		||||
                    this._state.resultsNumber = 0;
 | 
			
		||||
                    this.view.disableNavButtons();
 | 
			
		||||
                    this.allResultsWasRemoved();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			@ -240,11 +235,20 @@ define([
 | 
			
		|||
                searchSettings.put_WholeWords(this._state.matchWord);
 | 
			
		||||
                this.api.asc_replaceText(searchSettings, textReplace, true);
 | 
			
		||||
 | 
			
		||||
                this.hideResults();
 | 
			
		||||
                this.resultItems = [];
 | 
			
		||||
                this.allResultsWasRemoved();
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        allResultsWasRemoved: function () {
 | 
			
		||||
            this.resultItems = [];
 | 
			
		||||
            this.hideResults();
 | 
			
		||||
            this.view.updateResultsNumber(undefined, 0);
 | 
			
		||||
            this.view.disableReplaceButtons(true);
 | 
			
		||||
            this._state.currentResult = 0;
 | 
			
		||||
            this._state.resultsNumber = 0;
 | 
			
		||||
            this.view.disableNavButtons();
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onUpdateSearchCurrent: function (current, all) {
 | 
			
		||||
            if (current === -1) return;
 | 
			
		||||
            this._state.currentResult = current;
 | 
			
		||||
| 
						 | 
				
			
			@ -252,7 +256,7 @@ define([
 | 
			
		|||
            if (this.view) {
 | 
			
		||||
                this.view.updateResultsNumber(current, all);
 | 
			
		||||
                this.view.disableNavButtons(current, all);
 | 
			
		||||
                if (this.resultItems.length > 0) {
 | 
			
		||||
                if (this.resultItems && this.resultItems.length > 0) {
 | 
			
		||||
                    this.resultItems.forEach(function (item) {
 | 
			
		||||
                        item.selected = false;
 | 
			
		||||
                    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -191,12 +191,7 @@ define([
 | 
			
		|||
                searchSettings.put_MatchCase(this._state.matchCase);
 | 
			
		||||
                searchSettings.put_WholeWords(this._state.matchWord);
 | 
			
		||||
                if (!this.api.asc_replaceText(searchSettings, textReplace, false)) {
 | 
			
		||||
                    this.resultItems = [];
 | 
			
		||||
                    this.view.updateResultsNumber(undefined, 0);
 | 
			
		||||
                    this.view.disableReplaceButtons(true);
 | 
			
		||||
                    this._state.currentResult = 0;
 | 
			
		||||
                    this._state.resultsNumber = 0;
 | 
			
		||||
                    this.view.disableNavButtons();
 | 
			
		||||
                    this.allResultsWasRemoved();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			@ -209,11 +204,20 @@ define([
 | 
			
		|||
                searchSettings.put_WholeWords(this._state.matchWord);
 | 
			
		||||
                this.api.asc_replaceText(searchSettings, textReplace, true);
 | 
			
		||||
 | 
			
		||||
                this.hideResults();
 | 
			
		||||
                this.resultItems = [];
 | 
			
		||||
                this.allResultsWasRemoved();
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        allResultsWasRemoved: function () {
 | 
			
		||||
            this.resultItems = [];
 | 
			
		||||
            this.hideResults();
 | 
			
		||||
            this.view.updateResultsNumber(undefined, 0);
 | 
			
		||||
            this.view.disableReplaceButtons(true);
 | 
			
		||||
            this._state.currentResult = 0;
 | 
			
		||||
            this._state.resultsNumber = 0;
 | 
			
		||||
            this.view.disableNavButtons();
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onUpdateSearchCurrent: function (current, all) {
 | 
			
		||||
            if (current === -1) return;
 | 
			
		||||
            this._state.currentResult = current;
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +225,7 @@ define([
 | 
			
		|||
            if (this.view) {
 | 
			
		||||
                this.view.updateResultsNumber(current, all);
 | 
			
		||||
                this.view.disableNavButtons(current, all);
 | 
			
		||||
                if (this.resultItems.length > 0) {
 | 
			
		||||
                if (this.resultItems && this.resultItems.length > 0) {
 | 
			
		||||
                    this.resultItems.forEach(function (item) {
 | 
			
		||||
                        item.selected = false;
 | 
			
		||||
                    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -311,12 +311,7 @@ define([
 | 
			
		|||
            var me = this;
 | 
			
		||||
            if (this.api.isReplaceAll) {
 | 
			
		||||
                if (!found) {
 | 
			
		||||
                    this.resultItems = [];
 | 
			
		||||
                    this.view.updateResultsNumber(undefined, 0);
 | 
			
		||||
                    this.view.disableReplaceButtons(true);
 | 
			
		||||
                    this._state.currentResult = 0;
 | 
			
		||||
                    this._state.resultsNumber = 0;
 | 
			
		||||
                    this.view.disableNavButtons();
 | 
			
		||||
                    this.allResultsWasRemoved();
 | 
			
		||||
                } else {
 | 
			
		||||
                    Common.UI.info({
 | 
			
		||||
                        msg: !found-replaced ? Common.Utils.String.format(this.textReplaceSuccess,replaced) : Common.Utils.String.format(this.textReplaceSkipped,found-replaced),
 | 
			
		||||
| 
						 | 
				
			
			@ -338,14 +333,19 @@ define([
 | 
			
		|||
                options.asc_setScanByRows(this._state.searchByRows);
 | 
			
		||||
                options.asc_setLookIn(this._state.lookInFormulas ? Asc.c_oAscFindLookIn.Formulas : Asc.c_oAscFindLookIn.Value);
 | 
			
		||||
                if (!this.api.asc_findText(options)) {
 | 
			
		||||
                    this.allResultsWasRemoved();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        allResultsWasRemoved: function () {
 | 
			
		||||
            this.resultItems = [];
 | 
			
		||||
            this.hideResults();
 | 
			
		||||
            this.view.updateResultsNumber(undefined, 0);
 | 
			
		||||
            this.view.disableReplaceButtons(true);
 | 
			
		||||
            this._state.currentResult = 0;
 | 
			
		||||
            this._state.resultsNumber = 0;
 | 
			
		||||
            this.view.disableNavButtons();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        onApiRemoveTextAroundSearch: function (arr) {
 | 
			
		||||
| 
						 | 
				
			
			@ -366,7 +366,7 @@ define([
 | 
			
		|||
            if (this.view) {
 | 
			
		||||
                this.view.updateResultsNumber(current, all);
 | 
			
		||||
                this.view.disableNavButtons(current, all);
 | 
			
		||||
                if (this.resultItems.length > 0) {
 | 
			
		||||
                if (this.resultItems && this.resultItems.length > 0) {
 | 
			
		||||
                    this.resultItems.forEach(function (item) {
 | 
			
		||||
                        item.selected = false;
 | 
			
		||||
                    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue