summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-04-29 11:24:11 +0200
committeremkael <emkael@tlen.pl>2016-04-29 11:24:11 +0200
commit7a2a894fab8414200b53da9d2d6959c80271cad8 (patch)
tree9d0d222dcb580b8d2fc981a55f7bbf58dd19469d /app
parent7a728e107ca20c98cacea406ab555d3d12605caf (diff)
* JS libraries as control dependencies
Diffstat (limited to 'app')
-rw-r--r--app/php/web/TemplateControl.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/app/php/web/TemplateControl.php b/app/php/web/TemplateControl.php
index e3c9e26..a397f6f 100644
--- a/app/php/web/TemplateControl.php
+++ b/app/php/web/TemplateControl.php
@@ -9,10 +9,30 @@ class TemplateControl extends TTemplateControl {
. '.js';
}
+ private function _getLibScriptPath($identifier) {
+ return Prado::getPathOfNamespace('Lib')
+ . DIRECTORY_SEPARATOR
+ . $identifier
+ . '.js';
+ }
+
public function onPreRender($param) {
parent::onPreRender($param);
$scriptFile = $this->_getControlScriptPath(get_class($this));
if (file_exists($scriptFile)) {
+ foreach ($this->getExternalScriptDependencies() as $dependency) {
+ $this->Page->ClientScript->registerHeadScriptFile(
+ $dependency, $dependency
+ );
+ }
+ foreach ($this->getLibScriptDependencies() as $dependency) {
+ $this->Page->ClientScript->registerScriptFile(
+ 'LibScript.' . $dependency,
+ $this->Application->AssetManager->publishFilePath(
+ $this->_getLibScriptPath($dependency)
+ )
+ );
+ }
foreach ($this->getPradoScriptDependencies() as $dependency) {
$this->Page->ClientScript->registerPradoScript($dependency);
}
@@ -24,11 +44,6 @@ class TemplateControl extends TTemplateControl {
)
);
}
- foreach ($this->getExternalScriptDependencies() as $dependency) {
- $this->Page->ClientScript->registerHeadScriptFile(
- $dependency, $dependency
- );
- }
$this->Page->ClientScript->registerScriptFile(
'TemplateControl.' . get_class($this),
$this->Application->AssetManager->publishFilePath($scriptFile)
@@ -44,6 +59,10 @@ class TemplateControl extends TTemplateControl {
return [];
}
+ protected function getLibScriptDependencies() {
+ return [];
+ }
+
protected function getExternalScriptDependencies() {
return [];
}