async_futurize 0.1.10 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a12b25da2b5758f71855d8b5ed5c957ea175eb4318fc84ffb4d382af161dd347
|
4
|
+
data.tar.gz: 547abd3295c49f82ed4cde236e84bace98e0584198ede046ef5afb032e6ed91f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6ba71e1b44595f4a60f7fea88e19e5e1e5c0d192b2b5a38ec2631f415890792ceaa5dde422f22e8adc83ebb39b9ea512eaf063116f7127dbc5ce488b357193
|
7
|
+
data.tar.gz: 99795b75406f43751e4e03e960d71c939b79e5e63311c748413d1a39fd9c9e5c4103d268f6949078ae30ca3bd681d565d5c3d17d5048d1197dbe27ecc921e7cd
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module AsyncFuturize
|
2
|
-
class FuturizeController
|
2
|
+
class FuturizeController
|
3
3
|
def loadComponent
|
4
4
|
locals = { component: params[:component_to_load], component_params: params[:component_params] }
|
5
5
|
render json: { component: params[:component_to_load], html: render_to_string(partial: './futurize_component_ajax', locals: locals) }
|
@@ -1,50 +1,51 @@
|
|
1
|
+
console.log('Futurize loaded ..')
|
1
2
|
global.FuturizeComponent = {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
3
|
+
init: function (css_selector) {
|
4
|
+
var obj = document.querySelectorAll(css_selector);
|
5
|
+
for (var i in obj) {
|
6
|
+
if (obj.hasOwnProperty(i)) {
|
7
|
+
//console.log(obj[i].getAttribute('data-futurize-component'));
|
8
|
+
this.load_component(obj[i])
|
9
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
10
|
}
|
11
|
+
},
|
12
|
+
|
13
|
+
reload: function(css_selector) {
|
14
|
+
document.querySelectorAll(css_selector).forEach(function(o) {
|
15
|
+
o.innerHTML = ""
|
16
|
+
})
|
17
|
+
},
|
18
|
+
|
19
|
+
load_component: function (obj) {
|
20
|
+
var component_name = obj.getAttribute('data-futurize-component'),
|
21
|
+
component_params = obj.getAttribute('data-futurize-params');
|
22
|
+
|
23
|
+
if (obj.innerHTML.trim().length <= 0) {
|
24
|
+
obj.innerHTML = 'Loading....';
|
25
|
+
}
|
26
|
+
|
27
|
+
var AUTH_TOKEN = document.querySelector('meta[name=csrf-token]').getAttribute('content');
|
28
|
+
fetch('/home/loadComponent', {
|
29
|
+
mode: 'same-origin',
|
30
|
+
method: 'POST',
|
31
|
+
dataType: 'json',
|
32
|
+
body : JSON.stringify({ component_to_load: component_name, component_params: component_params }),
|
33
|
+
headers: {
|
34
|
+
'Content-Type': 'application/json',
|
35
|
+
'X-CSRF-Token' : AUTH_TOKEN,
|
36
|
+
},
|
37
|
+
})
|
38
|
+
.then(response => response.json())
|
39
|
+
.then(data => {
|
40
|
+
obj.innerHTML = data.html
|
41
|
+
obj.querySelectorAll("script").forEach(function(o) {
|
42
|
+
eval(o.innerHTML)
|
43
|
+
})
|
44
|
+
}).catch((error) => {
|
45
|
+
console.error('Error:', error);
|
46
|
+
});
|
47
47
|
}
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
}
|
49
|
+
document.addEventListener('DOMContentLoaded', function () {
|
50
|
+
FuturizeComponent.init('[data-futurize-component]');
|
51
|
+
})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashesh Tuladhar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Asynchronously load view components.
|
14
14
|
email:
|
@@ -26,7 +26,6 @@ files:
|
|
26
26
|
- Rakefile
|
27
27
|
- app/controllers/async_futurize/futurize_controller.rb
|
28
28
|
- app/helpers/futurize_helper.rb
|
29
|
-
- app/javascript/packs/futurize.js
|
30
29
|
- app/views/_futurize_component_ajax.html.erb
|
31
30
|
- app/views/_futurize_partial_ajax.html.erb
|
32
31
|
- async_futurize.gemspec
|
@@ -1,50 +0,0 @@
|
|
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
|
-
})
|