Commit 1d2c38bc authored by Toby Hodges's avatar Toby Hodges

Merge branch 'default-display' into 'master'

add default option with no displayed div for activities and exercises

See merge request stamper/image-analysis-training-resources!1
parents 4c929a4a 49efd7c8
...@@ -10,78 +10,60 @@ function set_view_defaults() { ...@@ -10,78 +10,60 @@ function set_view_defaults() {
set_activity_view_defaults(); set_activity_view_defaults();
set_exercises_view_defaults(); set_exercises_view_defaults();
} }
{% endif %}
{% if page.activities %}
function set_activity_view_defaults() { function set_activity_view_defaults() {
{% assign first = true %}
{% endif %} {% endif %}
{% for platform in page.activities %} {% for platform in page.activities %}
document.getElementById("{{ platform[0] | slugify }}-activity-div").style.display = 'none'; document.getElementById("{{ platform[0] | slugify }}-activity-div").style.display = 'none';
{% if first %}
document.getElementById("{{ platform[0] | slugify }}-activity-div").style.display = 'block';
{% assign first = false %}
{% endif %}
{% endfor %} {% endfor %}
{% if page.activities or page.exercises %} {% if page.activities %}
}; };
function change_activity_content_by_platform(form_control){ function change_activity_content_by_platform(form_control){
{% assign first = true %}
{% endif %} {% endif %}
{% for platform in page.activities %} {% for platform in page.activities %}
document.getElementById("{{ platform[0] | slugify }}-activity-div").style.display = 'none'; document.getElementById("{{ platform[0] | slugify }}-activity-div").style.display = 'none';
{% endfor %} {% endfor %}
{% for platform in page.activities %} {% if page.activities %}
{% if first %} if (!form_control || document.getElementById(form_control).value == "default-activity") {
if (!form_control || document.getElementById(form_control).value == "{{ platform[0] | slugify }}-activity") {
set_activity_view_defaults(); set_activity_view_defaults();
{% assign first = false %} {% endif %}
{% else %} {% for platform in page.activities %}
} else if (document.getElementById(form_control).value == "{{ platform[0] | slugify }}-activity") { } else if (document.getElementById(form_control).value == "{{ platform[0] | slugify }}-activity") {
document.getElementById("{{ platform[0] | slugify }}-activity-div").style.display = 'block'; document.getElementById("{{ platform[0] | slugify }}-activity-div").style.display = 'block';
{% endif %}
{% endfor %} {% endfor %}
{% if page.activities %} {% if page.activities %}
} else { } else {
alert("Error: Missing platform value for 'change_activity_content_by_platform()' script!"); alert("Error: Missing platform value for 'change_activity_content_by_platform()' script!");
} }
{% endif %}
{% if page.activities or page.exercises %}
} }
{% assign first = false %} {% endif %}
{% if page.exercises %}
function set_exercises_view_defaults() { function set_exercises_view_defaults() {
{% assign first = true %}
{% endif %} {% endif %}
{% for platform in page.exercises %} {% for platform in page.exercises %}
document.getElementById("{{ platform[0] | slugify }}-exercises-div").style.display = 'none'; document.getElementById("{{ platform[0] | slugify }}-exercises-div").style.display = 'none';
{% if first %}
document.getElementById("{{ platform[0] | slugify }}-exercises-div").style.display = 'block';
{% assign first = false %}
{% endif %}
{% endfor %} {% endfor %}
{% if page.activities or page.exercises %} {% if page.exercises %}
}; };
function change_exercises_content_by_platform(form_control){ function change_exercises_content_by_platform(form_control){
{% assign first = true %}
{% endif %} {% endif %}
{% for platform in page.exercises %} {% for platform in page.exercises %}
document.getElementById("{{ platform[0] | slugify }}-exercises-div").style.display = 'none'; document.getElementById("{{ platform[0] | slugify }}-exercises-div").style.display = 'none';
{% endfor %} {% endfor %}
{% for platform in page.exercises %} if (!form_control || document.getElementById(form_control).value == "default-exercises") {
{% if first %}
if (!form_control || document.getElementById(form_control).value == "{{ platform[0] | slugify }}-exercises") {
set_exercises_view_defaults(); set_exercises_view_defaults();
{% assign first = false %} {% for platform in page.exercises %}
{% else %}
} else if (document.getElementById(form_control).value == "{{ platform[0] | slugify }}-exercises") { } else if (document.getElementById(form_control).value == "{{ platform[0] | slugify }}-exercises") {
document.getElementById("{{ platform[0] | slugify }}-exercises-div").style.display = 'block'; document.getElementById("{{ platform[0] | slugify }}-exercises-div").style.display = 'block';
{% endif %}
{% endfor %} {% endfor %}
{% if page.exercises %} {% if page.exercises %}
} else { } else {
alert("Error: Missing platform value for 'change_exercises_content_by_platform()' script!"); alert("Error: Missing platform value for 'change_exercises_content_by_platform()' script!");
} }
}
{% endif %} {% endif %}
{% if page.activities or page.exercises %} {% if page.activities or page.exercises %}
}
window.onload = set_view_defaults; window.onload = set_view_defaults;
</script> </script>
{% endif %} {% endif %}
...@@ -154,16 +136,10 @@ window.onload = set_view_defaults; ...@@ -154,16 +136,10 @@ window.onload = set_view_defaults;
{% if page.activities %} {% if page.activities %}
Show activity for: <select id="id_activity_platform" name="activityplatformlist" onchange="change_activity_content_by_platform('id_activity_platform');return false;"> Show activity for: <select id="id_activity_platform" name="activityplatformlist" onchange="change_activity_content_by_platform('id_activity_platform');return false;">
{% assign first = true %} <option value="default-activity" id="default-activity-option" selected="selected"> Select a platform... </option>
{% endif %} {% endif %}
{% for platform in page.activities %} {% for platform in page.activities %}
{% if first %}
<option value="{{ platform[0] | slugify }}-activity" id="{{ platform[0] | slugify }}-activity-option" selected="selected"> {{ platform[0] }} </option>
{% assign first = false %}
{% else %}
<option value="{{ platform[0] | slugify }}-activity" id="{{ platform[0] | slugify }}-activity-option"> {{ platform[0] }} </option> <option value="{{ platform[0] | slugify }}-activity" id="{{ platform[0] | slugify }}-activity-option"> {{ platform[0] }} </option>
{% endif %}
{% endfor %} {% endfor %}
{% if page.activities %} {% if page.activities %}
</select> </select>
...@@ -192,16 +168,10 @@ Show activity for: <select id="id_activity_platform" name="activityplatformlist" ...@@ -192,16 +168,10 @@ Show activity for: <select id="id_activity_platform" name="activityplatformlist"
{% if page.exercises %} {% if page.exercises %}
Perform additional excercises for: <select id="id_exercises_platform" name="exercisesplatformlist" onchange="change_exercises_content_by_platform('id_exercises_platform');return false;"> Perform additional excercises for: <select id="id_exercises_platform" name="exercisesplatformlist" onchange="change_exercises_content_by_platform('id_exercises_platform');return false;">
{% assign first = true %} <option value="default-exercises" id="default-exercises-option" selected="selected"> Select a platform... </option>
{% endif %} {% endif %}
{% for platform in page.exercises %} {% for platform in page.exercises %}
{% if first %}
<option value="{{ platform[0] | slugify }}-exercises" id="{{ platform[0] | slugify }}-exercises-option" selected="selected"> {{ platform[0] }} </option>
{% assign first = false %}
{% else %}
<option value="{{ platform[0] | slugify }}-exercises" id="{{ platform[0] | slugify }}-exercises-option"> {{ platform[0] }} </option> <option value="{{ platform[0] | slugify }}-exercises" id="{{ platform[0] | slugify }}-exercises-option"> {{ platform[0] }} </option>
{% endif %}
{% endfor %} {% endfor %}
{% if page.exercises %} {% if page.exercises %}
</select> </select>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment