X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Pman.Download.js;h=2f16b24689413da76ec062818932f5ab201c7308;hp=31ff831819b1ef55c15db1c0d54c74ce61cab07e;hb=443623f47935eb52acd65a3ff0d84eab1fd5a98b;hpb=281453d9332b8d7b0c4346cde19a579413567eef diff --git a/Pman.Download.js b/Pman.Download.js index 31ff8318..2f16b246 100644 --- a/Pman.Download.js +++ b/Pman.Download.js @@ -8,6 +8,7 @@ var t = new Pman.Download({ url: baseURL + '/Images/Download/0/myfile.jpg', newWindow : false, params: { .... }, + doctype: 'pdf' success : function() { Roo.MessageBox.alert("File has downloaded"); } @@ -20,129 +21,157 @@ var t = new Pman.Download({ * @cfg {String} url Location to download from. * @cfg {String} method GET or POST (default GET), POST will create a form, and post that into the hidden frame. * @cfg {Boolean} newWindow (optional) download to new window - +* @cfg {String} doctype (optional) download PDF to new window +* @cfg {Boolean} limit (optional) limit for grid downloads. + + * @cfg {String} csvCols - use '*' to override grid coluns + * @cfg {String} csvTitles - use '*' to override grid coluns + + + +* @cfg {Function} success (optional) MAY fire on download completed (fails on attachments).. +* @cfg {Number} timeout (optional) in milliseconds before it gives up (default 30000 = 30s) +* @cfg {Roo.grid.Grid} grid (optional) if you want to just download a grid, (without renderers..) +* */ + Pman.Download = function(cfg) { - - if (cfg.newWindow) { - // as ie seems buggy... - window.open( cfg.url + '?' + Roo.urlEncode(cfg.params || {}), '_blank'); + + + + this.params = {}; + + Roo.apply(this, cfg); + + if (this.grid) { + + this.buildFromGrid(); + Roo.log(this); + } + + + if (this.newWindow && this.method == 'GET') { + // as ie seems buggy... + window.open( this.url + '?' + Roo.urlEncode(this.params || {}), '_blank'); return ; } + - var submit = false; - this.createCsvFrame(); - var requested = 0; + //this.submit = false; + //this.createCsvFrame(); + //var requested = 0; + + //Roo.EventManager.on( this.csvFrame, 'load', this.onLoad, this); - function cb() - { - // requested++; // second request is real one.. - // if (requested < 2) { - // return; - //} // n - if (!submit) { - return; - } - - Roo.log('downloaded'); - var frame = this.csvFrame; - var success = true; - try { - var doc = Roo.isIE ? - frame.contentWindow.document : - (frame.contentDocument || window.frames[Pman.Download.csvFrame.id].document); - - - if(doc && doc.body && doc.body.innerHTML.length){ - // alert(doc.body.innerHTML); - if (doc.body.innerHTML == 'false') { - cb.defer(1000, this); - return; - } - // firebug plays with iner html... - if (doc.body.innerHTML.replace(/\