[DE] Make new search: edit shortcut method
This commit is contained in:
parent
2bfe6b2d2c
commit
f91f696cd6
|
@ -116,12 +116,17 @@ define([
|
|||
return this;
|
||||
},
|
||||
|
||||
show: function() {
|
||||
show: function(text) {
|
||||
var top = $('#app-title').height() + $('#toolbar').height() + 2,
|
||||
left = Common.Utils.innerWidth() - ($('#right-menu').is(':visible') ? $('#right-menu').width() : 0) - this.options.width - 32;
|
||||
Common.UI.Window.prototype.show.call(this, left, top);
|
||||
|
||||
this.inputSearch.val('');
|
||||
if (text) {
|
||||
this.inputSearch.val(text);
|
||||
} else {
|
||||
this.inputSearch.val('');
|
||||
}
|
||||
|
||||
this.focus();
|
||||
},
|
||||
|
||||
|
@ -133,6 +138,10 @@ define([
|
|||
}, 10);
|
||||
},
|
||||
|
||||
setText: function (text) {
|
||||
this.inputSearch.val(text);
|
||||
},
|
||||
|
||||
getSettings: function() {
|
||||
return {
|
||||
|
||||
|
|
|
@ -210,11 +210,12 @@ define([
|
|||
this.fireEvent('hide', this );
|
||||
},
|
||||
|
||||
focus: function() {
|
||||
var me = this;
|
||||
focus: function(type) {
|
||||
var me = this,
|
||||
el = type === 'replace' ? me.inputReplace.$el : me.inputText.$el;
|
||||
setTimeout(function(){
|
||||
me.inputText.$el.find('input').focus();
|
||||
me.inputText.$el.find('input').select();
|
||||
el.find('input').focus();
|
||||
el.find('input').select();
|
||||
}, 10);
|
||||
},
|
||||
|
||||
|
@ -243,7 +244,7 @@ define([
|
|||
textreplace : this.inputReplace.getValue(),
|
||||
matchcase : this.chCaseSensitive.checked,
|
||||
useregexp : this.chUseRegExp.checked,
|
||||
matchword : this.chMatchWord.checked,
|
||||
matchword : this.chMatchWord && this.chMatchWord.checked,
|
||||
//highlight : this.miHighlight.checked
|
||||
};
|
||||
this.fireEvent('search:'+action, [this, opts, true]);
|
||||
|
|
|
@ -80,7 +80,8 @@ define([
|
|||
},
|
||||
'LeftMenu': {
|
||||
'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'),
|
||||
|
@ -798,10 +799,29 @@ define([
|
|||
switch (s) {
|
||||
case 'replace':
|
||||
case 'search':
|
||||
Common.UI.Menu.Manager.hideAll();
|
||||
this.showSearchDlg(true,s);
|
||||
this.leftMenu.btnSearch.toggle(true,true);
|
||||
this.leftMenu.btnAbout.toggle(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);
|
||||
// this.leftMenu.menuFile.hide();
|
||||
return false;
|
||||
case 'save':
|
||||
|
@ -921,24 +941,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;
|
||||
},
|
||||
|
||||
isCommentsVisible: function() {
|
||||
|
|
|
@ -164,6 +164,7 @@ define([
|
|||
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
|
||||
Common.NotificationCenter.on('uitheme:changed', this.onThemeChanged.bind(this));
|
||||
Common.NotificationCenter.on('contenttheme:dark', this.onContentThemeChangedToDark.bind(this));
|
||||
Common.NotificationCenter.on('search:show', _.bind(this.onSearchShow, this));
|
||||
},
|
||||
|
||||
onAppShowed: function (config) {
|
||||
|
@ -339,7 +340,7 @@ define([
|
|||
me.header.menuItemsDarkMode.$el.prev('.divider').hide();
|
||||
}
|
||||
}
|
||||
me.header.btnSearch.on('click', me.onSearchClick.bind(this));
|
||||
me.header.btnSearch.on('toggle', me.onSearchToggle.bind(this));
|
||||
},
|
||||
|
||||
onLayoutChanged: function(area) {
|
||||
|
@ -462,22 +463,32 @@ define([
|
|||
this.header && this.header.lockHeaderBtns( 'rename-user', disable);
|
||||
},
|
||||
|
||||
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',
|
||||
|
|
|
@ -271,6 +271,7 @@ define([
|
|||
if (this.panelSearch) {
|
||||
if (this.btnSearchBar.pressed) {
|
||||
this.panelSearch.show();
|
||||
this.fireEvent('search:aftershow', this);
|
||||
} else {
|
||||
this.panelSearch.hide();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue