diff --git a/apps/common/main/lib/template/SearchPanel.template b/apps/common/main/lib/template/SearchPanel.template
index 75b4bb0f67..449c7fcbcc 100644
--- a/apps/common/main/lib/template/SearchPanel.template
+++ b/apps/common/main/lib/template/SearchPanel.template
@@ -35,6 +35,9 @@
|
+
+ |
+
diff --git a/apps/common/main/lib/view/SearchBar.js b/apps/common/main/lib/view/SearchBar.js
index f7b9c3e0dc..0ea7c17f9e 100644
--- a/apps/common/main/lib/view/SearchBar.js
+++ b/apps/common/main/lib/view/SearchBar.js
@@ -73,6 +73,7 @@ define([
Common.UI.Window.prototype.initialize.call(this, this.options);
Common.NotificationCenter.on('layout:changed', _.bind(this.onLayoutChanged, this));
+ $(window).on('resize', _.bind(this.onLayoutChanged, this));
},
render: function() {
diff --git a/apps/common/main/lib/view/SearchPanel.js b/apps/common/main/lib/view/SearchPanel.js
index 544c31948f..e22a774e45 100644
--- a/apps/common/main/lib/view/SearchPanel.js
+++ b/apps/common/main/lib/view/SearchPanel.js
@@ -88,6 +88,7 @@ define([
dataHint: '1',
dataHintDirection: 'bottom'
});
+ this.btnBack.on('click', _.bind(this.onBtnClick, this, 'next'));
this.btnNext = new Common.UI.Button({
parentEl: $('#search-adv-next'),
@@ -96,14 +97,17 @@ define([
dataHint: '1',
dataHintDirection: 'bottom'
});
+ this.btnNext.on('click', _.bind(this.onBtnClick, this, 'next'));
this.btnReplace = new Common.UI.Button({
el: $('#search-adv-replace')
});
+ this.btnReplace.on('click', _.bind(this.onBtnClick, this, 'replace'));
this.btnReplaceAll = new Common.UI.Button({
el: $('#search-adv-replace-all')
});
+ this.btnReplaceAll.on('click', _.bind(this.onBtnClick, this, 'replaceall'));
this.chCaseSensitive = new Common.UI.CheckBox({
el: $('#search-adv-case-sensitive'),
@@ -121,6 +125,14 @@ define([
dataHintOffset: 'small'
});
+ this.chMatchWord = new Common.UI.CheckBox({
+ el: $('#search-adv-match-word'),
+ labelText: this.options.matchwordstr || this.textWholeWords,
+ dataHint: '1',
+ dataHintDirection: 'left',
+ dataHintOffset: 'small'
+ });
+
this.buttonClose = new Common.UI.Button({
parentEl: $('#search-btn-close', this.$el),
cls: 'btn-toolbar',
@@ -145,6 +157,14 @@ define([
this.fireEvent('hide', this );
},
+ focus: function() {
+ var me = this;
+ setTimeout(function(){
+ me.inputText.$el.find('input').focus();
+ me.inputText.$el.find('input').select();
+ }, 10);
+ },
+
ChangeSettings: function(props) {
},
@@ -156,6 +176,18 @@ define([
Common.NotificationCenter.trigger('leftmenu:change', 'hide');
},
+ onBtnClick: function(action) {
+ var opts = {
+ textsearch : this.inputText.getValue(),
+ textreplace : this.inputReplace.getValue(),
+ matchcase : this.chCaseSensitive.checked,
+ useregexp : this.chUseRegExp.checked,
+ matchword : this.chMatchWord.checked,
+ //highlight : this.miHighlight.checked
+ };
+ this.fireEvent('search:'+action, [this, opts]);
+ },
+
textFind: 'Find',
textFindAndReplace: 'Find and replace',
textCloseSearch: 'Close search',
@@ -164,7 +196,8 @@ define([
textSearchResults: 'Search results: {0}/{1}',
textReplaceWith: 'Replace with',
textCaseSensitive: 'Case sensitive',
- textMatchUsingRegExp: 'Match using regular expressions'
+ textMatchUsingRegExp: 'Match using regular expressions',
+ textWholeWords: 'Whole words only',
}, Common.Views.SearchPanel || {}));
});
\ No newline at end of file
diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js
index a53fb2ad57..562d3cb2e2 100644
--- a/apps/documenteditor/main/app/controller/Search.js
+++ b/apps/documenteditor/main/app/controller/Search.js
@@ -58,6 +58,12 @@ define([
'SearchBar': {
'search:back': _.bind(this.onQuerySearch, this, 'back'),
'search:next': _.bind(this.onQuerySearch, this, 'next'),
+ },
+ 'Common.Views.SearchPanel': {
+ 'search:back': _.bind(this.onQuerySearch, this, 'back'),
+ 'search:next': _.bind(this.onQuerySearch, this, 'next'),
+ 'search:replace': _.bind(this.onQueryReplace, this),
+ 'search:replaceall': _.bind(this.onQueryReplaceAll, this)
}
});
},
@@ -83,7 +89,7 @@ define([
onQuerySearch: function (d, w, opts) {
if (opts.textsearch && opts.textsearch.length) {
- if (!this.api.asc_findText(opts.textsearch, d != 'back')) {
+ if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) {
var me = this;
Common.UI.info({
msg: this.textNoTextFound,
@@ -95,6 +101,26 @@ define([
}
},
+ onQueryReplace: function(w, opts) {
+ if (!_.isEmpty(opts.textsearch)) {
+ if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) {
+ var me = this;
+ Common.UI.info({
+ msg: this.textNoTextFound,
+ callback: function() {
+ me.view.focus();
+ }
+ });
+ }
+ }
+ },
+
+ onQueryReplaceAll: function(w, opts) {
+ if (!_.isEmpty(opts.textsearch)) {
+ this.api.asc_replaceText(opts.textsearch, opts.textreplace, true, opts.matchcase, opts.matchword);
+ }
+ },
+
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',
}, DE.Controllers.Search || {}));