Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ajax.min.js |
define ("core/ajax",["jquery","core/config","core/log","core/url"],function(a,b,c,d){var e=!1,f=function(a){var b=this,c=null,e=0,f,g,h;if(a.error){for(;e<b.length;e++){f=b[e];f.deferred.reject(a)}return}for(e=0;e<b.length;e++){f=b[e];g=a[e];if("undefined"!=typeof g){if(!1===g.error){f.deferred.resolve(g.data)}else{c=g.exception;h=b[e].nosessionupdate;break}}else{c=new Error("missing response");break}}if(null!==c){if("servicerequireslogin"===c.errorcode&&!h){window.location=d.relativeUrl("/login/index.php")}else{b.forEach(function(a){a.deferred.reject(c)})}}},g=function(a,b,d){var f=this,g=0;for(g=0;g<f.length;g++){var h=f[g];if(e){c.error("Page unloaded.");c.error(d)}else{h.deferred.reject(d)}}};return{call:function call(c,d,h,j,k,l){a(window).bind("beforeunload",function(){e=!0});var m=[],n,o=[],p=[],q="";if("undefined"==typeof h){h=!0}if("undefined"==typeof d){d=!0}if("undefined"==typeof k){k=0}if("undefined"==typeof l){l=null}else{l=parseInt(l);if(0>=l){l=null}else if(!l){l=null}}if("undefined"==typeof j){j=!1}for(n=0;n<c.length;n++){var r=c[n];m.push({index:n,methodname:r.methodname,args:r.args});r.nosessionupdate=j;r.deferred=a.Deferred();o.push(r.deferred.promise());if("undefined"!=typeof r.done){r.deferred.done(r.done)}if("undefined"!=typeof r.fail){r.deferred.fail(r.fail)}r.index=n;p.push(r.methodname)}if(5>=p.length){q=p.sort().join()}else{q=p.length+"-method-calls"}m=JSON.stringify(m);var s={type:"POST",context:c,dataType:"json",processData:!1,async:d,contentType:"application/json",timeout:k},t="service.php",u=b.wwwroot+"/lib/ajax/";if(!h){t="service-nologin.php";u+=t+"?info="+q;if(l){u+="&cachekey="+l;s.type="GET"}}else{u+=t+"?sesskey="+b.sesskey+"&info="+q}if(j){u+="&nosessionupdate=true"}if("POST"===s.type){s.data=m}else{var v=u+"&args="+encodeURIComponent(m);if(v.length>2e3){s.type="POST";s.data=m}else{u=v}}if(d){a.ajax(u,s).done(f).fail(g)}else{s.success=f;s.error=g;a.ajax(u,s)}return o}}}); //# sourceMappingURL=ajax.min.js.map