+
of 0
@@ -255,6 +256,8 @@
+
+
diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js
index c2a007ef8..309d7bd06 100644
--- a/apps/documenteditor/embed/js/ApplicationController.js
+++ b/apps/documenteditor/embed/js/ApplicationController.js
@@ -75,6 +75,8 @@ DE.ApplicationController = new(function(){
embedConfig = $.extend(embedConfig, data.config.embedded);
common.controller.modals.init(embedConfig);
+ common.controller.SearchBar.init(embedConfig);
+
// Docked toolbar
if (embedConfig.toolbarDocked === 'bottom') {
@@ -450,6 +452,10 @@ DE.ApplicationController = new(function(){
embed: '#idt-embed'
});
+ common.controller.SearchBar.attach({
+ search: '#id-search'
+ });
+
api.asc_registerCallback('asc_onStartAction', onLongActionBegin);
api.asc_registerCallback('asc_onEndAction', onLongActionEnd);
api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart);
@@ -912,6 +918,8 @@ DE.ApplicationController = new(function(){
Common.Gateway.on('opendocument', loadDocument);
Common.Gateway.on('showmessage', onExternalMessage);
Common.Gateway.appReady();
+
+ common.controller.SearchBar.setApi(api);
}
return me;
diff --git a/apps/documenteditor/embed/js/SearchBar.js b/apps/documenteditor/embed/js/SearchBar.js
new file mode 100644
index 000000000..0ac1b28e6
--- /dev/null
+++ b/apps/documenteditor/embed/js/SearchBar.js
@@ -0,0 +1,175 @@
+/*
+ *
+ * (c) Copyright Ascensio System SIA 2010-2020
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
+ * street, Riga, Latvia, EU, LV-1050.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+ */
+
+/**
+ * SearchBar.js
+ *
+ * Created by Julia Svinareva on 27.04.2022
+ * Copyright (c) 2022 Ascensio System SIA. All rights reserved.
+ *
+ */
+
++function () {
+ !window.common && (window.common = {});
+ !common.controller && (common.controller = {});
+
+ common.controller.SearchBar = new(function() {
+ var $searchBar,
+ $searchBtn,
+ $searchInput,
+ appConfig,
+ api,
+ _state = {
+ searchText: ''
+ },
+ _lastInputChange,
+ _searchTimer;
+
+ var setApi = function (appApi) {
+ api = appApi;
+ if (api) {
+ api.asc_registerCallback('asc_onSetSearchCurrent', onApiUpdateSearchCurrent);
+ }
+ };
+
+ var create = function () {
+ $searchBar = common.view.SearchBar.create();
+ if (appConfig.toolbarDocked === 'bottom') {
+ $searchBar.css({'right': '45px', 'bottom': '31px'});
+ } else {
+ $searchBar.css({'right': '45px', 'top': '31px'});
+ }
+
+ $searchInput = $searchBar.find('#search-bar-text');
+ $searchInput.on('input', function(e){
+ common.view.SearchBar.disableNavButtons();
+ onInputSearchChange($searchInput.val());
+ }).on('keydown', function (e) {
+ onSearchNext('keydown', $searchInput.val(), e);
+ });
+ $searchBar.find('#search-bar-back').on('click', function(e){
+ onSearchNext('back', $searchInput.val());
+ });
+ $searchBar.find('#search-bar-next').on('click', function(e){
+ onSearchNext('next', $searchInput.val());
+ });
+ $searchBar.find('#search-bar-close').on('click', function(e){
+ highlightResults(false);
+ $searchBar.hide();
+ $searchBtn.find('button').button('toggle');
+ });
+
+ common.view.SearchBar.disableNavButtons();
+ };
+
+ var attachToView = function(config) {
+ if ( !$searchBar ) {
+ create();
+ }
+
+ $searchBtn = $(config.search);
+ $searchBtn.on('click', function(e){
+ if ($searchBar.is(':visible')) {
+ highlightResults(false);
+ $searchBar.hide();
+ } else {
+ highlightResults(true);
+ var text = (api && api.asc_GetSelectedText()) || _state.searchText;
+ $searchInput.val(text);
+ (text.length > 0) && onInputSearchChange(text);
+
+ $searchBar.show();
+ $searchInput.focus();
+ $searchInput.select();
+ }
+ $searchBtn.find('button').button('toggle');
+ });
+ };
+
+ var onInputSearchChange = function (text) {
+ if (_state.searchText !== text) {
+ _state.newSearchText = text;
+ _lastInputChange = (new Date());
+ if (_searchTimer === undefined) {
+ _searchTimer = setInterval(function() {
+ if ((new Date()) - _lastInputChange < 400) return;
+
+ _state.searchText = _state.newSearchText;
+ (_state.newSearchText !== '') && onQuerySearch();
+ clearInterval(_searchTimer);
+ _searchTimer = undefined;
+ }, 10);
+ }
+ }
+ };
+
+ var onQuerySearch = function (d, w) {
+ var searchSettings = new AscCommon.CSearchSettings();
+ searchSettings.put_Text(_state.searchText);
+ searchSettings.put_MatchCase(false);
+ searchSettings.put_WholeWords(false);
+ if (!api.asc_findText(searchSettings, d != 'back')) {
+ common.view.SearchBar.disableNavButtons();
+ return false;
+ }
+ return true;
+ };
+
+ var onSearchNext = function (type, text, e) {
+ if (text && text.length > 0 && (type === 'keydown' && e.keyCode === 13 || type !== 'keydown')) {
+ _state.searchText = text;
+ if (onQuerySearch(type) && _searchTimer) {
+ clearInterval(_searchTimer);
+ _searchTimer = undefined;
+ }
+ }
+ };
+
+ var onApiUpdateSearchCurrent = function (current, all) {
+ common.view.SearchBar.disableNavButtons(current, all);
+ };
+
+ var highlightResults = function (val) {
+ if (_state.isHighlightedResults !== val) {
+ api.asc_selectSearchingResults(val);
+ _state.isHighlightedResults = val;
+ }
+ };
+
+ return {
+ init: function(config) { appConfig = config; },
+ attach: attachToView,
+ setApi: setApi
+ };
+ });
+}();
\ No newline at end of file
diff --git a/apps/presentationeditor/embed/index.html b/apps/presentationeditor/embed/index.html
index a8f46bea0..bbe83d6e5 100644
--- a/apps/presentationeditor/embed/index.html
+++ b/apps/presentationeditor/embed/index.html
@@ -250,6 +250,7 @@
+
of 0
@@ -305,6 +306,8 @@
+
+
diff --git a/apps/presentationeditor/embed/js/ApplicationController.js b/apps/presentationeditor/embed/js/ApplicationController.js
index d451768e3..74d4e5ec4 100644
--- a/apps/presentationeditor/embed/js/ApplicationController.js
+++ b/apps/presentationeditor/embed/js/ApplicationController.js
@@ -72,6 +72,7 @@ PE.ApplicationController = new(function(){
embedConfig = $.extend(embedConfig, data.config.embedded);
common.controller.modals.init(embedConfig);
+ common.controller.SearchBar.init(embedConfig);
// Docked toolbar
if (embedConfig.toolbarDocked === 'bottom') {
@@ -293,6 +294,10 @@ PE.ApplicationController = new(function(){
embed: '#idt-embed'
});
+ common.controller.SearchBar.attach({
+ search: '#id-search'
+ });
+
api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart);
api.asc_registerCallback('asc_onMouseMoveEnd', onDocMouseMoveEnd);
api.asc_registerCallback('asc_onMouseMove', onDocMouseMove);
@@ -720,6 +725,8 @@ PE.ApplicationController = new(function(){
Common.Gateway.on('opendocument', loadDocument);
Common.Gateway.on('showmessage', onExternalMessage);
Common.Gateway.appReady();
+
+ common.controller.SearchBar.setApi(api);
}
return me;
diff --git a/apps/presentationeditor/embed/js/SearchBar.js b/apps/presentationeditor/embed/js/SearchBar.js
new file mode 100644
index 000000000..ab3f3905a
--- /dev/null
+++ b/apps/presentationeditor/embed/js/SearchBar.js
@@ -0,0 +1,165 @@
+/*
+ *
+ * (c) Copyright Ascensio System SIA 2010-2020
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
+ * street, Riga, Latvia, EU, LV-1050.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+ */
+
+/**
+ * SearchBar.js
+ *
+ * Created by Julia Svinareva on 27.04.2022
+ * Copyright (c) 2022 Ascensio System SIA. All rights reserved.
+ *
+ */
+
++function () {
+ !window.common && (window.common = {});
+ !common.controller && (common.controller = {});
+
+ common.controller.SearchBar = new(function() {
+ var $searchBar,
+ $searchBtn,
+ $searchInput,
+ appConfig,
+ api,
+ _state = {
+ searchText: ''
+ },
+ _lastInputChange,
+ _searchTimer;
+
+ var setApi = function (appApi) {
+ api = appApi;
+ if (api) {
+ api.asc_registerCallback('asc_onSetSearchCurrent', onApiUpdateSearchCurrent);
+ }
+ };
+
+ var create = function () {
+ $searchBar = common.view.SearchBar.create();
+ if (appConfig.toolbarDocked === 'bottom') {
+ $searchBar.css({'right': '45px', 'bottom': '31px'});
+ } else {
+ $searchBar.css({'right': '45px', 'top': '31px'});
+ }
+
+ $searchInput = $searchBar.find('#search-bar-text');
+ $searchInput.on('input', function(e){
+ common.view.SearchBar.disableNavButtons();
+ onInputSearchChange($searchInput.val());
+ }).on('keydown', function (e) {
+ onSearchNext('keydown', $searchInput.val(), e);
+ });
+ $searchBar.find('#search-bar-back').on('click', function(e){
+ onSearchNext('back', $searchInput.val());
+ });
+ $searchBar.find('#search-bar-next').on('click', function(e){
+ onSearchNext('next', $searchInput.val());
+ });
+ $searchBar.find('#search-bar-close').on('click', function(e){
+ $searchBar.hide();
+ $searchBtn.find('button').button('toggle');
+ });
+
+ common.view.SearchBar.disableNavButtons();
+ };
+
+ var attachToView = function(config) {
+ if ( !$searchBar ) {
+ create();
+ }
+
+ $searchBtn = $(config.search);
+ $searchBtn.on('click', function(e){
+ if ($searchBar.is(':visible')) {
+ $searchBar.hide();
+ } else {
+ var text = (api && api.asc_GetSelectedText()) || _state.searchText;
+ $searchInput.val(text);
+ (text.length > 0) && onInputSearchChange(text);
+
+ $searchBar.show();
+ $searchInput.focus();
+ $searchInput.select();
+ }
+ $searchBtn.find('button').button('toggle');
+ });
+ };
+
+ var onInputSearchChange = function (text) {
+ if (_state.searchText !== text) {
+ _state.newSearchText = text;
+ _lastInputChange = (new Date());
+ if (_searchTimer === undefined) {
+ _searchTimer = setInterval(function() {
+ if ((new Date()) - _lastInputChange < 400) return;
+
+ _state.searchText = _state.newSearchText;
+ (_state.newSearchText !== '') && onQuerySearch();
+ clearInterval(_searchTimer);
+ _searchTimer = undefined;
+ }, 10);
+ }
+ }
+ };
+
+ var onQuerySearch = function (d, w) {
+ var searchSettings = new AscCommon.CSearchSettings();
+ searchSettings.put_Text(_state.searchText);
+ searchSettings.put_MatchCase(false);
+ searchSettings.put_WholeWords(false);
+ if (!api.asc_findText(searchSettings, d != 'back')) {
+ common.view.SearchBar.disableNavButtons();
+ return false;
+ }
+ return true;
+ };
+
+ var onSearchNext = function (type, text, e) {
+ if (text && text.length > 0 && (type === 'keydown' && e.keyCode === 13 || type !== 'keydown')) {
+ _state.searchText = text;
+ if (onQuerySearch(type) && _searchTimer) {
+ clearInterval(_searchTimer);
+ _searchTimer = undefined;
+ }
+ }
+ };
+
+ var onApiUpdateSearchCurrent = function (current, all) {
+ common.view.SearchBar.disableNavButtons(current, all);
+ };
+
+ return {
+ init: function(config) { appConfig = config; },
+ attach: attachToView,
+ setApi: setApi
+ };
+ });
+}();
\ No newline at end of file
diff --git a/apps/spreadsheeteditor/embed/index.html b/apps/spreadsheeteditor/embed/index.html
index 94cf225af..f626036aa 100644
--- a/apps/spreadsheeteditor/embed/index.html
+++ b/apps/spreadsheeteditor/embed/index.html
@@ -224,6 +224,7 @@
+
@@ -281,6 +282,8 @@
+
+
diff --git a/apps/spreadsheeteditor/embed/js/ApplicationController.js b/apps/spreadsheeteditor/embed/js/ApplicationController.js
index 5e0d7bcf4..aaebbc0f5 100644
--- a/apps/spreadsheeteditor/embed/js/ApplicationController.js
+++ b/apps/spreadsheeteditor/embed/js/ApplicationController.js
@@ -74,6 +74,7 @@ SSE.ApplicationController = new(function(){
embedConfig = $.extend(embedConfig, data.config.embedded);
common.controller.modals.init(embedConfig);
+ common.controller.SearchBar.init(embedConfig);
// Docked toolbar
if (embedConfig.toolbarDocked === 'bottom') {
@@ -232,6 +233,10 @@ SSE.ApplicationController = new(function(){
embed: '#idt-embed'
});
+ common.controller.SearchBar.attach({
+ search: '#id-search'
+ });
+
api.asc_registerCallback('asc_onMouseMove', onApiMouseMove);
api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink);
api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl);
@@ -666,6 +671,8 @@ SSE.ApplicationController = new(function(){
Common.Gateway.on('opendocument', loadDocument);
Common.Gateway.on('showmessage', onExternalMessage);
Common.Gateway.appReady();
+
+ common.controller.SearchBar.setApi(api);
}
return me;
diff --git a/apps/spreadsheeteditor/embed/js/SearchBar.js b/apps/spreadsheeteditor/embed/js/SearchBar.js
new file mode 100644
index 000000000..dfc5fe20b
--- /dev/null
+++ b/apps/spreadsheeteditor/embed/js/SearchBar.js
@@ -0,0 +1,179 @@
+/*
+ *
+ * (c) Copyright Ascensio System SIA 2010-2020
+ *
+ * This program is a free software product. You can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License (AGPL)
+ * version 3 as published by the Free Software Foundation. In accordance with
+ * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
+ * that Ascensio System SIA expressly excludes the warranty of non-infringement
+ * of any third-party rights.
+ *
+ * This program is distributed WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
+ * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
+ *
+ * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
+ * street, Riga, Latvia, EU, LV-1050.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of the Program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU AGPL version 3.
+ *
+ * Pursuant to Section 7(b) of the License you must retain the original Product
+ * logo when distributing the program. Pursuant to Section 7(e) we decline to
+ * grant you any rights under trademark law for use of our trademarks.
+ *
+ * All the Product's GUI elements, including illustrations and icon sets, as
+ * well as technical writing content are licensed under the terms of the
+ * Creative Commons Attribution-ShareAlike 4.0 International. See the License
+ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
+ *
+ */
+
+/**
+ * SearchBar.js
+ *
+ * Created by Julia Svinareva on 27.04.2022
+ * Copyright (c) 2022 Ascensio System SIA. All rights reserved.
+ *
+ */
+
++function () {
+ !window.common && (window.common = {});
+ !common.controller && (common.controller = {});
+
+ common.controller.SearchBar = new(function() {
+ var $searchBar,
+ $searchBtn,
+ $searchInput,
+ appConfig,
+ api,
+ _state = {
+ searchText: ''
+ },
+ _lastInputChange,
+ _searchTimer;
+
+ var setApi = function (appApi) {
+ api = appApi;
+ if (api) {
+ api.asc_registerCallback('asc_onSetSearchCurrent', onApiUpdateSearchCurrent);
+ }
+ };
+
+ var create = function () {
+ $searchBar = common.view.SearchBar.create();
+ if (appConfig.toolbarDocked === 'bottom') {
+ $searchBar.css({'right': '45px', 'bottom': '31px'});
+ } else {
+ $searchBar.css({'right': '45px', 'top': '31px'});
+ }
+
+ $searchInput = $searchBar.find('#search-bar-text');
+ $searchInput.on('input', function(e){
+ common.view.SearchBar.disableNavButtons();
+ onInputSearchChange($searchInput.val());
+ }).on('keydown', function (e) {
+ onSearchNext('keydown', $searchInput.val(), e);
+ });
+ $searchBar.find('#search-bar-back').on('click', function(e){
+ onSearchNext('back', $searchInput.val());
+ });
+ $searchBar.find('#search-bar-next').on('click', function(e){
+ onSearchNext('next', $searchInput.val());
+ });
+ $searchBar.find('#search-bar-close').on('click', function(e){
+ highlightResults(false);
+ $searchBar.hide();
+ $searchBtn.find('button').button('toggle');
+ });
+
+ common.view.SearchBar.disableNavButtons();
+ };
+
+ var attachToView = function(config) {
+ if ( !$searchBar ) {
+ create();
+ }
+
+ $searchBtn = $(config.search);
+ $searchBtn.on('click', function(e){
+ if ($searchBar.is(':visible')) {
+ highlightResults(false);
+ $searchBar.hide();
+ } else {
+ highlightResults(true);
+ var text = (api && api.asc_GetSelectedText()) || _state.searchText;
+ $searchInput.val(text);
+ (text.length > 0) && onInputSearchChange(text);
+
+ $searchBar.show();
+ $searchInput.focus();
+ $searchInput.select();
+ }
+ $searchBtn.find('button').button('toggle');
+ });
+ };
+
+ var onInputSearchChange = function (text) {
+ if (_state.searchText !== text) {
+ _state.newSearchText = text;
+ _lastInputChange = (new Date());
+ if (_searchTimer === undefined) {
+ _searchTimer = setInterval(function() {
+ if ((new Date()) - _lastInputChange < 400) return;
+
+ _state.searchText = _state.newSearchText;
+ (_state.newSearchText !== '') && onQuerySearch();
+ clearInterval(_searchTimer);
+ _searchTimer = undefined;
+ }, 10);
+ }
+ }
+ };
+
+ var onQuerySearch = function (d, w) {
+ var options = new Asc.asc_CFindOptions();
+ options.asc_setFindWhat(_state.searchText);
+ options.asc_setScanForward(d != 'back');
+ options.asc_setIsMatchCase(false);
+ options.asc_setIsWholeCell(false);
+ options.asc_setScanOnOnlySheet(Asc.c_oAscSearchBy.Sheet);
+ options.asc_setScanByRows(true);
+ options.asc_setLookIn(Asc.c_oAscFindLookIn.Formulas);
+ if (!api.asc_findText(options)) {
+ common.view.SearchBar.disableNavButtons();
+ return false;
+ }
+ return true;
+ };
+
+ var onSearchNext = function (type, text, e) {
+ if (text && text.length > 0 && (type === 'keydown' && e.keyCode === 13 || type !== 'keydown')) {
+ _state.searchText = text;
+ if (onQuerySearch(type) && _searchTimer) {
+ clearInterval(_searchTimer);
+ _searchTimer = undefined;
+ }
+ }
+ };
+
+ var onApiUpdateSearchCurrent = function (current, all) {
+ common.view.SearchBar.disableNavButtons(current, all);
+ };
+
+ var highlightResults = function (val) {
+ if (_state.isHighlightedResults !== val) {
+ api.asc_selectSearchingResults(val);
+ _state.isHighlightedResults = val;
+ }
+ };
+
+ return {
+ init: function(config) { appConfig = config; },
+ attach: attachToView,
+ setApi: setApi
+ };
+ });
+}();
\ No newline at end of file