diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index c2f5cd8e7c..9cf073d2f3 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -1369,7 +1369,7 @@ define([], function () { if (window.isrtl === undefined) { if (window.nativeprocvars && window.nativeprocvars.rtl !== undefined) window.isrtl = window.nativeprocvars.rtl; - else window.isrtl = !Common.Utils.isIE && Common.localStorage.getBool("ui-rtl", Common.Locale.isCurrentLanguageRtl()); + else window.isrtl = Common.Locale.isCurrentLanguageRtl() ? !Common.Utils.isIE && Common.localStorage.getBool("ui-rtl", Common.Locale.isCurrentLanguageRtl()) : false; } return window.isrtl; diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js index eacc736f04..dec32ddbaa 100644 --- a/apps/common/main/lib/view/OpenDialog.js +++ b/apps/common/main/lib/view/OpenDialog.js @@ -258,13 +258,16 @@ define([ delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null, delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null; (delimiter == -1) && (delimiter = null); - if (!this.closable && this.type == Common.Utils.importTextType.TXT) { //save last encoding only for opening txt files - Common.localStorage.setItem("de-settings-open-encoding", encoding); - } - if (this.type === Common.Utils.importTextType.CSV) { // only for csv files - Common.localStorage.setItem("sse-settings-csv-delimiter", delimiter === null ? -1 : delimiter); - Common.localStorage.setItem("sse-settings-csv-delimiter-char", delimiterChar || ''); - Common.localStorage.setItem("sse-settings-csv-encoding", encoding); + if (this.type === Common.Utils.importTextType.TXT) { //save last encoding only for txt files + this._isEncodingChanged && Common.localStorage.setItem("de-settings-open-encoding", encoding); + } else if (this.type === Common.Utils.importTextType.CSV) { // only for csv files + this._isDelimChanged && Common.localStorage.setItem("sse-settings-csv-delimiter", delimiter === null ? -1 : delimiter); + this._isDelimCharChanged && Common.localStorage.setItem("sse-settings-csv-delimiter-char", delimiterChar || ''); + this._isEncodingChanged && Common.localStorage.setItem("sse-settings-csv-encoding", encoding); + } else if (this.type === Common.Utils.importTextType.Paste || this.type === Common.Utils.importTextType.Columns || this.type === Common.Utils.importTextType.Data) { + this._isDelimChanged && Common.localStorage.setItem("sse-settings-data-delimiter", delimiter === null ? -1 : delimiter); + this._isDelimCharChanged && Common.localStorage.setItem("sse-settings-data-delimiter-char", delimiterChar || ''); + this._isEncodingChanged && Common.localStorage.setItem("sse-settings-data-encoding", encoding); } var decimal = this.separatorOptions ? this.separatorOptions.decimal : undefined, @@ -286,7 +289,7 @@ define([ }, initCodePages: function () { - var i, c, codepage, encodedata = [], listItems = [], length = 0, lcid_width = 0; + var i, c, codepage, encodedata = [], listItems = [], length = 0, lcid_width = 0, utf8 = 0; if (this.codepages) { encodedata = []; @@ -296,6 +299,7 @@ define([ c[0] = codepage.asc_getCodePage(); c[1] = codepage.asc_getCodePageName(); c[2] = codepage.asc_getLcid(); + (c[2]===65001) && (utf8 = i); encodedata.push(c); } @@ -337,17 +341,22 @@ define([ }); this.cmbEncoding.setDisabled(false); - var encoding = (this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : encodedata[0][0]; - if (!this.closable && this.type == Common.Utils.importTextType.TXT) { // only for opening txt files - var value = Common.localStorage.getItem("de-settings-open-encoding"); - value && (encoding = parseInt(value)); - } else if (this.type === Common.Utils.importTextType.CSV) { // only for csv files - var value = Common.localStorage.getItem("sse-settings-csv-encoding"); - value && (encoding = parseInt(value)); + var encoding = (this.settings && this.settings.asc_getCodePage()) ? this.settings.asc_getCodePage() : encodedata[utf8][0]; + if (encoding===-1) { + if (this.type == Common.Utils.importTextType.TXT) { // only for opening txt files + var value = Common.localStorage.getItem("de-settings-open-encoding"); + value && (encoding = parseInt(value)); + } else if (this.type === Common.Utils.importTextType.CSV) { // only for csv files + var value = Common.localStorage.getItem("sse-settings-csv-encoding"); + value && (encoding = parseInt(value)); + } else if (this.type === Common.Utils.importTextType.Data) { + var value = Common.localStorage.getItem("sse-settings-data-encoding"); + value && (encoding = parseInt(value)); + } + (encoding===-1) && (encoding = encodedata[utf8][0]); } this.cmbEncoding.setValue(encoding); - if (this.preview) - this.cmbEncoding.on('selected', _.bind(this.onCmbEncodingSelect, this)); + this.cmbEncoding.on('selected', _.bind(this.onCmbEncodingSelect, this)); var ul = this.cmbEncoding.cmpEl.find('ul'), a = ul.find('li:nth(0) a'), @@ -358,14 +367,12 @@ define([ if (this.type == Common.Utils.importTextType.CSV || this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns || this.type == Common.Utils.importTextType.Data) { var delimiter = this.settings && this.settings.asc_getDelimiter() ? this.settings.asc_getDelimiter() : 4, delimiterChar = this.settings && this.settings.asc_getDelimiterChar() ? this.settings.asc_getDelimiterChar() : ''; - if (this.type == Common.Utils.importTextType.CSV) { // only for csv files - var value = Common.localStorage.getItem("sse-settings-csv-delimiter"); - if (value) { - value = parseInt(value); - if (!isNaN(value)) { - delimiter = value; - (delimiter===-1) && (delimiterChar = Common.localStorage.getItem("sse-settings-csv-delimiter-char") || ''); - } + var value = Common.localStorage.getItem(this.type == Common.Utils.importTextType.CSV ? "sse-settings-csv-delimiter" : "sse-settings-data-delimiter"); + if (value) { + value = parseInt(value); + if (!isNaN(value)) { + delimiter = value; + (delimiter===-1) && (delimiterChar = Common.localStorage.getItem(this.type == Common.Utils.importTextType.CSV ? "sse-settings-csv-delimiter-char" : "sse-settings-data-delimiter-char") || ''); } } @@ -396,8 +403,7 @@ define([ value: delimiterChar }); this.inputDelimiter.setVisible(delimiter===-1); - if (this.preview) - this.inputDelimiter.on ('changing', _.bind(this.updatePreview, this)); + this.inputDelimiter.on ('changing', _.bind(this.onInputCharChanging, this)); if (this.type == Common.Utils.importTextType.Paste || this.type == Common.Utils.importTextType.Columns || this.type == Common.Utils.importTextType.Data) { this.btnAdvanced = new Common.UI.Button({ @@ -538,10 +544,17 @@ define([ setTimeout(function(){me.inputDelimiter.focus();}, 10); if (this.preview) this.updatePreview(); + this._isDelimChanged = true; + }, + + onInputCharChanging: function(){ + this.preview && this.updatePreview(); + this._isDelimCharChanged = true; }, onCmbEncodingSelect: function(combo, record){ - this.updatePreview(); + this.preview && this.updatePreview(); + this._isEncodingChanged = true; }, onAdvancedClick: function() {