Skip to content

Commit 16c8c5c

Browse files
committed
fix scripts.html
1 parent 4ddd9ac commit 16c8c5c

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{% case site.comments.provider %}
2+
{% when "disqus" %}
3+
<script>
4+
var disqus_config = function () {
5+
this.page.url = "{{ page.url | absolute_url }}";
6+
this.page.identifier = "{{ page.url | absolute_url }}";
7+
};
8+
(function() {
9+
var d = document, s = d.createElement('script');
10+
s.src = 'https://{{ site.comments.disqus.shortname }}.disqus.com/embed.js';
11+
s.setAttribute('data-timestamp', +new Date());
12+
(d.head || d.body).appendChild(s);
13+
})();
14+
</script>
15+
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
16+
{% when "facebook" %}
17+
<script>
18+
window.fbAsyncInit = function() {
19+
FB.init({
20+
appId : '{{ site.comments.facebook.appid }}',
21+
autoLogAppEvents : true,
22+
xfbml : true,
23+
version : 'v2.10'
24+
});
25+
};
26+
(function(d, s, id){
27+
var js, fjs = d.getElementsByTagName(s)[0];
28+
if (d.getElementById(id)) {return;}
29+
js = d.createElement(s); js.id = id;
30+
js.src = "https://connect.facebook.net/en_US/sdk.js";
31+
fjs.parentNode.insertBefore(js, fjs);
32+
}(document, 'script', 'facebook-jssdk'));
33+
</script>
34+
{% when "staticman" %}
35+
<script>
36+
(function ($) {
37+
$('#new_comment').submit(function () {
38+
var form = this;
39+
$(form).addClass('disabled');
40+
$('#comment-form-submit').html('<i class="fa fa-spinner fa-spin fa-fw"></i> {{ site.data.ui-text[site.locale].loading_label | default: "Loading..." }}');
41+
$.ajax({
42+
type: $(this).attr('method'),
43+
url: $(this).attr('action'),
44+
data: $(this).serialize(),
45+
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
46+
success: function (data) {
47+
$('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submitted | default: "Submitted" }}');
48+
$('.page__comments-form .js-notice').removeClass('notice--danger');
49+
$('.page__comments-form .js-notice').addClass('notice--success');
50+
showAlert('<strong>{{ site.data.ui-text[site.locale].comment_success_msg | default: "Thanks for your comment! It will show on the site once it has been approved." }}</strong>');
51+
},
52+
error: function (err) {
53+
console.log(err);
54+
$('#comment-form-submit').html('{{ site.data.ui-text[site.locale].comment_btn_submit | default: "Submit Comment" }}');
55+
$('.page__comments-form .js-notice').removeClass('notice--success');
56+
$('.page__comments-form .js-notice').addClass('notice--danger');
57+
showAlert('<strong>{{ site.data.ui-text[site.locale].comment_error_msg | default: "Sorry, there was an error with your submission. Please make sure all required fields have been completed and try again." }}</strong>');
58+
$(form).removeClass('disabled');
59+
}
60+
});
61+
return false;
62+
});
63+
function showAlert(message) {
64+
$('.page__comments-form .js-notice').removeClass('hidden');
65+
$('.page__comments-form .js-notice-text').html(message);
66+
}
67+
})(jQuery);
68+
</script>
69+
{% endcase %}

0 commit comments

Comments
 (0)