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

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