async_futurize 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async_futurize.rb +0 -1
- data/lib/async_futurize/version.rb +1 -1
- data/vendor/assets/javascripts/futurize.js +50 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f1891d7183ce37d2b64efd34549e6022eb8cea45786a547064cec97c7925a16
|
4
|
+
data.tar.gz: 26b33f3cbe9960d1b2c0cfb668d5549ad88dbd893ef04457d430640944c60c30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49f4ed9cfc115a9f3f0ddece36c6d6227cb120e351a0efec98bd45b927294c0d3405a7505575520d8cec4e7d59d8588a03263f4f5d522b321d0a4793a90527fb
|
7
|
+
data.tar.gz: ceedc2ca87a2dc6077847710ce2ec78080aa7e9237ade86d15b9072b5b44e6d30488ec8ae393a4bcda746192c4bfea3f96c1852e1da5e01dbb5b043478ab53d7
|
data/lib/async_futurize.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require_relative "async_futurize/version"
|
4
4
|
require_relative '../app/helpers/futurize_helper.rb'
|
5
5
|
require_relative '../app/controllers/async_futurize/futurize_controller.rb'
|
6
|
-
require_relative '../app/javascript/packs/futurize.js'
|
7
6
|
|
8
7
|
module AsyncFuturize
|
9
8
|
class Base
|
@@ -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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashesh Tuladhar
|
@@ -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
|