async_futurize 0.1.8 → 0.1.13
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: 576f8c119fc7dad8942079ceee9fee9f499212e752bac16c7261ebc56ace7a0c
|
4
|
+
data.tar.gz: 76cd8050599e2a4b90d75c5fc1ac7df9bd4830af6a758bba70a8f9894fcb65d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61a490a1fa29b11b56637e76dd55849921aacbedc40ae2c9daa596b28146fb00c10ca3428b0f6bde35a1da821492265c4f34d31d8391d304844ca5a518631367
|
7
|
+
data.tar.gz: d557e4a8551d9fd42948e13f0490f35364dbb3efb708d1fe9988ec173145baf032b1b9630988925837f6381332cdcbb794cf3581596b4a3742b3e5bad2537c76
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module
|
2
|
-
class FuturizeController
|
1
|
+
module AsyncFuturize
|
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) }
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashesh Tuladhar
|
@@ -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
|
@@ -35,6 +34,7 @@ files:
|
|
35
34
|
- lib/async_futurize.rb
|
36
35
|
- lib/async_futurize/engine.rb
|
37
36
|
- lib/async_futurize/version.rb
|
37
|
+
- vendor/assets/javascripts/futurize.js
|
38
38
|
homepage: https://gitlab.com/asheshtuldhar/async_futurize
|
39
39
|
licenses:
|
40
40
|
- MIT
|
@@ -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
|
-
})
|