| Current Path : /home/lejardintz/www/media/foundry/3.1/scripts/ |
| Current File : /home/lejardintz/www/media/foundry/3.1/scripts/server.min.js |
FD31.plugin("server",function($){var self=$.server=function(options){var request=$.Deferred(),ajaxOptions=$.extend(!0,{},self.defaultOptions,options,{success:function(){}});return request.xhr=$.Ajax(ajaxOptions).done(function(commands){if("string"==typeof commands)try{commands=$.parseJSON(commands)}catch(e){request.rejectWith(request,["Unable to parse Ajax commands.","error"])}if($.isArray(commands)){var parse=function(command){var type=command.type,parser=self.parsers[type]||options[type];return $.isFunction(parser)?parser.apply(request,command.data):void 0
},commands=$.map(commands,function(command){return"notify"!=command.type?command:(parse(command),void 0)});$.each(commands,function(i,command){parse(command)})}else request.rejectWith(request,["Invalid ajax commands.","error"]);"pending"===request.state()&&request.resolveWith(request)}).fail(function(xhr,status,statusText){request.rejectWith(request,[statusText,status])}),request};self.defaultOptions={type:"POST",data:{tmpl:"component",format:"ajax",no_html:1},dataType:"json"},self.parsers={script:function(){var data=$.makeArray(arguments);
if("string"!=typeof data[0]){var chain=window,chainBroken=!1;$.each(data,function(i,chainer){"Foundry"===chainer.property&&(chainer.property=$.globalNamespace),"Foundry"===chainer.method&&(chainer.method=$.globalNamespace);try{switch(chainer.type){case"get":chain=chain[chainer.property];break;case"set":chain[chainer.property]=chainer.value,chainBroken=!0;break;case"call":chain=chain[chainer.method].apply(chain,chainer.args)}}catch(err){chainBroken=!0}})}else try{eval(data[0])}catch(err){}},resolve:function(){this.resolveWith(this,arguments)
},reject:function(){this.rejectWith(this,arguments)},notify:function(){this.notifyWith(this,arguments)},redirect:function(url){window.location=url}}});