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.
@@ -1,51 +1,54 @@
1
1
  // Generated by CoffeeScript 1.6.3
2
- var ModalLogic, exports,
3
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
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
- function ModalLogic() {
9
- this.showModal = __bind(this.showModal, this);
10
- this.createOrUpdateModalContent = __bind(this.createOrUpdateModalContent, this);
11
- var that;
12
- that = this;
13
- $('a[data-remote][modal],form[data-remote][modal]').live('ajax:complete', function(jq_event, xhr) {
14
- var response;
15
- response = JSON.parse(xhr.responseText);
16
- if (response != null) {
17
- if (response.close != null) {
18
- return window.location = response.redirect_location != null ? response.redirect_location : window.location;
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(response);
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
- return that.createOrUpdateModalContent({
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
- ModalLogic.prototype.createOrUpdateModalContent = function(context) {
32
- var $modal, html;
33
- html = HandlebarsTemplates['modal/crud']({
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
- ModalLogic.prototype.showModal = function() {
46
- return $('.modal.modal-logic').modal('show');
47
- };
50
+ return ModalLogic;
48
51
 
49
- return ModalLogic;
52
+ })();
50
53
 
51
- })();
54
+ }).call(this);
@@ -1,3 +1,3 @@
1
1
  module ModalLogic
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modal_logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: