(type, filename, options, range, interceptCallback)
| 47 | |
| 48 | //trigger file download |
| 49 | download(type, filename, options, range, interceptCallback){ |
| 50 | var downloadFunc = false; |
| 51 | |
| 52 | function buildLink(data, mime){ |
| 53 | if(interceptCallback){ |
| 54 | if(interceptCallback === true){ |
| 55 | this.triggerDownload(data, mime, type, filename, true); |
| 56 | }else{ |
| 57 | interceptCallback(data); |
| 58 | } |
| 59 | |
| 60 | }else{ |
| 61 | this.triggerDownload(data, mime, type, filename); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | if(typeof type == "function"){ |
| 66 | downloadFunc = type; |
| 67 | }else{ |
| 68 | if(Download.downloaders[type]){ |
| 69 | downloadFunc = Download.downloaders[type]; |
| 70 | }else{ |
| 71 | console.warn("Download Error - No such download type found: ", type); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | if(downloadFunc){ |
| 76 | var list = this.generateExportList(range); |
| 77 | |
| 78 | downloadFunc.call(this.table, list , options || {}, buildLink.bind(this)); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | generateExportList(range){ |
| 83 | var list = this.table.modules.export.generateExportList(this.table.options.downloadConfig, false, range || this.table.options.downloadRowRange, "download"); |
no test coverage detected