diff --git a/Resources/public/modules/tabs/tabs.js b/Resources/public/modules/tabs/tabs.js index 77de95bff..13957abee 100644 --- a/Resources/public/modules/tabs/tabs.js +++ b/Resources/public/modules/tabs/tabs.js @@ -29,8 +29,11 @@ let countNewActive = function(links, link) /* * Set class active on both new elements: link and content */ -let setNewActive = function(link, contents, rank) +let setNewActive = function(links, contents, rank) { + if (! links[rank-1]) { rank = 1; } + link = links[rank-1]; + link.classList.add('active'); count = 0; @@ -42,6 +45,19 @@ let setNewActive = function(link, contents, rank) }); } +/* + * 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 + }); +} + /* * Main function */ @@ -61,15 +77,21 @@ window.addEventListener('load', function() tabPanel.classList.add('pills'); } + if (! unit.startPanel) { + unit.startPanel = 1; + } + + setPaneHeight(contents); + // initial position - setNewActive(links[unit.startPanel-1], contents, unit.startPanel); + setNewActive(links, contents, unit.startPanel); // listen links.forEach(function(link) { link.addEventListener('click', function() { resetActive(links, contents); - setNewActive(link, contents, countNewActive(links, link)); + setNewActive(links, contents, countNewActive(links, link)); }); }); diff --git a/Resources/views/Test/index.html.twig b/Resources/views/Test/index.html.twig index e391dbe56..046d8e22e 100644 --- a/Resources/views/Test/index.html.twig +++ b/Resources/views/Test/index.html.twig @@ -12,17 +12,18 @@ let tabParams = [{ id : 'test1', type: 'tab', - startPanel: 5, + startPanel: 2, disposition: 'horizontal', fade: true }, { id : 'test2', type: 'pill', - startPanel: 3, + startPanel: 5, disposition: 'vertical', fade: false - }]; + } + ]; @@ -46,7 +47,7 @@ Link 4