'use strict'; (function ($){ $.django = function (){ function func(method){ function wrapper(){ if (arguments.length > 1){ var opts = {url: arguments[0], data: arguments[1]}; }else{ if ($.isPlainObject(arguments[0])){ var opts = arguments[0]; }else{ var opts = {url: arguments[0]}; }; }; var opts = $.extend( {}, { type: method, beforeSend: function(xhr, settings) { App.blockUI({message: 'Aguarde...'}); xhr.setRequestHeader('X-CSRFToken', 'wPQNaCv76wMlilqekO1esZvDYMPHjEOgZDBND6NcnlI9uOZ9WKgj9MbJS3U6TsEO'); }, complete: function(){ App.unblockUI(); } }, opts ); return $.ajax(opts); }; return wrapper } return { 'delete': func('delete'), 'get': func('get'), 'post': func('post'), 'put': func('put'), 'patch': func('patch') } }(); }(jQuery));