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