diff --git a/apps/common/main/lib/view/OpenDialog.js b/apps/common/main/lib/view/OpenDialog.js
index 95e6b3a86..1fcb92d10 100644
--- a/apps/common/main/lib/view/OpenDialog.js
+++ b/apps/common/main/lib/view/OpenDialog.js
@@ -92,17 +92,13 @@ define([
'
',
'',
'
',
- '<% if (type == Asc.c_oAscAdvancedOptionsID.CSV) { %>',
'
',
- '
',
- '<% } else { %>',
- '
',
- '<% } %>',
'
',
'
',
'<% } %>',
@@ -140,12 +136,10 @@ define([
this.$window.find('.tool').hide();
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
- this.previewPanel = this.$window.find((this.type == Asc.c_oAscAdvancedOptionsID.CSV) ? '#id-preview-csv-data' : '#id-preview-txt');
- if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) {
- this.csvPreview = this.$window.find('#id-preview-csv');
- this.csvPreviewInner = this.csvPreview.find('div:first-child');
- this.previewParent = this.previewPanel.parent();
- }
+ this.previewPanel = this.$window.find('#id-preview-data');
+ this.previewParent = this.previewPanel.parent();
+ this.previewScrolled = this.$window.find('#id-preview');
+ this.previewInner = this.previewScrolled.find('div:first-child');
if (this.type == Asc.c_oAscAdvancedOptionsID.DRM) {
this.inputPwd = new Common.UI.InputField({
@@ -430,41 +424,26 @@ define([
var delimiter = this.cmbDelimiter ? this.cmbDelimiter.getValue() : null,
delimiterChar = (delimiter == -1) ? this.inputDelimiter.getValue() : null;
(delimiter == -1) && (delimiter = null);
- this.api.asc_decodeBuffer(this.preview, new Asc.asc_CCSVAdvancedOptions(this.cmbEncoding.getValue(), delimiter, delimiterChar), _.bind(this.previewCsvCallback, this));
+ this.api.asc_decodeBuffer(this.preview, new Asc.asc_CCSVAdvancedOptions(this.cmbEncoding.getValue(), delimiter, delimiterChar), _.bind(this.previewCallback, this));
} else {
- if (!_.isUndefined(this.previewYScroller)) {
- this.previewYScroller.destroy();
- delete this.previewYScroller;
- }
- this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTXTAdvancedOptions(this.cmbEncoding.getValue()), _.bind(this.previewTxtCallback, this));
+ this.api.asc_decodeBuffer(this.preview, new Asc.asc_CTXTAdvancedOptions(this.cmbEncoding.getValue()), _.bind(this.previewCallback, this));
}
},
- previewTxtCallback: function(data) {
- if (!data || !data.length) return;
-
- this.previewPanel.text(data);
- this.previewYScroller = new Common.UI.Scroller({
- el: this.previewPanel,
- minScrollbarLength : 20,
- alwaysVisibleY: true
- });
- },
-
- previewCsvCallback: function(data) {
+ previewCallback: function(data) {
if (!data || !data.length) return;
this.data = data;
- this.csvPreviewInner.height(data.length*17);
+ this.previewInner.height(data.length*17);
- if (!this.previewScroller)
- this.previewScroller = new Common.UI.Scroller({
- el: this.csvPreview,
+ if (!this.scrollerY)
+ this.scrollerY = new Common.UI.Scroller({
+ el: this.previewScrolled,
minScrollbarLength : 20,
alwaysVisibleY: true,
onChange: _.bind(function(){
- if (this.previewScroller) {
- var startPos = this.previewScroller.getScrollTop(),
+ if (this.scrollerY) {
+ var startPos = this.scrollerY.getScrollTop(),
start = Math.floor(startPos/17+0.5),
end = start+Math.min(6, this.data.length);
if (end>this.data.length) {
@@ -474,40 +453,48 @@ define([
}
this.previewParent.height(108);
this.previewParent.css({top: startPos});
- this.previewCsvDataBlock(this.data.slice(start, end));
+ this.previewDataBlock(this.data.slice(start, end));
}
}, this)
});
- this.previewScroller.update();
- this.previewScroller.scrollTop(0);
+ this.scrollerY.update();
+ this.scrollerY.scrollTop(0);
},
- previewCsvDataBlock: function(data) {
- if (!_.isUndefined(this.previewXScroller)) {
- this.previewXScroller.destroy();
- delete this.previewXScroller;
+ previewDataBlock: function(data) {
+ if (!_.isUndefined(this.scrollerX)) {
+ this.scrollerX.destroy();
+ delete this.scrollerX;
}
- var maxlength = 0;
- for (var i=0; i
maxlength)
- maxlength = data[i].length;
- }
- var tpl = '';
- for (var i=0; i';
- for (var j=0; j' + Common.Utils.String.htmlEncode(data[i][j]) + '';
+ if (this.type == Asc.c_oAscAdvancedOptionsID.CSV) {
+ var maxlength = 0;
+ for (var i=0; imaxlength)
+ maxlength = data[i].length;
}
- for (j=data[i].length; j';
+ var tpl = '';
+ for (var i=0; i';
+ for (var j=0; j' + Common.Utils.String.htmlEncode(data[i][j]) + '';
+ }
+ for (j=data[i].length; j';
+ }
+ tpl += '';
}
- tpl += '';
+ tpl += '
';
+ } else {
+ var tpl = '';
+ for (var i=0; i' + Common.Utils.String.htmlEncode(data[i]) + ' | ';
+ }
+ tpl += '
';
}
- tpl += '
';
this.previewPanel.html(tpl);
- this.previewXScroller = new Common.UI.Scroller({
+ this.scrollerX = new Common.UI.Scroller({
el: this.previewPanel,
suppressScrollY: true,
alwaysVisibleX: true,
diff --git a/apps/common/main/resources/less/opendialog.less b/apps/common/main/resources/less/opendialog.less
index 823c3fd36..762e50ef6 100644
--- a/apps/common/main/resources/less/opendialog.less
+++ b/apps/common/main/resources/less/opendialog.less
@@ -38,17 +38,19 @@
}
- #id-preview-csv, #id-preview-txt, #id-preview-csv-data {
- position:relative;
+ #id-preview {
width: 100%;
height: 110px !important;
+ position:relative;
overflow:hidden;
border: @gray-soft solid 1px;
}
- #id-preview-csv-data {
- border: none;
+ #id-preview-data {
+ width: 100%;
height: 108px !important;
+ position:relative;
+ overflow:hidden;
}
table {