[DE PE] refactoring

This commit is contained in:
Maxim Kadushkin 2022-12-11 13:40:41 +03:00
parent 2c15f82cb9
commit 7188921e5a
6 changed files with 54 additions and 52 deletions

View file

@ -207,6 +207,14 @@ define([
case '2': this.api.SetFontRenderingMode(2); break;
}
if ( !Common.Utils.isIE ) {
if ( /^https?:\/\//.test('{{HELP_CENTER_WEB_DE}}') ) {
const _url_obj = new URL('{{HELP_CENTER_WEB_DE}}');
_url_obj.searchParams.set('lang', Common.Locale.getCurrentLanguage());
Common.Utils.InternalSettings.set("url-help-center", _url_obj.toString());
}
}
this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this));
this.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(this.onDocumentContentReady, this));
this.api.asc_registerCallback('asc_onOpenDocumentProgress', _.bind(this.onOpenDocument, this));

View file

@ -69,7 +69,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

@ -2041,14 +2041,6 @@ define([
this.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
this.openUrl = null;
if ( !Common.Utils.isIE ) {
if ( /^https?:\/\//.test('{{HELP_CENTER_WEB_DE}}') ) {
const _url_obj = new URL('{{HELP_CENTER_WEB_DE}}');
_url_obj.searchParams.set('lang', Common.Locale.getCurrentLanguage());
this.urlHelpCenter = _url_obj.toString();
}
}
this.en_data = [
{"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Document Editor user interface", "headername": "Program Interface"},
{"src": "ProgramInterface/FileTab.htm", "name": "File tab"},
@ -2168,22 +2160,10 @@ define([
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
store.fetch(config);
} else {
if ( Common.Controllers.Desktop.isActive() ) {
if ( store.contentLang === '{{DEFAULT_LANG}}' || !Common.Controllers.Desktop.helpUrl() ) {
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
store.contentLang = store.contentLang === lang ? '{{DEFAULT_LANG}}' : lang;
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/' + store.contentLang + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.reset(me.en_data);
}
}
},
success: function () {
var rec = me.openUrl ? store.find(function(record){
@ -2196,10 +2176,22 @@ define([
me.onSelectItem(me.openUrl ? me.openUrl : rec.get('src'));
}
};
if ( Common.Controllers.Desktop.isActive() ) {
if ( !Common.Controllers.Desktop.isHelpAvailable() ) {
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
store.url = 'resources/help/' + lang + '/Contents.json';
store.fetch(config);
this.urlPref = 'resources/help/' + lang + '/';
}
}
},
show: function (url) {

View file

@ -182,6 +182,14 @@ define([
Common.Utils.InternalSettings.set("pe-settings-fontrender", value);
this.api.SetFontRenderingMode(parseInt(value));
if ( !Common.Utils.isIE ) {
if ( /^https?:\/\//.test('{{HELP_CENTER_WEB_PE}}') ) {
const _url_obj = new URL('{{HELP_CENTER_WEB_PE}}');
_url_obj.searchParams.set('lang', Common.Locale.getCurrentLanguage());
Common.Utils.InternalSettings.set("url-help-center", _url_obj.toString());
}
}
this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this));
this.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(this.onDocumentContentReady, this));
this.api.asc_registerCallback('asc_onOpenDocumentProgress', _.bind(this.onOpenDocument, this));

View file

@ -72,7 +72,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

@ -1535,14 +1535,6 @@ define([
this.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
this.openUrl = null;
if ( !Common.Utils.isIE ) {
if ( /^https?:\/\//.test('{{HELP_CENTER_WEB_PE}}') ) {
const _url_obj = new URL('{{HELP_CENTER_WEB_PE}}');
_url_obj.searchParams.set('lang', Common.Locale.getCurrentLanguage());
this.urlHelpCenter = _url_obj.toString();
}
}
this.en_data = [
{"src": "ProgramInterface/ProgramInterface.htm", "name": "Introducing Presentation Editor user interface", "headername": "Program Interface"},
{"src": "ProgramInterface/FileTab.htm", "name": "File tab"},
@ -1645,22 +1637,10 @@ define([
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
store.fetch(config);
} else {
if ( Common.Controllers.Desktop.isActive() ) {
if ( store.contentLang === '{{DEFAULT_LANG}}' || !Common.Controllers.Desktop.helpUrl() ) {
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
store.contentLang = store.contentLang === lang ? '{{DEFAULT_LANG}}' : lang;
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/' + store.contentLang + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.reset(me.en_data);
}
}
},
success: function () {
var rec = me.openUrl ? store.find(function(record){
@ -1673,10 +1653,22 @@ define([
me.onSelectItem(me.openUrl ? me.openUrl : rec.get('src'));
}
};
if ( Common.Controllers.Desktop.isActive() ) {
if ( !Common.Controllers.Desktop.isHelpAvailable() ) {
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
store.url = 'resources/help/' + lang + '/Contents.json';
store.fetch(config);
this.urlPref = 'resources/help/' + lang + '/';
}
}
},
show: function (url) {