async_futurize 0.1.5 → 0.1.10

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: d391fed07f9c09a30470bf1a4c7fbb947f796b9b8f704a3194668b2ef7f97f58
4
- data.tar.gz: 7160498ce6d969cc8e24dee4aada92d0785d6a86e11f2f1e502ee801b622275a
3
+ metadata.gz: 54a2ffe3a30c4bae87a3d167fad40d50ab746ca8646f9f54e83bc53a4cda9434
4
+ data.tar.gz: 8e45e89b5db8955ccec5c5c64a6b28a0195bf2998f3b4beedb342a51004ff25d
5
5
  SHA512:
6
- metadata.gz: 1c1d8a2470e4f1c6ad566224cf2dd479ab89f4aedcce32e25f3b4925b1edde97724bb2e735490a9492948082fd6ad03cb676933e61acd2450066be19f64edd2f
7
- data.tar.gz: c3548f24edf702bf2ac9e3afd17074ed9b7e79a34c25923ac4d86b7bc6d618dad04eb814cc04cda63cf8fbb6c783de2fd969ac4cacc821aafc95f8e6568d1a1b
6
+ metadata.gz: 06bac83343261bb75fa4b2ee08ed419c6d83c1f6459cf0102f693c1a8e5bcc338bb3dde4e2b6ff4eca58a82a2b4bdb72ca4c59e7c8d118f5caf4fd82774a4a37
7
+ data.tar.gz: e085f393dd0634b79a817d9eda95eccdec981d8ac0f6ebc979d05199b4fb9618967af97b3b9a77d375a5484149796bc761487cb072ac2476e2a5e28db73586c9
@@ -1,4 +1,4 @@
1
- module async_futurize
1
+ module AsyncFuturize
2
2
  class FuturizeController < ApplicationController
3
3
  def loadComponent
4
4
  locals = { component: params[:component_to_load], component_params: params[:component_params] }
@@ -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.5"
4
+ VERSION = "0.1.10"
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.5
4
+ version: 0.1.10
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