diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index 58a3f7929..7910bcda7 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -169,6 +169,13 @@ class Module */ protected $cssFiles = array(); + /** + * The Javascript files this module provides + * + * @var array + */ + protected $jsFiles = array(); + /** * Routes to add to the route chain * @@ -445,6 +452,19 @@ class Module return $files; } + /** + * Provide an additional Javascript file + * + * @param string $path The path to the file, relative to self::$jsdir + * + * @return $this + */ + protected function provideJsFile($path) + { + $this->jsFiles[] = $this->jsdir . DIRECTORY_SEPARATOR . $path; + return $this; + } + /** * Test if module provides js * @@ -452,7 +472,12 @@ class Module */ public function hasJs() { - return file_exists($this->getJsFilename()); + if (file_exists($this->getJsFilename())) { + return true; + } + + $this->launchConfigScript(); + return !empty($this->jsFiles); } /** @@ -465,6 +490,18 @@ class Module return $this->jsdir . '/module.js'; } + /** + * Return the Javascript files this module provides + * + * @return array + */ + public function getJsFiles() + { + $files = $this->jsFiles; + $files[] = $this->getJsFilename(); + return $files; + } + /** * Get the module name *