modal_logic 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/modal_logic.js +43 -40
- data/lib/modal_logic/version.rb +1 -1
- metadata +1 -1
@@ -1,51 +1,54 @@
|
|
1
1
|
// Generated by CoffeeScript 1.6.3
|
2
|
-
|
3
|
-
|
2
|
+
(function() {
|
3
|
+
var ModalLogic, exports,
|
4
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
4
5
|
|
5
|
-
exports = exports != null ? exports : window;
|
6
|
+
exports = exports != null ? exports : window;
|
6
7
|
|
7
|
-
exports.ModalLogic = ModalLogic = (function() {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
exports.ModalLogic = ModalLogic = (function() {
|
9
|
+
function ModalLogic() {
|
10
|
+
this.showModal = __bind(this.showModal, this);
|
11
|
+
this.createOrUpdateModalContent = __bind(this.createOrUpdateModalContent, this);
|
12
|
+
var that;
|
13
|
+
that = this;
|
14
|
+
$('a[data-remote][modal],form[data-remote][modal]').live('ajax:complete', function(jq_event, xhr) {
|
15
|
+
var response;
|
16
|
+
response = JSON.parse(xhr.responseText);
|
17
|
+
if (response != null) {
|
18
|
+
if (response.close != null) {
|
19
|
+
return window.location = response.redirect_location != null ? response.redirect_location : window.location;
|
20
|
+
} else {
|
21
|
+
return that.createOrUpdateModalContent(response);
|
22
|
+
}
|
19
23
|
} else {
|
20
|
-
return that.createOrUpdateModalContent(
|
24
|
+
return that.createOrUpdateModalContent({
|
25
|
+
title: 'Error',
|
26
|
+
body: 'There was an error. Please reload the page and try again'
|
27
|
+
});
|
21
28
|
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
ModalLogic.prototype.createOrUpdateModalContent = function(context) {
|
33
|
+
var $modal, html;
|
34
|
+
html = HandlebarsTemplates['modal/crud']({
|
35
|
+
modal: context
|
36
|
+
});
|
37
|
+
$modal = $('.modal.modal-logic');
|
38
|
+
if ($modal.length > 0) {
|
39
|
+
$modal.modal('hide').replaceWith(html);
|
22
40
|
} else {
|
23
|
-
|
24
|
-
title: 'Error',
|
25
|
-
body: 'There was an error. Please reload the page and try again'
|
26
|
-
});
|
41
|
+
$('body').append(html);
|
27
42
|
}
|
28
|
-
|
29
|
-
|
43
|
+
return this.showModal();
|
44
|
+
};
|
30
45
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
modal: context
|
35
|
-
});
|
36
|
-
$modal = $('.modal.modal-logic');
|
37
|
-
if ($modal.length > 0) {
|
38
|
-
$modal.modal('hide').replaceWith(html);
|
39
|
-
} else {
|
40
|
-
$('body').append(html);
|
41
|
-
}
|
42
|
-
return this.showModal();
|
43
|
-
};
|
46
|
+
ModalLogic.prototype.showModal = function() {
|
47
|
+
return $('.modal.modal-logic').modal('show');
|
48
|
+
};
|
44
49
|
|
45
|
-
|
46
|
-
return $('.modal.modal-logic').modal('show');
|
47
|
-
};
|
50
|
+
return ModalLogic;
|
48
51
|
|
49
|
-
|
52
|
+
})();
|
50
53
|
|
51
|
-
})();
|
54
|
+
}).call(this);
|
data/lib/modal_logic/version.rb
CHANGED