[SSE mobile] Add Highlight results into search

This commit is contained in:
Julia Svinareva 2019-06-06 14:44:02 +03:00
parent 4841a1628b
commit 30445d51b6
3 changed files with 46 additions and 4 deletions

View file

@ -81,7 +81,8 @@ define([
'searchbar:show' : this.onSearchbarShow, 'searchbar:show' : this.onSearchbarShow,
'searchbar:hide' : this.onSearchbarHide, 'searchbar:hide' : this.onSearchbarHide,
'searchbar:render' : this.onSearchbarRender, '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', searchIn = Common.SharedSettings.get('search-in') === 'sheet' ? 'sheet' : 'workbook',
isMatchCase = Common.SharedSettings.get('search-match-case') === true, isMatchCase = Common.SharedSettings.get('search-match-case') === true,
isMatchCell = Common.SharedSettings.get('search-match-cell') === true, isMatchCell = Common.SharedSettings.get('search-match-cell') === true,
isHighlightRes = Common.SharedSettings.get('search-highlight-res') === true,
$pageSettings = $('.page[data-page=search-settings]'), $pageSettings = $('.page[data-page=search-settings]'),
$inputType = $pageSettings.find('input[name=search-type]'), $inputType = $pageSettings.find('input[name=search-type]'),
$inputSearchIn = $pageSettings.find('input[name=search-in]'), $inputSearchIn = $pageSettings.find('input[name=search-in]'),
$inputMatchCase = $pageSettings.find('#search-match-case input:checkbox'), $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']); $inputType.val([isReplace ? 'replace' : 'search']);
$inputSearchIn.val([searchIn]); $inputSearchIn.val([searchIn]);
$inputMatchCase.prop('checked', isMatchCase); $inputMatchCase.prop('checked', isMatchCase);
$inputMatchCell.prop('checked', isMatchCell); $inputMatchCell.prop('checked', isMatchCell);
$inputHighlightResults.prop('checked', isHighlightRes);
// init events // init events
$inputType.single('change', _.bind(me.onTypeChange, me)); $inputType.single('change', _.bind(me.onTypeChange, me));
$inputSearchIn.single('change', _.bind(me.onSearchInChange, me)); $inputSearchIn.single('change', _.bind(me.onSearchInChange, me));
$inputMatchCase.single('change', _.bind(me.onMatchCaseClick, me)); $inputMatchCase.single('change', _.bind(me.onMatchCaseClick, me));
$inputMatchCell.single('change', _.bind(me.onMatchCellClick, me)); $inputMatchCell.single('change', _.bind(me.onMatchCellClick, me));
$inputHighlightResults.single('change', _.bind(me.onHighlightResultsClick, me));
}, },
onSearchbarShow: function(bar) { onSearchbarShow: function(bar) {
@ -241,7 +246,11 @@ define([
}, },
onReplace: function (btn) { 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) { onReplaceAll: function (e) {
@ -359,6 +368,16 @@ define([
Common.SharedSettings.set('search-match-cell', $(e.currentTarget).is(':checked')); 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 // API handlers
textNoTextFound: 'Text not found', textNoTextFound: 'Text not found',

View file

@ -123,6 +123,19 @@
</div> </div>
</div> </div>
</li> </li>
<li>
<div id="search-highlight-res" class="item-content">
<div class="item-inner">
<div class="item-title"><%= scope.textHighlightRes %></div>
<div class="item-after">
<label class="label-switch">
<input type="checkbox">
<div class="checkbox"></div>
</label>
</div>
</div>
</div>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -155,6 +155,13 @@ define([
me.fireEvent('searchbar:render', me); me.fireEvent('searchbar:render', me);
me.fireEvent('searchbar:show', 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'); searchBar = $$('.searchbar.document');
_.defer(function() { _.defer(function() {
@ -188,6 +195,8 @@ define([
uiApp.hideNavbar(searchBar); uiApp.hideNavbar(searchBar);
}, 10); }, 10);
} }
this.fireEvent('search:highlight', [this, false]);
}, },
textFind: 'Find', textFind: 'Find',
@ -199,7 +208,8 @@ define([
textMatchCell: 'Match Cell', textMatchCell: 'Match Cell',
textSearchIn: 'Search In', textSearchIn: 'Search In',
textWorkbook: 'Workbook', textWorkbook: 'Workbook',
textSheet: 'Sheet' textSheet: 'Sheet',
textHighlightRes: 'Highlight results'
} }
})(), SSE.Views.Search || {})) })(), SSE.Views.Search || {}))
}); });