[DE PE SSE] New search: hide settings in view mode

This commit is contained in:
JuliaSvinareva 2022-03-02 13:58:18 +03:00
parent 3a774f6546
commit 2ac854edc4
5 changed files with 60 additions and 19 deletions

View file

@ -1,6 +1,6 @@
<div id="search-box" class="layout-ct vbox search-panel"> <div id="search-box" class="layout-ct vbox search-panel">
<div id="search-header"> <div id="search-header">
<label><%= headerText %></label> <label id="search-adv-title"></label>
<div id="search-btn-close"></div> <div id="search-btn-close"></div>
</div> </div>
<div id="search-adv-settings"> <div id="search-adv-settings">
@ -9,7 +9,7 @@
<tr> <tr>
<td class="padding-small"><div id="search-adv-text"></div></td> <td class="padding-small"><div id="search-adv-text"></div></td>
</tr> </tr>
<tr> <tr class="edit-setting">
<td class="padding-large"><div id="search-adv-replace-text"></div></td> <td class="padding-large"><div id="search-adv-replace-text"></div></td>
</tr> </tr>
<tr> <tr>
@ -23,7 +23,7 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr class="edit-setting">
<td class="padding-large"> <td class="padding-large">
<button type="button" class="btn btn-text-default" id="search-adv-replace" style="display: inline-block; min-width: 62px;" data-hint="1" data-hint-direction="bottom" data-hint-offset="big"><%= scope.textReplace %></button> <button type="button" class="btn btn-text-default" id="search-adv-replace" style="display: inline-block; min-width: 62px;" data-hint="1" data-hint-direction="bottom" data-hint-offset="big"><%= scope.textReplace %></button>
<button type="button" class="btn btn-text-default" id="search-adv-replace-all" style="display: inline-block; min-width: 78px;" data-hint="1" data-hint-direction="bottom" data-hint-offset="big"><%= scope.textReplaceAll %></button> <button type="button" class="btn btn-text-default" id="search-adv-replace-all" style="display: inline-block; min-width: 78px;" data-hint="1" data-hint-direction="bottom" data-hint-offset="big"><%= scope.textReplaceAll %></button>

View file

@ -51,8 +51,7 @@ define([
_.extend(this, options); _.extend(this, options);
Common.UI.BaseView.prototype.initialize.call(this, arguments); Common.UI.BaseView.prototype.initialize.call(this, arguments);
this.isEdit = options.mode.isEdit; this.mode = false;
window.SSE && (this.extendedOptions = Common.localStorage.getBool('sse-search-options-extended', true)); window.SSE && (this.extendedOptions = Common.localStorage.getBool('sse-search-options-extended', true));
}, },
@ -61,8 +60,7 @@ define([
if (!this.rendered) { if (!this.rendered) {
el = el || this.el; el = el || this.el;
$(el).html(this.template({ $(el).html(this.template({
scope: this, scope: this
headerText: this.isEdit ? this.textFindAndReplace : this.textFind
})); }));
this.$el = $(el); this.$el = $(el);
@ -129,15 +127,6 @@ define([
dataHintOffset: 'small' dataHintOffset: 'small'
}); });
this.chMatchWord = new Common.UI.CheckBox({
el: $('#search-adv-match-word'),
labelText: this.options.matchwordstr || this.textWholeWords,
value: false,
dataHint: '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.buttonClose = new Common.UI.Button({ this.buttonClose = new Common.UI.Button({
parentEl: $('#search-btn-close', this.$el), parentEl: $('#search-btn-close', this.$el),
cls: 'btn-toolbar', cls: 'btn-toolbar',
@ -147,6 +136,14 @@ define([
this.buttonClose.on('click', _.bind(this.onClickClosePanel, this)); this.buttonClose.on('click', _.bind(this.onClickClosePanel, this));
if (window.SSE) { if (window.SSE) {
this.chMatchWord = new Common.UI.CheckBox({
el: $('#search-adv-match-word'),
labelText: this.options.matchwordstr || this.textWholeWords,
value: false,
dataHint: '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.cmbWithin = new Common.UI.ComboBox({ this.cmbWithin = new Common.UI.ComboBox({
el: $('#search-adv-cmb-within'), el: $('#search-adv-cmb-within'),
@ -221,6 +218,14 @@ define([
}, 10); }, 10);
}, },
setSearchMode: function (mode) {
if (this.mode !== mode) {
this.$el.find('.edit-setting')[mode !== 'no-replace' ? 'show' : 'hide']();
this.$el.find('#search-adv-title').text(mode !== 'no-replace' ? this.textFindAndReplace : this.textFind);
this.mode = mode;
}
},
ChangeSettings: function(props) { ChangeSettings: function(props) {
}, },

View file

@ -127,6 +127,7 @@ define([
onLaunch: function() { onLaunch: function() {
this.leftMenu = this.createView('LeftMenu').render(); this.leftMenu = this.createView('LeftMenu').render();
this.leftMenu.btnSearch.on('toggle', _.bind(this.onMenuSearch, this)); this.leftMenu.btnSearch.on('toggle', _.bind(this.onMenuSearch, this));
this.leftMenu.btnSearchBar.on('toggle', _.bind(this.onMenuSearchBar, this));
Common.util.Shortcuts.delegateShortcuts({ Common.util.Shortcuts.delegateShortcuts({
shortcuts: { shortcuts: {
@ -666,6 +667,8 @@ define([
this.viewmode = mode; this.viewmode = mode;
this.dlgSearch && this.dlgSearch.setMode(this.viewmode ? 'no-replace' : 'search'); this.dlgSearch && this.dlgSearch.setMode(this.viewmode ? 'no-replace' : 'search');
this.leftMenu.panelSearch && this.leftMenu.panelSearch.setSearchMode(this.viewmode ? 'no-replace' : 'search');
}, },
SetDisabled: function(disable, options) { SetDisabled: function(disable, options) {
@ -918,9 +921,11 @@ define([
} }
}, },
onShowHideSearch: function (state) { onShowHideSearch: function (state, action) {
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';
this.leftMenu.panelSearch.setSearchMode(mode);
this.leftMenu.showMenu('advancedsearch'); this.leftMenu.showMenu('advancedsearch');
} else { } else {
this.leftMenu.btnSearchBar.toggle(false, true); this.leftMenu.btnSearchBar.toggle(false, true);
@ -928,6 +933,13 @@ define([
} }
}, },
onMenuSearchBar: function(obj, show) {
if (show) {
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
this.leftMenu.panelSearch.setSearchMode(mode);
}
},
isCommentsVisible: function() { isCommentsVisible: function() {
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible(); return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
}, },

View file

@ -124,6 +124,7 @@ define([
this.leftMenu.btnSearch.on('toggle', _.bind(this.onMenuSearch, this)); this.leftMenu.btnSearch.on('toggle', _.bind(this.onMenuSearch, this));
this.leftMenu.btnThumbs.on('toggle', _.bind(this.onShowTumbnails, this)); this.leftMenu.btnThumbs.on('toggle', _.bind(this.onShowTumbnails, this));
this.isThumbsShown = true; this.isThumbsShown = true;
this.leftMenu.btnSearchBar.on('toggle', _.bind(this.onMenuSearchBar, this));
Common.util.Shortcuts.delegateShortcuts({ Common.util.Shortcuts.delegateShortcuts({
shortcuts: { shortcuts: {
@ -537,6 +538,8 @@ define([
this.viewmode = mode; this.viewmode = mode;
this.dlgSearch && this.dlgSearch.setMode(this.viewmode ? 'no-replace' : 'search'); this.dlgSearch && this.dlgSearch.setMode(this.viewmode ? 'no-replace' : 'search');
this.leftMenu.panelSearch && this.leftMenu.panelSearch.setSearchMode(this.viewmode ? 'no-replace' : 'search');
}, },
onApiServerDisconnect: function(enableDownload) { onApiServerDisconnect: function(enableDownload) {
@ -771,9 +774,11 @@ define([
} }
}, },
onShowHideSearch: function (state) { onShowHideSearch: function (state, action) {
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';
this.leftMenu.panelSearch.setSearchMode(mode);
this.leftMenu.showMenu('advancedsearch'); this.leftMenu.showMenu('advancedsearch');
} else { } else {
this.leftMenu.btnSearchBar.toggle(false, true); this.leftMenu.btnSearchBar.toggle(false, true);
@ -781,6 +786,13 @@ define([
} }
}, },
onMenuSearchBar: function(obj, show) {
if (show) {
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
this.leftMenu.panelSearch.setSearchMode(mode);
}
},
showHistory: function() { showHistory: function() {
if (!this.mode.wopi) { if (!this.mode.wopi) {
var maincontroller = PE.getController('Main'); var maincontroller = PE.getController('Main');

View file

@ -116,6 +116,7 @@ define([
onLaunch: function() { onLaunch: function() {
this.leftMenu = this.createView('LeftMenu').render(); this.leftMenu = this.createView('LeftMenu').render();
this.leftMenu.btnSearch.on('toggle', _.bind(this.onMenuSearch, this)); this.leftMenu.btnSearch.on('toggle', _.bind(this.onMenuSearch, this));
this.leftMenu.btnSearchBar.on('toggle', _.bind(this.onMenuSearchBar, this));
Common.util.Shortcuts.delegateShortcuts({ Common.util.Shortcuts.delegateShortcuts({
shortcuts: { shortcuts: {
@ -722,6 +723,8 @@ define([
this.viewmode = mode; this.viewmode = mode;
this.dlgSearch && this.dlgSearch.setMode(this.viewmode ? 'no-replace' : 'search'); this.dlgSearch && this.dlgSearch.setMode(this.viewmode ? 'no-replace' : 'search');
this.leftMenu.panelSearch && this.leftMenu.panelSearch.setSearchMode(this.viewmode ? 'no-replace' : 'search');
}, },
onApiServerDisconnect: function(enableDownload) { onApiServerDisconnect: function(enableDownload) {
@ -980,9 +983,11 @@ define([
} }
}, },
onShowHideSearch: function (state) { onShowHideSearch: function (state, action) {
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';
this.leftMenu.panelSearch.setSearchMode(mode);
this.leftMenu.showMenu('advancedsearch'); this.leftMenu.showMenu('advancedsearch');
} else { } else {
this.leftMenu.btnSearchBar.toggle(false, true); this.leftMenu.btnSearchBar.toggle(false, true);
@ -990,6 +995,13 @@ define([
} }
}, },
onMenuSearchBar: function(obj, show) {
if (show) {
var mode = this.mode.isEdit && !this.viewmode ? undefined : 'no-replace';
this.leftMenu.panelSearch.setSearchMode(mode);
}
},
onMenuChange: function (value) { onMenuChange: function (value) {
if ('hide' === value) { if ('hide' === value) {
if (this.leftMenu.btnComments.isActive() && this.api) { if (this.leftMenu.btnComments.isActive() && this.api) {