From 91c4292a8063dd2d7a27e7629c015faa4bf052d6 Mon Sep 17 00:00:00 2001 From: wei <> Date: Wed, 5 Jul 2006 01:43:07 +0000 Subject: Upate TClientScript --- .gitattributes | 1 + HISTORY | 340 ++++++++++----------- buildscripts/texbuilder/pages.php | 1 + .../protected/pages/Advanced/Scripts3.page | 3 + .../protected/pages/Controls/ClientScript.page | 52 ++++ .../protected/pages/Controls/Standard.page | 4 + framework/Web/UI/WebControls/TClientScript.php | 120 ++------ framework/Web/UI/WebControls/TStyleSheet.php | 7 +- .../features/protected/pages/ClientScripTest.page | 8 +- 9 files changed, 264 insertions(+), 272 deletions(-) create mode 100644 demos/quickstart/protected/pages/Controls/ClientScript.page diff --git a/.gitattributes b/.gitattributes index aa284132..6aa5af74 100644 --- a/.gitattributes +++ b/.gitattributes @@ -807,6 +807,7 @@ demos/quickstart/protected/pages/Configurations/Templates3.page -text demos/quickstart/protected/pages/Construction.page -text demos/quickstart/protected/pages/Controls/Button.page -text demos/quickstart/protected/pages/Controls/CheckBox.page -text +demos/quickstart/protected/pages/Controls/ClientScript.page -text demos/quickstart/protected/pages/Controls/ColorPicker.page -text demos/quickstart/protected/pages/Controls/Data.page -text demos/quickstart/protected/pages/Controls/DataGrid.page -text diff --git a/HISTORY b/HISTORY index 22ead533..2ecf7f8a 100644 --- a/HISTORY +++ b/HISTORY @@ -1,170 +1,170 @@ -Version 3.0.3 August 6, 2006 -============================ -BUG: Ticket#264 - Typos in some exception throw statements (Knut) -BUG: Ticket#268 - THttpResponse.redirect() may fail for some browsers (Qiang) -BUG: TDataGrid may complain getting ItemType on a non-object if the grid is not data-bound (Qiang) -NEW: Added TStyleSheet (Wei) - -Version 3.0.2 July 2, 2006 -========================== -BUG: Ticket#182 - List and validator controls cause problem in child classes (Qiang) -BUG: Ticket#191 - Duplicated postbacks occur when using TButton with validators (Qiang) -BUG: Ticket#207 - Validators ClientSide.OnError triggered twice (Wei) -BUG: Ticket#213 - PRADO Requirements Checker charset error (Qiang) -BUG: Ticket#227 - Enabled property doesn't works with THtmlArea (Wei) -BUG: Ticket#234 - Postback target could be out of date (Qiang) -BUG: Ticket#239 - Ondeactivate handler for the first View of MultiView is always fired (Qiang) -BUG: Ticket#244 - redirect() needs absolute URL (Qiang) -BUG: Ticket#245 - getIsSecureConnection() is not working correctly (Qiang) -BUG: Ticket#246 - TDatePicker wrong popup position in scrolled div (Wei) -BUG: Ticket#260 - Wrong value of a configuration option in setUseTransparentSessionID (Qiang) -CHG: ensureChildControls() is now invoked in TControl::initRecursive (Qiang) -CHG: Postback enabled control will always disable default client-side browser action. (Qiang) -CHG: CSS and JS files in a theme are now included in page in alphabetic order (Qiang) -ENH: Ticket#206 - Added OnValidate, OnError, OnSuccess events to validators (Qiang) -ENH: Ticket#230 - Added TDataList.EmptyTemplate property (Qiang) -ENH: Ticket#231 - Added TButton.ButtonType property to allow reset button (Qiang) -ENH: Ticket#232 - Allow <%# %> and <%= %> embedded within property values (Qiang) -ENH: Ticket#256 - Datagrid columns can now be accessed via IDs (Qiang) -ENH: Ticket#257 - OnSelectedIndexChanged event of TDataList and TDataGrid now passes the original command parameter (Qiang) -ENH: Ticket#262 - Added TCheckBox.Value property (Qiang) -ENH: TRepeater, TDataList and TDataGrid will store data indices in DataKeys if DataKeyField is not set. (Qiang) -ENH: Added TPageService.BasePageClass property (Qiang) -ENH: Added TDataGrid.EmptyTemplate property (Qiang) -ENH: Added paging feature to all TDataBoundControl-derived controls (Qiang) -ENH: ClientSide.ObserveChanges="false" to only revalidate client side validator when control changes (Wei) -NEW: Added TPager (Qiang) -NEW: Added Dreamweaver taglib extension (Stanislav, Qiang) -NEW: Prado Command line script to create a new project, see framework/prado-cli.php (Wei) - -Version 3.0.1 June 4, 2006 -========================== -BUG: Ticket#28 - OnClick does not work with Safari/KHTML (Wei) -BUG: Ticket#37 - Changes of config files do not trigger cache update (Qiang) -BUG: Ticket#44 - THtmlArea (tiny_mce) not working on some systems (Qiang) -BUG: Ticket#162 - Missing currency sign in TNumberFormat if Value is 0 (Wei) -BUG: Ticket#167 - TSecurityManager issues warning when trying to encrypt/decrypt strings (Qiang) -BUG: Ticket#169 - Validation of subclass of THtmlArea/TDatePicker fails (Wei) -BUG: Ticket#179 - CGI incompatibility causing clientscripts.php failure (Qiang) -BUG: Ticket#181 - Unable to change Content-Type in response header if charset is not set (Qiang) -BUG: Ticket#200 - onClick javascript event triggered twice on CheckBox label (Qiang) -BUG: newly created controls during postbacks might get their initial states reset during loadStateRecursive. (Qiang) -ENH: Ticket#150 - TDataGrid and TDataList now render table section tags (Qiang) -ENH: Ticket#152 - constituent parts of TWizard are exposed (Qiang) -ENH: Ticket#184 - added TUserManager.Users and Roles properties (Qiang) -ENH: Ticket#197 - sanity check for datagrid header and footer (Qiang) -ENH: added sanity check to calling event handlers (Qiang) -ENH: added search for quickstart tutorials (Wei) -ENH: added support to property tags for template owner control (Qiang) -ENH: added Bulgarian requirement checker messages (StanProg) -ENH: added TTheme.BaseUrl and TTheme.BasePath property (Qiang) -ENH: added TListControl.SelectedValues property (Qiang) -ENH: added TThemeManager.AvailableThemes property (Qiang) -ENH: refactored TUserManager and TAuthManager so that they are easier to be extended (Qiang) -ENH: template syntax now supports setting event handler via subproperties (Qiang) -CHG: Ticket#151 - URL format is modified to handle empty GET values (Qiang) -CHG: Ticket#153 - TAssetManager now ignores .svn directories (Qiang) -CHG: Changed TControl::onBubbleEvent() to TControl::bubbleEvent() (Qiang) -NEW: TTableHeaderRow, TTableFooterRow and table section support (Qiang) -NEW: TCompositeControl (Qiang) -NEW: TTextProcessor (Qiang) -NEW: TMarkdown (Wei) -NEW: Blog demo (Qiang) - -Version 3.0.0 May 1, 2006 -========================= -BUG: Ticket#68 - 2 TButtons with THtmlArea causes second button to fail to function (Wei) -BUG: Ticket#70 - Javascript for TDataTypeValidator added (Wei) -BUG: Ticket#131 - TImageMap and TLinkButton continue to postback even client validator fails (Wei) -BUG: Ticket#135 - TBrowserLogRoute reports wrong timings (Qiang) -BUG: Ticket#137 - The JavasciptLogger does not work (Qiang) -BUG: Ticket#138 - missing file in TDataGrid (Qiang) -BUG: Ticket#139 - TThemeManager::setBasePath() should understand an alias path (Qiang) -BUG: Non-control components can now use expressions in their properties (Qiang) -BUG: TControl.Visible did not make use of overriden getVisible() (Qiang) -BUG: TWizard did not stop navigation upon a validation failure (Qiang) -BUG: NumberFormat will now zero-fill numbers base on the pattern. (Wei) -ENH: TButton, TImageButton and TLinkButton now implement IButtonControl interface (Qiang) -ENH: TResponse::writeFile takes three additional parameters to allow sending memory data (Qiang) -ENH: TButtonColumn can now be a column of image buttons (Qiang) -ENH: TLiteral will display body content if Text is empty (Qiang) -ENH: Format string in classes extending TDataGridColumn can now evaluate an expression (Qiang) -ENH: Format string in classes extending TListControl can now evaluate an expression (Qiang) -ENH: Added THttpResponse::reload() (Qiang) -ENH: Custom visual effects can be added to client-side validators via ClientSide property in validators. (Wei) -ENH: TJavascript::encode() allows raw javascript code when string begins with "javascript:" (Wei) -ENH: Update TinyMCE to 2.0.5.1 -CHG: Rewrote client-side javascript validators, check your client-side validation behaviour (Wei) -CHG: Updated the javascript Prototype library, a few utilties functions REMOVED, may break your existing javascript code. (Wei) -CHG: Build javascript without compression, only comments are removed. (Wei) -CHG: TDatePicker's date can be set using Date property, it value must be in same format as DateFormat, TimeStamp must be set as integer (wei) -CHG: TSimpleDateFormatter::parse() now return an integer or null on parse error (Wei) -CHG: TControl::createControls() is changed to public. (Qiang) -CHG: Template comment tag is changed from to (Qiang) -NEW: TListControlValidator (Wei) -NEW: TClientScript (Wei) - - -Version 3.0RC2 April 16, 2006 -============================= -BUG: Ticket#54 - recursive reverse() definition (Wei) -BUG: Ticket#93 - ValidationGroup not working in TImageMap for js validator (Wei) -BUG: Ticket#97 - Invalid return type value for TSimpleDateFormatter::parse (Wei) -BUG: Ticket#118 - Variables that may not have been initialized (Qiang) -BUG: Ticket#121 - OnClick don't fire with TImageButton and TRequiredFieldValidator (Wei) -BUG: Ticket#129 - TRadioButtonList in TWizard step does not postback correctly (Qiang) -CHG: Moved localize() into PradoBase (Qiang) -CHG: List controls now use array keys as list item values even if the array is integer-indexed (Qiang) -CHG: THttpUtility::htmlEncode and htmlDecode now do not deal with & (Qiang) -CHG: Expressions appeared in a template are evaluated in PreRender stage (Qiang) -CHG: The context of expressions appeared in a template is changed to the template control (Qiang) -ENH: Optimized the representation and evaluation of template expressions (Qiang) -ENH: Added Raw layout to TDataList (Qiang) -ENH: Added TRepeater.DataKeys and TRepeater.DataKeyField (Qiang) - -Version 3.0RC1 April 5, 2006 -============================ -BUG: Ticket#85 - Undefined TDataGrid::setSelectedIndex (Qiang) -BUG: Ticket#87 - Typo in IDbConnection (Qiang) -BUG: Ticket#88 - Unclosed HTML tag in TDatePicker and TColorPicker (Qiang) -BUG: Ticket#89 - TInlineFrame::ScrollBars wrong behaviour expected (Qiang) -BUG: Ticket#95 - Typo in TTemplateControl::registerContentPlaceHolder (Qiang) -BUG: Ticket#103 - Typo in TStyle::setVerticalAlign (Qiang) -BUG: Ticket#107 - ListControls not respect parent disabling (Qiang) -BUG: SF#1432624 - Incorrect documentation about caching expiry (Qiang) -BUG: SF#1446846 - Typo in THead (Qiang) -BUG: THttpSession fails when user storage module is used (Qiang) -CHG: TTextHighlighter.EnableCopyCode defaults to false (Qiang) -CHG: Reorganized quickstart tutorial demo, added new sections (Qiang) -CHG: Reorganized folders under framework (Qiang) -CHG: Modified THtmlArea default toolbar and size. (Qiang) -CHG: Pagers in TDataGrid are now enclosed within panels (Qiang) -ENH: Ticket#92 - Support for user exception message file (Qiang) -ENH: Ticket#106 - Support for validation on THiddenField (Qiang) -ENH: Ticket#110 - Support for TVarDump with syntax highlight (Qiang) -ENH: TDataFieldAccessor can access public class variables (Qiang) -ENH: TPhpErrorException now shows the actual error lines (Qiang) -ENH: Refactored cache classes with support for cache dependency (Qiang) -NEW: TStack component (Qiang) -NEW: TImageMap control (Qiang) -NEW: TWizard control (Qiang) -NEW: TVarDumper and PradoBase::varDump() (Qiang) -NEW: TComponentReflection (Qiang) -NEW: TParameterModule (Qiang) -NEW: TPropelLogRoute (Jason) - -Version 3.0b March 6, 2006 -========================== -BUG: fixed many -CHG: event names must be prefixed with 'On' (Qiang) -CHG: values of properties whose name ends with 'Template' are parsed directly by template parser (Qiang) -ENH: template parser reports exact error location (Qiang) -ENH: cookie HMAC check (Qiang) -NEW: TInlineFrame (Jason) -NEW: TAPCCache (Alban) -NEW: TColorPicker, TDatePicker, TRatingList, TAdodbProvider, TCreoleProvider (Wei) -NEW: TMultiView, TView, TControlAdapter, TWebControlAdapter, TPagedList, TAttributeCollection (Qiang) - -Version 3.0a January 18, 2006 -============================= -Starting, main feaures ready (Qiang) +Version 3.0.3 August 6, 2006 +============================ +BUG: Ticket#264 - Typos in some exception throw statements (Knut) +BUG: Ticket#268 - THttpResponse.redirect() may fail for some browsers (Qiang) +BUG: TDataGrid may complain getting ItemType on a non-object if the grid is not data-bound (Qiang) +NEW: Added TStyleSheet (Wei) + +Version 3.0.2 July 2, 2006 +========================== +BUG: Ticket#182 - List and validator controls cause problem in child classes (Qiang) +BUG: Ticket#191 - Duplicated postbacks occur when using TButton with validators (Qiang) +BUG: Ticket#207 - Validators ClientSide.OnError triggered twice (Wei) +BUG: Ticket#213 - PRADO Requirements Checker charset error (Qiang) +BUG: Ticket#227 - Enabled property doesn't works with THtmlArea (Wei) +BUG: Ticket#234 - Postback target could be out of date (Qiang) +BUG: Ticket#239 - Ondeactivate handler for the first View of MultiView is always fired (Qiang) +BUG: Ticket#244 - redirect() needs absolute URL (Qiang) +BUG: Ticket#245 - getIsSecureConnection() is not working correctly (Qiang) +BUG: Ticket#246 - TDatePicker wrong popup position in scrolled div (Wei) +BUG: Ticket#260 - Wrong value of a configuration option in setUseTransparentSessionID (Qiang) +CHG: ensureChildControls() is now invoked in TControl::initRecursive (Qiang) +CHG: Postback enabled control will always disable default client-side browser action. (Qiang) +CHG: CSS and JS files in a theme are now included in page in alphabetic order (Qiang) +ENH: Ticket#206 - Added OnValidate, OnError, OnSuccess events to validators (Qiang) +ENH: Ticket#230 - Added TDataList.EmptyTemplate property (Qiang) +ENH: Ticket#231 - Added TButton.ButtonType property to allow reset button (Qiang) +ENH: Ticket#232 - Allow <%# %> and <%= %> embedded within property values (Qiang) +ENH: Ticket#256 - Datagrid columns can now be accessed via IDs (Qiang) +ENH: Ticket#257 - OnSelectedIndexChanged event of TDataList and TDataGrid now passes the original command parameter (Qiang) +ENH: Ticket#262 - Added TCheckBox.Value property (Qiang) +ENH: TRepeater, TDataList and TDataGrid will store data indices in DataKeys if DataKeyField is not set. (Qiang) +ENH: Added TPageService.BasePageClass property (Qiang) +ENH: Added TDataGrid.EmptyTemplate property (Qiang) +ENH: Added paging feature to all TDataBoundControl-derived controls (Qiang) +ENH: ClientSide.ObserveChanges="false" to only revalidate client side validator when control changes (Wei) +NEW: Added TPager (Qiang) +NEW: Added Dreamweaver taglib extension (Stanislav, Qiang) +NEW: Prado Command line script to create a new project, see framework/prado-cli.php (Wei) + +Version 3.0.1 June 4, 2006 +========================== +BUG: Ticket#28 - OnClick does not work with Safari/KHTML (Wei) +BUG: Ticket#37 - Changes of config files do not trigger cache update (Qiang) +BUG: Ticket#44 - THtmlArea (tiny_mce) not working on some systems (Qiang) +BUG: Ticket#162 - Missing currency sign in TNumberFormat if Value is 0 (Wei) +BUG: Ticket#167 - TSecurityManager issues warning when trying to encrypt/decrypt strings (Qiang) +BUG: Ticket#169 - Validation of subclass of THtmlArea/TDatePicker fails (Wei) +BUG: Ticket#179 - CGI incompatibility causing clientscripts.php failure (Qiang) +BUG: Ticket#181 - Unable to change Content-Type in response header if charset is not set (Qiang) +BUG: Ticket#200 - onClick javascript event triggered twice on CheckBox label (Qiang) +BUG: newly created controls during postbacks might get their initial states reset during loadStateRecursive. (Qiang) +ENH: Ticket#150 - TDataGrid and TDataList now render table section tags (Qiang) +ENH: Ticket#152 - constituent parts of TWizard are exposed (Qiang) +ENH: Ticket#184 - added TUserManager.Users and Roles properties (Qiang) +ENH: Ticket#197 - sanity check for datagrid header and footer (Qiang) +ENH: added sanity check to calling event handlers (Qiang) +ENH: added search for quickstart tutorials (Wei) +ENH: added support to property tags for template owner control (Qiang) +ENH: added Bulgarian requirement checker messages (StanProg) +ENH: added TTheme.BaseUrl and TTheme.BasePath property (Qiang) +ENH: added TListControl.SelectedValues property (Qiang) +ENH: added TThemeManager.AvailableThemes property (Qiang) +ENH: refactored TUserManager and TAuthManager so that they are easier to be extended (Qiang) +ENH: template syntax now supports setting event handler via subproperties (Qiang) +CHG: Ticket#151 - URL format is modified to handle empty GET values (Qiang) +CHG: Ticket#153 - TAssetManager now ignores .svn directories (Qiang) +CHG: Changed TControl::onBubbleEvent() to TControl::bubbleEvent() (Qiang) +NEW: TTableHeaderRow, TTableFooterRow and table section support (Qiang) +NEW: TCompositeControl (Qiang) +NEW: TTextProcessor (Qiang) +NEW: TMarkdown (Wei) +NEW: Blog demo (Qiang) + +Version 3.0.0 May 1, 2006 +========================= +BUG: Ticket#68 - 2 TButtons with THtmlArea causes second button to fail to function (Wei) +BUG: Ticket#70 - Javascript for TDataTypeValidator added (Wei) +BUG: Ticket#131 - TImageMap and TLinkButton continue to postback even client validator fails (Wei) +BUG: Ticket#135 - TBrowserLogRoute reports wrong timings (Qiang) +BUG: Ticket#137 - The JavasciptLogger does not work (Qiang) +BUG: Ticket#138 - missing file in TDataGrid (Qiang) +BUG: Ticket#139 - TThemeManager::setBasePath() should understand an alias path (Qiang) +BUG: Non-control components can now use expressions in their properties (Qiang) +BUG: TControl.Visible did not make use of overriden getVisible() (Qiang) +BUG: TWizard did not stop navigation upon a validation failure (Qiang) +BUG: NumberFormat will now zero-fill numbers base on the pattern. (Wei) +ENH: TButton, TImageButton and TLinkButton now implement IButtonControl interface (Qiang) +ENH: TResponse::writeFile takes three additional parameters to allow sending memory data (Qiang) +ENH: TButtonColumn can now be a column of image buttons (Qiang) +ENH: TLiteral will display body content if Text is empty (Qiang) +ENH: Format string in classes extending TDataGridColumn can now evaluate an expression (Qiang) +ENH: Format string in classes extending TListControl can now evaluate an expression (Qiang) +ENH: Added THttpResponse::reload() (Qiang) +ENH: Custom visual effects can be added to client-side validators via ClientSide property in validators. (Wei) +ENH: TJavascript::encode() allows raw javascript code when string begins with "javascript:" (Wei) +ENH: Update TinyMCE to 2.0.5.1 +CHG: Rewrote client-side javascript validators, check your client-side validation behaviour (Wei) +CHG: Updated the javascript Prototype library, a few utilties functions REMOVED, may break your existing javascript code. (Wei) +CHG: Build javascript without compression, only comments are removed. (Wei) +CHG: TDatePicker's date can be set using Date property, it value must be in same format as DateFormat, TimeStamp must be set as integer (wei) +CHG: TSimpleDateFormatter::parse() now return an integer or null on parse error (Wei) +CHG: TControl::createControls() is changed to public. (Qiang) +CHG: Template comment tag is changed from to (Qiang) +NEW: TListControlValidator (Wei) +NEW: TClientScript (Wei) + + +Version 3.0RC2 April 16, 2006 +============================= +BUG: Ticket#54 - recursive reverse() definition (Wei) +BUG: Ticket#93 - ValidationGroup not working in TImageMap for js validator (Wei) +BUG: Ticket#97 - Invalid return type value for TSimpleDateFormatter::parse (Wei) +BUG: Ticket#118 - Variables that may not have been initialized (Qiang) +BUG: Ticket#121 - OnClick don't fire with TImageButton and TRequiredFieldValidator (Wei) +BUG: Ticket#129 - TRadioButtonList in TWizard step does not postback correctly (Qiang) +CHG: Moved localize() into PradoBase (Qiang) +CHG: List controls now use array keys as list item values even if the array is integer-indexed (Qiang) +CHG: THttpUtility::htmlEncode and htmlDecode now do not deal with & (Qiang) +CHG: Expressions appeared in a template are evaluated in PreRender stage (Qiang) +CHG: The context of expressions appeared in a template is changed to the template control (Qiang) +ENH: Optimized the representation and evaluation of template expressions (Qiang) +ENH: Added Raw layout to TDataList (Qiang) +ENH: Added TRepeater.DataKeys and TRepeater.DataKeyField (Qiang) + +Version 3.0RC1 April 5, 2006 +============================ +BUG: Ticket#85 - Undefined TDataGrid::setSelectedIndex (Qiang) +BUG: Ticket#87 - Typo in IDbConnection (Qiang) +BUG: Ticket#88 - Unclosed HTML tag in TDatePicker and TColorPicker (Qiang) +BUG: Ticket#89 - TInlineFrame::ScrollBars wrong behaviour expected (Qiang) +BUG: Ticket#95 - Typo in TTemplateControl::registerContentPlaceHolder (Qiang) +BUG: Ticket#103 - Typo in TStyle::setVerticalAlign (Qiang) +BUG: Ticket#107 - ListControls not respect parent disabling (Qiang) +BUG: SF#1432624 - Incorrect documentation about caching expiry (Qiang) +BUG: SF#1446846 - Typo in THead (Qiang) +BUG: THttpSession fails when user storage module is used (Qiang) +CHG: TTextHighlighter.EnableCopyCode defaults to false (Qiang) +CHG: Reorganized quickstart tutorial demo, added new sections (Qiang) +CHG: Reorganized folders under framework (Qiang) +CHG: Modified THtmlArea default toolbar and size. (Qiang) +CHG: Pagers in TDataGrid are now enclosed within panels (Qiang) +ENH: Ticket#92 - Support for user exception message file (Qiang) +ENH: Ticket#106 - Support for validation on THiddenField (Qiang) +ENH: Ticket#110 - Support for TVarDump with syntax highlight (Qiang) +ENH: TDataFieldAccessor can access public class variables (Qiang) +ENH: TPhpErrorException now shows the actual error lines (Qiang) +ENH: Refactored cache classes with support for cache dependency (Qiang) +NEW: TStack component (Qiang) +NEW: TImageMap control (Qiang) +NEW: TWizard control (Qiang) +NEW: TVarDumper and PradoBase::varDump() (Qiang) +NEW: TComponentReflection (Qiang) +NEW: TParameterModule (Qiang) +NEW: TPropelLogRoute (Jason) + +Version 3.0b March 6, 2006 +========================== +BUG: fixed many +CHG: event names must be prefixed with 'On' (Qiang) +CHG: values of properties whose name ends with 'Template' are parsed directly by template parser (Qiang) +ENH: template parser reports exact error location (Qiang) +ENH: cookie HMAC check (Qiang) +NEW: TInlineFrame (Jason) +NEW: TAPCCache (Alban) +NEW: TColorPicker, TDatePicker, TRatingList, TAdodbProvider, TCreoleProvider (Wei) +NEW: TMultiView, TView, TControlAdapter, TWebControlAdapter, TPagedList, TAttributeCollection (Qiang) + +Version 3.0a January 18, 2006 +============================= +Starting, main feaures ready (Qiang) diff --git a/buildscripts/texbuilder/pages.php b/buildscripts/texbuilder/pages.php index f49d15fd..9b8a97ad 100644 --- a/buildscripts/texbuilder/pages.php +++ b/buildscripts/texbuilder/pages.php @@ -33,6 +33,7 @@ $pages['Configurations'] = array( $pages['Control Reference : Standard Controls'] = array( 'Controls/Button.page', 'Controls/CheckBox.page', + 'Controls/ClientScript.page', 'Controls/ColorPicker.page', 'Controls/DatePicker.page', 'Controls/Expression.page', diff --git a/demos/quickstart/protected/pages/Advanced/Scripts3.page b/demos/quickstart/protected/pages/Advanced/Scripts3.page index 9883f43e..123caa3a 100644 --- a/demos/quickstart/protected/pages/Advanced/Scripts3.page +++ b/demos/quickstart/protected/pages/Advanced/Scripts3.page @@ -29,4 +29,7 @@ that require a particular library will also automatically load the necessary lib For example, if you add a TDatePicker component on the page, the datapicker and its dependencies will be automatically included on the page.

+

See TClientScript for options of adding + your custom javascript code to the page.

+ \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/ClientScript.page b/demos/quickstart/protected/pages/Controls/ClientScript.page new file mode 100644 index 00000000..5dab41d5 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/ClientScript.page @@ -0,0 +1,52 @@ + + +

TClientScript

+ +

Including Bundled Javascript Libraries in Prado

+

+TClientScript allows javascript code to be insert or linked to the +page template. Prado is bundled with a large library of javascript functionality +including effects, AJAX, basic event handlers, and many others. The bundled +javascript libraries can be linked to the current page template using the +UsingPradoScripts property. Multiple bundled javascript libraries +can be specified using comma delimited string of the name of javascript library +to include on the page. For following example will include the "ajax" and "effects" library. +

+ +<com:TClientScript UsingPradoScripts="ajax, effects" /> + + +

+ The available bundled libraries included in Prado are +

+

+

The dependencies for each library are automatically resolved. That is, + specifying, say the "ajax", will also include the "prado" library.

+ +

Including Custom Javascript Files

+

Custom javascript files can be register using the ScriptUrl property. +The following example includes the javascript file "test.js" to the page. In this case, the file +"test.js" is relative the current template you are using. Since the property value is +dynamic asset tag, the file "test.js" will be published +automatically, that is, the file will be copied to the assets directory if necessary. +

+ +<com:TClientScript ScriptUrl=<%~ test.js %> /> + +

You can include javascript files from other servers by specifying the full URL string in + the ScriptUrl property.

+ +

Including Custom Javascript Code Blocks

+

Any content within the TClientScript control tag will be considered as + javascript code and will be rendered where it is declared.

+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Standard.page b/demos/quickstart/protected/pages/Controls/Standard.page index 156b39e5..086ba293 100644 --- a/demos/quickstart/protected/pages/Controls/Standard.page +++ b/demos/quickstart/protected/pages/Controls/Standard.page @@ -11,6 +11,10 @@ TCheckBox represents a checkbox on a Web page. It can be used to collect two-state user input. +
  • + TClientScript adds javascript code to the page. +
  • +
  • * TColorPicker represents an input field taking color values via a color dialog.
  • diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php index b2fbf925..abc23c45 100644 --- a/framework/Web/UI/WebControls/TClientScript.php +++ b/framework/Web/UI/WebControls/TClientScript.php @@ -22,11 +22,6 @@ * * * - * The {@link setPreRenderControlTypes PreRenderControlTypes} property can - * be used to specify that controls type/class names that should pre-render itself - * even though they may not be rendered on the page. This is useful to publish - * controls that require assets and is only visible after a callback response. - * * Custom javascript files can be register using the {@link setScriptUrl ScriptUrl} * property. * @@ -34,18 +29,13 @@ * * * Contents within TClientScript will be treated as javascript code and will be - * rendered. - * - * The {@link setScriptPosition ScriptPosition} property specifies where the script - * will be rendered. The allows values of {@link setScriptPosition ScriptPosition} are + * rendered in place. * - * - Head -- renders the script within the <head> - * - Begin -- renders the script within and near the begining of TForm - * - Here -- renders the script inplace, this is the default - * - End -- renders the script within and near the end of TForm + * The {@link setPreRenderControlTypes PreRenderControlTypes} property can + * be used to specify that controls type/class names that should pre-render itself + * even though they may not be rendered on the page. This is useful to publish + * controls that require assets and is only visible after a callback response. * - * TODO: Allow binding expressions inside scripts - * * @author Wei Zhuo * @version $Revision: $ $Date: $ * @package System.Web.UI.WebControls @@ -53,11 +43,6 @@ */ class TClientScript extends TControl { - /** - * @var string body contents - */ - private $_content = ''; - /** * @return string comma delimited list of javascript libraries to included * on the page. @@ -112,26 +97,7 @@ class TClientScript extends TControl { return $this->getViewState('PreRenderControls', ''); } - - /** - * @return string position the script should be rendered, default is 'Here'. - */ - public function getScriptPosition() - { - return $this->getViewState('ScriptPosition', 'Here'); - } - - /** - * Sets the position where the script will be rendered. - * The allow positions are 'Head', 'Begin', 'Here', and 'End', default is 'Here'. - * @param string script position 'Head', 'Begin', 'Here' or 'End'. - */ - public function setScriptPosition($value) - { - $this->setViewState('ScriptPosition', - TPropertyValue::ensureEnum($value, 'Head', 'Begin', 'Here', 'End'), 'Here'); - } - + /** * Calls the client script manager to add each of the requested client * script libraries. @@ -148,42 +114,9 @@ class TClientScript extends TControl if(strlen($script) > 0) $cs->registerPradoScript($script); } - if($this->getEnabled(true)) - { - $this->registerCustomScriptFile(); - $this->registerCustomScript(); - } $this->preRenderControls($param); } - - /** - * Registers the custom script file. - */ - protected function registerCustomScriptFile() - { - $scriptUrl = $this->getScriptUrl(); - if(strlen($scriptUrl)) - { - $position = $this->getScriptPosition(); - $cs = $this->getPage()->getClientScript(); - switch($this->getScriptPosition()) - { - case 'Head': - $cs->registerHeadScriptFile($scriptUrl, $scriptUrl); - break; - case 'Begin': - $cs->registerScriptFile($scriptUrl, $scriptUrl); - break; - case 'Here': - $this->_content .= TJavascript::renderScriptFile($scriptUrl); - break; - default : - throw new TConfigurationException('clientscript_invalid_file_position', - $this->getID(), $position); - } - } - } - + /** * Renders the body content as javascript block. * Overrides parent implementation, parent renderChildren method is called during @@ -192,31 +125,32 @@ class TClientScript extends TControl */ public function render($writer) { - if($this->getEnabled(true) && strlen($this->_content) > 0) - $writer->write($this->_content); + $this->renderCustomScriptFile($writer); + $this->renderCustomScript($writer); } /** - * Registers the body content as scripts at specific locations. Calls - * {@link parent::renderChildren} to capture the body contents. + * Renders the custom script file. + * @param THtmLWriter the renderer + */ + protected function renderCustomScriptFile($writer) + { + $scriptUrl = $this->getScriptUrl(); + if(strlen($scriptUrl) > 0) + $writer->write("\n"); + } + + /** + * Registers the body content as javascript. + * @param THtmlWriter the renderer */ - protected function registerCustomScript() + protected function renderCustomScript($writer) { - $textWriter=new TTextWriter; - $this->renderChildren(new THtmlWriter($textWriter)); - $script=$textWriter->flush(); - if(strlen($script)>0) + if($this->getHasControls()) { - $cs = $this->getPage()->getClientScript(); - $position = $this->getScriptPosition(); - if($position == 'Here') - $this->_content .= TJavaScript::renderScriptBlock($script); - else - { - $key = sprintf('%08X', crc32($script)); - $method = 'register'.$position.'Script'; - $cs->{$method}($key, $script); - } + $writer->write("\n"); } } diff --git a/framework/Web/UI/WebControls/TStyleSheet.php b/framework/Web/UI/WebControls/TStyleSheet.php index 02ac40cd..5925645c 100644 --- a/framework/Web/UI/WebControls/TStyleSheet.php +++ b/framework/Web/UI/WebControls/TStyleSheet.php @@ -52,11 +52,8 @@ class TStyleSheet extends TControl */ public function onPreRender($param) { - if($this->getEnabled(true)) - { - if(($url=$this->getStyleSheetUrl())!=='') - $this->getPage()->getClientScript()->registerStyleSheetFile($url,$url); - } + if(($url=$this->getStyleSheetUrl())!=='') + $this->getPage()->getClientScript()->registerStyleSheetFile($url,$url); } /** diff --git a/tests/FunctionalTests/features/protected/pages/ClientScripTest.page b/tests/FunctionalTests/features/protected/pages/ClientScripTest.page index 8dbf7133..d5b6e182 100644 --- a/tests/FunctionalTests/features/protected/pages/ClientScripTest.page +++ b/tests/FunctionalTests/features/protected/pages/ClientScripTest.page @@ -1,13 +1,13 @@

    ClientScript Test

    - ScriptPosition="Head"> + > if(typeof(ClientScriptInfo) == "undefined") ClientScriptInfo = []; ClientScriptInfo.push("ok 3?") - + if(typeof(ClientScriptInfo) == "undefined") ClientScriptInfo = []; ClientScriptInfo.push("ok 2!") @@ -16,12 +16,12 @@ - + Event.observe("button1", "click", function() { element = $("<%= $this->label1->ClientID %>"); if(element) - element.innerHTML = inspect(ClientScriptInfo); + element.innerHTML = "Label 1: "+inspect(ClientScriptInfo); else alert("failed"); }); -- cgit v1.2.3