diff --git a/library/Icinga/Application/webrouter.php b/library/Icinga/Application/webrouter.php index d9ab30b4a..47210808e 100644 --- a/library/Icinga/Application/webrouter.php +++ b/library/Icinga/Application/webrouter.php @@ -63,11 +63,13 @@ if (in_array($path, $special)) { exit; case 'js/icinga.dev.js': - JavaScript::send(); + $forIe11 = (bool) preg_match('/Trident\/7.0;.*rv:11/', $_SERVER['HTTP_USER_AGENT']); + JavaScript::send(false, $forIe11); exit; case 'js/icinga.min.js': - JavaScript::sendMinified(); + $forIe11 = (bool) preg_match('/Trident\/7.0;.*rv:11/', $_SERVER['HTTP_USER_AGENT']); + JavaScript::sendMinified($forIe11); break; default: diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index 520aef93c..00d970e30 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -53,9 +53,9 @@ class JavaScript 'js/define.js' ]; - public static function sendMinified() + public static function sendMinified($forIe11 = false) { - self::send(true); + self::send(true, $forIe11); } /** @@ -65,7 +65,7 @@ class JavaScript * * @param bool $minified Whether to compress the client side script code */ - public static function send($minified = false) + public static function send($minified = false, $forIe11 = false) { header('Content-Type: application/javascript'); $basedir = Icinga::app()->getBootstrapDirectory(); @@ -91,9 +91,11 @@ class JavaScript $files[] = $filePath; } - // Prepare library file list - foreach (Icinga::app()->getLibraries() as $library) { - $files = array_merge($files, $library->getJsAssets()); + if (! $forIe11) { + // Prepare library file list + foreach (Icinga::app()->getLibraries() as $library) { + $files = array_merge($files, $library->getJsAssets()); + } } // Prepare core file list @@ -154,26 +156,28 @@ class JavaScript $js .= file_get_contents($file) . "\n\n\n"; } - // Library files need to be namespaced first before they can be included - foreach (Icinga::app()->getLibraries() as $library) { - foreach ($library->getJsAssets() as $file) { - $alreadyMinified = false; - if ($minified && file_exists(($minFile = substr($file, 0, -3) . '.min.js'))) { - $alreadyMinified = true; - $file = $minFile; - } + if (! $forIe11) { + // Library files need to be namespaced first before they can be included + foreach (Icinga::app()->getLibraries() as $library) { + foreach ($library->getJsAssets() as $file) { + $alreadyMinified = false; + if ($minified && file_exists(($minFile = substr($file, 0, -3) . '.min.js'))) { + $alreadyMinified = true; + $file = $minFile; + } - $content = self::optimizeDefine( - file_get_contents($file), - $file, - $library->getJsAssetPath(), - $library->getName() - ); + $content = self::optimizeDefine( + file_get_contents($file), + $file, + $library->getJsAssetPath(), + $library->getName() + ); - if ($alreadyMinified) { - $out .= ';' . ltrim(trim($content), ';') . "\n"; - } else { - $js .= $content . "\n\n\n"; + if ($alreadyMinified) { + $out .= ';' . ltrim(trim($content), ';') . "\n"; + } else { + $js .= $content . "\n\n\n"; + } } } } diff --git a/public/js/helpers.js b/public/js/helpers.js index bcb273629..306d02925 100644 --- a/public/js/helpers.js +++ b/public/js/helpers.js @@ -1,5 +1,11 @@ /*! Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */ +/* IE11 Polyfills */ + +if (window.NodeList && !NodeList.prototype.forEach) { + NodeList.prototype.forEach = Array.prototype.forEach; +} + /* jQuery Plugins */ (function ($) { diff --git a/public/js/icinga/behavior/input-enrichment.js b/public/js/icinga/behavior/input-enrichment.js index e75b167ed..f0bfec128 100644 --- a/public/js/icinga/behavior/input-enrichment.js +++ b/public/js/icinga/behavior/input-enrichment.js @@ -7,9 +7,14 @@ "use strict"; - var FilterInput = require('icinga/ipl/widget/FilterInput'); - var TermInput = require('icinga/ipl/widget/TermInput'); - var Completer = require('icinga/ipl/widget/Completer'); + try { + var FilterInput = require('icinga/ipl/widget/FilterInput'); + var TermInput = require('icinga/ipl/widget/TermInput'); + var Completer = require('icinga/ipl/widget/Completer'); + } catch (e) { + console.warn('Unable to provide input enrichments. Libraries not available:', e); + return; + } Icinga.Behaviors = Icinga.Behaviors || {};