nexaas-async-collector 3.3.2 → 3.3.3

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
- SHA1:
3
- metadata.gz: 0ace8ebdcf15e52a1a8e73205906d70fe843189d
4
- data.tar.gz: d64ad488388958efbce193c40e980770e3003027
2
+ SHA256:
3
+ metadata.gz: 842bb99f8a3e92981689ee7978d4fd93b39e62294053ddc93770266378137b52
4
+ data.tar.gz: 00b1fefc5c70c5cc67edd3b235529e65ec4a20907f493a38c458e09b5da9162c
5
5
  SHA512:
6
- metadata.gz: 6bce043a62b74c58571e0587104470d2e4c0ec8ceeb2a275961611d7613a1c425b0ac9bc2463308fa18f2ff220edea9faa63e78a688831a32d11f154a15f3080
7
- data.tar.gz: 590d33cb22ae3e4775a7ac6b9cf2857cc60dfd5a387d36f0c5299e24e52f0fdc2123302cac96bdbaa11a884f9160e4cc6e09be66e68161b971b30c1a87ca819b
6
+ metadata.gz: 5812d59457d8b3a630838ef360e82c10fcd287edc99d028c7ec81bcc13a9afaf22817787be83ad469f7e7a52a689c500faf52fdadf382f59da8393c7d04346b3
7
+ data.tar.gz: 2fefb161bc113d27519ab3fd285f61e6075d12fef116a0bae7655cd60c7812484b0ea3fb737737b510f36050418760c1b57520c21018034ede7d2b15038abeb0
@@ -1,16 +1,44 @@
1
1
  <script type="text/javascript" id="js-nexaas-async-collector-<%= unique_id %>">
2
- if (!!window.nexaas_async_interval)
3
- clearInterval(window.nexaas_async_interval);
4
-
5
- var requestContent = function() {
6
- $.ajax({
7
- url: '<%= nexaas_async_collector.async_resource_path(collect_id) %>',
8
- dataType: 'script',
9
- data: { unique_id: '<%= unique_id %>' }
10
- })
11
- }
12
-
13
- window.nexaas_async_interval = setInterval(requestContent, 3000);
2
+ (function registerCollector(id, path) {
3
+ window.nexaas_async_collector = window.nexaas_async_collector || {};
4
+
5
+ var collector = window.nexaas_async_collector[id];
6
+ var isCollectorPresent = !!collector;
7
+
8
+ if (isCollectorPresent) {
9
+ clearInterval(collector.interval);
10
+ }
11
+
12
+ var requestContent = function() {
13
+ $.ajax({
14
+ url: path,
15
+ dataType: 'script',
16
+ data: { unique_id: id }
17
+ })
18
+ };
19
+
20
+ var removeLoader = function(self) {
21
+ clearInterval(self.interval);
22
+ $('#js-nexaas-async-collector-loading-' + id).remove();
23
+ $('#js-nexaas-async-collector-style-' + id).remove();
24
+ };
25
+
26
+ window.nexaas_async_collector[id] = {
27
+ interval: setInterval(requestContent, 3000),
28
+
29
+ collectHTML: function(html) {
30
+ removeLoader(this);
31
+ var $collector = $('#js-nexaas-async-collector-' + id);
32
+ $collector.parent().append(html);
33
+ $collector.remove();
34
+ },
35
+
36
+ collectUrl: function(url) {
37
+ removeLoader(this);
38
+ window.location.href = url;
39
+ }
40
+ };
41
+ })('<%= unique_id %>', '<%= nexaas_async_collector.async_resource_path(collect_id) %>');
14
42
  </script>
15
43
 
16
44
  <%= render partial: "nexaas/async/collector/async_resource/loading", locals: { unique_id: unique_id } %>
@@ -1,13 +1,11 @@
1
1
  <% if @result.content_is_ready? %>
2
- clearInterval(window.nexaas_async_interval);
3
-
4
2
  <% if @result.is_file? %>
5
- $('#js-nexaas-async-collector-loading-<%= @unique_id %>').remove();
6
- window.location.href = '<%= nexaas_async_collector.async_resource_path(params[:id], format: @result.extension) %>';
3
+ window.nexaas_async_collector['<%= @unique_id %>'].collectUrl(
4
+ '<%= nexaas_async_collector.async_resource_path(params[:id], format: @result.extension) %>'
5
+ );
7
6
  <% else %>
8
- $('#js-nexaas-async-collector-loading-<%= @unique_id %>').remove();
9
- $('#js-nexaas-async-collector-<%= @unique_id %>').parent().append("<%= escape_javascript(@result.content.force_encoding('UTF-8').html_safe) %>");
10
- $('#js-nexaas-async-collector-<%= @unique_id %>').remove()
11
- $('#js-nexaas-async-collector-style-<%= @unique_id %>').remove()
7
+ window.nexaas_async_collector['<%= @unique_id %>'].collectHTML(
8
+ '<%= escape_javascript(@result.content.force_encoding('UTF-8').html_safe) %>'
9
+ );
12
10
  <% end %>
13
11
  <% end %>
@@ -1,7 +1,7 @@
1
1
  module Nexaas
2
2
  module Async
3
3
  module Collector
4
- VERSION = '3.3.2'
4
+ VERSION = '3.3.3'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexaas-async-collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Hertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-30 00:00:00.000000000 Z
11
+ date: 2018-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 0.6.0
95
+ version: 0.7.0
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 0.6.0
102
+ version: 0.7.0
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: byebug
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  requirements: []
177
177
  rubyforge_project:
178
- rubygems_version: 2.6.14.1
178
+ rubygems_version: 2.7.6
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Collect and generate async content.