Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
synergy-components
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
synergy-components
Commits
3631642b
Commit
3631642b
authored
Feb 02, 2022
by
Irina Oleynik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
c970de59
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
interpreter/tabs
interpreter/tabs
+88
-0
No files found.
interpreter/tabs
0 → 100644
View file @
3631642b
/*
model.tabs = [];
model.tabs.push({name: '', blocks: []});
model.tabs.push({name: '', blocks: [], accordion: [
{titleID: '', open: true, blocks: []}
]});
@param name - наименование таба
@param blocks - массив, перечисление ID компонентов которые будут входить в данный блок.
@param accordion.titleID - ID компонента на форме с типом label для заголовка блока
@param accordion.open - true/false, открытый или закрытый блок
@param accordion.blocks - массив, перечисление ID компонентов которые будут входить в данный блок.
*/
let parentContainer = view.playerView.container;
let tabContainer = $('<div>', {class: 'tab-container'});
let tab = $('<div>', {class: 'tab'});
let tabsData = [];
tabContainer.append(tab);
$(view.container).append(tabContainer);
if(model.hasOwnProperty('tabs')) tabsData = model.tabs;
const toggleAcc = (el, block) => {
el = el[0];
el.classList.toggle("active");
block.open = $(el).hasClass('active');
let panel = el.nextElementSibling;
if (panel.style.maxHeight) panel.style.maxHeight = null;
else panel.style.maxHeight = "initial";
}
tabsData.forEach((item, i) => {
let tabButton = $('<button>', {class: 'tablinks'}).text(item.name);
let tabcontent = $('<div>', {class: 'tabcontent'});
tab.append(tabButton);
tabContainer.append(tabcontent);
tabButton.on('click', e => {
tabContainer.find('.tablinks').removeClass('active');
tabButton.addClass('active');
tabContainer.find('.tabcontent').removeClass('active');
tabcontent.addClass('active');
});
if(i == 0) {
tabButton.addClass('active');
tabcontent.addClass('active');
}
if(item.hasOwnProperty('blocks')) {
item.blocks.forEach(block => {
let tabData = $(parentContainer).find(`[data-asformid $= ".container.${block}"]`);
tabData.parent().parent().hide();
tabcontent.append(tabData.detach());
});
}
if(item.hasOwnProperty('accordion')) {
let accordionContainer = $('<div class="custom-accordion">');
tabcontent.append(accordionContainer);
item.accordion.forEach(acc => {
let block = $('<div class="accordion-block">')
let title = $(parentContainer).find(`[data-asformid="label.label.${acc.titleID}"]`);
let button = $(`<button class="accordion-button">${title.text()}</button>`);
let body = $('<div class="accordion-body">');
title.parent().parent().parent().hide();
accordionContainer.append(block);
block.append(button).append(body);
button.on('click', () => toggleAcc(button, acc));
acc.blocks.forEach(accblock => {
let cc = $(parentContainer).find(`[data-asformid $= ".container.${accblock}"]`);
cc.parent().parent().hide();
body.append(cc.detach());
});
body.append('<div class="accordion-footer"></div>');
if(acc.open) toggleAcc(button, acc);
});
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment