mirror of
https://github.com/ONLYOFFICE/web-apps.git
synced 2026-07-24 07:31:55 +08:00
Merge pull request #3083 from ONLYOFFICE/feature/units-region-mobile
[DE PE SSE mobile] Adding region parameter for measurement units
This commit is contained in:
@ -20,7 +20,7 @@ import EncodingController from "./Encoding";
|
||||
import DropdownListController from "./DropdownList";
|
||||
import { Device } from '../../../../common/mobile/utils/device';
|
||||
import { processArrayScripts } from '../../../../common/mobile/utils/processArrayScripts.js';
|
||||
|
||||
import '../../../../common/main/lib/util/LanguageInfo.js'
|
||||
@inject(
|
||||
"users",
|
||||
"storeAppOptions",
|
||||
@ -186,6 +186,9 @@ class MainController extends Component {
|
||||
|
||||
this.props.storeAppOptions.wopi = this.editorConfig.wopi;
|
||||
Common.Notifications.trigger('configOptionsFill');
|
||||
|
||||
this.loadDefaultMetricSettings();
|
||||
|
||||
};
|
||||
|
||||
const loadDocument = data => {
|
||||
@ -496,6 +499,36 @@ class MainController extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
loadDefaultMetricSettings() {
|
||||
const appOptions = this.props.storeAppOptions;
|
||||
let region = '';
|
||||
|
||||
if (appOptions.location) {
|
||||
console.log("Obsolete: The 'location' parameter of the 'editorConfig' section is deprecated. Please use 'region' parameter in the 'editorConfig' section instead.");
|
||||
region = appOptions.location;
|
||||
} else if (appOptions.region) {
|
||||
let val = appOptions.region;
|
||||
val = Common.util.LanguageInfo.getLanguages().hasOwnProperty(val) ? Common.util.LanguageInfo.getLocalLanguageName(val)[0] : val;
|
||||
|
||||
if (val && typeof val === 'string') {
|
||||
let arr = val.split(/[\-_]/);
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
}
|
||||
} else {
|
||||
let arr = (appOptions.lang || 'en').split(/[\-_]/);
|
||||
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
if (!region) {
|
||||
arr = (navigator.language || '').split(/[\-_]/);
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
}
|
||||
}
|
||||
|
||||
if (/^(ca|us)$/i.test(region)) {
|
||||
Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch);
|
||||
}
|
||||
}
|
||||
|
||||
changeEditorBrandColorForPdf() {
|
||||
const bodyElement = document.body;
|
||||
bodyElement.classList.add('pdf-view');
|
||||
|
||||
@ -125,6 +125,7 @@ export class storeAppOptions {
|
||||
this.createUrl = config.createUrl;
|
||||
this.lang = config.lang ?? 'en';
|
||||
this.location = (typeof (config.location) == 'string') ? config.location.toLowerCase() : '';
|
||||
this.region = (typeof (config.region) == 'string') ? config.region.toLowerCase() : config.region;
|
||||
this.sharingSettingsUrl = config.sharingSettingsUrl;
|
||||
this.canRequestSharingSettings = config.canRequestSharingSettings;
|
||||
this.fileChoiceUrl = config.fileChoiceUrl;
|
||||
|
||||
@ -17,6 +17,7 @@ import PluginsController from '../../../../common/mobile/lib/controller/Plugins.
|
||||
import { Device } from '../../../../common/mobile/utils/device';
|
||||
import { Themes } from '../../../../common/mobile/lib/controller/Themes.jsx';
|
||||
import { processArrayScripts } from '../../../../common/mobile/utils/processArrayScripts.js';
|
||||
import '../../../../common/main/lib/util/LanguageInfo.js'
|
||||
|
||||
@inject(
|
||||
"users",
|
||||
@ -128,6 +129,8 @@ class MainController extends Component {
|
||||
|
||||
value = LocalStorage.getItem("pe-mobile-allow-macros-request");
|
||||
this.props.storeApplicationSettings.changeMacrosRequest((value !== null) ? parseInt(value) : 0);
|
||||
|
||||
this.loadDefaultMetricSettings();
|
||||
};
|
||||
|
||||
const loadDocument = data => {
|
||||
@ -317,6 +320,36 @@ class MainController extends Component {
|
||||
window.onunload = this.onUnload.bind(this);
|
||||
}
|
||||
|
||||
loadDefaultMetricSettings() {
|
||||
const appOptions = this.props.storeAppOptions;
|
||||
let region = '';
|
||||
|
||||
if (appOptions.location) {
|
||||
console.log("Obsolete: The 'location' parameter of the 'editorConfig' section is deprecated. Please use 'region' parameter in the 'editorConfig' section instead.");
|
||||
region = appOptions.location;
|
||||
} else if (appOptions.region) {
|
||||
let val = appOptions.region;
|
||||
val = Common.util.LanguageInfo.getLanguages().hasOwnProperty(val) ? Common.util.LanguageInfo.getLocalLanguageName(val)[0] : val;
|
||||
|
||||
if (val && typeof val === 'string') {
|
||||
let arr = val.split(/[\-_]/);
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
}
|
||||
} else {
|
||||
let arr = (appOptions.lang || 'en').split(/[\-_]/);
|
||||
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
if (!region) {
|
||||
arr = (navigator.language || '').split(/[\-_]/);
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
}
|
||||
}
|
||||
|
||||
if (/^(ca|us)$/i.test(region)) {
|
||||
Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch);
|
||||
}
|
||||
}
|
||||
|
||||
onDocumentModifiedChanged () {
|
||||
const isModified = this.api.asc_isDocumentCanSave();
|
||||
if (this._state.isDocModified !== isModified) {
|
||||
|
||||
@ -60,6 +60,7 @@ export class storeAppOptions {
|
||||
this.createUrl = config.createUrl;
|
||||
this.lang = config.lang;
|
||||
this.location = (typeof (config.location) == 'string') ? config.location.toLowerCase() : '';
|
||||
this.region = (typeof (config.region) == 'string') ? config.region.toLowerCase() : config.region;
|
||||
this.sharingSettingsUrl = config.sharingSettingsUrl;
|
||||
this.fileChoiceUrl = config.fileChoiceUrl;
|
||||
this.mergeFolderUrl = config.mergeFolderUrl;
|
||||
|
||||
@ -24,6 +24,7 @@ import { StatusbarController } from "./Statusbar";
|
||||
import { Device } from '../../../../common/mobile/utils/device';
|
||||
import { Themes } from '../../../../common/mobile/lib/controller/Themes.jsx';
|
||||
import { processArrayScripts } from '../../../../common/mobile/utils/processArrayScripts.js';
|
||||
import '../../../../common/main/lib/util/LanguageInfo.js'
|
||||
|
||||
@inject(
|
||||
"users",
|
||||
@ -188,7 +189,7 @@ class MainController extends Component {
|
||||
EditorUIController.isSupportEditFeature();
|
||||
|
||||
this.editorConfig = Object.assign({}, this.editorConfig, data.config);
|
||||
this.appOptions.lang = this.editorConfig.lang;
|
||||
this.appOptions.lang = this.editorConfig.lang;
|
||||
|
||||
const appOptions = this.props.storeAppOptions;
|
||||
appOptions.setConfigOptions(this.editorConfig, _t);
|
||||
@ -204,30 +205,27 @@ class MainController extends Component {
|
||||
if (value !== null) {
|
||||
this.api.asc_setLocale(parseInt(value));
|
||||
} else {
|
||||
value = appOptions.region;
|
||||
value = Common.util.LanguageInfo.getLanguages().hasOwnProperty(value) ? value : Common.util.LanguageInfo.getLocalLanguageCode(value);
|
||||
if (value !== null) {
|
||||
value = parseInt(value);
|
||||
} else {
|
||||
value = (appOptions.lang) ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(appOptions.lang)) : 0x0409;
|
||||
}
|
||||
this.api.asc_setLocale(value);
|
||||
value = appOptions.region;
|
||||
value = Common.util.LanguageInfo.getLanguages().hasOwnProperty(value) ? value : Common.util.LanguageInfo.getLocalLanguageCode(value);
|
||||
if (value !== null) {
|
||||
value = parseInt(value);
|
||||
} else {
|
||||
value = (appOptions.lang) ? parseInt(Common.util.LanguageInfo.getLocalLanguageCode(appOptions.lang)) : 0x0409;
|
||||
}
|
||||
this.api.asc_setLocale(value);
|
||||
}
|
||||
|
||||
if (appOptions.location == 'us' || appOptions.location == 'ca') {
|
||||
Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch);
|
||||
}
|
||||
|
||||
//if (!appOptions.customization || !(appOptions.customization.loaderName || appOptions.customization.loaderLogo))
|
||||
//$('#editor_sdk').append('<div class="doc-placeholder">' + '<div class="columns"></div>'.repeat(2) + '</div>');
|
||||
this.loadDefaultMetricSettings();
|
||||
|
||||
value = LocalStorage.getItem("sse-mobile-macros-mode");
|
||||
|
||||
if (value === null) {
|
||||
value = appOptions.customization ? appOptions.customization.macrosMode : 'warn';
|
||||
value = (value === 'enable') ? 1 : (value === 'disable' ? 2 : 0);
|
||||
value = appOptions.customization ? appOptions.customization.macrosMode : 'warn';
|
||||
value = (value === 'enable') ? 1 : (value === 'disable' ? 2 : 0);
|
||||
} else {
|
||||
value = parseInt(value);
|
||||
}
|
||||
|
||||
this.props.storeApplicationSettings.changeMacrosSettings(value);
|
||||
|
||||
value = LocalStorage.getItem("sse-mobile-allow-macros-request");
|
||||
@ -395,6 +393,36 @@ class MainController extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
loadDefaultMetricSettings() {
|
||||
const appOptions = this.props.storeAppOptions;
|
||||
let region = '';
|
||||
|
||||
if (appOptions.location) {
|
||||
console.log("Obsolete: The 'location' parameter of the 'editorConfig' section is deprecated. Please use 'region' parameter in the 'editorConfig' section instead.");
|
||||
region = appOptions.location;
|
||||
} else if (appOptions.region) {
|
||||
let val = appOptions.region;
|
||||
val = Common.util.LanguageInfo.getLanguages().hasOwnProperty(val) ? Common.util.LanguageInfo.getLocalLanguageName(val)[0] : val;
|
||||
|
||||
if (val && typeof val === 'string') {
|
||||
let arr = val.split(/[\-_]/);
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
}
|
||||
} else {
|
||||
let arr = (appOptions.lang || 'en').split(/[\-_]/);
|
||||
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
if (!region) {
|
||||
arr = (navigator.language || '').split(/[\-_]/);
|
||||
if (arr.length > 1) region = arr[arr.length - 1]
|
||||
}
|
||||
}
|
||||
|
||||
if (/^(ca|us)$/i.test(region)) {
|
||||
Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch);
|
||||
}
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
$$(window).on('resize', () => {
|
||||
this.api.asc_Resize();
|
||||
|
||||
Reference in New Issue
Block a user