diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index b64b5d96c..c765ca380 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -163,6 +163,7 @@ class Module $this->name = $name; $this->basedir = $basedir; $this->cssdir = $basedir . '/public/css'; + $this->jsdir = $basedir . '/public/js'; $this->libdir = $basedir . '/library'; $this->configdir = $basedir . '/config'; $this->localedir = $basedir . '/application/locale'; @@ -250,6 +251,26 @@ class Module return $this->cssdir . '/module.less'; } + /** + * Test if module provides js + * + * @return bool + */ + public function hasJs() + { + return file_exists($this->getJsFilename()); + } + + /** + * Returns the complete js file name + * + * @return string + */ + public function getJsFilename() + { + return $this->jsdir . '/module.js'; + } + /** * Getter for module name * diff --git a/library/Icinga/Web/JavaScript.php b/library/Icinga/Web/JavaScript.php index 6b7cc0570..d17709a6c 100644 --- a/library/Icinga/Web/JavaScript.php +++ b/library/Icinga/Web/JavaScript.php @@ -31,7 +31,18 @@ class JavaScript public static function listFiles() { - return array_merge(self::$vendorFiles, self::$jsFiles); + return array_merge(self::$vendorFiles, self::$jsFiles, self::listModuleFiles()); + } + + public static function listModuleFiles() + { + $list = array(); + foreach (Icinga::app()->getModuleManager()->getLoadedModules() as $name => $module) { + if ($module->hasJs()) { + $list[] = 'js/' . $name . '/module.js'; + } + } + return $list; } public static function sendMinified()