diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index a064822b7..43e510ce1 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -62,7 +62,8 @@ define([ 'btn-save-coauth': 'coauth', 'btn-synch': 'synch' }; - var nativevars; + var nativevars, + helpUrl; if ( !!native ) { native.features = native.features || {}; @@ -236,6 +237,45 @@ define([ } } + const _checkHelpAvailable = function () { + const curr_lang = Common.Locale.getCurrentLanguage(); + let url = 'resources/help/' + curr_lang; + fetch(url + '/Contents.json').then(function (response) { + if ( response.ok ) { + /* local help avail */ + helpUrl = url; + } else + if ( curr_lang != Common.Locale.getDefaultLanguage() ) { + url = 'resources/help/' + Common.Locale.getDefaultLanguage(); + fetch(url + '/Contents.json').then(function (response){ + if ( response.ok ) { + /* local help avail. def lang */ + helpUrl = url; + } else + if ( this.helpUrl() ) { + url = this.helpUrl() + curr_lang; + fetch(url + '/Contents.json').then(function (response){ + if ( response.ok ) { + /* remote help avail */ + helpUrl = url; + } else { + url = this.helpUrl() + Common.getDefaultLanguage(); + fetch(url + '/Contents.json').then(function (response){ + if ( response.ok ) { + /* remote help avail. def lang */ + helpUrl = url; + } else { + /* no help avail. open help center */ + } + }); + } + }); + } + }); + } + }); + } + return { init: function (opts) { _.extend(config, opts); @@ -281,6 +321,8 @@ define([ this.close(); }).show(); } + + _checkHelpAvailable(); } }); @@ -450,6 +492,9 @@ define([ } }, helpUrl: function () { + if ( helpUrl ) + return helpUrl; + if ( !!nativevars && nativevars.helpUrl ) { var webapp = window.SSE ? 'spreadsheeteditor' : window.PE ? 'presentationeditor' : 'documenteditor'; @@ -458,6 +503,9 @@ define([ return undefined; }, + helpAvailable: function () { + return !!helpUrl; + }, getDefaultPrinterName: function () { return nativevars ? nativevars.defaultPrinterName : ''; }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 946af7870..42d6165d5 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -197,6 +197,14 @@ define([ Common.Utils.InternalSettings.set("sse-settings-fontrender", value); this.api.asc_setFontRenderingMode(parseInt(value)); + if ( !Common.Utils.isIE ) { + if ( /^https?:\/\//.test('{{HELP_CENTER_WEB_SSE}}') ) { + const _url_obj = new URL('{{HELP_CENTER_WEB_SSE}}'); + _url_obj.searchParams.set('lang', Common.Locale.getCurrentLanguage()); + Common.Utils.InternalSettings.set("url-help-center", _url_obj.toString()); + } + } + this.api.asc_registerCallback('asc_onOpenDocumentProgress', _.bind(this.onOpenDocument, this)); this.api.asc_registerCallback('asc_onEndAction', _.bind(this.onLongActionEnd, this)); this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this)); diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 84b635217..22a2e0c6e 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -59,7 +59,8 @@ define([ if (item.options.action === 'help') { if ( panel.noHelpContents === true && navigator.onLine ) { this.fireEvent('item:click', [this, 'external-help', true]); - !!panel.urlHelpCenter && window.open(panel.urlHelpCenter, '_blank'); + const helpCenter = Common.Utils.InternalSettings.get('url-help-center'); + !!helpCenter && window.open(helpCenter, '_blank'); return; } } diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 76c2ca4b6..f855086e5 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1923,14 +1923,6 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({ this.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; this.openUrl = null; - if ( !Common.Utils.isIE ) { - if ( /^https?:\/\//.test('{{HELP_CENTER_WEB_SSE}}') ) { - const _url_obj = new URL('{{HELP_CENTER_WEB_SSE}}'); - _url_obj.searchParams.set('lang', Common.Locale.getCurrentLanguage()); - this.urlHelpCenter = _url_obj.toString(); - } - } - this.en_data = [ {"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Spreadsheet Editor user interface", "headername": "Program Interface"}, {"src": "ProgramInterface/FileTab.htm", "name": "File tab"}, diff --git a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js index 2bcb0f506..617c49802 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js @@ -456,24 +456,43 @@ define([ lang = (this.lang) ? this.lang.split(/[\-\_]/)[0] : 'en'; var me = this, - name = '/Functions/' + this.funcprops.origin.toLocaleLowerCase().replace(/\./g, '-') + '.htm', + func = this.funcprops.origin.toLocaleLowerCase().replace(/\./g, '-'), + name = '/Functions/' + func + '.htm', url = 'resources/help/' + lang + name; + if ( Common.Controllers.Desktop.isActive() ) { + if ( Common.Controllers.Desktop.helpAvailable() ) + url = Common.Controllers.Desktop.helpUrl() + name; + else { + const helpCenter = Common.Utils.InternalSettings.get('url-help-center'); + if ( helpCenter ) { + const _url_obj = new URL(helpCenter); + _url_obj.searchParams.set('function', func); + + window.open(_url_obj.toString(), '_blank'); + } + + return; + } + } + fetch(url).then(function(response){ if ( response.ok ) { Common.Utils.InternalSettings.set("sse-settings-func-help", lang); me.helpUrl = url; me.showHelp(); } else { - lang = '{{DEFAULT_LANG}}'; - url = 'resources/help/' + lang + name; + url = 'resources/help/' + '{{DEFAULT_LANG}}' + name; fetch(url).then(function(response){ if ( response.ok ) { - Common.Utils.InternalSettings.set("sse-settings-func-help", lang); + Common.Utils.InternalSettings.set("sse-settings-func-help", '{{DEFAULT_LANG}}'); me.helpUrl = url; me.showHelp(); } else { - me.helpUrl = null; + // me.helpUrl = null; + if ( Common.Controllers.Desktop.isActive() ) { + url = 'resources/help/' + lang + name; + } } }); }