From cbd89f5cd2e592a0fba91bee23e6111d30aeb1f9 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 19 Mar 2015 18:01:18 +0100 Subject: [PATCH] [WebProfilerBundle] Fix javascript toolbar on IE8 --- .../views/Profiler/base_js.html.twig | 21 +++++++++++++------ .../views/Profiler/toolbar_js.html.twig | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index 2d0a56e668972..502ee36fcda14 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -4,6 +4,17 @@ var noop = function() {}, + collectionToArray = function (collection) { + var length = collection.length || 0, + results = new Array(length); + + while (length--) { + results[length] = collection[length]; + } + + return results; + }, + profilerStorageKey = 'sf2/profiler/', request = function(url, onSuccess, onError, payload, options) { @@ -131,13 +142,13 @@ } } else if (request.loading) { requestState = 'loading'; - state = 'loading' + state = 'loading'; } row.className = 'sf-ajax-request sf-ajax-request-' + requestState; } var infoSpan = document.querySelectorAll(".sf-toolbar-ajax-info")[0]; - var children = Array.prototype.slice.call(tbody.children); + var children = collectionToArray(tbody.children); for (var i = 0; i < children.length; i++) { tbody.removeChild(children[i]); } @@ -185,7 +196,7 @@ } {% if excluded_ajax_paths is defined %} - if (window.XMLHttpRequest) { + if (window.XMLHttpRequest && XMLHttpRequest.addEventListener) { var proxied = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url, async, user, pass) { @@ -262,9 +273,7 @@ }, toggle: function(selector, elOn, elOff) { - var i, - style, - tmp = elOn.style.display, + var tmp = elOn.style.display, el = document.getElementById(selector); elOn.style.display = elOff.style.display; diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig index eebc50fb230df..91ad9ad10ecf1 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig @@ -33,10 +33,10 @@ Sfjs.renderAjaxRequests(); /* Handle toolbar-info position */ - var toolbarBlocks = document.getElementsByClassName('sf-toolbar-block'); + var toolbarBlocks = document.querySelectorAll('.sf-toolbar-block'); for (var i = 0; i < toolbarBlocks.length; i += 1) { toolbarBlocks[i].onmouseover = function () { - var toolbarInfo = this.getElementsByClassName('sf-toolbar-info')[0]; + var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0]; var pageWidth = document.body.clientWidth; var elementWidth = toolbarInfo.offsetWidth; var leftValue = (elementWidth + this.offsetLeft) - pageWidth;