[SSE] for bug 59924

This commit is contained in:
Maxim Kadushkin 2022-12-10 00:47:01 +03:00
parent 36fcd1ee61
commit 955c01d65d
5 changed files with 83 additions and 15 deletions
apps
common/main/lib/controller
spreadsheeteditor/main/app

View file

@ -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 : '';
},

View file

@ -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));

View file

@ -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;
}
}

View file

@ -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"},

View file

@ -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;
}
}
});
}