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