[PE] Make new search: edit shortcut method
This commit is contained in:
parent
f91f696cd6
commit
dbf08b77bc
|
@ -79,7 +79,8 @@ define([
|
||||||
'LeftMenu': {
|
'LeftMenu': {
|
||||||
'panel:show': _.bind(this.menuExpand, this),
|
'panel:show': _.bind(this.menuExpand, this),
|
||||||
'comments:show': _.bind(this.commentsShowHide, this, 'show'),
|
'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': {
|
'FileMenu': {
|
||||||
'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'),
|
'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'),
|
||||||
|
@ -648,10 +649,31 @@ define([
|
||||||
if ((!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) {
|
if ((!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) {
|
||||||
Common.UI.Menu.Manager.hideAll();
|
Common.UI.Menu.Manager.hideAll();
|
||||||
var full_menu_pressed = this.leftMenu.btnAbout.pressed;
|
var full_menu_pressed = this.leftMenu.btnAbout.pressed;
|
||||||
this.showSearchDlg(true,s);
|
|
||||||
this.leftMenu.btnSearch.toggle(true,true);
|
|
||||||
this.leftMenu.btnAbout.toggle(false);
|
this.leftMenu.btnAbout.toggle(false);
|
||||||
full_menu_pressed && this.menuExpand(this.leftMenu.btnAbout, 'files', 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;
|
return false;
|
||||||
case 'save':
|
case 'save':
|
||||||
|
@ -682,6 +704,10 @@ define([
|
||||||
return false;
|
return false;
|
||||||
case 'escape':
|
case 'escape':
|
||||||
// if (!this.leftMenu.isOpened()) return true;
|
// 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:
|
// TODO:
|
||||||
if ( this.leftMenu.menuFile.isVisible() ) {
|
if ( this.leftMenu.menuFile.isVisible() ) {
|
||||||
if (Common.UI.HintManager.needCloseFileMenu())
|
if (Common.UI.HintManager.needCloseFileMenu())
|
||||||
|
@ -774,24 +800,37 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onShowHideSearch: function (state, findText, action) {
|
onShowHideSearch: function (state, findText) {
|
||||||
if (state) {
|
if (state) {
|
||||||
Common.UI.Menu.Manager.hideAll();
|
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.leftMenu.showMenu('advancedsearch');
|
||||||
|
this.onShowAfterSearch(findText);
|
||||||
} else {
|
} else {
|
||||||
this.leftMenu.btnSearchBar.toggle(false, true);
|
this.leftMenu.btnSearchBar.toggle(false, true);
|
||||||
this.leftMenu.onBtnMenuClick(this.leftMenu.btnSearchBar);
|
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) {
|
onMenuSearchBar: function(obj, show) {
|
||||||
if (show) {
|
if (show) {
|
||||||
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
|
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
|
||||||
this.leftMenu.panelSearch.setSearchMode(mode);
|
this.leftMenu.panelSearch.setSearchMode(mode);
|
||||||
}
|
}
|
||||||
|
this.leftMenu._state.isSearchOpen = show;
|
||||||
|
},
|
||||||
|
|
||||||
|
isSearchPanelVisible: function () {
|
||||||
|
return this.leftMenu._state.isSearchOpen;
|
||||||
},
|
},
|
||||||
|
|
||||||
showHistory: function() {
|
showHistory: function() {
|
||||||
|
|
|
@ -174,6 +174,7 @@ define([
|
||||||
|
|
||||||
Common.NotificationCenter.on('app:face', this.onAppShowed.bind(this));
|
Common.NotificationCenter.on('app:face', this.onAppShowed.bind(this));
|
||||||
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
|
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
|
||||||
|
Common.NotificationCenter.on('search:show', _.bind(this.onSearchShow, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
onAppShowed: function (config) {
|
onAppShowed: function (config) {
|
||||||
|
@ -343,7 +344,7 @@ define([
|
||||||
|
|
||||||
me.header.btnOptions.menu.on('item:click', me.onOptionsItemClick.bind(this));
|
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) {
|
onLayoutChanged: function(area) {
|
||||||
|
@ -514,22 +515,32 @@ define([
|
||||||
Common.localStorage.setBool('pe-hidden-notes', !bIsShow);
|
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) {
|
if (!this.searchBar) {
|
||||||
this.searchBar = new Common.UI.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.header.btnSearch.pressed) {
|
||||||
if (this.searchBar.isVisible()) {
|
this.searchBar.show(this.api.asc_GetSelectedText());
|
||||||
this.searchBar.focus();
|
|
||||||
} else {
|
|
||||||
this.searchBar.show();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.searchBar.hide();
|
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',
|
textFitPage: 'Fit to Page',
|
||||||
|
|
|
@ -255,6 +255,7 @@ define([
|
||||||
if (this.panelSearch) {
|
if (this.panelSearch) {
|
||||||
if (this.btnSearchBar.pressed) {
|
if (this.btnSearchBar.pressed) {
|
||||||
this.panelSearch.show();
|
this.panelSearch.show();
|
||||||
|
this.fireEvent('search:aftershow', this);
|
||||||
} else {
|
} else {
|
||||||
this.panelSearch.hide();
|
this.panelSearch.hide();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue