Added format parameter to downloadAs api method.
This commit is contained in:
Julia Radzhabova 2017-10-24 14:23:15 +03:00
parent 304e08e23c
commit 5da46ba82c
5 changed files with 45 additions and 10 deletions

View file

@ -511,9 +511,10 @@
});
};
var _downloadAs = function() {
var _downloadAs = function(data) {
_sendCommand({
command: 'downloadAs'
command: 'downloadAs',
data: data
});
};

View file

@ -80,8 +80,8 @@ if (Common === undefined) {
$me.trigger('processmailmerge', data);
},
'downloadAs': function() {
$me.trigger('downloadas');
'downloadAs': function(data) {
$me.trigger('downloadas', data);
},
'processMouse': function(data) {

View file

@ -364,10 +364,25 @@ define([
}
},
onDownloadAs: function() {
onDownloadAs: function(format) {
this._state.isFromGatewayDownloadAs = true;
var type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);
(type && typeof type[1] === 'string') ? this.api.asc_DownloadOrigin(true) : this.api.asc_DownloadAs(Asc.c_oAscFileType.DOCX, true);
if (type && typeof type[1] === 'string')
this.api.asc_DownloadOrigin(true);
else {
var _format = (format && (typeof format == 'string')) ? Asc.c_oAscFileType[ format.toUpperCase() ] : null,
_supported = [
Asc.c_oAscFileType.TXT,
Asc.c_oAscFileType.ODT,
Asc.c_oAscFileType.DOCX,
Asc.c_oAscFileType.HTML,
Asc.c_oAscFileType.PDF
];
if ( !_format || _supported.indexOf(_format) < 0 )
_format = Asc.c_oAscFileType.DOCX;
this.api.asc_DownloadAs(_format, true);
}
},
onProcessMouse: function(data) {

View file

@ -356,8 +356,17 @@ define([
}
},
onDownloadAs: function() {
this.api.asc_DownloadAs(Asc.c_oAscFileType.PPTX, true);
onDownloadAs: function(format) {
var _format = (format && (typeof format == 'string')) ? Asc.c_oAscFileType[ format.toUpperCase() ] : null,
_supported = [
Asc.c_oAscFileType.PPTX,
Asc.c_oAscFileType.ODP,
Asc.c_oAscFileType.PDF
];
if ( !_format || _supported.indexOf(_format) < 0 )
_format = Asc.c_oAscFileType.PPTX;
this.api.asc_DownloadAs(_format, true);
},
onProcessMouse: function(data) {

View file

@ -393,8 +393,18 @@ define([
}
},
onDownloadAs: function() {
this.api.asc_DownloadAs(Asc.c_oAscFileType.XLSX, true);
onDownloadAs: function(format) {
var _format = (format && (typeof format == 'string')) ? Asc.c_oAscFileType[ format.toUpperCase() ] : null,
_supported = [
Asc.c_oAscFileType.XLSX,
Asc.c_oAscFileType.ODS,
Asc.c_oAscFileType.CSV,
Asc.c_oAscFileType.PDF
];
if ( !_format || _supported.indexOf(_format) < 0 )
_format = Asc.c_oAscFileType.XLSX;
this.api.asc_DownloadAs(_format, true);
},
onProcessMouse: function(data) {