[DE] New search: add methods in controller
This commit is contained in:
parent
ab5241d11a
commit
2bf17f6f5a
|
@ -35,6 +35,9 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="padding-small"><div id="search-adv-use-regexp"></div></td>
|
<td class="padding-small"><div id="search-adv-use-regexp"></div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="padding-small"><div id="search-adv-match-word"></div></td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -73,6 +73,7 @@ define([
|
||||||
Common.UI.Window.prototype.initialize.call(this, this.options);
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
||||||
|
|
||||||
Common.NotificationCenter.on('layout:changed', _.bind(this.onLayoutChanged, this));
|
Common.NotificationCenter.on('layout:changed', _.bind(this.onLayoutChanged, this));
|
||||||
|
$(window).on('resize', _.bind(this.onLayoutChanged, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
|
@ -88,6 +88,7 @@ define([
|
||||||
dataHint: '1',
|
dataHint: '1',
|
||||||
dataHintDirection: 'bottom'
|
dataHintDirection: 'bottom'
|
||||||
});
|
});
|
||||||
|
this.btnBack.on('click', _.bind(this.onBtnClick, this, 'next'));
|
||||||
|
|
||||||
this.btnNext = new Common.UI.Button({
|
this.btnNext = new Common.UI.Button({
|
||||||
parentEl: $('#search-adv-next'),
|
parentEl: $('#search-adv-next'),
|
||||||
|
@ -96,14 +97,17 @@ define([
|
||||||
dataHint: '1',
|
dataHint: '1',
|
||||||
dataHintDirection: 'bottom'
|
dataHintDirection: 'bottom'
|
||||||
});
|
});
|
||||||
|
this.btnNext.on('click', _.bind(this.onBtnClick, this, 'next'));
|
||||||
|
|
||||||
this.btnReplace = new Common.UI.Button({
|
this.btnReplace = new Common.UI.Button({
|
||||||
el: $('#search-adv-replace')
|
el: $('#search-adv-replace')
|
||||||
});
|
});
|
||||||
|
this.btnReplace.on('click', _.bind(this.onBtnClick, this, 'replace'));
|
||||||
|
|
||||||
this.btnReplaceAll = new Common.UI.Button({
|
this.btnReplaceAll = new Common.UI.Button({
|
||||||
el: $('#search-adv-replace-all')
|
el: $('#search-adv-replace-all')
|
||||||
});
|
});
|
||||||
|
this.btnReplaceAll.on('click', _.bind(this.onBtnClick, this, 'replaceall'));
|
||||||
|
|
||||||
this.chCaseSensitive = new Common.UI.CheckBox({
|
this.chCaseSensitive = new Common.UI.CheckBox({
|
||||||
el: $('#search-adv-case-sensitive'),
|
el: $('#search-adv-case-sensitive'),
|
||||||
|
@ -121,6 +125,14 @@ define([
|
||||||
dataHintOffset: 'small'
|
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({
|
this.buttonClose = new Common.UI.Button({
|
||||||
parentEl: $('#search-btn-close', this.$el),
|
parentEl: $('#search-btn-close', this.$el),
|
||||||
cls: 'btn-toolbar',
|
cls: 'btn-toolbar',
|
||||||
|
@ -145,6 +157,14 @@ define([
|
||||||
this.fireEvent('hide', this );
|
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) {
|
ChangeSettings: function(props) {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -156,6 +176,18 @@ define([
|
||||||
Common.NotificationCenter.trigger('leftmenu:change', 'hide');
|
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',
|
textFind: 'Find',
|
||||||
textFindAndReplace: 'Find and replace',
|
textFindAndReplace: 'Find and replace',
|
||||||
textCloseSearch: 'Close search',
|
textCloseSearch: 'Close search',
|
||||||
|
@ -164,7 +196,8 @@ define([
|
||||||
textSearchResults: 'Search results: {0}/{1}',
|
textSearchResults: 'Search results: {0}/{1}',
|
||||||
textReplaceWith: 'Replace with',
|
textReplaceWith: 'Replace with',
|
||||||
textCaseSensitive: 'Case sensitive',
|
textCaseSensitive: 'Case sensitive',
|
||||||
textMatchUsingRegExp: 'Match using regular expressions'
|
textMatchUsingRegExp: 'Match using regular expressions',
|
||||||
|
textWholeWords: 'Whole words only',
|
||||||
|
|
||||||
}, Common.Views.SearchPanel || {}));
|
}, Common.Views.SearchPanel || {}));
|
||||||
});
|
});
|
|
@ -58,6 +58,12 @@ define([
|
||||||
'SearchBar': {
|
'SearchBar': {
|
||||||
'search:back': _.bind(this.onQuerySearch, this, 'back'),
|
'search:back': _.bind(this.onQuerySearch, this, 'back'),
|
||||||
'search:next': _.bind(this.onQuerySearch, this, 'next'),
|
'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) {
|
onQuerySearch: function (d, w, opts) {
|
||||||
if (opts.textsearch && opts.textsearch.length) {
|
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;
|
var me = this;
|
||||||
Common.UI.info({
|
Common.UI.info({
|
||||||
msg: this.textNoTextFound,
|
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.',
|
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',
|
||||||
|
|
||||||
}, DE.Controllers.Search || {}));
|
}, DE.Controllers.Search || {}));
|
||||||
|
|
Loading…
Reference in a new issue