addJS() public method

Add a javascript file into the array
public addJS ( string $file, boolean $minify = true, boolean $addTimestamp = null, integer $priorityGroup = self::PRIORITY_GROUP_DEFAULT )
$file string The path to the javascript-file that should be loaded.
$minify boolean Should the file be minified?
$addTimestamp boolean May we add a timestamp for caching purposes?
$priorityGroup integer
Beispiel #1
0
 /**
  * Execute the action
  * If a javascript file with the name of the module or action exists it will be loaded.
  */
 public function execute()
 {
     // build path to the module
     $frontendModulePath = FRONTEND_MODULES_PATH . '/' . $this->getModule();
     // build URL to the module
     $frontendModuleURL = '/src/Frontend/Modules/' . $this->getModule() . '/Js';
     // add javascript file with same name as module (if the file exists)
     if (is_file($frontendModulePath . '/Js/' . $this->getModule() . '.js')) {
         $this->header->addJS($frontendModuleURL . '/' . $this->getModule() . '.js', true, true, Header::PRIORITY_GROUP_MODULE);
     }
     // add javascript file with same name as the action (if the file exists)
     if (is_file($frontendModulePath . '/Js/' . $this->getAction() . '.js')) {
         $this->header->addJS($frontendModuleURL . '/' . $this->getAction() . '.js', true, true, Header::PRIORITY_GROUP_MODULE);
     }
 }