mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 17:15:02 +00:00
reorganize assets: move files and adapt links, remove unused
* chill: chill theme entrypoint * lib: local libs, called in several place but don't have entrypoint * module: local libs with specific entrypoints * page: pages with specific entrypoints * vuejs: vue components with specific entrypoints remove local libs jquery and select2, they already exists in node_modules remove duplicate fonts
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
require("./tabs.js");
|
||||
require("./tabs.scss");
|
118
src/Bundle/ChillMainBundle/Resources/public/lib/tabs/tabs.js
Normal file
118
src/Bundle/ChillMainBundle/Resources/public/lib/tabs/tabs.js
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Remove active class on both elements: link and content
|
||||
*/
|
||||
let resetActive = function(links, contents)
|
||||
{
|
||||
for (items of [links, contents]) {
|
||||
items.forEach(function(item) {
|
||||
if (item.classList.contains('active')) {
|
||||
item.classList.remove('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Count links array and return rank of given link
|
||||
*/
|
||||
let countNewActive = function(links, link)
|
||||
{
|
||||
let rank = 0;
|
||||
for (let i = 0; i < links.length; ++i) {
|
||||
rank++;
|
||||
if(links[i] == link) {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set class active on both new elements: link and content
|
||||
*/
|
||||
let setNewActive = function(links, contents, rank)
|
||||
{
|
||||
if (! links[rank-1]) { rank = 1; }
|
||||
link = links[rank-1];
|
||||
|
||||
link.classList.add('active');
|
||||
|
||||
count = 0;
|
||||
contents.forEach(function(pane) {
|
||||
count++;
|
||||
if (rank == count) {
|
||||
pane.classList.add('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Set height of content pane
|
||||
*/
|
||||
let setPaneHeight = function(contents)
|
||||
{
|
||||
contents.forEach(function(pane) {
|
||||
|
||||
// let computedStyle = getComputedStyle(pane);
|
||||
// console.log(computedStyle.height);
|
||||
// comment prendre la hauteur d'une div masquée avec display:none
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if links are defined in controller
|
||||
* If true, disable javascript listener
|
||||
*/
|
||||
let isLinkRef = function(link) {
|
||||
|
||||
if (link.getAttribute('href') == "#") {
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Main function
|
||||
*/
|
||||
window.addEventListener('load', function()
|
||||
{
|
||||
tabParams.forEach(function(unit) {
|
||||
|
||||
let tabPanel = document.querySelector('#'+ unit.id );
|
||||
if (tabPanel) {
|
||||
|
||||
let
|
||||
nav = tabPanel.querySelector('nav'),
|
||||
tabs = nav.querySelectorAll('ul.nav-tabs li.nav-item'),
|
||||
links = nav.querySelectorAll('ul.nav-tabs li.nav-item a.nav-link'),
|
||||
contents = tabPanel.querySelectorAll('div.tab-content div.tab-pane')
|
||||
;
|
||||
|
||||
if (unit.type == 'pill') {
|
||||
tabPanel.classList.add('pills');
|
||||
}
|
||||
|
||||
if (! unit.initPane) {
|
||||
unit.initPane = 1;
|
||||
}
|
||||
|
||||
setPaneHeight(contents);
|
||||
|
||||
// initial position
|
||||
setNewActive(links, contents, unit.initPane);
|
||||
|
||||
// listen
|
||||
links.forEach(function(link) {
|
||||
if (isLinkRef(link) == false) {
|
||||
link.addEventListener('click', function()
|
||||
{
|
||||
resetActive(links, contents);
|
||||
setNewActive(links, contents, countNewActive(links, link));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
@@ -0,0 +1,98 @@
|
||||
|
||||
$navigation-color: #334d5c;
|
||||
$body-font-color: #ffffff;
|
||||
$tab-font-color: #495057;
|
||||
$border-color: #dee2e6;
|
||||
$pills-color: #ed9345;
|
||||
$radius : .25rem;
|
||||
|
||||
div.tabs {
|
||||
margin: 3em;
|
||||
|
||||
nav {
|
||||
ul.nav-tabs {
|
||||
|
||||
display: flex;
|
||||
display: -ms-flexbox;
|
||||
flex-wrap: wrap;
|
||||
-ms-flex-wrap: wrap;
|
||||
|
||||
list-style: none;
|
||||
padding-left: 0;
|
||||
margin-bottom: 0;
|
||||
|
||||
li.nav-item {
|
||||
margin-bottom: -1px;
|
||||
|
||||
a.nav-link {
|
||||
display: block;
|
||||
padding: .5rem 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
div.tab-content {
|
||||
|
||||
div.tab-pane {
|
||||
display: none;
|
||||
|
||||
&.fade {
|
||||
transition: opacity .15s linear;
|
||||
}
|
||||
&.active {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.pills) {
|
||||
nav {
|
||||
ul.nav-tabs {
|
||||
border-bottom: 1px solid $border-color;
|
||||
|
||||
li.nav-item {
|
||||
|
||||
a.nav-link {
|
||||
border: 1px solid transparent;
|
||||
border-top-left-radius: $radius;
|
||||
border-top-right-radius: $radius;
|
||||
color: $navigation-color;
|
||||
}
|
||||
|
||||
&.show a.nav-link,
|
||||
& a.nav-link.active {
|
||||
|
||||
color: $tab-font-color;
|
||||
background-color: $body-font-color;
|
||||
border-color: $border-color $border-color $body-font-color;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.pills {
|
||||
nav {
|
||||
ul.nav-tabs {
|
||||
|
||||
border-bottom: 0;
|
||||
li.nav-item {
|
||||
|
||||
& a.nav-link {
|
||||
border: 0;
|
||||
border-radius: $radius;
|
||||
}
|
||||
|
||||
&.show > a.nav-link,
|
||||
& a.nav-link.active {
|
||||
color: $body-font-color;
|
||||
background-color: $pills-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user