Class TClientScriptLoader

Description

The TClientScriptLoader publish a collection of javascript files as assets.

The PackagePath property can be an existing asset directory or a namespace path to the directory containing javascript files. E.g.

  1. <com:TClientScriptLoader PackagePath=<%~ mylib/js %> />
  2. <com:TClientScriptLoader PackagePath="Application.myscripts" />

When the files in the PackagePath are published as assets, a script loader php file corresponding to TClientScriptManager::SCRIPT_LOADER is also copied to that asset directory.

The script loader, combines multiple javascript files and serve up as gzip if possible. Allowable scripts and script dependencies can be specified in a "packages.php" file with the following format. This "packages.php" is optional, if absent the filenames without ".js" extension are used. The "packages.php" must be in the directory given by PackagePath.

  1. <?php
  2. $packages = array(
  3. 'package1' => array('file1.js', 'file2.js'),
  4. 'package2' => array('file3.js', 'file4.js'));
  5.  
  6. $deps = array(
  7. 'package1' => array('package1'),
  8. 'package2' => array('package1', 'package2')); //package2 requires package1 first.
  9.  
  10. return array($packages,$deps); //must return $packages and $deps in an array

Set the PackageScripts property with value 'package1' to serve up the 'package1' scripts. A maxium of 25 packages separated by commas is allowed.

Dependencies of the packages are automatically resolved by the script loader php file. E.g.

  1. <com:TClientScriptLoader PackagePath=<%~ mylib/js %> PackageScripts="package2" />

The DebugMode property when false removes comments and whitespaces from the published javascript files. If the DebugMode property is not set, the debug mode is determined from the application mode.

The EnableGzip property (default is true) enables the published javascripts to be served as zipped if the browser and php server allows it.

If the DebugMode is false either explicitly or when the application mode is non-debug, then cache headers are also sent to inform the browser and proxies to cache the file. Moreover, the post-processed (comments removed and zipped) are saved in the assets directory for the next requests. That is, in non-debug mode the scripts are cached in the assets directory until they are deleted.

Located in /Web/UI/WebControls/TClientScriptLoader.php (line 71)

TComponent
   |
   --TApplicationComponent
      |
      --TControl
         |
         --TWebControl
            |
            --TClientScriptLoader
Method Summary
string getClientScriptUrl ()
boolean getDebugMode ()
boolean getEnableGzip ()
string getPackagePath ()
string getPackageScripts ()
string getTagName ()
void setDebugMode (boolean $value)
void setEnableGzip (boolean $value)
void setPackagePath (string $value)
void setPackageScripts (string $value)
Methods
addAttributesToRender (line 86)

Adds attribute name-value pairs to renderer.

This overrides the parent implementation with additional button specific attributes.

  • access: protected
void addAttributesToRender (THtmlWriter $writer)
  • THtmlWriter $writer: the writer used for the rendering purpose

Redefinition of:
TWebControl::addAttributesToRender()
Adds attribute name-value pairs to renderer.
getClientScriptUrl (line 96)
  • return: clientscript.php url.
  • access: protected
string getClientScriptUrl ()
getDebugMode (line 157)
  • return: javascript comments stripped in non-debug mode. Debug mode will depend on the application mode if null.
  • access: public
boolean getDebugMode ()
getEnableGzip (line 148)
  • return: enables gzip compression of the javascript if possible, default is true.
  • access: public
boolean getEnableGzip ()
getPackagePath (line 115)
  • return: custom javascript library directory.
  • access: public
string getPackagePath ()
getPackageScripts (line 132)
  • return: comma delimited list of javascript library packages to load.
  • access: public
string getPackageScripts ()
getTagName (line 76)
  • return: tag name of the script element
  • access: protected
string getTagName ()

Redefinition of:
TWebControl::getTagName()
Returns the tag name used for this control.
setDebugMode (line 165)
  • access: public
void setDebugMode (boolean $value)
  • boolean $value: true to enable debug mode, default is null thus dependent on the application mode.
setEnableGzip (line 140)
  • access: public
void setEnableGzip (boolean $value)
  • boolean $value: enables gzip compression of the javascript.
setPackagePath (line 107)
  • access: public
void setPackagePath (string $value)
  • string $value: custom javascript library directory.
setPackageScripts (line 124)
  • access: public
void setPackageScripts (string $value)
  • string $value: load specific packages from the javascript library in the PackagePath, comma delimited package names. A maximum of 25 packages is allowed.

Inherited Methods

Inherited From TWebControl

TWebControl::addAttributesToRender()
TWebControl::clearStyle()
TWebControl::copyBaseAttributes()
TWebControl::createStyle()
TWebControl::getAccessKey()
TWebControl::getBackColor()
TWebControl::getBorderColor()
TWebControl::getBorderStyle()
TWebControl::getBorderWidth()
TWebControl::getCssClass()
TWebControl::getDisplay()
TWebControl::getFont()
TWebControl::getForeColor()
TWebControl::getHasStyle()
TWebControl::getHeight()
TWebControl::getStyle()
TWebControl::getTabIndex()
TWebControl::getTagName()
TWebControl::getToolTip()
TWebControl::getWidth()
TWebControl::render()
TWebControl::renderBeginTag()
TWebControl::renderContents()
TWebControl::renderEndTag()
TWebControl::setAccessKey()
TWebControl::setBackColor()
TWebControl::setBorderColor()
TWebControl::setBorderStyle()
TWebControl::setBorderWidth()
TWebControl::setCssClass()
TWebControl::setDisplay()
TWebControl::setForeColor()
TWebControl::setHeight()
TWebControl::setStyle()
TWebControl::setTabIndex()
TWebControl::setToolTip()
TWebControl::setWidth()

Inherited From TControl

TControl::__construct()
TControl::addedControl()
TControl::addParsedObject()
TControl::addToPostDataLoader()
TControl::applyStyleSheetSkin()
TControl::autoBindProperty()
TControl::autoDataBindProperties()
TControl::bindProperty()
TControl::broadcastEvent()
TControl::bubbleEvent()
TControl::clearChildState()
TControl::clearControlState()
TControl::clearNamingContainer()
TControl::clearViewState()
TControl::convertUniqueIdToClientId()
TControl::createChildControls()
TControl::createControlCollection()
TControl::dataBind()
TControl::dataBindChildren()
TControl::dataBindProperties()
TControl::ensureChildControls()
TControl::findControl()
TControl::findControlsByID()
TControl::findControlsByType()
TControl::focus()
TControl::getAdapter()
TControl::getAllowChildControls()
TControl::getAttribute()
TControl::getAttributes()
TControl::getChildControlsCreated()
TControl::getClientID()
TControl::getControls()
TControl::getControlStage()
TControl::getControlState()
TControl::getCustomData()
TControl::getEnabled()
TControl::getEnableTheming()
TControl::getEnableViewState()
TControl::getHasAdapter()
TControl::getHasAttributes()
TControl::getHasChildInitialized()
TControl::getHasControls()
TControl::getHasInitialized()
TControl::getHasLoaded()
TControl::getHasLoadedPostData()
TControl::getHasPreRendered()
TControl::getID()
TControl::getNamingContainer()
TControl::getPage()
TControl::getParent()
TControl::getRegisteredObject()
TControl::getSkinID()
TControl::getSourceTemplateControl()
TControl::getTemplateControl()
TControl::getUniqueID()
TControl::getViewState()
TControl::getVisible()
TControl::hasAttribute()
TControl::initRecursive()
TControl::isDescendentOf()
TControl::isObjectRegistered()
TControl::loadRecursive()
TControl::loadState()
TControl::loadStateRecursive()
TControl::onDataBinding()
TControl::onInit()
TControl::onLoad()
TControl::onPreRender()
TControl::onUnload()
TControl::preRenderRecursive()
TControl::raiseBubbleEvent()
TControl::registerObject()
TControl::removeAttribute()
TControl::removedControl()
TControl::render()
TControl::renderChildren()
TControl::renderControl()
TControl::saveState()
TControl::saveStateRecursive()
TControl::setAdapter()
TControl::setAttribute()
TControl::setChildControlsCreated()
TControl::setControlStage()
TControl::setControlState()
TControl::setCustomData()
TControl::setEnabled()
TControl::setEnableTheming()
TControl::setEnableViewState()
TControl::setID()
TControl::setPage()
TControl::setSkinID()
TControl::setTemplateControl()
TControl::setViewState()
TControl::setVisible()
TControl::trackViewState()
TControl::traverseChildControls()
TControl::unbindProperty()
TControl::unloadRecursive()
TControl::unregisterObject()
TControl::__get()

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Class Constants

Documentation generated on Mon, 21 Apr 2008 11:33:26 -0400 by phpDocumentor 1.3.0RC4