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