Class TClientScriptLoader
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. 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. - <?php
- $packages = array(
- 'package1' => array('file1.js', 'file2.js'),
- 'package2' => array('file3.js', 'file4.js'));
-
- $deps = array(
- 'package1' => array('package1'),
- 'package2' => array('package1', 'package2')); //package2 requires package1 first.
-
-
- 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. 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.
Constants Inherited From TControl |
AUTOMATIC_ID_PREFIX,
CLIENT_ID_SEPARATOR,
CS_CHILD_INITIALIZED,
CS_CONSTRUCTED,
CS_INITIALIZED,
CS_LOADED,
CS_PRERENDERED,
CS_STATE_LOADED,
ID_FORMAT,
ID_SEPARATOR,
IS_CHILD_CREATED,
IS_CREATING_CHILD,
IS_DISABLE_THEMING,
IS_DISABLE_VIEWSTATE,
IS_ID_SET,
IS_SKIN_APPLIED,
IS_STYLESHEET_APPLIED,
RF_ADAPTER,
RF_AUTO_BINDINGS,
RF_CHILD_STATE,
RF_CONTROLS,
RF_CONTROLSTATE,
RF_DATA_BINDINGS,
RF_EVENTS,
RF_NAMED_CONTROLS,
RF_NAMED_CONTROLS_ID,
RF_NAMED_OBJECTS,
RF_SKIN_ID,
|
Method Summary |
protected
void
|
Adds attribute name-value pairs to renderer.
|
protected
string
|
|
boolean
|
|
boolean
|
|
string
|
|
string
|
|
protected
string
|
|
void
|
|
void
|
|
void
|
|
void
|
|
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()
|
Methods Inherited From TControl |
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()
|
Methods 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()
|
Method Details |
addAttributesToRender
protected void addAttributesToRender |
(THtmlWriter $writer ) |
Adds attribute name-value pairs to renderer.
This overrides the parent implementation with additional button specific attributes.
Input |
THtmlWriter | $writer | the writer used for the rendering purpose |
Output |
Exception |
|
getClientScriptUrl
protected string getClientScriptUrl |
() |
Output |
string
| clientscript.php url. |
Exception |
|
getDebugMode
public boolean getDebugMode |
() |
Output |
boolean
| javascript comments stripped in non-debug mode. Debug mode will depend on the application mode if null. |
Exception |
|
getEnableGzip
public boolean getEnableGzip |
() |
Output |
boolean
| enables gzip compression of the javascript if possible, default is true. |
Exception |
|
getPackagePath
public string getPackagePath |
() |
Output |
string
| custom javascript library directory. |
Exception |
|
getPackageScripts
public string getPackageScripts |
() |
Output |
string
| comma delimited list of javascript library packages to load. |
Exception |
|
getTagName
protected string getTagName |
() |
Output |
string
| tag name of the script element |
Exception |
|
setDebugMode
public void setDebugMode |
(boolean $value ) |
Input |
boolean | $value | true to enable debug mode, default is null thus dependent on the application mode. |
Output |
Exception |
|
setEnableGzip
public void setEnableGzip |
(boolean $value ) |
Input |
boolean | $value | enables gzip compression of the javascript. |
Output |
Exception |
|
setPackagePath
public void setPackagePath |
(string $value ) |
Input |
string | $value | custom javascript library directory. |
Output |
Exception |
|
setPackageScripts
public void setPackageScripts |
(string $value ) |
Input |
string | $value | load specific packages from the javascript library in the PackagePath, comma delimited package names. A maximum of 25 packages is allowed. |
Output |
Exception |
|
|