diff options
Diffstat (limited to 'tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php')
-rw-r--r-- | tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php b/tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php new file mode 100644 index 00000000..964b48a5 --- /dev/null +++ b/tests/FunctionalTests/features/protected/pages/MyJavascriptLib.php @@ -0,0 +1,32 @@ +<?php
+
+class MyJavascriptLib extends TComponent
+{
+ private $_packages=array(); //keep track of all registrations
+
+ private $_manager;
+
+ protected function __construct(TPage $owner)
+ {
+ $this->_manager = $owner->getClientScript();
+ $owner->onPreRenderComplete = array($this, 'registerScriptLoader');
+ }
+
+ public static function registerPackage(TControl $control, $name)
+ {
+ static $instance;
+ if($instance===null)
+ $instance=new self($control->getPage());
+ $instance->_packages[$name]=true;
+ }
+
+ protected function registerScriptLoader()
+ {
+ $dir = dirname(__FILE__).'/myscripts'; //contains my javascript files
+ $scripts = array_keys($this->_packages);
+ $url = $this->_manager->registerJavascriptPackages($dir, $scripts);
+ $this->_manager->registerScriptFile($url,$url);
+ }
+}
+
+?>
\ No newline at end of file |