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