async_futurize 0.1.5 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/async_futurize/futurize_controller.rb +1 -1
- data/app/{assets/javascript → javascript/packs}/futurize.js +0 -0
- data/lib/async_futurize.rb +1 -0
- data/lib/async_futurize/engine.rb +0 -2
- data/lib/async_futurize/version.rb +1 -1
- data/vendor/assets/javascripts/futurize.js +50 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54a2ffe3a30c4bae87a3d167fad40d50ab746ca8646f9f54e83bc53a4cda9434
|
4
|
+
data.tar.gz: 8e45e89b5db8955ccec5c5c64a6b28a0195bf2998f3b4beedb342a51004ff25d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06bac83343261bb75fa4b2ee08ed419c6d83c1f6459cf0102f693c1a8e5bcc338bb3dde4e2b6ff4eca58a82a2b4bdb72ca4c59e7c8d118f5caf4fd82774a4a37
|
7
|
+
data.tar.gz: e085f393dd0634b79a817d9eda95eccdec981d8ac0f6ebc979d05199b4fb9618967af97b3b9a77d375a5484149796bc761487cb072ac2476e2a5e28db73586c9
|
File without changes
|
data/lib/async_futurize.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
global.FuturizeComponent = {
|
2
|
+
init: function (css_selector) {
|
3
|
+
var obj = document.querySelectorAll(css_selector);
|
4
|
+
for (var i in obj) {
|
5
|
+
if (obj.hasOwnProperty(i)) {
|
6
|
+
//console.log(obj[i].getAttribute('data-futurize-component'));
|
7
|
+
this.load_component(obj[i])
|
8
|
+
}
|
9
|
+
}
|
10
|
+
},
|
11
|
+
|
12
|
+
reload: function(css_selector) {
|
13
|
+
document.querySelectorAll(css_selector).forEach(function(o) {
|
14
|
+
o.innerHTML = ""
|
15
|
+
})
|
16
|
+
},
|
17
|
+
|
18
|
+
load_component: function (obj) {
|
19
|
+
var component_name = obj.getAttribute('data-futurize-component'),
|
20
|
+
component_params = obj.getAttribute('data-futurize-params');
|
21
|
+
|
22
|
+
if (obj.innerHTML.trim().length <= 0) {
|
23
|
+
obj.innerHTML = 'Loading....';
|
24
|
+
}
|
25
|
+
|
26
|
+
var AUTH_TOKEN = document.querySelector('meta[name=csrf-token]').getAttribute('content');
|
27
|
+
fetch('/home/loadComponent', {
|
28
|
+
mode: 'same-origin',
|
29
|
+
method: 'POST',
|
30
|
+
dataType: 'json',
|
31
|
+
body : JSON.stringify({ component_to_load: component_name, component_params: component_params }),
|
32
|
+
headers: {
|
33
|
+
'Content-Type': 'application/json',
|
34
|
+
'X-CSRF-Token' : AUTH_TOKEN,
|
35
|
+
},
|
36
|
+
})
|
37
|
+
.then(response => response.json())
|
38
|
+
.then(data => {
|
39
|
+
obj.innerHTML = data.html
|
40
|
+
obj.querySelectorAll("script").forEach(function(o) {
|
41
|
+
eval(o.innerHTML)
|
42
|
+
})
|
43
|
+
}).catch((error) => {
|
44
|
+
console.error('Error:', error);
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}
|
48
|
+
document.addEventListener('DOMContentLoaded', function () {
|
49
|
+
FuturizeComponent.init('[data-futurize-component]');
|
50
|
+
})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async_futurize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashesh Tuladhar
|
@@ -24,9 +24,9 @@ files:
|
|
24
24
|
- LICENSE.txt
|
25
25
|
- README.md
|
26
26
|
- Rakefile
|
27
|
-
- app/assets/javascript/futurize.js
|
28
27
|
- app/controllers/async_futurize/futurize_controller.rb
|
29
28
|
- app/helpers/futurize_helper.rb
|
29
|
+
- app/javascript/packs/futurize.js
|
30
30
|
- app/views/_futurize_component_ajax.html.erb
|
31
31
|
- app/views/_futurize_partial_ajax.html.erb
|
32
32
|
- async_futurize.gemspec
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/async_futurize.rb
|
36
36
|
- lib/async_futurize/engine.rb
|
37
37
|
- lib/async_futurize/version.rb
|
38
|
+
- vendor/assets/javascripts/futurize.js
|
38
39
|
homepage: https://gitlab.com/asheshtuldhar/async_futurize
|
39
40
|
licenses:
|
40
41
|
- MIT
|