Skip to content
Snippets Groups Projects
Commit 3fdebef2 authored by Eric Bremner's avatar Eric Bremner
Browse files

Updating multi-type-list

parent db21932c
No related branches found
No related tags found
No related merge requests found
...@@ -4331,24 +4331,22 @@ fieldset, ...@@ -4331,24 +4331,22 @@ fieldset,
.mobile-menu__subnav .mobile-menu__link:hover, .mobile-menu__subnav .mobile-menu__link:focus, .mobile-menu__subnav .mobile-menu__link:active { .mobile-menu__subnav .mobile-menu__link:hover, .mobile-menu__subnav .mobile-menu__link:focus, .mobile-menu__subnav .mobile-menu__link:active {
color: #000; } color: #000; }
/* Style the tab */ .uw-tab {
.uw-multi-type-list-tab {
background-color: #f1f1f1; background-color: #f1f1f1;
border: 1px solid #ccc; border: 1px solid #ccc;
overflow: hidden; } overflow: hidden; }
.uw-multi-type-list-tab button { .uw-tab button {
background-color: inherit; background-color: inherit;
cursor: pointer; cursor: pointer;
float: left; float: left;
outline: none; outline: none;
padding: 14px 16px; padding: 14px 16px;
transition: 0.3s; } transition: 0.3s; }
.uw-multi-type-list-tab button:hover { .uw-tab button:hover {
background-color: #ddd; } background-color: #ddd; }
.uw-multi-type-list-tab button:active { .uw-tab button:active {
background-color: #ccc; } background-color: #ccc; }
/* Style the tab content */
.uw-tabcontent { .uw-tabcontent {
border: 1px solid #ccc; border: 1px solid #ccc;
display: none; display: none;
......
...@@ -117,21 +117,34 @@ ...@@ -117,21 +117,34 @@
attach: function (context, settings) { attach: function (context, settings) {
$(document).ready(function() { $(document).ready(function() {
if ($('.uw-multi-type-list-tab').length > 0) {
// If there are tabs, process them.
if ($('.uw-tab').length > 0) {
// Set the first of the tabs to be displayted.
$('.uw-tabcontent')[0].style.display = 'block'; $('.uw-tabcontent')[0].style.display = 'block';
// Step through each of the tab buttons and add the click.
$('.uw-tablinks').each(function(index, value) { $('.uw-tablinks').each(function(index, value) {
var type = this.getAttribute('data-type');
this.click(function() { // Add the click function to open the tab.
openTab(type); $(value).click(function() {
// The open tab function with the data attribute.
openTab(this.getAttribute('data-type'));
}); });
}); });
} }
}); });
function openTab(cityName) { /**
alert('CLICKED'); * Function to open a tab.
*
* @param contentType
* The type of tab to open.
*/
function openTab(contentType) {
// Declare all variables // Declare all variables
var i, tabcontent, tablinks; var i, tabcontent, tablinks;
...@@ -148,7 +161,7 @@ ...@@ -148,7 +161,7 @@
} }
// Show the current tab, and add an "active" class to the button that opened the tab // Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(cityName).style.display = "block"; document.getElementById(contentType).style.display = "block";
evt.currentTarget.className += " active"; evt.currentTarget.className += " active";
} }
} }
......
/* Style the tab */ .uw-tab {
.uw-multi-type-list-tab {
background-color: #f1f1f1; background-color: #f1f1f1;
border: 1px solid #ccc; border: 1px solid #ccc;
overflow: hidden; overflow: hidden;
...@@ -22,7 +21,6 @@ ...@@ -22,7 +21,6 @@
} }
} }
/* Style the tab content */
.uw-tabcontent { .uw-tabcontent {
border: 1px solid #ccc; border: 1px solid #ccc;
display: none; display: none;
......
...@@ -3,21 +3,34 @@ ...@@ -3,21 +3,34 @@
attach: function (context, settings) { attach: function (context, settings) {
$(document).ready(function() { $(document).ready(function() {
if ($('.uw-multi-type-list-tab').length > 0) {
// If there are tabs, process them.
if ($('.uw-tab').length > 0) {
// Set the first of the tabs to be displayted.
$('.uw-tabcontent')[0].style.display = 'block'; $('.uw-tabcontent')[0].style.display = 'block';
// Step through each of the tab buttons and add the click.
$('.uw-tablinks').each(function(index, value) { $('.uw-tablinks').each(function(index, value) {
var type = this.getAttribute('data-type');
this.click(function() { // Add the click function to open the tab.
openTab(type); $(value).click(function() {
// The open tab function with the data attribute.
openTab(this.getAttribute('data-type'));
}); });
}); });
} }
}); });
function openTab(cityName) { /**
alert('CLICKED'); * Function to open a tab.
*
* @param contentType
* The type of tab to open.
*/
function openTab(contentType) {
// Declare all variables // Declare all variables
var i, tabcontent, tablinks; var i, tabcontent, tablinks;
...@@ -34,7 +47,7 @@ ...@@ -34,7 +47,7 @@
} }
// Show the current tab, and add an "active" class to the button that opened the tab // Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(cityName).style.display = "block"; document.getElementById(contentType).style.display = "block";
evt.currentTarget.className += " active"; evt.currentTarget.className += " active";
} }
} }
......
<div class="uw-multi-type-list-tab"> <div class="uw-tab">
{% for type, list in lists %} {% for type, list in lists %}
<button class="uw-tablinks" data-type="{{ type }}">{{ type }}</button> <button class="uw-tablinks" data-type="{{ type }}">{{ type }}</button>
{% endfor %} {% endfor %}
...@@ -48,6 +48,6 @@ ...@@ -48,6 +48,6 @@
'content': content.content 'content': content.content
} %} } %}
{% endif %} {% endif %}
</div> {% endfor %}
{% endfor %} </div>
{% endfor %} {% endfor %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment