Skip to content

Commit

Permalink
Merge pull request #177 from f5devcentral/feedback-exclude
Browse files Browse the repository at this point in the history
fix: Enable ability to exclude survey from appearing on specific pages when survey is enabled
  • Loading branch information
jswongF5 committed May 24, 2022
2 parents b683ca1 + db5e9ea commit f3e7d8e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Setup and Configuration
# 'surveymonkey_url' = '', \\ DEFAULTS TO ""
# 'medallia_embed_url' = '', \\ DEFAULTS TO ""
# 'medallia_id' = '', \\ DEFAULTS TO "medallia_inline_survey"
# 'feedback_exclude_pages': ['page.html'], \\ DEFAULTS TO ['index.html', 'search.html'], THE TABLE OF CONTENTS AND SEARCH PAGE
# 'base_url' = '' \\ DEFAULTS TO '/'
}

Expand Down
2 changes: 1 addition & 1 deletion f5_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from os import path


__version__ = "2.2.0"
__version__ = "2.2.1"


def get_html_theme_path():
Expand Down
7 changes: 4 additions & 3 deletions f5_sphinx_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ <h5>{{ project }} {{ version }} </h5>
</div>
</div>
{% endif %}
{% if theme_medallia_embed_url %}
{% if theme_medallia_embed_url and (pagename+file_suffix) not in theme_feedback_exclude_pages %}
<hr>
<div id="{{ theme_medallia_id }}" class="medallia_survey">
</div>
<script type="text/javascript" src="{{ theme_medallia_embed_url }}" async></script>
{% endif %}
{% if theme_surveymonkey_url %}
{% if theme_surveymonkey_url and (pagename+file_suffix) not in theme_feedback_exclude_pages %}
<hr>
<div id="survey-sm-div" survey-sm-url="{{ theme_surveymonkey_url }}">
<a id="survey-sm" target="_blank" rel="noopener noreferrer">Click here to provide feedback</a>
Expand All @@ -165,7 +165,8 @@ <h5>{{ project }} {{ version }} </h5>
{% if (theme_version_selector) %}
<script src="{{ pathto('_static/js/index.js', 1) }}"></script>
{%- endif %}
{% if (theme_surveymonkey_url or theme_medallia_embed_url) %}
{% if (theme_surveymonkey_url or theme_medallia_embed_url) and (pagename+file_suffix) not in
theme_feedback_exclude_pages %}
<script src="{{ pathto('_static/js/feedback.js', 1) }}"></script>
{%- endif %}
<script src="{{ pathto('_static/js/jquery.appear.js', 1) }}"></script>
Expand Down
11 changes: 1 addition & 10 deletions f5_sphinx_theme/static/js/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const surveyMonkeyAId = "survey-sm";
const surveyMonkeyUrlAttr = 'survey-sm-url';

const htmlString = ".html";
const htmlDefaultIndex = "index.html";

// 'window' is a global variable. Define 'medalliaData' global variable here.
var medalliaData = {};
Expand Down Expand Up @@ -49,16 +48,8 @@ function renderSM(smDiv) {
const url = new URL(window.location.href);
const urlPathNames = url.pathname.split('/').filter(Boolean);

// If this is an 'index.html' or isn't even an html page, hide the SurveyMonkey link.
if (url.pathname.trim().endsWith(htmlDefaultIndex) || !url.pathname.endsWith(htmlString)) {
console.debug('This page need to hide SurveyMonkey link')
// Hide the SurveyMonkey Div because this pages doesn't need it.
if (smDiv != null) {
$("#" + surveyMonkeyDivId).hide();
}
}
// Otherwise determine the custom variables for SurveyMonkey.
else if (urlPathNames[urlPathNames.length - 1].endsWith(htmlString)) {
if (urlPathNames[urlPathNames.length - 1].endsWith(htmlString)) {
if (urlPathNames.length == 1) {
surveyMonkey.searchParams.append(data.surveyMonkey.page, urlPathNames[urlPathNames.length - 1]);
} else if (urlPathNames.length == 2) {
Expand Down
1 change: 1 addition & 0 deletions f5_sphinx_theme/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ enable_version_warning_banner = False
surveymonkey_url =
medallia_embed_url =
medallia_id = medallia_inline_survey
feedback_exclude_pages = ['index.html', 'search.html']

0 comments on commit f3e7d8e

Please sign in to comment.