modal_logic 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a414771edc95819b29e9b892f618db4298ecdb5b
|
4
|
+
data.tar.gz: 3a9becac0400be64929e15b4589f947d536701b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6330b9756963d54245cffb95f7bfe8894f71f42d68cc22dc15795c661d9a493b5823399e9f0231223ced936249b6170e19e3f8bcdb579555fb2918c3135049a7
|
7
|
+
data.tar.gz: 4376115b3132139119c0cb117267d47cf90ac193973e000d007fec1935f1053f9436a5d4cc972f849fd03d8258d7fdb2ef8224d305a00c687048f7ab643d64a7
|
@@ -3,8 +3,9 @@ exports = exports ? window
|
|
3
3
|
exports.ModalLogic = class ModalLogic
|
4
4
|
constructor: ->
|
5
5
|
that = @
|
6
|
-
$('a[data-remote][modal]
|
6
|
+
$('a[data-remote][modal]').on 'ajax:complete', (jq_event, xhr) ->
|
7
7
|
response = JSON.parse(xhr.responseText)
|
8
|
+
|
8
9
|
if response?
|
9
10
|
if response.close?
|
10
11
|
window.location = if response.redirect_location? then response.redirect_location else window.location
|
@@ -15,13 +16,33 @@ exports.ModalLogic = class ModalLogic
|
|
15
16
|
title: 'Error'
|
16
17
|
body: 'There was an error. Please reload the page and try again'
|
17
18
|
|
19
|
+
processResponse: (jq_event, xhr) ->
|
20
|
+
that = @
|
21
|
+
response = JSON.parse(xhr.responseText)
|
22
|
+
|
23
|
+
if response?
|
24
|
+
if response.close?
|
25
|
+
window.location = if response.redirect_location? then response.redirect_location else window.location
|
26
|
+
else
|
27
|
+
that.createOrUpdateModalContent(response)
|
28
|
+
else
|
29
|
+
that.createOrUpdateModalContent
|
30
|
+
title: 'Error'
|
31
|
+
body: 'There was an error. Please reload the page and try again'
|
32
|
+
|
18
33
|
createOrUpdateModalContent: (context) =>
|
19
34
|
html = HandlebarsTemplates['modal/crud']( modal: context )
|
20
35
|
$modal = $('.modal.modal-logic')
|
36
|
+
|
21
37
|
if $modal.length > 0
|
22
38
|
$modal.modal('hide').replaceWith html
|
23
39
|
else
|
24
40
|
$('body').append html
|
41
|
+
|
42
|
+
that = @
|
43
|
+
$('form[data-remote][modal]').on 'ajax:complete', (jq_event, xhr) ->
|
44
|
+
that.processResponse(jq_event, xhr)
|
45
|
+
|
25
46
|
@showModal()
|
26
47
|
|
27
48
|
showModal: =>
|
@@ -1,54 +1,73 @@
|
|
1
|
-
// Generated by CoffeeScript 1.
|
2
|
-
|
3
|
-
|
4
|
-
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
1
|
+
// Generated by CoffeeScript 1.7.1
|
2
|
+
var ModalLogic, exports,
|
3
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
5
4
|
|
6
|
-
|
5
|
+
exports = exports != null ? exports : window;
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
} else {
|
21
|
-
return that.createOrUpdateModalContent(response);
|
22
|
-
}
|
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]').on('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;
|
23
19
|
} else {
|
24
|
-
return that.createOrUpdateModalContent(
|
25
|
-
title: 'Error',
|
26
|
-
body: 'There was an error. Please reload the page and try again'
|
27
|
-
});
|
20
|
+
return that.createOrUpdateModalContent(response);
|
28
21
|
}
|
29
|
-
}
|
30
|
-
|
22
|
+
} else {
|
23
|
+
return that.createOrUpdateModalContent({
|
24
|
+
title: 'Error',
|
25
|
+
body: 'There was an error. Please reload the page and try again'
|
26
|
+
});
|
27
|
+
}
|
28
|
+
});
|
29
|
+
}
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
$modal.modal('hide').replaceWith(html);
|
31
|
+
ModalLogic.prototype.processResponse = function(jq_event, xhr) {
|
32
|
+
var response, that;
|
33
|
+
that = this;
|
34
|
+
response = JSON.parse(xhr.responseText);
|
35
|
+
if (response != null) {
|
36
|
+
if (response.close != null) {
|
37
|
+
return window.location = response.redirect_location != null ? response.redirect_location : window.location;
|
40
38
|
} else {
|
41
|
-
|
39
|
+
return that.createOrUpdateModalContent(response);
|
42
40
|
}
|
43
|
-
|
44
|
-
|
41
|
+
} else {
|
42
|
+
return that.createOrUpdateModalContent({
|
43
|
+
title: 'Error',
|
44
|
+
body: 'There was an error. Please reload the page and try again'
|
45
|
+
});
|
46
|
+
}
|
47
|
+
};
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
ModalLogic.prototype.createOrUpdateModalContent = function(context) {
|
50
|
+
var $modal, html, that;
|
51
|
+
html = HandlebarsTemplates['modal/crud']({
|
52
|
+
modal: context
|
53
|
+
});
|
54
|
+
$modal = $('.modal.modal-logic');
|
55
|
+
if ($modal.length > 0) {
|
56
|
+
$modal.modal('hide').replaceWith(html);
|
57
|
+
} else {
|
58
|
+
$('body').append(html);
|
59
|
+
}
|
60
|
+
that = this;
|
61
|
+
$('form[data-remote][modal]').on('ajax:complete', function(jq_event, xhr) {
|
62
|
+
return that.processResponse(jq_event, xhr);
|
63
|
+
});
|
64
|
+
return this.showModal();
|
65
|
+
};
|
49
66
|
|
50
|
-
|
67
|
+
ModalLogic.prototype.showModal = function() {
|
68
|
+
return $('.modal.modal-logic').modal('show');
|
69
|
+
};
|
51
70
|
|
52
|
-
|
71
|
+
return ModalLogic;
|
53
72
|
|
54
|
-
})
|
73
|
+
})();
|
data/lib/modal_logic/version.rb
CHANGED
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modal_logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam Hallett
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '4'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '4'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: handlebars_assets
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - '='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - '='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -93,27 +88,26 @@ files:
|
|
93
88
|
- test/test_helper.rb
|
94
89
|
homepage: http://github.com/atomical/modal_logic
|
95
90
|
licenses: []
|
91
|
+
metadata: {}
|
96
92
|
post_install_message:
|
97
93
|
rdoc_options: []
|
98
94
|
require_paths:
|
99
95
|
- lib
|
100
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
97
|
requirements:
|
103
|
-
- -
|
98
|
+
- - '>='
|
104
99
|
- !ruby/object:Gem::Version
|
105
100
|
version: '0'
|
106
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
102
|
requirements:
|
109
|
-
- -
|
103
|
+
- - '>='
|
110
104
|
- !ruby/object:Gem::Version
|
111
105
|
version: '0'
|
112
106
|
requirements: []
|
113
107
|
rubyforge_project:
|
114
|
-
rubygems_version:
|
108
|
+
rubygems_version: 2.0.14
|
115
109
|
signing_key:
|
116
|
-
specification_version:
|
110
|
+
specification_version: 4
|
117
111
|
summary: The simplicity of Rails forms coupled with Bootstrap modal
|
118
112
|
test_files:
|
119
113
|
- test/dummy/app/assets/javascripts/application.js
|