[PE] Make new search: edit shortcut method

This commit is contained in:
JuliaSvinareva 2022-03-04 17:38:29 +03:00
parent f91f696cd6
commit dbf08b77bc
3 changed files with 68 additions and 17 deletions

View file

@ -79,7 +79,8 @@ define([
'LeftMenu': {
'panel:show': _.bind(this.menuExpand, this),
'comments:show': _.bind(this.commentsShowHide, this, 'show'),
'comments:hide': _.bind(this.commentsShowHide, this, 'hide')
'comments:hide': _.bind(this.commentsShowHide, this, 'hide'),
'search:aftershow': _.bind(this.onShowAfterSearch, this)
},
'FileMenu': {
'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'),
@ -648,10 +649,31 @@ define([
if ((!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) {
Common.UI.Menu.Manager.hideAll();
var full_menu_pressed = this.leftMenu.btnAbout.pressed;
this.showSearchDlg(true,s);
this.leftMenu.btnSearch.toggle(true,true);
this.leftMenu.btnAbout.toggle(false);
full_menu_pressed && this.menuExpand(this.leftMenu.btnAbout, 'files', false);
var selectedText = this.api.asc_GetSelectedText();
if (this.isSearchPanelVisible()) {
selectedText && this.leftMenu.panelSearch.setFindText(selectedText);
this.leftMenu.panelSearch.focus(s);
return false;
} else if (this.getApplication().getController('Viewport').isSearchBarVisible()) {
if (s === 'replace') {
this.getApplication().getController('Viewport').header.btnSearch.toggle(false);
this.onShowHideSearch(true, this.getApplication().getController('Viewport').searchBar.inputSearch.val());
} else {
selectedText && this.getApplication().getController('Viewport').searchBar.setText(selectedText);
this.getApplication().getController('Viewport').searchBar.focus();
return false;
}
} else if (s === 'search') {
Common.NotificationCenter.trigger('search:show');
return false;
} else {
this.onShowHideSearch(true, selectedText);
}
this.leftMenu.btnSearchBar.toggle(true,true);
this.leftMenu.panelSearch.focus(s);
}
return false;
case 'save':
@ -682,6 +704,10 @@ define([
return false;
case 'escape':
// if (!this.leftMenu.isOpened()) return true;
var btnSearch = this.getApplication().getController('Viewport').header.btnSearch;
btnSearch.pressed && btnSearch.toggle(false);
this.leftMenu._state.isSearchOpen && (this.leftMenu._state.isSearchOpen = false);
// TODO:
if ( this.leftMenu.menuFile.isVisible() ) {
if (Common.UI.HintManager.needCloseFileMenu())
@ -774,24 +800,37 @@ define([
}
},
onShowHideSearch: function (state, findText, action) {
onShowHideSearch: function (state, findText) {
if (state) {
Common.UI.Menu.Manager.hideAll();
var mode = this.mode.isEdit && !this.viewmode ? (action || undefined) : 'no-replace';
findText && this.leftMenu.panelSearch.setFindText(findText);
this.leftMenu.panelSearch.setSearchMode(mode);
this.leftMenu.showMenu('advancedsearch');
this.onShowAfterSearch(findText);
} else {
this.leftMenu.btnSearchBar.toggle(false, true);
this.leftMenu.onBtnMenuClick(this.leftMenu.btnSearchBar);
}
},
onShowAfterSearch: function (findText) {
var text = findText || this.api.asc_GetSelectedText();
if (text) {
this.leftMenu.panelSearch.setFindText(text);
} else if (text !== undefined) {
this.leftMenu.panelSearch.setFindText('');
}
this.leftMenu.panelSearch.focus();
},
onMenuSearchBar: function(obj, show) {
if (show) {
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
this.leftMenu.panelSearch.setSearchMode(mode);
}
this.leftMenu._state.isSearchOpen = show;
},
isSearchPanelVisible: function () {
return this.leftMenu._state.isSearchOpen;
},
showHistory: function() {

View file

@ -174,6 +174,7 @@ define([
Common.NotificationCenter.on('app:face', this.onAppShowed.bind(this));
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
Common.NotificationCenter.on('search:show', _.bind(this.onSearchShow, this));
},
onAppShowed: function (config) {
@ -343,7 +344,7 @@ define([
me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this));
}
me.header.btnSearch.on('click', me.onSearchClick.bind(this));
me.header.btnSearch.on('toggle', me.onSearchToggle.bind(this));
},
onLayoutChanged: function(area) {
@ -514,22 +515,32 @@ define([
Common.localStorage.setBool('pe-hidden-notes', !bIsShow);
},
onSearchClick: function () {
onSearchShow: function () {
this.header.btnSearch && this.header.btnSearch.toggle(true);
},
onSearchToggle: function () {
var leftMenu = this.getApplication().getController('LeftMenu');
if (leftMenu.isSearchPanelVisible()) {
this.header.btnSearch.toggle(false, true);
leftMenu.getView('LeftMenu').panelSearch.focus();
return;
}
if (!this.searchBar) {
this.searchBar = new Common.UI.SearchBar({});
this.searchBar.on('hide', _.bind(function () {
this.header.btnSearch.toggle(false, true);
}, this));
}
if (this.header.btnSearch.pressed) {
if (this.searchBar.isVisible()) {
this.searchBar.focus();
} else {
this.searchBar.show();
}
this.searchBar.show(this.api.asc_GetSelectedText());
} else {
this.searchBar.hide();
}
this.searchBar.on('hide', _.bind(function () {
this.header.btnSearch.toggle(false);
}, this));
},
isSearchBarVisible: function () {
return this.searchBar && this.searchBar.isVisible();
},
textFitPage: 'Fit to Page',

View file

@ -255,6 +255,7 @@ define([
if (this.panelSearch) {
if (this.btnSearchBar.pressed) {
this.panelSearch.show();
this.fireEvent('search:aftershow', this);
} else {
this.panelSearch.hide();
}