vendor/symfony/web-profiler-bundle/Resources/views/Profiler/base_js.html.twig line 335

Open in your IDE?
  1. {# This file is partially duplicated in TwigBundle/Resources/views/base_js.html.twig. If you
  2.    make any change in this file, verify the same change is needed in the other file. #}
  3. <script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
  4.     {# Caution: the contents of this file are processed by Twig before loading
  5.                 them as JavaScript source code. Always use '/*' comments instead
  6.                 of '//' comments to avoid impossible-to-debug side-effects #}
  7.     Sfjs = (function() {
  8.         "use strict";
  9.         if ('classList' in document.documentElement) {
  10.             var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };
  11.             var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };
  12.             var addClass = function(el, cssClass) { el.classList.add(cssClass); };
  13.             var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };
  14.         } else {
  15.             var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\b' + cssClass + '\\b')); };
  16.             var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\b' + cssClass + '\\b'), ' '); };
  17.             var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += " " + cssClass; } };
  18.             var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };
  19.         }
  20.         var noop = function() {};
  21.         var profilerStorageKey = 'symfony/profiler/';
  22.         var request = function(url, onSuccess, onError, payload, options) {
  23.             var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
  24.             options = options || {};
  25.             options.maxTries = options.maxTries || 0;
  26.             xhr.open(options.method || 'GET', url, true);
  27.             xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  28.             xhr.onreadystatechange = function(state) {
  29.                 if (4 !== xhr.readyState) {
  30.                     return null;
  31.                 }
  32.                 if (xhr.status == 404 && options.maxTries > 1) {
  33.                     setTimeout(function(){
  34.                         options.maxTries--;
  35.                         request(url, onSuccess, onError, payload, options);
  36.                     }, 1000);
  37.                     return null;
  38.                 }
  39.                 if (200 === xhr.status) {
  40.                     (onSuccess || noop)(xhr);
  41.                 } else {
  42.                     (onError || noop)(xhr);
  43.                 }
  44.             };
  45.             xhr.send(payload || '');
  46.         };
  47.         var getPreference = function(name) {
  48.             if (!window.localStorage) {
  49.                 return null;
  50.             }
  51.             return localStorage.getItem(profilerStorageKey + name);
  52.         };
  53.         var setPreference = function(name, value) {
  54.             if (!window.localStorage) {
  55.                 return null;
  56.             }
  57.             localStorage.setItem(profilerStorageKey + name, value);
  58.         };
  59.         var requestStack = [];
  60.         var extractHeaders = function(xhr, stackElement) {
  61.             /* Here we avoid to call xhr.getResponseHeader in order to */
  62.             /* prevent polluting the console with CORS security errors */
  63.             var allHeaders = xhr.getAllResponseHeaders();
  64.             var ret;
  65.             if (ret = allHeaders.match(/^x-debug-token:\s+(.*)$/im)) {
  66.                 stackElement.profile = ret[1];
  67.             }
  68.             if (ret = allHeaders.match(/^x-debug-token-link:\s+(.*)$/im)) {
  69.                 stackElement.profilerUrl = ret[1];
  70.             }
  71.             if (ret = allHeaders.match(/^Symfony-Debug-Toolbar-Replace:\s+(.*)$/im)) {
  72.                 stackElement.toolbarReplaceFinished = false;
  73.                 stackElement.toolbarReplace = '1' === ret[1];
  74.             }
  75.         };
  76.         var successStreak = 4;
  77.         var pendingRequests = 0;
  78.         var renderAjaxRequests = function() {
  79.             var requestCounter = document.querySelector('.sf-toolbar-ajax-request-counter');
  80.             if (!requestCounter) {
  81.                 return;
  82.             }
  83.             requestCounter.textContent = requestStack.length;
  84.             var infoSpan = document.querySelector(".sf-toolbar-ajax-info");
  85.             if (infoSpan) {
  86.                 infoSpan.textContent = requestStack.length + ' AJAX request' + (requestStack.length !== 1 ? 's' : '');
  87.             }
  88.             var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax');
  89.             if (requestStack.length) {
  90.                 ajaxToolbarPanel.style.display = 'block';
  91.             } else {
  92.                 ajaxToolbarPanel.style.display = 'none';
  93.             }
  94.             if (pendingRequests > 0) {
  95.                 addClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  96.             } else if (successStreak < 4) {
  97.                 addClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  98.                 removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  99.             } else {
  100.                 removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  101.                 removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  102.             }
  103.         };
  104.         var startAjaxRequest = function(index) {
  105.             var tbody = document.querySelector('.sf-toolbar-ajax-request-list');
  106.             if (!tbody) {
  107.                 return;
  108.             }
  109.             var nbOfAjaxRequest = tbody.rows.length;
  110.             if (nbOfAjaxRequest >= 100) {
  111.                 tbody.deleteRow(0);
  112.             }
  113.             var request = requestStack[index];
  114.             pendingRequests++;
  115.             var row = document.createElement('tr');
  116.             request.DOMNode = row;
  117.             var requestNumberCell = document.createElement('td');
  118.             requestNumberCell.textContent = index + 1;
  119.             row.appendChild(requestNumberCell);
  120.             var profilerCell = document.createElement('td');
  121.             profilerCell.textContent = 'n/a';
  122.             row.appendChild(profilerCell);
  123.             var methodCell = document.createElement('td');
  124.             methodCell.textContent = request.method;
  125.             row.appendChild(methodCell);
  126.             var typeCell = document.createElement('td');
  127.             typeCell.textContent = request.type;
  128.             row.appendChild(typeCell);
  129.             var statusCodeCell = document.createElement('td');
  130.             var statusCode = document.createElement('span');
  131.             statusCode.textContent = 'n/a';
  132.             statusCodeCell.appendChild(statusCode);
  133.             row.appendChild(statusCodeCell);
  134.             var pathCell = document.createElement('td');
  135.             pathCell.className = 'sf-ajax-request-url';
  136.             if ('GET' === request.method) {
  137.                 var pathLink = document.createElement('a');
  138.                 pathLink.setAttribute('href', request.url);
  139.                 pathLink.textContent = request.url;
  140.                 pathCell.appendChild(pathLink);
  141.             } else {
  142.                 pathCell.textContent = request.url;
  143.             }
  144.             pathCell.setAttribute('title', request.url);
  145.             row.appendChild(pathCell);
  146.             var durationCell = document.createElement('td');
  147.             durationCell.className = 'sf-ajax-request-duration';
  148.             durationCell.textContent = 'n/a';
  149.             row.appendChild(durationCell);
  150.             request.liveDurationHandle = setInterval(function() {
  151.                 durationCell.textContent = (new Date() - request.start) + 'ms';
  152.             }, 100);
  153.             row.className = 'sf-ajax-request sf-ajax-request-loading';
  154.             tbody.insertBefore(row, null);
  155.             var toolbarInfo = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  156.             toolbarInfo.scrollTop = toolbarInfo.scrollHeight;
  157.             renderAjaxRequests();
  158.         };
  159.         var finishAjaxRequest = function(index) {
  160.             var request = requestStack[index];
  161.             clearInterval(request.liveDurationHandle);
  162.             if (!request.DOMNode) {
  163.                 return;
  164.             }
  165.             if (request.toolbarReplace && !request.toolbarReplaceFinished && request.profile) {
  166.                 /* Flag as complete because finishAjaxRequest can be called multiple times. */
  167.                 request.toolbarReplaceFinished = true;
  168.                 /* Search up through the DOM to find the toolbar's container ID. */
  169.                 for (var elem = request.DOMNode; elem && elem !== document; elem = elem.parentNode) {
  170.                     if (elem.id.match(/^sfwdt/)) {
  171.                         Sfjs.loadToolbar(elem.id.replace(/^sfwdt/, ''), request.profile);
  172.                         break;
  173.                     }
  174.                 }
  175.             }
  176.             pendingRequests--;
  177.             var row = request.DOMNode;
  178.             /* Unpack the children from the row */
  179.             var profilerCell = row.children[1];
  180.             var methodCell = row.children[2];
  181.             var statusCodeCell = row.children[4];
  182.             var statusCodeElem = statusCodeCell.children[0];
  183.             var durationCell = row.children[6];
  184.             if (request.error) {
  185.                 row.className = 'sf-ajax-request sf-ajax-request-error';
  186.                 methodCell.className = 'sf-ajax-request-error';
  187.                 successStreak = 0;
  188.             } else {
  189.                 row.className = 'sf-ajax-request sf-ajax-request-ok';
  190.                 successStreak++;
  191.             }
  192.             if (request.statusCode) {
  193.                 if (request.statusCode < 300) {
  194.                     statusCodeElem.setAttribute('class', 'sf-toolbar-status');
  195.                 } else if (request.statusCode < 400) {
  196.                     statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow');
  197.                 } else {
  198.                     statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  199.                 }
  200.                 statusCodeElem.textContent = request.statusCode;
  201.             } else {
  202.                 statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  203.             }
  204.             if (request.duration) {
  205.                 durationCell.textContent = request.duration + 'ms';
  206.             }
  207.             if (request.profilerUrl) {
  208.                 profilerCell.textContent = '';
  209.                 var profilerLink = document.createElement('a');
  210.                 profilerLink.setAttribute('href', request.statusCode < 400 ? request.profilerUrl : request.profilerUrl + '?panel=exception');
  211.                 profilerLink.textContent = request.profile;
  212.                 profilerCell.appendChild(profilerLink);
  213.             }
  214.             renderAjaxRequests();
  215.         };
  216.         var addEventListener;
  217.         var el = document.createElement('div');
  218.         if (!('addEventListener' in el)) {
  219.             addEventListener = function (element, eventName, callback) {
  220.                 element.attachEvent('on' + eventName, callback);
  221.             };
  222.         } else {
  223.             addEventListener = function (element, eventName, callback) {
  224.                 element.addEventListener(eventName, callback, false);
  225.             };
  226.         }
  227.         {% if excluded_ajax_paths is defined %}
  228.             if (window.fetch && window.fetch.polyfill === undefined) {
  229.                 var oldFetch = window.fetch;
  230.                 window.fetch = function () {
  231.                     var promise = oldFetch.apply(this, arguments);
  232.                     var url = arguments[0];
  233.                     var params = arguments[1];
  234.                     var paramType = Object.prototype.toString.call(arguments[0]);
  235.                     if (paramType === '[object Request]') {
  236.                         url = arguments[0].url;
  237.                         params = {
  238.                             method: arguments[0].method,
  239.                             credentials: arguments[0].credentials,
  240.                             headers: arguments[0].headers,
  241.                             mode: arguments[0].mode,
  242.                             redirect: arguments[0].redirect
  243.                         };
  244.                     } else {
  245.                         url = String(url);
  246.                     }
  247.                     if (!url.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
  248.                         var method = 'GET';
  249.                         if (params && params.method !== undefined) {
  250.                             method = params.method;
  251.                         }
  252.                         var stackElement = {
  253.                             error: false,
  254.                             url: url,
  255.                             method: method,
  256.                             type: 'fetch',
  257.                             start: new Date()
  258.                         };
  259.                         var idx = requestStack.push(stackElement) - 1;
  260.                         promise.then(function (r) {
  261.                             stackElement.duration = new Date() - stackElement.start;
  262.                             stackElement.error = r.status < 200 || r.status >= 400;
  263.                             stackElement.statusCode = r.status;
  264.                             stackElement.profile = r.headers.get('x-debug-token');
  265.                             stackElement.profilerUrl = r.headers.get('x-debug-token-link');
  266.                             stackElement.toolbarReplaceFinished = false;
  267.                             stackElement.toolbarReplace = '1' === r.headers.get('Symfony-Debug-Toolbar-Replace');
  268.                             finishAjaxRequest(idx);
  269.                         }, function (e){
  270.                             stackElement.error = true;
  271.                             finishAjaxRequest(idx);
  272.                         });
  273.                         startAjaxRequest(idx);
  274.                     }
  275.                     return promise;
  276.                 };
  277.             }
  278.             if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {
  279.                 var proxied = XMLHttpRequest.prototype.open;
  280.                 XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
  281.                     var self = this;
  282.                     /* prevent logging AJAX calls to static and inline files, like templates */
  283.                     var path = url;
  284.                     if (url.substr(0, 1) === '/') {
  285.                         if (0 === url.indexOf('{{ request.basePath|e('js') }}')) {
  286.                             path = url.substr({{ request.basePath|length }});
  287.                         }
  288.                     }
  289.                     else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) {
  290.                         path = url.substr({{ (request.schemeAndHttpHost ~ request.basePath)|length }});
  291.                     }
  292.                     if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
  293.                         var stackElement = {
  294.                             error: false,
  295.                             url: url,
  296.                             method: method,
  297.                             type: 'xhr',
  298.                             start: new Date()
  299.                         };
  300.                         var idx = requestStack.push(stackElement) - 1;
  301.                         this.addEventListener('readystatechange', function() {
  302.                             if (self.readyState == 4) {
  303.                                 stackElement.duration = new Date() - stackElement.start;
  304.                                 stackElement.error = self.status < 200 || self.status >= 400;
  305.                                 stackElement.statusCode = self.status;
  306.                                 extractHeaders(self, stackElement);
  307.                                 finishAjaxRequest(idx);
  308.                             }
  309.                         }, false);
  310.                         startAjaxRequest(idx);
  311.                     }
  312.                     proxied.apply(this, Array.prototype.slice.call(arguments));
  313.                 };
  314.             }
  315.         {% endif %}
  316.         return {
  317.             hasClass: hasClass,
  318.             removeClass: removeClass,
  319.             addClass: addClass,
  320.             toggleClass: toggleClass,
  321.             getPreference: getPreference,
  322.             setPreference: setPreference,
  323.             addEventListener: addEventListener,
  324.             request: request,
  325.             renderAjaxRequests: renderAjaxRequests,
  326.             load: function(selector, url, onSuccess, onError, options) {
  327.                 var el = document.getElementById(selector);
  328.                 if (el && el.getAttribute('data-sfurl') !== url) {
  329.                     request(
  330.                         url,
  331.                         function(xhr) {
  332.                             el.innerHTML = xhr.responseText;
  333.                             el.setAttribute('data-sfurl', url);
  334.                             removeClass(el, 'loading');
  335.                             var pending = pendingRequests;
  336.                             for (var i = 0; i < requestStack.length; i++) {
  337.                                 startAjaxRequest(i);
  338.                                 if (requestStack[i].duration) {
  339.                                     finishAjaxRequest(i);
  340.                                 }
  341.                             }
  342.                             /* Revert the pending state in case there was a start called without a finish above. */
  343.                             pendingRequests = pending;
  344.                             (onSuccess || noop)(xhr, el);
  345.                         },
  346.                         function(xhr) { (onError || noop)(xhr, el); },
  347.                         '',
  348.                         options
  349.                     );
  350.                 }
  351.                 return this;
  352.             },
  353.             loadToolbar: function(token, newToken) {
  354.                 newToken = (newToken || token);
  355.                 this.load(
  356.                     'sfwdt' + token,
  357.                     '{{ path("_wdt", { "token": "xxxxxx" }) }}'.replace(/xxxxxx/, newToken),
  358.                     function(xhr, el) {
  359.                         /* Evaluate in global scope scripts embedded inside the toolbar */
  360.                         var i, scripts = [].slice.call(el.querySelectorAll('script'));
  361.                         for (i = 0; i < scripts.length; ++i) {
  362.                             eval.call({}, scripts[i].firstChild.nodeValue);
  363.                         }
  364.                         el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
  365.                         if (el.style.display == 'none') {
  366.                             return;
  367.                         }
  368.                         if (getPreference('toolbar/displayState') == 'none') {
  369.                             document.getElementById('sfToolbarMainContent-' + newToken).style.display = 'none';
  370.                             document.getElementById('sfToolbarClearer-' + newToken).style.display = 'none';
  371.                             document.getElementById('sfMiniToolbar-' + newToken).style.display = 'block';
  372.                         } else {
  373.                             document.getElementById('sfToolbarMainContent-' + newToken).style.display = 'block';
  374.                             document.getElementById('sfToolbarClearer-' + newToken).style.display = 'block';
  375.                             document.getElementById('sfMiniToolbar-' + newToken).style.display = 'none';
  376.                         }
  377.                         /* Handle toolbar-info position */
  378.                         var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
  379.                         for (i = 0; i < toolbarBlocks.length; ++i) {
  380.                             toolbarBlocks[i].onmouseover = function () {
  381.                                 var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];
  382.                                 var pageWidth = document.body.clientWidth;
  383.                                 var elementWidth = toolbarInfo.offsetWidth;
  384.                                 var leftValue = (elementWidth + this.offsetLeft) - pageWidth;
  385.                                 var rightValue = (elementWidth + (pageWidth - this.offsetLeft)) - pageWidth;
  386.                                 /* Reset right and left value, useful on window resize */
  387.                                 toolbarInfo.style.right = '';
  388.                                 toolbarInfo.style.left = '';
  389.                                 if (elementWidth > pageWidth) {
  390.                                     toolbarInfo.style.left = 0;
  391.                                 }
  392.                                 else if (leftValue > 0 && rightValue > 0) {
  393.                                     toolbarInfo.style.right = (rightValue * -1) + 'px';
  394.                                 } else if (leftValue < 0) {
  395.                                     toolbarInfo.style.left = 0;
  396.                                 } else {
  397.                                     toolbarInfo.style.right = '0px';
  398.                                 }
  399.                             };
  400.                         }
  401.                         addEventListener(document.getElementById('sfToolbarHideButton-' + newToken), 'click', function (event) {
  402.                             event.preventDefault();
  403.                             var p = this.parentNode;
  404.                             p.style.display = 'none';
  405.                             (p.previousElementSibling || p.previousSibling).style.display = 'none';
  406.                             document.getElementById('sfMiniToolbar-' + newToken).style.display = 'block';
  407.                             setPreference('toolbar/displayState', 'none');
  408.                         });
  409.                         addEventListener(document.getElementById('sfToolbarMiniToggler-' + newToken), 'click', function (event) {
  410.                             event.preventDefault();
  411.                             var elem = this.parentNode;
  412.                             if (elem.style.display == 'none') {
  413.                                 document.getElementById('sfToolbarMainContent-' + newToken).style.display = 'none';
  414.                                 document.getElementById('sfToolbarClearer-' + newToken).style.display = 'none';
  415.                                 elem.style.display = 'block';
  416.                             } else {
  417.                                 document.getElementById('sfToolbarMainContent-' + newToken).style.display = 'block';
  418.                                 document.getElementById('sfToolbarClearer-' + newToken).style.display = 'block';
  419.                                 elem.style.display = 'none'
  420.                             }
  421.                             setPreference('toolbar/displayState', 'block');
  422.                         });
  423.                         renderAjaxRequests();
  424.                         addEventListener(document.querySelector('.sf-toolbar-block-ajax'), 'mouseenter', function (event) {
  425.                             var elem = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  426.                             elem.scrollTop = elem.scrollHeight;
  427.                         });
  428.                         addEventListener(document.querySelector('.sf-toolbar-block-ajax > .sf-toolbar-icon'), 'click', function (event) {
  429.                             event.preventDefault();
  430.                             toggleClass(this.parentNode, 'hover');
  431.                         });
  432.                         var dumpInfo = document.querySelector('.sf-toolbar-block-dump .sf-toolbar-info');
  433.                         if (null !== dumpInfo) {
  434.                             addEventListener(dumpInfo, 'sfbeforedumpcollapse', function () {
  435.                                 dumpInfo.style.minHeight = dumpInfo.getBoundingClientRect().height+'px';
  436.                             });
  437.                             addEventListener(dumpInfo, 'mouseleave', function () {
  438.                                 dumpInfo.style.minHeight = '';
  439.                             });
  440.                         }
  441.                     },
  442.                     function(xhr) {
  443.                         if (xhr.status !== 0) {
  444.                             var sfwdt = document.getElementById('sfwdt' + token);
  445.                             sfwdt.innerHTML = '\
  446.                                 <div class="sf-toolbarreset">\
  447.                                     <div class="sf-toolbar-icon"><svg width="26" height="28" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 26 28" enable-background="new 0 0 26 28" xml:space="preserve"><path fill="#FFFFFF" d="M13 0C5.8 0 0 5.8 0 13c0 7.2 5.8 13 13 13c7.2 0 13-5.8 13-13C26 5.8 20.2 0 13 0z M20 7.5 c-0.6 0-1-0.3-1-0.9c0-0.2 0-0.4 0.2-0.6c0.1-0.3 0.2-0.3 0.2-0.4c0-0.3-0.5-0.4-0.7-0.4c-2 0.1-2.5 2.7-2.9 4.8l-0.2 1.1 c1.1 0.2 1.9 0 2.4-0.3c0.6-0.4-0.2-0.8-0.1-1.3C18 9.2 18.4 9 18.7 8.9c0.5 0 0.8 0.5 0.8 1c0 0.8-1.1 2-3.3 1.9 c-0.3 0-0.5 0-0.7-0.1L15 14.1c-0.4 1.7-0.9 4.1-2.6 6.2c-1.5 1.8-3.1 2.1-3.8 2.1c-1.3 0-2.1-0.6-2.2-1.6c0-0.9 0.8-1.4 1.3-1.4 c0.7 0 1.2 0.5 1.2 1.1c0 0.5-0.2 0.6-0.4 0.7c-0.1 0.1-0.3 0.2-0.3 0.4c0 0.1 0.1 0.3 0.4 0.3c0.5 0 0.9-0.3 1.2-0.5 c1.3-1 1.7-2.9 2.4-6.2l0.1-0.8c0.2-1.1 0.5-2.3 0.8-3.5c-0.9-0.7-1.4-1.5-2.6-1.8c-0.8-0.2-1.3 0-1.7 0.4C8.4 10 8.6 10.7 9 11.1 l0.7 0.7c0.8 0.9 1.3 1.7 1.1 2.7c-0.3 1.6-2.1 2.8-4.3 2.1c-1.9-0.6-2.2-1.9-2-2.7c0.2-0.6 0.7-0.8 1.2-0.6 c0.5 0.2 0.7 0.8 0.6 1.3c0 0.1 0 0.1-0.1 0.3C6 15 5.9 15.2 5.9 15.3c-0.1 0.4 0.4 0.7 0.8 0.8c0.8 0.3 1.7-0.2 1.9-0.9 c0.2-0.6-0.2-1.1-0.4-1.2l-0.8-0.9c-0.4-0.4-1.2-1.5-0.8-2.8c0.2-0.5 0.5-1 0.9-1.4c1-0.7 2-0.8 3-0.6c1.3 0.4 1.9 1.2 2.8 1.9 c0.5-1.3 1.1-2.6 2-3.8c0.9-1 2-1.7 3.3-1.8C20 4.8 21 5.4 21 6.3C21 6.7 20.8 7.5 20 7.5z"/></svg></div>\
  448.                                     An error occurred while loading the web debug toolbar. <a href="{{ path("_profiler_home") }}' + newToken + '>Open the web profiler.</a>\
  449.                                 </div>\
  450.                             ';
  451.                             sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar');
  452.                         }
  453.                     },
  454.                     { maxTries: 5 }
  455.                 );
  456.                 return this;
  457.             },
  458.             toggle: function(selector, elOn, elOff) {
  459.                 var tmp = elOn.style.display,
  460.                     el = document.getElementById(selector);
  461.                 elOn.style.display = elOff.style.display;
  462.                 elOff.style.display = tmp;
  463.                 if (el) {
  464.                     el.style.display = 'none' === tmp ? 'none' : 'block';
  465.                 }
  466.                 return this;
  467.             },
  468.             createTabs: function() {
  469.                 var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
  470.                 /* create the tab navigation for each group of tabs */
  471.                 for (var i = 0; i < tabGroups.length; i++) {
  472.                     var tabs = tabGroups[i].querySelectorAll(':scope > .tab');
  473.                     var tabNavigation = document.createElement('ul');
  474.                     tabNavigation.className = 'tab-navigation';
  475.                     var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
  476.                     for (var j = 0; j < tabs.length; j++) {
  477.                         var tabId = 'tab-' + i + '-' + j;
  478.                         var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
  479.                         var tabNavigationItem = document.createElement('li');
  480.                         tabNavigationItem.setAttribute('data-tab-id', tabId);
  481.                         if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
  482.                         if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); }
  483.                         tabNavigationItem.innerHTML = tabTitle;
  484.                         tabNavigation.appendChild(tabNavigationItem);
  485.                         var tabContent = tabs[j].querySelector('.tab-content');
  486.                         tabContent.parentElement.setAttribute('id', tabId);
  487.                     }
  488.                     tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
  489.                     addClass(document.querySelector('[data-tab-id="' + selectedTabId + '"]'), 'active');
  490.                 }
  491.                 /* display the active tab and add the 'click' event listeners */
  492.                 for (i = 0; i < tabGroups.length; i++) {
  493.                     tabNavigation = tabGroups[i].querySelectorAll(':scope > .tab-navigation li');
  494.                     for (j = 0; j < tabNavigation.length; j++) {
  495.                         tabId = tabNavigation[j].getAttribute('data-tab-id');
  496.                         document.getElementById(tabId).querySelector('.tab-title').className = 'hidden';
  497.                         if (hasClass(tabNavigation[j], 'active')) {
  498.                             document.getElementById(tabId).className = 'block';
  499.                         } else {
  500.                             document.getElementById(tabId).className = 'hidden';
  501.                         }
  502.                         tabNavigation[j].addEventListener('click', function(e) {
  503.                             var activeTab = e.target || e.srcElement;
  504.                             /* needed because when the tab contains HTML contents, user can click */
  505.                             /* on any of those elements instead of their parent '<li>' element */
  506.                             while (activeTab.tagName.toLowerCase() !== 'li') {
  507.                                 activeTab = activeTab.parentNode;
  508.                             }
  509.                             /* get the full list of tabs through the parent of the active tab element */
  510.                             var tabNavigation = activeTab.parentNode.children;
  511.                             for (var k = 0; k < tabNavigation.length; k++) {
  512.                                 var tabId = tabNavigation[k].getAttribute('data-tab-id');
  513.                                 document.getElementById(tabId).className = 'hidden';
  514.                                 removeClass(tabNavigation[k], 'active');
  515.                             }
  516.                             addClass(activeTab, 'active');
  517.                             var activeTabId = activeTab.getAttribute('data-tab-id');
  518.                             document.getElementById(activeTabId).className = 'block';
  519.                         });
  520.                     }
  521.                     tabGroups[i].setAttribute('data-processed', 'true');
  522.                 }
  523.             },
  524.             createToggles: function() {
  525.                 var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
  526.                 for (var i = 0; i < toggles.length; i++) {
  527.                     var elementSelector = toggles[i].getAttribute('data-toggle-selector');
  528.                     var element = document.querySelector(elementSelector);
  529.                     addClass(element, 'sf-toggle-content');
  530.                     if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {
  531.                         addClass(toggles[i], 'sf-toggle-on');
  532.                         addClass(element, 'sf-toggle-visible');
  533.                     } else {
  534.                         addClass(toggles[i], 'sf-toggle-off');
  535.                         addClass(element, 'sf-toggle-hidden');
  536.                     }
  537.                     addEventListener(toggles[i], 'click', function(e) {
  538.                         e.preventDefault();
  539.                         if ('' !== window.getSelection().toString()) {
  540.                             /* Don't do anything on text selection */
  541.                             return;
  542.                         }
  543.                         var toggle = e.target || e.srcElement;
  544.                         /* needed because when the toggle contains HTML contents, user can click */
  545.                         /* on any of those elements instead of their parent '.sf-toggle' element */
  546.                         while (!hasClass(toggle, 'sf-toggle')) {
  547.                             toggle = toggle.parentNode;
  548.                         }
  549.                         var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));
  550.                         toggleClass(toggle, 'sf-toggle-on');
  551.                         toggleClass(toggle, 'sf-toggle-off');
  552.                         toggleClass(element, 'sf-toggle-hidden');
  553.                         toggleClass(element, 'sf-toggle-visible');
  554.                         /* the toggle doesn't change its contents when clicking on it */
  555.                         if (!toggle.hasAttribute('data-toggle-alt-content')) {
  556.                             return;
  557.                         }
  558.                         if (!toggle.hasAttribute('data-toggle-original-content')) {
  559.                             toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);
  560.                         }
  561.                         var currentContent = toggle.innerHTML;
  562.                         var originalContent = toggle.getAttribute('data-toggle-original-content');
  563.                         var altContent = toggle.getAttribute('data-toggle-alt-content');
  564.                         toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
  565.                     });
  566.                     /* Prevents from disallowing clicks on links inside toggles */
  567.                     var toggleLinks = toggles[i].querySelectorAll('a');
  568.                     for (var j = 0; j < toggleLinks.length; j++) {
  569.                         addEventListener(toggleLinks[j], 'click', function(e) {
  570.                             e.stopPropagation();
  571.                         });
  572.                     }
  573.                     toggles[i].setAttribute('data-processed', 'true');
  574.                 }
  575.             },
  576.             createFilters: function() {
  577.                 document.querySelectorAll('[data-filters] [data-filter]').forEach(function (filter) {
  578.                     var filters = filter.closest('[data-filters]'),
  579.                         type = 'choice',
  580.                         name = filter.dataset.filter,
  581.                         ucName = name.charAt(0).toUpperCase()+name.slice(1),
  582.                         list = document.createElement('ul'),
  583.                         values = filters.dataset['filter'+ucName] || filters.querySelectorAll('[data-filter-'+name+']'),
  584.                         labels = {},
  585.                         defaults = null,
  586.                         indexed = {},
  587.                         processed = {};
  588.                     if (typeof values === 'string') {
  589.                         type = 'level';
  590.                         labels = values.split(',');
  591.                         values = values.toLowerCase().split(',');
  592.                         defaults = values.length - 1;
  593.                     }
  594.                     addClass(list, 'filter-list');
  595.                     addClass(list, 'filter-list-'+type);
  596.                     values.forEach(function (value, i) {
  597.                         if (value instanceof HTMLElement) {
  598.                             value = value.dataset['filter'+ucName];
  599.                         }
  600.                         if (value in processed) {
  601.                             return;
  602.                         }
  603.                         var option = document.createElement('li'),
  604.                             label = i in labels ? labels[i] : value,
  605.                             active = false,
  606.                             matches;
  607.                         if ('' === label) {
  608.                             option.innerHTML = '<em>(none)</em>';
  609.                         } else {
  610.                             option.innerText = label;
  611.                         }
  612.                         option.dataset.filter = value;
  613.                         option.setAttribute('title', 1 === (matches = filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').length) ? 'Matches 1 row' : 'Matches '+matches+' rows');
  614.                         indexed[value] = i;
  615.                         list.appendChild(option);
  616.                         addEventListener(option, 'click', function () {
  617.                             if ('choice' === type) {
  618.                                 filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
  619.                                     if (option.dataset.filter === row.dataset['filter'+ucName]) {
  620.                                         toggleClass(row, 'filter-hidden-'+name);
  621.                                     }
  622.                                 });
  623.                                 toggleClass(option, 'active');
  624.                             } else if ('level' === type) {
  625.                                 if (i === this.parentNode.querySelectorAll('.active').length - 1) {
  626.                                     return;
  627.                                 }
  628.                                 this.parentNode.querySelectorAll('li').forEach(function (currentOption, j) {
  629.                                     if (j <= i) {
  630.                                         addClass(currentOption, 'active');
  631.                                         if (i === j) {
  632.                                             addClass(currentOption, 'last-active');
  633.                                         } else {
  634.                                             removeClass(currentOption, 'last-active');
  635.                                         }
  636.                                     } else {
  637.                                         removeClass(currentOption, 'active');
  638.                                         removeClass(currentOption, 'last-active');
  639.                                     }
  640.                                 });
  641.                                 filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
  642.                                     if (i < indexed[row.dataset['filter'+ucName]]) {
  643.                                         addClass(row, 'filter-hidden-'+name);
  644.                                     } else {
  645.                                         removeClass(row, 'filter-hidden-'+name);
  646.                                     }
  647.                                 });
  648.                             }
  649.                         });
  650.                         if ('choice' === type) {
  651.                             active = null === defaults || 0 <= defaults.indexOf(value);
  652.                         } else if ('level' === type) {
  653.                             active = i <= defaults;
  654.                             if (active && i === defaults) {
  655.                                 addClass(option, 'last-active');
  656.                             }
  657.                         }
  658.                         if (active) {
  659.                             addClass(option, 'active');
  660.                         } else {
  661.                             filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').forEach(function (row) {
  662.                                 toggleClass(row, 'filter-hidden-'+name);
  663.                             });
  664.                         }
  665.                         processed[value] = true;
  666.                     });
  667.                     if (1 < list.childNodes.length) {
  668.                         filter.appendChild(list);
  669.                         filter.dataset.filtered = '';
  670.                     }
  671.                 });
  672.             }
  673.         };
  674.     })();
  675.     Sfjs.addEventListener(document, 'DOMContentLoaded', function() {
  676.         Sfjs.createTabs();
  677.         Sfjs.createToggles();
  678.     });
  679. /*]]>*/</script>