diff --git a/apps/common/main/lib/template/SearchPanel.template b/apps/common/main/lib/template/SearchPanel.template
index 808667fbe..079887f33 100644
--- a/apps/common/main/lib/template/SearchPanel.template
+++ b/apps/common/main/lib/template/SearchPanel.template
@@ -1,6 +1,6 @@
diff --git a/apps/common/main/lib/view/SearchBar.js b/apps/common/main/lib/view/SearchBar.js
index acb2e9252..f7b9c3e0d 100644
--- a/apps/common/main/lib/view/SearchBar.js
+++ b/apps/common/main/lib/view/SearchBar.js
@@ -152,7 +152,8 @@ define([
},
onOpenPanel: function () {
-
+ this.hide();
+ this.fireEvent('search:show', [true]);
},
textFind: 'Find'
diff --git a/apps/common/main/lib/view/SearchPanel.js b/apps/common/main/lib/view/SearchPanel.js
index 7d23f33f6..864d155b2 100644
--- a/apps/common/main/lib/view/SearchPanel.js
+++ b/apps/common/main/lib/view/SearchPanel.js
@@ -50,12 +50,17 @@ define([
initialize: function(options) {
_.extend(this, options);
Common.UI.BaseView.prototype.initialize.call(this, arguments);
+
+ this.isEdit = options.mode.isEdit;
},
render: function(el) {
if (!this.rendered) {
el = el || this.el;
- $(el).html(this.template({scope: this}));
+ $(el).html(this.template({
+ scope: this,
+ headerText: this.isEdit ? this.textFindAndReplace : this.textFind
+ }));
this.$el = $(el);
this.buttonClose = new Common.UI.Button({
@@ -90,6 +95,7 @@ define([
},
textFind: 'Find',
+ textFindAndReplace: 'Find and replace',
textCloseSearch: 'Close search'
}, Common.Views.SearchPanel || {}));
diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js
index 53c704c04..67ac025c4 100644
--- a/apps/documenteditor/main/app/controller/LeftMenu.js
+++ b/apps/documenteditor/main/app/controller/LeftMenu.js
@@ -110,6 +110,9 @@ define([
},
'ViewTab': {
'viewtab:navigation': _.bind(this.onShowHideNavigation, this)
+ },
+ 'SearchBar': {
+ 'search:show': _.bind(this.onShowHideSearch, this)
}
});
@@ -172,6 +175,8 @@ define([
if (this.mode.canUseHistory)
this.getApplication().getController('Common.Controllers.History').setApi(this.api).setMode(this.mode);
this.getApplication().getController('PageThumbnails').setApi(this.api).setMode(this.mode);
+ this.getApplication().getController('Search').setApi(this.api).setMode(this.mode);
+ this.leftMenu.setOptionsPanel('advancedsearch', this.getApplication().getController('Search').getView('Common.Views.SearchPanel'));
return this;
},
@@ -192,8 +197,6 @@ define([
},
createDelayedElements: function() {
- this.leftMenu.setOptionsPanel('searchbar', this.getApplication().getController('Search').getView('Common.Views.SearchPanel'));
-
/** coauthoring begin **/
if ( this.mode.canCoAuthoring ) {
this.leftMenu.btnComments[(this.mode.canViewComments && !this.mode.isLightVersion) ? 'show' : 'hide']();
@@ -915,6 +918,16 @@ define([
}
},
+ onShowHideSearch: function (state) {
+ if (state) {
+ Common.UI.Menu.Manager.hideAll();
+ this.leftMenu.showMenu('advancedsearch');
+ } else {
+ this.leftMenu.btnSearchBar.toggle(false, true);
+ this.leftMenu.onBtnMenuClick(this.leftMenu.btnSearchBar);
+ }
+ },
+
isCommentsVisible: function() {
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
},
diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js
index 0fe0ac009..a53fb2ad5 100644
--- a/apps/documenteditor/main/app/controller/Search.js
+++ b/apps/documenteditor/main/app/controller/Search.js
@@ -63,8 +63,10 @@ define([
},
onLaunch: function () {
this._state = {};
+ },
- this.view = this.createView('Common.Views.SearchPanel');
+ setMode: function (mode) {
+ this.view = this.createView('Common.Views.SearchPanel', { mode: mode });
},
setApi: function (api) {
diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js
index 7673a3f4b..0f62363aa 100644
--- a/apps/documenteditor/main/app/view/LeftMenu.js
+++ b/apps/documenteditor/main/app/view/LeftMenu.js
@@ -103,7 +103,7 @@ define([
});
this.btnSearchBar = new Common.UI.Button({
- action: 'searchbar',
+ action: 'advancedsearch',
el: $markup.elementById('#left-btn-searchbar'),
hint: this.tipSearch + Common.Utils.String.platformKey('Ctrl+F'),
disabled: true,
@@ -303,7 +303,7 @@ define([
if (name == 'thumbnails') {
this.panelThumbnails = panel.render('#left-panel-thumbnails');
}
- if (name == 'searchbar') {
+ if (name == 'advancedsearch') {
this.panelSearch = panel.render('#left-panel-search');
}
},
@@ -411,6 +411,13 @@ define([
this.onBtnMenuClick(this.btnNavigation);
this.onCoauthOptions();
}
+ } else if (menu == 'advancedsearch') {
+ if (this.btnSearchBar.isVisible() &&
+ !this.btnSearchBar.isDisabled() && !this.btnSearchBar.pressed) {
+ this.btnSearchBar.toggle(true);
+ this.onBtnMenuClick(this.btnSearchBar);
+ this.onCoauthOptions();
+ }
}
/** coauthoring end **/
}