social_rails 2.1.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/app.js +16 -14
- data/app/assets/javascripts/social_rails/social-rails.js +41 -13
- data/app/views/social_rails/shared/_placeholder.html.erb +1 -1
- data/lib/social_rails/helpers/helper_methods.rb +1 -1
- data/lib/social_rails/version.rb +1 -1
- data/lib/social_rails.rb +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60ef8763a3b5568a98a7a83c8d8be31effb2a7ee
|
4
|
+
data.tar.gz: 1a438a17ccb3c1e2148168a400da3f481639ddf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0f6bd9b924ad5ec6811486874b1fbbb55d7e1ace14b3e19cd62813d627a18696ca7343399d61dff93fdd5c6a66614583921aee9594074ffef5e39bf6b0ff860
|
7
|
+
data.tar.gz: bef7740c827c635620dd9003b5ee551274d47e1cf77573f447d0511c7b0fd9b61f8ed540f4465de4e50a5c965408be7ee829353e2b3f097ac0f910ca276eb10b
|
@@ -6,27 +6,29 @@ window.SocialRails = () => {
|
|
6
6
|
twitter: '/social/twitter'
|
7
7
|
}
|
8
8
|
|
9
|
+
for (const placeholder of document.getElementsByClassName('js-social')) {
|
10
|
+
const namespace = placeholder.dataset.namespace
|
11
|
+
const node = document.getElementById(`social-${namespace}`)
|
12
|
+
const options = JSON.parse(node.dataset.options)
|
13
|
+
node.dataset.options = []
|
14
|
+
update_social_content(placeholder, { namespace, node, options })
|
15
|
+
}
|
9
16
|
|
10
|
-
|
11
|
-
|
12
|
-
for( let i = 0, len = placeholders.length; i < len; i++ ) {
|
13
|
-
|
14
|
-
let namespace = placeholders[i].dataset.namespace
|
15
|
-
let node = document.getElementById('social-' + namespace)
|
16
|
-
let options = node.dataset.options
|
17
|
-
let xhr = new XMLHttpRequest();
|
18
|
-
|
19
|
-
// xhr.open('GET', `${routes[namespace]}?options=${options}`);
|
17
|
+
function update_social_content (placeholder, {namespace, node, options}) {
|
18
|
+
const xhr = new XMLHttpRequest()
|
20
19
|
xhr.open('GET', routes[namespace])
|
21
20
|
|
22
21
|
xhr.onload = () => {
|
23
|
-
if (xhr.status === 200)
|
24
|
-
node.
|
25
|
-
|
22
|
+
if (xhr.status === 200) {
|
23
|
+
node.innerHTML = xhr.responseText
|
24
|
+
}
|
26
25
|
|
26
|
+
if (options.refresh === true) {
|
27
|
+
setTimeout(() => update_social_content(placeholder, { namespace, node, options }), options.refresh_time)
|
28
|
+
}
|
29
|
+
}
|
27
30
|
xhr.send()
|
28
31
|
}
|
29
|
-
|
30
32
|
}
|
31
33
|
|
32
34
|
/* Auto init */
|
@@ -8,27 +8,55 @@ window.SocialRails = function () {
|
|
8
8
|
twitter: '/social/twitter'
|
9
9
|
};
|
10
10
|
|
11
|
-
var
|
11
|
+
var _iteratorNormalCompletion = true;
|
12
|
+
var _didIteratorError = false;
|
13
|
+
var _iteratorError = undefined;
|
12
14
|
|
13
|
-
|
15
|
+
try {
|
16
|
+
for (var _iterator = document.getElementsByClassName('js-social')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
17
|
+
var placeholder = _step.value;
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
var namespace = placeholder.dataset.namespace;
|
20
|
+
var node = document.getElementById('social-' + namespace);
|
21
|
+
var options = JSON.parse(node.dataset.options);
|
22
|
+
node.dataset.options = [];
|
23
|
+
update_social_content(placeholder, { namespace: namespace, node: node, options: options });
|
24
|
+
}
|
25
|
+
} catch (err) {
|
26
|
+
_didIteratorError = true;
|
27
|
+
_iteratorError = err;
|
28
|
+
} finally {
|
29
|
+
try {
|
30
|
+
if (!_iteratorNormalCompletion && _iterator.return) {
|
31
|
+
_iterator.return();
|
32
|
+
}
|
33
|
+
} finally {
|
34
|
+
if (_didIteratorError) {
|
35
|
+
throw _iteratorError;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
19
39
|
|
20
|
-
|
40
|
+
function update_social_content(placeholder, _ref) {
|
41
|
+
var namespace = _ref.namespace,
|
42
|
+
node = _ref.node,
|
43
|
+
options = _ref.options;
|
44
|
+
|
45
|
+
var xhr = new XMLHttpRequest();
|
21
46
|
xhr.open('GET', routes[namespace]);
|
22
47
|
|
23
48
|
xhr.onload = function () {
|
24
|
-
if (xhr.status === 200)
|
25
|
-
|
49
|
+
if (xhr.status === 200) {
|
50
|
+
node.innerHTML = xhr.responseText;
|
51
|
+
}
|
26
52
|
|
53
|
+
if (options.refresh === true) {
|
54
|
+
setTimeout(function () {
|
55
|
+
return update_social_content(placeholder, { namespace: namespace, node: node, options: options });
|
56
|
+
}, options.refresh_time);
|
57
|
+
}
|
58
|
+
};
|
27
59
|
xhr.send();
|
28
|
-
};
|
29
|
-
|
30
|
-
for (var i = 0, len = placeholders.length; i < len; i++) {
|
31
|
-
_loop(i, len);
|
32
60
|
}
|
33
61
|
};
|
34
62
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<div class="js-social" id="social-<%= namespace %>" data-namespace="<%= namespace %>">
|
1
|
+
<div class="js-social" id="social-<%= namespace %>" data-namespace="<%= namespace %>" data-options="<%= options.to_json %>">
|
2
2
|
<div class="spinner">
|
3
3
|
<div class="double-bounce1"></div>
|
4
4
|
<div class="double-bounce2"></div>
|
@@ -18,7 +18,7 @@ module SocialRails
|
|
18
18
|
if valid_media(api)
|
19
19
|
api = "SocialRails::API::#{api.to_s.capitalize}".constantize
|
20
20
|
api.set_public_options(options)
|
21
|
-
render partial: 'social_rails/shared/placeholder', locals: {namespace: api.uid}
|
21
|
+
render partial: 'social_rails/shared/placeholder', locals: {namespace: api.uid, options: api.config["public"]}
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
data/lib/social_rails/version.rb
CHANGED
data/lib/social_rails.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis G
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.6.
|
141
|
+
rubygems_version: 2.6.14
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Ease the pain of integrating social media posts in a Rails app.
|