1 | (function() {
|
2 | var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
3 | Batman.Request.prototype.send = function(data) {
|
4 | var options, _ref;
|
5 | options = {
|
6 | url: this.get('url'),
|
7 | type: this.get('method'),
|
8 | dataType: this.get('type'),
|
9 | data: data || this.get('data'),
|
10 | username: this.get('username'),
|
11 | password: this.get('password'),
|
12 | beforeSend: __bind(function() {
|
13 | return this.fire('loading');
|
14 | }, this),
|
15 | success: __bind(function(response, textStatus, xhr) {
|
16 | this.set('status', xhr.status);
|
17 | this.set('response', response);
|
18 | return this.fire('success', response);
|
19 | }, this),
|
20 | error: __bind(function(xhr, status, error) {
|
21 | this.set('status', xhr.status);
|
22 | this.set('response', xhr.responseText);
|
23 | xhr.request = this;
|
24 | return this.fire('error', xhr);
|
25 | }, this),
|
26 | complete: __bind(function() {
|
27 | return this.fire('loaded');
|
28 | }, this)
|
29 | };
|
30 | if ((_ref = this.get('method')) === 'PUT' || _ref === 'POST') {
|
31 | if (!this.get('formData')) {
|
32 | options.contentType = this.get('contentType');
|
33 | } else {
|
34 | options.contentType = false;
|
35 | options.processData = false;
|
36 | options.data = this.constructor.objectToFormData(options.data);
|
37 | }
|
38 | }
|
39 | return jQuery.ajax(options);
|
40 | };
|
41 | Batman.mixins.animation = {
|
42 | show: function(addToParent) {
|
43 | var jq, show, _ref, _ref2;
|
44 | jq = $(this);
|
45 | show = function() {
|
46 | return jq.show(600);
|
47 | };
|
48 | if (addToParent) {
|
49 | if ((_ref = addToParent.append) != null) {
|
50 | _ref.appendChild(this);
|
51 | }
|
52 | if ((_ref2 = addToParent.before) != null) {
|
53 | _ref2.parentNode.insertBefore(this, addToParent.before);
|
54 | }
|
55 | jq.hide();
|
56 | setTimeout(show, 0);
|
57 | } else {
|
58 | show();
|
59 | }
|
60 | return this;
|
61 | },
|
62 | hide: function(removeFromParent) {
|
63 | $(this).hide(600, __bind(function() {
|
64 | var _ref;
|
65 | if (removeFromParent) {
|
66 | return (_ref = this.parentNode) != null ? _ref.removeChild(this) : void 0;
|
67 | }
|
68 | }, this));
|
69 | return this;
|
70 | }
|
71 | };
|
72 | }).call(this);
|