Add Show Comments button

pull/931/merge
danroth27 2016-01-26 16:19:11 -08:00
parent bb2347344a
commit cd2b93ccd1
4 changed files with 29 additions and 41 deletions

View File

@ -128,6 +128,7 @@ else:
def setup(app):
app.add_stylesheet('custom.css?v=1')
# app.add_javascript('helpfulness.js')
app.add_javascript('disqus.js')
if on_rtd:
app.add_javascript('wedc.js')

View File

@ -0,0 +1,20 @@
$(function(){
var button = $('#showComments');
if (button.length)
{
var handler = function(){
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'aspnetdocs'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
button.hide();
};
button.on("click", handler);
}
});

View File

@ -1,34 +1,10 @@
<a id="helpfulness-btn-submit" href="javascript:;" class="common-btn">Submit</a>
{% extends "!page.html" %}
{% set disqus_shortname = 'aspnetdocs' %}
{#########################}
{# for disqus commenting #}
{#########################}
{% macro comments() %}
<hr/>
<h2 id="comments">
Comments
<a class="headerlink" href="#comments" title="Permalink to this headline"></a>
</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = '{{ disqus_shortname }}'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
{% endmacro %}
{%- block body %}
{{ super() }}
@ -47,7 +23,6 @@
Sorry this wasn't helpful.
<input type="text" id="txt-helpfulness" placeholder="Please let us know why this wasn't helpful">
<span id="helpfulness-characters-left">characters remaining</span>
<a id="helpfulness-btn-submit" href="javascript:;" class="common-btn">Submit</a>
<a id="helpfulness-btn-skip" href="javascript:;" class="common-btn secondary">Skip this</a>
</div>
<a href="javascript:;" class="helpfulness-close"></a>
@ -68,20 +43,11 @@
<img alt="" width="1" height="1" src="https://c.microsoft.com/trans_pixel.aspx"/>
</noscript>
{% if disqus_shortname and 'index' not in pagename and on_rtd %}
{% if next or prev %}
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
{% if next %}
<a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
{% endif %}
{% if prev %}
<a href="{{ prev.link|e }}" class="btn btn-neutral" title="{{ prev.title|striptags|e }}" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
{% endif %}
</div>
{% endif %}
{{ comments() }}
{% else %}
<!-- disqus commenting disabled; set disqus_shortname -->
<!-- disqus -->
{% if 'index' not in pagename %}
<button id="showComments" type="button" class="btn btn-neutral"><i class="fa fa-comment"></i> Show comments</button>
<div id="disqus_thread"></div>
<hr/>
{% endif %}
{%- endblock %}

View File

@ -135,7 +135,8 @@ else:
def setup(app):
app.add_stylesheet('custom.css?v=1')
# app.add_javascript('helpfulness.js')
# app.add_javascript('helpfulness.js')
app.add_javascript('disqus.js')
if on_rtd:
app.add_javascript('wedc.js')