From e4a7b35ff96a1398b3eaa3cb1635fdba5401784a Mon Sep 17 00:00:00 2001 From: danroth27 Date: Tue, 26 Jan 2016 16:19:11 -0800 Subject: [PATCH 1/3] Add Show Comments button --- aspnet/conf.py | 1 + common/_static/disqus.js | 22 ++++++++++++++++++ common/_templates/page.html | 46 +++++-------------------------------- mvc/conf.py | 3 ++- 4 files changed, 31 insertions(+), 41 deletions(-) create mode 100644 common/_static/disqus.js diff --git a/aspnet/conf.py b/aspnet/conf.py index dcab307793de..7f9567efb775 100644 --- a/aspnet/conf.py +++ b/aspnet/conf.py @@ -128,6 +128,7 @@ 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') diff --git a/common/_static/disqus.js b/common/_static/disqus.js new file mode 100644 index 000000000000..e6a8228349f8 --- /dev/null +++ b/common/_static/disqus.js @@ -0,0 +1,22 @@ +$(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 * * */ + (function() { + if (!$("#disqus_thread").html()) { + 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.on("click", handler); + } +}); \ No newline at end of file diff --git a/common/_templates/page.html b/common/_templates/page.html index 6d7b5ef0e57a..7ebd7bb22995 100644 --- a/common/_templates/page.html +++ b/common/_templates/page.html @@ -1,34 +1,10 @@ +Submit {% extends "!page.html" %} -{% set disqus_shortname = 'aspnetdocs' %} - {#########################} {# for disqus commenting #} {#########################} -{% macro comments() %} -
-

- Comments - -

- -
- - -{% endmacro %} - - {%- block body %} {{ super() }} @@ -47,7 +23,6 @@

Was this page helpful?

Sorry this wasn't helpful. characters remaining - Submit Skip this @@ -68,20 +43,11 @@

Was this page helpful?

- {% if disqus_shortname and 'index' not in pagename and on_rtd %} - {% if next or prev %} - - {% endif %} - {{ comments() }} - {% else %} - + + {% if 'index' not in pagename %} + +
+
{% endif %} {%- endblock %} diff --git a/mvc/conf.py b/mvc/conf.py index f4d447d3740a..2bc8c03141b7 100644 --- a/mvc/conf.py +++ b/mvc/conf.py @@ -135,7 +135,8 @@ 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') From c09570ac96312f707e037218ee823fe585d388d8 Mon Sep 17 00:00:00 2001 From: danroth27 Date: Tue, 26 Jan 2016 16:50:19 -0800 Subject: [PATCH 2/3] Hide button once clicked --- common/_static/disqus.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/_static/disqus.js b/common/_static/disqus.js index e6a8228349f8..d3018d4561b8 100644 --- a/common/_static/disqus.js +++ b/common/_static/disqus.js @@ -8,13 +8,13 @@ $(function(){ var disqus_shortname = 'aspnetdocs'; // required: replace example with your forum shortname /* * * DON'T EDIT BELOW THIS LINE * * */ - (function() { - if (!$("#disqus_thread").html()) { - 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); - } - })(); + if (!$("#disqus_thread").html()) { + 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); From 1eda14e9f20db5205bb88c936f602045eecbafe1 Mon Sep 17 00:00:00 2001 From: danroth27 Date: Tue, 26 Jan 2016 16:53:34 -0800 Subject: [PATCH 3/3] Remove unnecessary if check --- common/_static/disqus.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/common/_static/disqus.js b/common/_static/disqus.js index d3018d4561b8..fe6a27fc1d4c 100644 --- a/common/_static/disqus.js +++ b/common/_static/disqus.js @@ -8,11 +8,9 @@ $(function(){ var disqus_shortname = 'aspnetdocs'; // required: replace example with your forum shortname /* * * DON'T EDIT BELOW THIS LINE * * */ - if (!$("#disqus_thread").html()) { - 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); - } + 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(); };