mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)
* Update Symfony lib to version ~6.4.0 * Update code missing return type * Add an iTop general configuration entry to store application secret (Symfony mandatory parameter) * Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
@@ -9,12 +9,23 @@
|
||||
--color-warning: #a46a1f;
|
||||
--color-error: #b0413e;
|
||||
--color-muted: #999;
|
||||
--tab-background: #fff;
|
||||
--tab-background: #f0f0f0;
|
||||
--tab-border-color: #e5e5e5;
|
||||
--tab-active-border-color: #d4d4d4;
|
||||
--tab-color: #444;
|
||||
--tab-active-background: #666;
|
||||
--tab-active-color: #fafafa;
|
||||
--tab-active-background: #fff;
|
||||
--tab-active-color: var(--color-text);
|
||||
--tab-disabled-background: #f5f5f5;
|
||||
--tab-disabled-color: #999;
|
||||
--selected-badge-background: #e5e5e5;
|
||||
--selected-badge-color: #525252;
|
||||
--selected-badge-shadow: inset 0 0 0 1px #d4d4d4;
|
||||
--selected-badge-warning-background: #fde496;
|
||||
--selected-badge-warning-color: #785b02;
|
||||
--selected-badge-warning-shadow: inset 0 0 0 1px #e6af05;
|
||||
--selected-badge-danger-background: #FCE9ED;
|
||||
--selected-badge-danger-color: #83122A;
|
||||
--selected-badge-danger-shadow: inset 0 0 0 1px #F5B8C5;
|
||||
--metric-value-background: #fff;
|
||||
--metric-value-color: inherit;
|
||||
--metric-unit-color: #999;
|
||||
@@ -47,12 +58,23 @@
|
||||
--color-text: #e0e0e0;
|
||||
--color-muted: #777;
|
||||
--color-error: #d43934;
|
||||
--tab-background: #555;
|
||||
--tab-color: #ccc;
|
||||
--tab-active-background: #888;
|
||||
--tab-active-color: #fafafa;
|
||||
--tab-background: #404040;
|
||||
--tab-border-color: #737373;
|
||||
--tab-active-border-color: #171717;
|
||||
--tab-color: var(--color-text);
|
||||
--tab-active-background: #d4d4d4;
|
||||
--tab-active-color: #262626;
|
||||
--tab-disabled-background: var(--page-background);
|
||||
--tab-disabled-color: #777;
|
||||
--tab-disabled-color: #a3a3a3;
|
||||
--selected-badge-background: #555;
|
||||
--selected-badge-color: #ddd;
|
||||
--selected-badge-shadow: none;
|
||||
--selected-badge-warning-background: #fcd55f;
|
||||
--selected-badge-warning-color: #785b02;
|
||||
--selected-badge-warning-shadow: inset 0 0 0 1px #af8503;
|
||||
--selected-badge-danger-background: #B41939;
|
||||
--selected-badge-danger-color: #FCE9ED;
|
||||
--selected-badge-danger-shadow: none;
|
||||
--metric-value-background: #555;
|
||||
--metric-value-color: inherit;
|
||||
--metric-unit-color: #999;
|
||||
@@ -83,7 +105,7 @@
|
||||
--card-label-color: var(--tab-active-color);
|
||||
}
|
||||
|
||||
html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}
|
||||
html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}summary{cursor: pointer}
|
||||
|
||||
html {
|
||||
/* always display the vertical scrollbar to avoid jumps when toggling contents */
|
||||
@@ -132,15 +154,96 @@ thead.sf-toggle-content.sf-toggle-visible, tbody.sf-toggle-content.sf-toggle-vis
|
||||
.sf-toggle-off .icon-close, .sf-toggle-on .icon-open { display: none; }
|
||||
.sf-toggle-off .icon-open, .sf-toggle-on .icon-close { display: block; }
|
||||
|
||||
.tab-navigation { margin: 0 0 1em 0; padding: 0; }
|
||||
.tab-navigation li { background: var(--tab-background); border: 1px solid var(--table-border); color: var(--tab-color); cursor: pointer; display: inline-block; font-size: 16px; margin: 0 0 0 -1px; padding: .5em .75em; z-index: 1; }
|
||||
.tab-navigation li .badge { background-color: var(--base-1); color: var(--base-4); display: inline-block; font-size: 14px; font-weight: bold; margin-left: 8px; min-width: 10px; padding: 1px 6px; text-align: center; white-space: nowrap; }
|
||||
.tab-navigation li.disabled { background: var(--tab-disabled-background); color: var(--tab-disabled-color); }
|
||||
.tab-navigation li.active { background: var(--tab-active-background); color: var(--tab-active-color); z-index: 1100; }
|
||||
.tab-navigation li.active .badge { background-color: var(--base-5); color: var(--base-2); }
|
||||
.tab-content > *:first-child { margin-top: 0; }
|
||||
.tab-navigation li .badge.status-warning { background: var(--color-warning); color: #FFF; }
|
||||
.tab-navigation li .badge.status-error { background: var(--background-error); color: #FFF; }
|
||||
.tab-navigation {
|
||||
background-color: var(--tab-background);
|
||||
border-radius: 6px;
|
||||
box-shadow: inset 0 0 0 1px var(--tab-border-color), 0 0 0 5px var(--page-background);
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
margin: 0 0 15px;
|
||||
padding: 0;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.sf-tabs-sm .tab-navigation {
|
||||
box-shadow: inset 0 0 0 1px var(--tab-border-color), 0 0 0 4px var(--page-background);
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
.tab-navigation .tab-control {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
transition: box-shadow .05s ease-in, background-color .05s ease-in;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
margin: 0;
|
||||
padding: 4px 14px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
z-index: 1;
|
||||
}
|
||||
.sf-tabs-sm .tab-navigation .tab-control {
|
||||
font-size: 13px;
|
||||
padding: 2.5px 10px;
|
||||
}
|
||||
.tab-navigation .tab-control:before {
|
||||
background: var(--tab-border-color);
|
||||
bottom: 15%;
|
||||
content: "";
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 15%;
|
||||
width: 1px;
|
||||
}
|
||||
.tab-navigation .tab-control:first-child:before,
|
||||
.tab-navigation .tab-control.active + .tab-control:before,
|
||||
.tab-navigation .tab-control.active:before {
|
||||
width: 0;
|
||||
}
|
||||
.tab-navigation .tab-control .badge {
|
||||
background: var(--selected-badge-background);
|
||||
box-shadow: var(--selected-badge-shadow);
|
||||
color: var(--selected-badge-color);
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
margin-left: 8px;
|
||||
min-width: 10px;
|
||||
padding: 2px 6px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tab-navigation .tab-control.disabled {
|
||||
color: var(--tab-disabled-color);
|
||||
}
|
||||
.tab-navigation .tab-control.active {
|
||||
background-color: var(--tab-active-background);
|
||||
border-radius: 6px;
|
||||
box-shadow: inset 0 0 0 1.5px var(--tab-active-border-color);
|
||||
color: var(--tab-active-color);
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
.theme-dark .tab-navigation li.active {
|
||||
box-shadow: inset 0 0 0 1px var(--tab-border-color);
|
||||
}
|
||||
.tab-content > *:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.tab-navigation .tab-control .badge.status-warning {
|
||||
background: var(--selected-badge-warning-background);
|
||||
box-shadow: var(--selected-badge-warning-shadow);
|
||||
color: var(--selected-badge-warning-color);
|
||||
}
|
||||
.tab-navigation .tab-control .badge.status-error {
|
||||
background: var(--selected-badge-danger-background);
|
||||
box-shadow: var(--selected-badge-danger-shadow);
|
||||
color: var(--selected-badge-danger-color);
|
||||
}
|
||||
|
||||
.sf-tabs .tab:not(:first-child) { display: none; }
|
||||
|
||||
[data-filters] { position: relative; }
|
||||
@@ -208,6 +311,10 @@ header .container { display: flex; justify-content: space-between; }
|
||||
.exception-message a { border-bottom: 1px solid rgba(255, 255, 255, 0.5); font-size: inherit; text-decoration: none; }
|
||||
.exception-message a:hover { border-bottom-color: #ffffff; }
|
||||
|
||||
.exception-properties-wrapper { margin: .8em 0; }
|
||||
.exception-properties { background: var(--base-0); border: var(--border); box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); }
|
||||
.exception-properties pre { margin: 0; padding: 0.2em 0; }
|
||||
|
||||
.exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; }
|
||||
|
||||
.trace + .trace { margin-top: 30px; }
|
||||
@@ -217,7 +324,7 @@ header .container { display: flex; justify-content: space-between; }
|
||||
.trace-head .icon { position: absolute; right: 0; top: 0; }
|
||||
.trace-head .icon svg { fill: var(--base-5); height: 24px; width: 24px; }
|
||||
|
||||
.trace-details { background: var(--base-0); border: var(--border); box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; table-layout: fixed; }
|
||||
.trace-details { background: var(--base-0); border: var(--border); box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 0 0 1em; table-layout: fixed; }
|
||||
|
||||
.trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; }
|
||||
|
||||
|
||||
@@ -1,297 +1,304 @@
|
||||
/* This file is based on WebProfilerBundle/Resources/views/Profiler/base_js.html.twig.
|
||||
If you make any change in this file, verify the same change is needed in the other file. */
|
||||
/*<![CDATA[*/
|
||||
if (typeof Sfjs === 'undefined') {
|
||||
Sfjs = (function() {
|
||||
"use strict";
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
if ('classList' in document.documentElement) {
|
||||
var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };
|
||||
var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };
|
||||
var addClass = function(el, cssClass) { el.classList.add(cssClass); };
|
||||
var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };
|
||||
} else {
|
||||
var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\b' + cssClass + '\\b')); };
|
||||
var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\b' + cssClass + '\\b'), ' '); };
|
||||
var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += " " + cssClass; } };
|
||||
var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };
|
||||
if ('classList' in document.documentElement) {
|
||||
var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };
|
||||
var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };
|
||||
var addClass = function(el, cssClass) { el.classList.add(cssClass); };
|
||||
var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };
|
||||
} else {
|
||||
var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\b' + cssClass + '\\b')); };
|
||||
var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\b' + cssClass + '\\b'), ' '); };
|
||||
var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += " " + cssClass; } };
|
||||
var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };
|
||||
}
|
||||
|
||||
var addEventListener;
|
||||
|
||||
var el = document.createElement('div');
|
||||
if (!('addEventListener' in el)) {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.attachEvent('on' + eventName, callback);
|
||||
};
|
||||
} else {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.addEventListener(eventName, callback, false);
|
||||
};
|
||||
}
|
||||
|
||||
if (navigator.clipboard) {
|
||||
document.querySelectorAll('[data-clipboard-text]').forEach(function(element) {
|
||||
removeClass(element, 'hidden');
|
||||
element.addEventListener('click', function() {
|
||||
navigator.clipboard.writeText(element.getAttribute('data-clipboard-text'));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
(function createTabs() {
|
||||
/* the accessibility options of this component have been defined according to: */
|
||||
/* www.w3.org/WAI/ARIA/apg/example-index/tabs/tabs-manual.html */
|
||||
var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
|
||||
|
||||
/* create the tab navigation for each group of tabs */
|
||||
for (var i = 0; i < tabGroups.length; i++) {
|
||||
var tabs = tabGroups[i].querySelectorAll(':scope > .tab');
|
||||
var tabNavigation = document.createElement('div');
|
||||
tabNavigation.className = 'tab-navigation';
|
||||
tabNavigation.setAttribute('role', 'tablist');
|
||||
|
||||
var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
|
||||
for (var j = 0; j < tabs.length; j++) {
|
||||
var tabId = 'tab-' + i + '-' + j;
|
||||
var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
|
||||
|
||||
var tabNavigationItem = document.createElement('button');
|
||||
addClass(tabNavigationItem, 'tab-control');
|
||||
tabNavigationItem.setAttribute('data-tab-id', tabId);
|
||||
tabNavigationItem.setAttribute('role', 'tab');
|
||||
tabNavigationItem.setAttribute('aria-controls', tabId);
|
||||
if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
|
||||
if (hasClass(tabs[j], 'disabled')) {
|
||||
addClass(tabNavigationItem, 'disabled');
|
||||
}
|
||||
tabNavigationItem.innerHTML = tabTitle;
|
||||
tabNavigation.appendChild(tabNavigationItem);
|
||||
|
||||
var tabContent = tabs[j].querySelector('.tab-content');
|
||||
tabContent.parentElement.setAttribute('id', tabId);
|
||||
}
|
||||
|
||||
tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
|
||||
addClass(document.querySelector('[data-tab-id="' + selectedTabId + '"]'), 'active');
|
||||
}
|
||||
|
||||
var addEventListener;
|
||||
/* display the active tab and add the 'click' event listeners */
|
||||
for (i = 0; i < tabGroups.length; i++) {
|
||||
tabNavigation = tabGroups[i].querySelectorAll(':scope > .tab-navigation .tab-control');
|
||||
|
||||
var el = document.createElement('div');
|
||||
if (!('addEventListener' in el)) {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.attachEvent('on' + eventName, callback);
|
||||
};
|
||||
} else {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.addEventListener(eventName, callback, false);
|
||||
};
|
||||
}
|
||||
for (j = 0; j < tabNavigation.length; j++) {
|
||||
tabId = tabNavigation[j].getAttribute('data-tab-id');
|
||||
var tabPanel = document.getElementById(tabId);
|
||||
tabPanel.setAttribute('role', 'tabpanel');
|
||||
tabPanel.setAttribute('aria-labelledby', tabId);
|
||||
tabPanel.querySelector('.tab-title').className = 'hidden';
|
||||
|
||||
if (navigator.clipboard) {
|
||||
document.querySelectorAll('[data-clipboard-text]').forEach(function(element) {
|
||||
removeClass(element, 'hidden');
|
||||
element.addEventListener('click', function() {
|
||||
navigator.clipboard.writeText(element.getAttribute('data-clipboard-text'));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
addEventListener: addEventListener,
|
||||
|
||||
createTabs: function() {
|
||||
var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
|
||||
|
||||
/* create the tab navigation for each group of tabs */
|
||||
for (var i = 0; i < tabGroups.length; i++) {
|
||||
var tabs = tabGroups[i].querySelectorAll(':scope > .tab');
|
||||
var tabNavigation = document.createElement('ul');
|
||||
tabNavigation.className = 'tab-navigation';
|
||||
|
||||
var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
|
||||
for (var j = 0; j < tabs.length; j++) {
|
||||
var tabId = 'tab-' + i + '-' + j;
|
||||
var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
|
||||
|
||||
var tabNavigationItem = document.createElement('li');
|
||||
tabNavigationItem.setAttribute('data-tab-id', tabId);
|
||||
if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
|
||||
if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); }
|
||||
tabNavigationItem.innerHTML = tabTitle;
|
||||
tabNavigation.appendChild(tabNavigationItem);
|
||||
|
||||
var tabContent = tabs[j].querySelector('.tab-content');
|
||||
tabContent.parentElement.setAttribute('id', tabId);
|
||||
}
|
||||
|
||||
tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
|
||||
addClass(document.querySelector('[data-tab-id="' + selectedTabId + '"]'), 'active');
|
||||
if (hasClass(tabNavigation[j], 'active')) {
|
||||
tabPanel.className = 'block';
|
||||
tabNavigation[j].setAttribute('aria-selected', 'true');
|
||||
tabNavigation[j].removeAttribute('tabindex');
|
||||
} else {
|
||||
tabPanel.className = 'hidden';
|
||||
tabNavigation[j].removeAttribute('aria-selected');
|
||||
tabNavigation[j].setAttribute('tabindex', '-1');
|
||||
}
|
||||
|
||||
/* display the active tab and add the 'click' event listeners */
|
||||
for (i = 0; i < tabGroups.length; i++) {
|
||||
tabNavigation = tabGroups[i].querySelectorAll(':scope >.tab-navigation li');
|
||||
tabNavigation[j].addEventListener('click', function(e) {
|
||||
var activeTab = e.target || e.srcElement;
|
||||
|
||||
for (j = 0; j < tabNavigation.length; j++) {
|
||||
tabId = tabNavigation[j].getAttribute('data-tab-id');
|
||||
document.getElementById(tabId).querySelector('.tab-title').className = 'hidden';
|
||||
|
||||
if (hasClass(tabNavigation[j], 'active')) {
|
||||
document.getElementById(tabId).className = 'block';
|
||||
} else {
|
||||
document.getElementById(tabId).className = 'hidden';
|
||||
}
|
||||
|
||||
tabNavigation[j].addEventListener('click', function(e) {
|
||||
var activeTab = e.target || e.srcElement;
|
||||
|
||||
/* needed because when the tab contains HTML contents, user can click */
|
||||
/* on any of those elements instead of their parent '<li>' element */
|
||||
while (activeTab.tagName.toLowerCase() !== 'li') {
|
||||
activeTab = activeTab.parentNode;
|
||||
}
|
||||
|
||||
/* get the full list of tabs through the parent of the active tab element */
|
||||
var tabNavigation = activeTab.parentNode.children;
|
||||
for (var k = 0; k < tabNavigation.length; k++) {
|
||||
var tabId = tabNavigation[k].getAttribute('data-tab-id');
|
||||
document.getElementById(tabId).className = 'hidden';
|
||||
removeClass(tabNavigation[k], 'active');
|
||||
}
|
||||
|
||||
addClass(activeTab, 'active');
|
||||
var activeTabId = activeTab.getAttribute('data-tab-id');
|
||||
document.getElementById(activeTabId).className = 'block';
|
||||
});
|
||||
/* needed because when the tab contains HTML contents, user can click */
|
||||
/* on any of those elements instead of their parent '<button>' element */
|
||||
while (activeTab.tagName.toLowerCase() !== 'button') {
|
||||
activeTab = activeTab.parentNode;
|
||||
}
|
||||
|
||||
tabGroups[i].setAttribute('data-processed', 'true');
|
||||
}
|
||||
},
|
||||
|
||||
createToggles: function() {
|
||||
var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
|
||||
|
||||
for (var i = 0; i < toggles.length; i++) {
|
||||
var elementSelector = toggles[i].getAttribute('data-toggle-selector');
|
||||
var element = document.querySelector(elementSelector);
|
||||
|
||||
addClass(element, 'sf-toggle-content');
|
||||
|
||||
if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {
|
||||
addClass(toggles[i], 'sf-toggle-on');
|
||||
addClass(element, 'sf-toggle-visible');
|
||||
} else {
|
||||
addClass(toggles[i], 'sf-toggle-off');
|
||||
addClass(element, 'sf-toggle-hidden');
|
||||
/* get the full list of tabs through the parent of the active tab element */
|
||||
var tabNavigation = activeTab.parentNode.children;
|
||||
for (var k = 0; k < tabNavigation.length; k++) {
|
||||
var tabId = tabNavigation[k].getAttribute('data-tab-id');
|
||||
document.getElementById(tabId).className = 'hidden';
|
||||
removeClass(tabNavigation[k], 'active');
|
||||
tabNavigation[k].removeAttribute('aria-selected');
|
||||
tabNavigation[k].setAttribute('tabindex', '-1');
|
||||
}
|
||||
|
||||
addEventListener(toggles[i], 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if ('' !== window.getSelection().toString()) {
|
||||
/* Don't do anything on text selection */
|
||||
return;
|
||||
}
|
||||
|
||||
var toggle = e.target || e.srcElement;
|
||||
|
||||
/* needed because when the toggle contains HTML contents, user can click */
|
||||
/* on any of those elements instead of their parent '.sf-toggle' element */
|
||||
while (!hasClass(toggle, 'sf-toggle')) {
|
||||
toggle = toggle.parentNode;
|
||||
}
|
||||
|
||||
var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));
|
||||
|
||||
toggleClass(toggle, 'sf-toggle-on');
|
||||
toggleClass(toggle, 'sf-toggle-off');
|
||||
toggleClass(element, 'sf-toggle-hidden');
|
||||
toggleClass(element, 'sf-toggle-visible');
|
||||
|
||||
/* the toggle doesn't change its contents when clicking on it */
|
||||
if (!toggle.hasAttribute('data-toggle-alt-content')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!toggle.hasAttribute('data-toggle-original-content')) {
|
||||
toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);
|
||||
}
|
||||
|
||||
var currentContent = toggle.innerHTML;
|
||||
var originalContent = toggle.getAttribute('data-toggle-original-content');
|
||||
var altContent = toggle.getAttribute('data-toggle-alt-content');
|
||||
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
|
||||
});
|
||||
|
||||
/* Prevents from disallowing clicks on links inside toggles */
|
||||
var toggleLinks = toggles[i].querySelectorAll('a');
|
||||
for (var j = 0; j < toggleLinks.length; j++) {
|
||||
addEventListener(toggleLinks[j], 'click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
/* Prevents from disallowing clicks on "copy to clipboard" elements inside toggles */
|
||||
var copyToClipboardElements = toggles[i].querySelectorAll('span[data-clipboard-text]');
|
||||
for (var k = 0; k < copyToClipboardElements.length; k++) {
|
||||
addEventListener(copyToClipboardElements[k], 'click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
toggles[i].setAttribute('data-processed', 'true');
|
||||
}
|
||||
},
|
||||
|
||||
createFilters: function() {
|
||||
document.querySelectorAll('[data-filters] [data-filter]').forEach(function (filter) {
|
||||
var filters = filter.closest('[data-filters]'),
|
||||
type = 'choice',
|
||||
name = filter.dataset.filter,
|
||||
ucName = name.charAt(0).toUpperCase()+name.slice(1),
|
||||
list = document.createElement('ul'),
|
||||
values = filters.dataset['filter'+ucName] || filters.querySelectorAll('[data-filter-'+name+']'),
|
||||
labels = {},
|
||||
defaults = null,
|
||||
indexed = {},
|
||||
processed = {};
|
||||
if (typeof values === 'string') {
|
||||
type = 'level';
|
||||
labels = values.split(',');
|
||||
values = values.toLowerCase().split(',');
|
||||
defaults = values.length - 1;
|
||||
}
|
||||
addClass(list, 'filter-list');
|
||||
addClass(list, 'filter-list-'+type);
|
||||
values.forEach(function (value, i) {
|
||||
if (value instanceof HTMLElement) {
|
||||
value = value.dataset['filter'+ucName];
|
||||
}
|
||||
if (value in processed) {
|
||||
return;
|
||||
}
|
||||
var option = document.createElement('li'),
|
||||
label = i in labels ? labels[i] : value,
|
||||
active = false,
|
||||
matches;
|
||||
if ('' === label) {
|
||||
option.innerHTML = '<em>(none)</em>';
|
||||
} else {
|
||||
option.innerText = label;
|
||||
}
|
||||
option.dataset.filter = value;
|
||||
option.setAttribute('title', 1 === (matches = filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').length) ? 'Matches 1 row' : 'Matches '+matches+' rows');
|
||||
indexed[value] = i;
|
||||
list.appendChild(option);
|
||||
addEventListener(option, 'click', function () {
|
||||
if ('choice' === type) {
|
||||
filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
|
||||
if (option.dataset.filter === row.dataset['filter'+ucName]) {
|
||||
toggleClass(row, 'filter-hidden-'+name);
|
||||
}
|
||||
});
|
||||
toggleClass(option, 'active');
|
||||
} else if ('level' === type) {
|
||||
if (i === this.parentNode.querySelectorAll('.active').length - 1) {
|
||||
return;
|
||||
}
|
||||
this.parentNode.querySelectorAll('li').forEach(function (currentOption, j) {
|
||||
if (j <= i) {
|
||||
addClass(currentOption, 'active');
|
||||
if (i === j) {
|
||||
addClass(currentOption, 'last-active');
|
||||
} else {
|
||||
removeClass(currentOption, 'last-active');
|
||||
}
|
||||
} else {
|
||||
removeClass(currentOption, 'active');
|
||||
removeClass(currentOption, 'last-active');
|
||||
}
|
||||
});
|
||||
filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
|
||||
if (i < indexed[row.dataset['filter'+ucName]]) {
|
||||
addClass(row, 'filter-hidden-'+name);
|
||||
} else {
|
||||
removeClass(row, 'filter-hidden-'+name);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if ('choice' === type) {
|
||||
active = null === defaults || 0 <= defaults.indexOf(value);
|
||||
} else if ('level' === type) {
|
||||
active = i <= defaults;
|
||||
if (active && i === defaults) {
|
||||
addClass(option, 'last-active');
|
||||
}
|
||||
}
|
||||
if (active) {
|
||||
addClass(option, 'active');
|
||||
} else {
|
||||
filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').forEach(function (row) {
|
||||
toggleClass(row, 'filter-hidden-'+name);
|
||||
});
|
||||
}
|
||||
processed[value] = true;
|
||||
});
|
||||
|
||||
if (1 < list.childNodes.length) {
|
||||
filter.appendChild(list);
|
||||
filter.dataset.filtered = '';
|
||||
}
|
||||
addClass(activeTab, 'active');
|
||||
activeTab.setAttribute('aria-selected', 'true');
|
||||
activeTab.removeAttribute('tabindex');
|
||||
var activeTabId = activeTab.getAttribute('data-tab-id');
|
||||
document.getElementById(activeTabId).className = 'block';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
tabGroups[i].setAttribute('data-processed', 'true');
|
||||
}
|
||||
})();
|
||||
|
||||
Sfjs.addEventListener(document, 'DOMContentLoaded', function() {
|
||||
Sfjs.createTabs();
|
||||
Sfjs.createToggles();
|
||||
Sfjs.createFilters();
|
||||
});
|
||||
}
|
||||
(function createToggles() {
|
||||
var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
|
||||
|
||||
for (var i = 0; i < toggles.length; i++) {
|
||||
var elementSelector = toggles[i].getAttribute('data-toggle-selector');
|
||||
var element = document.querySelector(elementSelector);
|
||||
|
||||
addClass(element, 'sf-toggle-content');
|
||||
|
||||
if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {
|
||||
addClass(toggles[i], 'sf-toggle-on');
|
||||
addClass(element, 'sf-toggle-visible');
|
||||
} else {
|
||||
addClass(toggles[i], 'sf-toggle-off');
|
||||
addClass(element, 'sf-toggle-hidden');
|
||||
}
|
||||
|
||||
addEventListener(toggles[i], 'click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if ('' !== window.getSelection().toString()) {
|
||||
/* Don't do anything on text selection */
|
||||
return;
|
||||
}
|
||||
|
||||
var toggle = e.target || e.srcElement;
|
||||
|
||||
/* needed because when the toggle contains HTML contents, user can click */
|
||||
/* on any of those elements instead of their parent '.sf-toggle' element */
|
||||
while (!hasClass(toggle, 'sf-toggle')) {
|
||||
toggle = toggle.parentNode;
|
||||
}
|
||||
|
||||
var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));
|
||||
|
||||
toggleClass(toggle, 'sf-toggle-on');
|
||||
toggleClass(toggle, 'sf-toggle-off');
|
||||
toggleClass(element, 'sf-toggle-hidden');
|
||||
toggleClass(element, 'sf-toggle-visible');
|
||||
|
||||
/* the toggle doesn't change its contents when clicking on it */
|
||||
if (!toggle.hasAttribute('data-toggle-alt-content')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!toggle.hasAttribute('data-toggle-original-content')) {
|
||||
toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);
|
||||
}
|
||||
|
||||
var currentContent = toggle.innerHTML;
|
||||
var originalContent = toggle.getAttribute('data-toggle-original-content');
|
||||
var altContent = toggle.getAttribute('data-toggle-alt-content');
|
||||
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
|
||||
});
|
||||
|
||||
/* Prevents from disallowing clicks on links inside toggles */
|
||||
var toggleLinks = toggles[i].querySelectorAll('a');
|
||||
for (var j = 0; j < toggleLinks.length; j++) {
|
||||
addEventListener(toggleLinks[j], 'click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
/* Prevents from disallowing clicks on "copy to clipboard" elements inside toggles */
|
||||
var copyToClipboardElements = toggles[i].querySelectorAll('span[data-clipboard-text]');
|
||||
for (var k = 0; k < copyToClipboardElements.length; k++) {
|
||||
addEventListener(copyToClipboardElements[k], 'click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
toggles[i].setAttribute('data-processed', 'true');
|
||||
}
|
||||
})();
|
||||
|
||||
(function createFilters() {
|
||||
document.querySelectorAll('[data-filters] [data-filter]').forEach(function (filter) {
|
||||
var filters = filter.closest('[data-filters]'),
|
||||
type = 'choice',
|
||||
name = filter.dataset.filter,
|
||||
ucName = name.charAt(0).toUpperCase()+name.slice(1),
|
||||
list = document.createElement('ul'),
|
||||
values = filters.dataset['filter'+ucName] || filters.querySelectorAll('[data-filter-'+name+']'),
|
||||
labels = {},
|
||||
defaults = null,
|
||||
indexed = {},
|
||||
processed = {};
|
||||
if (typeof values === 'string') {
|
||||
type = 'level';
|
||||
labels = values.split(',');
|
||||
values = values.toLowerCase().split(',');
|
||||
defaults = values.length - 1;
|
||||
}
|
||||
addClass(list, 'filter-list');
|
||||
addClass(list, 'filter-list-'+type);
|
||||
values.forEach(function (value, i) {
|
||||
if (value instanceof HTMLElement) {
|
||||
value = value.dataset['filter'+ucName];
|
||||
}
|
||||
if (value in processed) {
|
||||
return;
|
||||
}
|
||||
var option = document.createElement('li'),
|
||||
label = i in labels ? labels[i] : value,
|
||||
active = false,
|
||||
matches;
|
||||
if ('' === label) {
|
||||
option.innerHTML = '<em>(none)</em>';
|
||||
} else {
|
||||
option.innerText = label;
|
||||
}
|
||||
option.dataset.filter = value;
|
||||
option.setAttribute('title', 1 === (matches = filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').length) ? 'Matches 1 row' : 'Matches '+matches+' rows');
|
||||
indexed[value] = i;
|
||||
list.appendChild(option);
|
||||
addEventListener(option, 'click', function () {
|
||||
if ('choice' === type) {
|
||||
filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
|
||||
if (option.dataset.filter === row.dataset['filter'+ucName]) {
|
||||
toggleClass(row, 'filter-hidden-'+name);
|
||||
}
|
||||
});
|
||||
toggleClass(option, 'active');
|
||||
} else if ('level' === type) {
|
||||
if (i === this.parentNode.querySelectorAll('.active').length - 1) {
|
||||
return;
|
||||
}
|
||||
this.parentNode.querySelectorAll('li').forEach(function (currentOption, j) {
|
||||
if (j <= i) {
|
||||
addClass(currentOption, 'active');
|
||||
if (i === j) {
|
||||
addClass(currentOption, 'last-active');
|
||||
} else {
|
||||
removeClass(currentOption, 'last-active');
|
||||
}
|
||||
} else {
|
||||
removeClass(currentOption, 'active');
|
||||
removeClass(currentOption, 'last-active');
|
||||
}
|
||||
});
|
||||
filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
|
||||
if (i < indexed[row.dataset['filter'+ucName]]) {
|
||||
addClass(row, 'filter-hidden-'+name);
|
||||
} else {
|
||||
removeClass(row, 'filter-hidden-'+name);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if ('choice' === type) {
|
||||
active = null === defaults || 0 <= defaults.indexOf(value);
|
||||
} else if ('level' === type) {
|
||||
active = i <= defaults;
|
||||
if (active && i === defaults) {
|
||||
addClass(option, 'last-active');
|
||||
}
|
||||
}
|
||||
if (active) {
|
||||
addClass(option, 'active');
|
||||
} else {
|
||||
filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').forEach(function (row) {
|
||||
toggleClass(row, 'filter-hidden-'+name);
|
||||
});
|
||||
}
|
||||
processed[value] = true;
|
||||
});
|
||||
|
||||
if (1 < list.childNodes.length) {
|
||||
filter.appendChild(list);
|
||||
filter.dataset.filtered = '';
|
||||
}
|
||||
});
|
||||
})();
|
||||
})();
|
||||
/*]]>*/
|
||||
|
||||
Reference in New Issue
Block a user