All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.wicket.extensions.ajax.wicket-ajaxdownload.min.js Maven / Gradle / Ivy

There is a newer version: 10.2.0
Show newest version
(function(a){if(!window.Wicket){window.Wicket={}}if(Wicket.AjaxDownload){return}Wicket.AjaxDownload={initiate:function(d){document.cookie=d.name+"=;path=/;Max-Age=0;expires=Thu, 01 Jan 1970 00:00:01 GMT";var b=function(h){d.attributes.ep=d.attributes.ep||{};d.attributes.ep.result=h;Wicket.Ajax.ajax(d.attributes)};var g=function(i){var h;if(document.cookie.indexOf(d.name+"=")>-1){h="success"}else{var j=i.html();if(j&&j.length){h="failed"}}if(h){i.dismiss(h);b(h)}else{setTimeout(function(){g(i)},100)}};if(d.method==="samewindow"){setTimeout(function(){window.location.assign(d.downloadUrl);g({html:function(){return jQuery()},dismiss:function(h){}})},10)}else{if(d.method==="newwindow"){var c=window.open(d.downloadUrl);g({html:function(){return jQuery(c?c.document:a).find("body").html()},dismiss:function(h){if(h==="failed"){c.close()}}})}else{if(d.method==="iframe"){var f=jQuery("").hide().prop("src",d.downloadUrl).appendTo("body");g({html:function(){return f.contents().find("body").html()},dismiss:function(){setTimeout(function(){f.remove()},0)}})}else{var e=new XMLHttpRequest();e.open("GET",d.downloadUrl);e.responseType="blob";e.onload=function(){if(this.status===200){var j="";var n=e.getResponseHeader("Content-Disposition");if(n){var m=/filename[^;=\n]*=(([""]).*?\2|[^;\n]*)/.exec(n);if(m!==null&&m[1]){j=m[1].replace(/[""]/g,"");j=decodeURIComponent(j)}}if(typeof window.navigator.msSaveOrOpenBlob!=="undefined"){window.navigator.msSaveOrOpenBlob(e.response,j)}else{var l=e.getResponseHeader("Content-Type");var i=new Blob([e.response],{type:l});var h=(window.URL||window.webkitURL).createObjectURL(i);var k=jQuery("").prop("href",h).prop("download",j).appendTo("body").hide();k[0].click();setTimeout(function(){URL.revokeObjectURL(h);k.remove()},100)}b("success")}else{b("failed")}};e.onerror=function(){b("failed")};e.send()}}}}}})();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy