diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index c9e29f643e..cd018fa5b2 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -46,6 +46,7 @@ editorConfig: { mode: 'view or edit', lang: , + location: , canCoAuthoring: , canAutosave: , canBackToFolder: - deprecated. use "customization.goback" parameter, diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 03ef2a714b..94152cb50f 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -259,6 +259,7 @@ Common.Utils.Metric = new(function() { }; me.currentMetric = me.c_MetricUnits.pt; me.metricName = ['cm', 'pt', '\"']; + me.defaultMetric = me.c_MetricUnits.cm; return { c_MetricUnits: me.c_MetricUnits, @@ -272,6 +273,14 @@ Common.Utils.Metric = new(function() { return me.currentMetric; }, + setDefaultMetric: function(value) { + me.defaultMetric = value; + }, + + getDefaultMetric: function() { + return me.defaultMetric; + }, + fnRecalcToMM: function(value) { // value in pt/cm/inch. need to convert to mm if (value!==null && value!==undefined) { diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 85ae7ecc56..21c6102212 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -235,6 +235,7 @@ define([ this.appOptions.recent = this.editorConfig.recent; this.appOptions.createUrl = this.editorConfig.createUrl; this.appOptions.lang = this.editorConfig.lang; + this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : ''; this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl; this.appOptions.fileChoiceUrl = this.editorConfig.fileChoiceUrl; this.appOptions.mergeFolderUrl = this.editorConfig.mergeFolderUrl; @@ -251,6 +252,9 @@ define([ if (this.editorConfig.lang) this.api.asc_setLocale(this.editorConfig.lang); + + if (this.appOptions.location == 'us' || this.appOptions.location == 'ca') + Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch); }, loadDocument: function(data) { @@ -1048,7 +1052,7 @@ define([ } var value = Common.localStorage.getItem('de-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.c_MetricUnits.cm; + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); Common.Utils.Metric.setCurrentMetric(value); me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); @@ -1587,7 +1591,7 @@ define([ unitsChanged: function(m) { var value = Common.localStorage.getItem("de-settings-unit"); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.c_MetricUnits.cm; + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); Common.Utils.Metric.setCurrentMetric(value); this.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); this.getApplication().getController('RightMenu').updateMetricUnit(); diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 50d43f8ffb..1ae7915c0f 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -348,7 +348,7 @@ define([ value = Common.localStorage.getItem("de-settings-unit"); item = this.cmbUnit.store.findWhere({value: parseInt(value)}); - this.cmbUnit.setValue(item ? parseInt(item.get('value')) : 0); + this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric()); this._oldUnits = this.cmbUnit.getValue(); value = Common.localStorage.getItem("de-settings-autosave"); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 3b4dd3f3fe..b6c40b7ba0 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -218,6 +218,7 @@ define([ this.appOptions.recent = this.editorConfig.recent; this.appOptions.createUrl = this.editorConfig.createUrl; this.appOptions.lang = this.editorConfig.lang; + this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : ''; this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl; this.appOptions.canAnalytics = false; this.appOptions.customization = this.editorConfig.customization; @@ -232,6 +233,9 @@ define([ if (this.editorConfig.lang) this.api.asc_setLocale(this.editorConfig.lang); + + if (this.appOptions.location == 'us' || this.appOptions.location == 'ca') + Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch); }, loadDocument: function(data) { @@ -816,7 +820,7 @@ define([ } var value = Common.localStorage.getItem('pe-settings-unit'); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.c_MetricUnits.cm; + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); Common.Utils.Metric.setCurrentMetric(value); me.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); @@ -1258,7 +1262,7 @@ define([ unitsChanged: function(m) { var value = Common.localStorage.getItem("pe-settings-unit"); - value = (value!==null) ? parseInt(value) : Common.Utils.Metric.c_MetricUnits.cm; + value = (value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric(); Common.Utils.Metric.setCurrentMetric(value); this.api.asc_SetDocumentUnits((value==Common.Utils.Metric.c_MetricUnits.inch) ? Asc.c_oAscDocumentUnits.Inch : ((value==Common.Utils.Metric.c_MetricUnits.pt) ? Asc.c_oAscDocumentUnits.Point : Asc.c_oAscDocumentUnits.Millimeter)); this.getApplication().getController('RightMenu').updateMetricUnit(); diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 34cdfd28a3..f6657bc130 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -282,7 +282,7 @@ define([ value = Common.localStorage.getItem("pe-settings-unit"); item = this.cmbUnit.store.findWhere({value: parseInt(value)}); - this.cmbUnit.setValue(item ? parseInt(item.get('value')) : 0); + this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric()); this._oldUnits = this.cmbUnit.getValue(); value = Common.localStorage.getItem("pe-settings-autosave"); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index b7a9af4740..240ed93d4a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -242,6 +242,7 @@ define([ this.appOptions.recent = this.editorConfig.recent; this.appOptions.createUrl = this.editorConfig.createUrl; this.appOptions.lang = this.editorConfig.lang; + this.appOptions.location = (typeof (this.editorConfig.location) == 'string') ? this.editorConfig.location.toLowerCase() : ''; this.appOptions.canAutosave = false; this.appOptions.canAnalytics = false; this.appOptions.sharingSettingsUrl = this.editorConfig.sharingSettingsUrl; @@ -270,6 +271,9 @@ define([ } else value = SSE.Views.FormulaLang.get(value); if (value) this.api.asc_setLocalization(value); + + if (this.appOptions.location == 'us' || this.appOptions.location == 'ca') + Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch); }, loadDocument: function(data) { @@ -867,7 +871,7 @@ define([ } var value = Common.localStorage.getItem('sse-settings-unit'); - Common.Utils.Metric.setCurrentMetric((value!==null) ? parseInt(value) : Common.Utils.Metric.c_MetricUnits.cm); + Common.Utils.Metric.setCurrentMetric((value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric()); if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { var options = {}; @@ -1549,7 +1553,7 @@ define([ unitsChanged: function(m) { var value = Common.localStorage.getItem("sse-settings-unit"); - Common.Utils.Metric.setCurrentMetric((value!==null) ? parseInt(value) : Common.Utils.Metric.c_MetricUnits.cm); + Common.Utils.Metric.setCurrentMetric((value!==null) ? parseInt(value) : Common.Utils.Metric.getDefaultMetric()); this.getApplication().getController('RightMenu').updateMetricUnit(); this.getApplication().getController('Print').getView('MainSettingsPrint').updateMetricUnit(); }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index db78c10161..3fa2daa317 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -661,7 +661,7 @@ define([ value = Common.localStorage.getItem("sse-settings-unit"); item = this.cmbUnit.store.findWhere({value: parseInt(value)}); - this.cmbUnit.setValue(item ? parseInt(item.get('value')) : 0); + this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric()); this._oldUnits = this.cmbUnit.getValue(); value = Common.localStorage.getItem("sse-settings-autosave");