diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 62788172d..bfc03f2cd 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -511,9 +511,10 @@ }); }; - var _downloadAs = function() { + var _downloadAs = function(data) { _sendCommand({ - command: 'downloadAs' + command: 'downloadAs', + data: data }); }; diff --git a/apps/common/Gateway.js b/apps/common/Gateway.js index 9a2c6000c..71d36ecc1 100644 --- a/apps/common/Gateway.js +++ b/apps/common/Gateway.js @@ -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) { diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 501c72319..356aeba1d 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -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) { diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 250937d9e..f36f03d1d 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -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) { diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index bdc72a8fc..68bddf0f7 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -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) {