async_futurize 0.1.17 → 0.1.18

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: d3b633a3db500a3127b51f76fdf54095a50240c5e246d5e5e6b7ee8b836e4fe0
4
- data.tar.gz: c05e15e6221091d388a810e4bbd4b7dc00f6067bd382435048f3b51d44b4417a
3
+ metadata.gz: 0ead6f3cbbd3c014a6be85440801baffc0b1679103cfadcdd5661b8ddd850774
4
+ data.tar.gz: c95e275b8ef981f4f5a7b77c1758e95139163e83bac94d65a304b2486a96c37e
5
5
  SHA512:
6
- metadata.gz: 4d17bb5939f50aed4de8dbdb01ab8a0048953e24ece7bce8796839052c0da86e5feed4d6bdc44c4548073d3c22381945dd0d3d92330b69a12d319e26f613402f
7
- data.tar.gz: aa1d0b68a397631f48f90c4ada8cf18a303ea159d606f0a0369e4210eb5be2a72d339df94c92cc68adfaeeca605fce0a71cfb097976810fcfc0d7eca11e6b216
6
+ metadata.gz: 7818e1f267d900df7defb2938d63d933f6506389fc19f8419df0f36afe6809249d2c42124913cc128b0102053441b2775e04c1be33dd2fe0bb5db41ed71d018c
7
+ data.tar.gz: 6c12f477dfbd10edf4e1c6b243c31ee712d5b12452d68b30d3c866c02bc87379a6209a97520e7b4fdeee35d70e36856e0c1d0952edc2bf7cab48bb34aeff8c8c
@@ -0,0 +1,51 @@
1
+ console.log('Futurize loaded ..')
2
+ global.FuturizeComponent = {
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
+ }
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
+ }
48
+ }
49
+ document.addEventListener('DOMContentLoaded', function () {
50
+ FuturizeComponent.init('[data-futurize-component]');
51
+ })
@@ -0,0 +1,6 @@
1
+ import { Controller } from "stimulus"
2
+ export default class extends Controller {
3
+ initialize() {
4
+ console.log("It's working...")
5
+ }
6
+ }
@@ -1,51 +1,58 @@
1
- console.log('Futurize loaded ..')
2
- global.FuturizeComponent = {
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
- }
10
- }
11
- },
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ global.futurize= factory();
5
+ } (this,function() {
12
6
 
13
- reload: function(css_selector) {
14
- document.querySelectorAll(css_selector).forEach(function(o) {
15
- o.innerHTML = ""
16
- })
17
- },
7
+ console.log('Futurize loaded ..')
8
+ // global.FuturizeComponent = {
9
+ // init: function (css_selector) {
10
+ // var obj = document.querySelectorAll(css_selector);
11
+ // for (var i in obj) {
12
+ // if (obj.hasOwnProperty(i)) {
13
+ // //console.log(obj[i].getAttribute('data-futurize-component'));
14
+ // this.load_component(obj[i])
15
+ // }
16
+ // }
17
+ // },
18
18
 
19
- load_component: function (obj) {
20
- var component_name = obj.getAttribute('data-futurize-component'),
21
- component_params = obj.getAttribute('data-futurize-params');
19
+ // reload: function(css_selector) {
20
+ // document.querySelectorAll(css_selector).forEach(function(o) {
21
+ // o.innerHTML = ""
22
+ // })
23
+ // },
22
24
 
23
- if (obj.innerHTML.trim().length <= 0) {
24
- obj.innerHTML = 'Loading....';
25
- }
25
+ // load_component: function (obj) {
26
+ // var component_name = obj.getAttribute('data-futurize-component'),
27
+ // component_params = obj.getAttribute('data-futurize-params');
26
28
 
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
- }
48
- }
49
- document.addEventListener('DOMContentLoaded', function () {
50
- FuturizeComponent.init('[data-futurize-component]');
51
- })
29
+ // if (obj.innerHTML.trim().length <= 0) {
30
+ // obj.innerHTML = 'Loading....';
31
+ // }
32
+
33
+ // var AUTH_TOKEN = document.querySelector('meta[name=csrf-token]').getAttribute('content');
34
+ // fetch('/home/loadComponent', {
35
+ // mode: 'same-origin',
36
+ // method: 'POST',
37
+ // dataType: 'json',
38
+ // body : JSON.stringify({ component_to_load: component_name, component_params: component_params }),
39
+ // headers: {
40
+ // 'Content-Type': 'application/json',
41
+ // 'X-CSRF-Token' : AUTH_TOKEN,
42
+ // },
43
+ // })
44
+ // .then(response => response.json())
45
+ // .then(data => {
46
+ // obj.innerHTML = data.html
47
+ // obj.querySelectorAll("script").forEach(function(o) {
48
+ // eval(o.innerHTML)
49
+ // })
50
+ // }).catch((error) => {
51
+ // console.error('Error:', error);
52
+ // });
53
+ // }
54
+ // }
55
+ // document.addEventListener('DOMContentLoaded', function () {
56
+ // FuturizeComponent.init('[data-futurize-component]');
57
+ // })
58
+ }))
@@ -1,3 +1,5 @@
1
+ require "async_futurize/version"
2
+
1
3
  module AsyncFuturize
2
4
  class Engine < Rails::Engine
3
5
  config.assets.precompile += %w(futurize.js)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AsyncFuturize
4
- VERSION = "0.1.17"
4
+ VERSION = "0.1.18"
5
5
  end
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.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashesh Tuladhar
@@ -66,8 +66,10 @@ files:
66
66
  - LICENSE.txt
67
67
  - README.md
68
68
  - Rakefile
69
+ - app/assets/javascripts/futurize.js
69
70
  - app/controllers/async_futurize/futurize_controller.rb
70
71
  - app/helpers/futurize_helper.rb
72
+ - app/javascript/controllers/hello_controller.js
71
73
  - app/javascript/packs/futurize.js
72
74
  - app/views/_futurize_component_ajax.html.erb
73
75
  - app/views/_futurize_partial_ajax.html.erb