async_futurize 0.1.12 → 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: d7f5e15a17cef1b822e92f47ff954c16dbaa3dee334dc71f814d6106a31e6427
4
- data.tar.gz: 0e41f1295ce58e1545f26b8dbfd996cc2a1a51b585d763a6ee3665ed8045aec7
3
+ metadata.gz: 576f8c119fc7dad8942079ceee9fee9f499212e752bac16c7261ebc56ace7a0c
4
+ data.tar.gz: 76cd8050599e2a4b90d75c5fc1ac7df9bd4830af6a758bba70a8f9894fcb65d1
5
5
  SHA512:
6
- metadata.gz: '054998df99628b7c151251a67b0d20f3a67eede2a7ca0e2445a5a16e735c829adc9fe34eefe5315e6f0bd49ab290985b574941bebf414a3f3ddb9527356d16a3'
7
- data.tar.gz: 1fc6880c905aa36665003d03196814a604eaab54bdf6f7708b857ec30a8c2bd95dc9624a68ca31b30573440a5b62b4b206dc68cad416eec94dc78d26afe72bf9
6
+ metadata.gz: 61a490a1fa29b11b56637e76dd55849921aacbedc40ae2c9daa596b28146fb00c10ca3428b0f6bde35a1da821492265c4f34d31d8391d304844ca5a518631367
7
+ data.tar.gz: d557e4a8551d9fd42948e13f0490f35364dbb3efb708d1fe9988ec173145baf032b1b9630988925837f6381332cdcbb794cf3581596b4a3742b3e5bad2537c76
@@ -1,5 +1,5 @@
1
1
  module AsyncFuturize
2
- class FuturizeController < ApplicationController
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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AsyncFuturize
4
- VERSION = "0.1.12"
4
+ VERSION = "0.1.13"
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.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ashesh Tuladhar
@@ -24,10 +24,8 @@ files:
24
24
  - LICENSE.txt
25
25
  - README.md
26
26
  - Rakefile
27
- - app/controllers/applicaton_controller.rb
28
27
  - app/controllers/async_futurize/futurize_controller.rb
29
28
  - app/helpers/futurize_helper.rb
30
- - app/javascript/packs/futurize.js
31
29
  - app/views/_futurize_component_ajax.html.erb
32
30
  - app/views/_futurize_partial_ajax.html.erb
33
31
  - async_futurize.gemspec
@@ -1,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -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
- })