From 30445d51b650a11462f71ae1c4a53703f5df0e8b Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Thu, 6 Jun 2019 14:44:02 +0300 Subject: [PATCH] [SSE mobile] Add Highlight results into search --- .../mobile/app/controller/Search.js | 25 ++++++++++++++++--- .../mobile/app/template/Search.template | 13 ++++++++++ .../mobile/app/view/Search.js | 12 ++++++++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/app/controller/Search.js b/apps/spreadsheeteditor/mobile/app/controller/Search.js index f9a4dbad5..20ba32618 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Search.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Search.js @@ -81,7 +81,8 @@ define([ 'searchbar:show' : this.onSearchbarShow, 'searchbar:hide' : this.onSearchbarHide, 'searchbar:render' : this.onSearchbarRender, - 'searchbar:showsettings': this.onSearchbarSettings + 'searchbar:showsettings': this.onSearchbarSettings, + 'search:highlight' : this.onSearchHighlight } }); }, @@ -168,22 +169,26 @@ define([ searchIn = Common.SharedSettings.get('search-in') === 'sheet' ? 'sheet' : 'workbook', isMatchCase = Common.SharedSettings.get('search-match-case') === true, isMatchCell = Common.SharedSettings.get('search-match-cell') === true, + isHighlightRes = Common.SharedSettings.get('search-highlight-res') === true, $pageSettings = $('.page[data-page=search-settings]'), $inputType = $pageSettings.find('input[name=search-type]'), $inputSearchIn = $pageSettings.find('input[name=search-in]'), $inputMatchCase = $pageSettings.find('#search-match-case input:checkbox'), - $inputMatchCell = $pageSettings.find('#search-match-cell input:checkbox'); + $inputMatchCell = $pageSettings.find('#search-match-cell input:checkbox'), + $inputHighlightResults = $pageSettings.find('#search-highlight-res input:checkbox'); $inputType.val([isReplace ? 'replace' : 'search']); $inputSearchIn.val([searchIn]); $inputMatchCase.prop('checked', isMatchCase); $inputMatchCell.prop('checked', isMatchCell); + $inputHighlightResults.prop('checked', isHighlightRes); // init events $inputType.single('change', _.bind(me.onTypeChange, me)); $inputSearchIn.single('change', _.bind(me.onSearchInChange, me)); $inputMatchCase.single('change', _.bind(me.onMatchCaseClick, me)); $inputMatchCell.single('change', _.bind(me.onMatchCellClick, me)); + $inputHighlightResults.single('change', _.bind(me.onHighlightResultsClick, me)); }, onSearchbarShow: function(bar) { @@ -241,7 +246,11 @@ define([ }, onReplace: function (btn) { - this.onQueryReplace(this.searchBar.query, this.replaceBar.query); + var me = this; + me.onQueryReplace(me.searchBar.query, me.replaceBar.query); + setTimeout(function () { + me.onQuerySearch(me.searchBar.query, 'next'); + }, 10); }, onReplaceAll: function (e) { @@ -359,6 +368,16 @@ define([ Common.SharedSettings.set('search-match-cell', $(e.currentTarget).is(':checked')); }, + onHighlightResultsClick: function (e) { + var value = $(e.currentTarget).is(':checked'); + Common.SharedSettings.set('search-highlight-res', value); + this.api.asc_selectSearchingResults(value); + }, + + onSearchHighlight: function(w, highlight) { + this.api.asc_selectSearchingResults(highlight); + }, + // API handlers textNoTextFound: 'Text not found', diff --git a/apps/spreadsheeteditor/mobile/app/template/Search.template b/apps/spreadsheeteditor/mobile/app/template/Search.template index e12450b88..9676c84b6 100644 --- a/apps/spreadsheeteditor/mobile/app/template/Search.template +++ b/apps/spreadsheeteditor/mobile/app/template/Search.template @@ -123,6 +123,19 @@ +
  • +
    +
    +
    <%= scope.textHighlightRes %>
    +
    + +
    +
    +
    +
  • diff --git a/apps/spreadsheeteditor/mobile/app/view/Search.js b/apps/spreadsheeteditor/mobile/app/view/Search.js index b10a29840..776daedc7 100644 --- a/apps/spreadsheeteditor/mobile/app/view/Search.js +++ b/apps/spreadsheeteditor/mobile/app/view/Search.js @@ -155,6 +155,13 @@ define([ me.fireEvent('searchbar:render', me); me.fireEvent('searchbar:show', me); + if(Common.SharedSettings.get('search-highlight-res') === undefined) { + Common.SharedSettings.set('search-highlight-res', true); + } + if (Common.SharedSettings.get('search-highlight-res')) { + this.fireEvent('search:highlight', [this, true]); + } + searchBar = $$('.searchbar.document'); _.defer(function() { @@ -188,6 +195,8 @@ define([ uiApp.hideNavbar(searchBar); }, 10); } + + this.fireEvent('search:highlight', [this, false]); }, textFind: 'Find', @@ -199,7 +208,8 @@ define([ textMatchCell: 'Match Cell', textSearchIn: 'Search In', textWorkbook: 'Workbook', - textSheet: 'Sheet' + textSheet: 'Sheet', + textHighlightRes: 'Highlight results' } })(), SSE.Views.Search || {})) }); \ No newline at end of file