implemented 'Download As' for 'preview' mode

This commit is contained in:
Maxim Kadushkin 2017-07-21 17:55:27 +03:00
parent b44a9f206c
commit 05ce65f5ee
3 changed files with 60 additions and 9 deletions

View file

@ -116,9 +116,31 @@ define([
'Common.Views.Header': { 'Common.Views.Header': {
'print': this.onPrint.bind(this), 'print': this.onPrint.bind(this),
'downloadas': function (opts) { 'downloadas': function (opts) {
// this.api.asc_DownloadOrigin(); var _main = this.getApplication().getController('Main');
console.log('download original'); var _file_type = _main.document.fileType,
}.bind(this), _format;
if ( !!_file_type ) {
if ( /^pdf|xps|djvu/i.test(_file_type) ) {
this.api.asc_DownloadOrigin();
return;
} else {
_format = Asc.c_oAscFileType[ _file_type.toUpperCase() ];
}
}
var _supported = [
Asc.c_oAscFileType.TXT,
Asc.c_oAscFileType.RTF,
Asc.c_oAscFileType.ODT,
Asc.c_oAscFileType.DOCX,
Asc.c_oAscFileType.HTML
];
if ( !_format || _supported.indexOf(_format) < 0 )
_format = Asc.c_oAscFileType.PDF;
_main.api.asc_DownloadAs(_format);
},
'go:editor': function() { 'go:editor': function() {
Common.Gateway.requestEditRights(); Common.Gateway.requestEditRights();
} }

View file

@ -127,9 +127,23 @@ define([
'Common.Views.Header': { 'Common.Views.Header': {
'print': this.onPrint.bind(this), 'print': this.onPrint.bind(this),
'downloadas': function (opts) { 'downloadas': function (opts) {
// this.api.asc_DownloadOrigin(); var _main = this.getApplication().getController('Main');
console.log('download original'); var _file_type = _main.document.fileType,
}.bind(this), _format;
if ( !!_file_type ) {
_format = Asc.c_oAscFileType[ _file_type.toUpperCase() ];
}
var _supported = [
Asc.c_oAscFileType.PPTX,
Asc.c_oAscFileType.ODP
];
if ( !_format || _supported.indexOf(_format) < 0 )
_format = Asc.c_oAscFileType.PDF;
_main.api.asc_DownloadAs(_format);
},
'go:editor': function() { 'go:editor': function() {
Common.Gateway.requestEditRights(); Common.Gateway.requestEditRights();
} }

View file

@ -81,9 +81,24 @@ define([
'Common.Views.Header': { 'Common.Views.Header': {
'print': this.onPrint.bind(this), 'print': this.onPrint.bind(this),
'downloadas': function (opts) { 'downloadas': function (opts) {
// this.api.asc_DownloadOrigin(); var _main = this.getApplication().getController('Main');
console.log('download original'); var _file_type = _main.appOptions.spreadsheet.fileType,
}.bind(this), _format;
if ( !!_file_type ) {
_format = Asc.c_oAscFileType[ _file_type.toUpperCase() ];
}
var _supported = [
Asc.c_oAscFileType.XLSX,
Asc.c_oAscFileType.ODS,
Asc.c_oAscFileType.CSV
];
if ( !_format || _supported.indexOf(_format) < 0 )
_format = Asc.c_oAscFileType.PDF;
_main.api.asc_DownloadAs(_format);
},
'go:editor': function() { 'go:editor': function() {
Common.Gateway.requestEditRights(); Common.Gateway.requestEditRights();
} }