async_futurize 0.1.4 → 0.1.9

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: d022045c88d555ca3850e71f4ea459bb96791e2549bc691ef03f51e34d0c4618
4
- data.tar.gz: e599d2643563dcd181d2d113fabefe523026b882a3d26b176be023bac8332943
3
+ metadata.gz: 9f1891d7183ce37d2b64efd34549e6022eb8cea45786a547064cec97c7925a16
4
+ data.tar.gz: 26b33f3cbe9960d1b2c0cfb668d5549ad88dbd893ef04457d430640944c60c30
5
5
  SHA512:
6
- metadata.gz: a503bea6252fef1b7a33883c8b980a0c98de2935bcfa30c5a199097e93e871442320ac14d97684c737bf3e0933e70ca06813c5c69bca5c4959d9fb562ef33a99
7
- data.tar.gz: 9efdcc261b15ed3c1b01ccd72f259998086d91aff901fc7efe369ffc85a8aa7da8c750f4d4bcdcdd7d26697ce53e8fa9ac9f3c044c8a4fbeb19f1c72e94b9fb0
6
+ metadata.gz: 49f4ed9cfc115a9f3f0ddece36c6d6227cb120e351a0efec98bd45b927294c0d3405a7505575520d8cec4e7d59d8588a03263f4f5d522b321d0a4793a90527fb
7
+ data.tar.gz: ceedc2ca87a2dc6077847710ce2ec78080aa7e9237ade86d15b9072b5b44e6d30488ec8ae393a4bcda746192c4bfea3f96c1852e1da5e01dbb5b043478ab53d7
@@ -1,5 +1,5 @@
1
1
  module FuturizeHelper
2
- def load_in_future_ajax(component,component_params = {},component_attributes = {})
2
+ def load_in_future_ajax_new(component,component_params = {},component_attributes = {})
3
3
  render :partial => './futurize_partial_ajax', :locals => { component: component, component_params: component_params, component_attributes: component_attributes }
4
4
  end
5
5
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "async_futurize/version"
4
4
  require_relative '../app/helpers/futurize_helper.rb'
5
+ require_relative '../app/controllers/async_futurize/futurize_controller.rb'
5
6
 
6
7
  module AsyncFuturize
7
8
  class Base
@@ -1,5 +1,3 @@
1
- #require "lodash/rails"
2
-
3
1
  module AsyncFuturize
4
2
  class Engine < Rails::Engine
5
3
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AsyncFuturize
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.9"
5
5
  end
@@ -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
4
+ version: 0.1.9
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