From 39446f979b52dd0acd75d5d243f352397a0410f6 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 7 Apr 2007 10:35:16 +0000 Subject: add TClientScriptLoader quickstart docs. --- .../protected/controls/RequiresVersion.php | 16 +++ .../protected/controls/RequiresVersion.tpl | 1 + .../quickstart/protected/controls/SinceVersion.php | 16 +++ .../quickstart/protected/controls/SinceVersion.tpl | 1 + .../protected/pages/Advanced/Scripts3.page | 64 ++++++++++- .../protected/pages/Controls/ClientScript.page | 9 +- .../pages/Controls/ClientScriptLoader.page | 123 +++++++++++++++++++++ .../protected/pages/Controls/Standard.page | 4 + .../protected/pages/Database/ActiveRecord.page | 1 + demos/quickstart/protected/pages/Database/DAO.page | 1 + .../protected/pages/Database/Scaffold.page | 1 + .../protected/pages/Database/SqlMap.page | 1 + .../protected/pages/Tutorial/AjaxChat.page | 1 + .../pages/Tutorial/CurrencyConverter.page | 3 + demos/quickstart/themes/PradoSoft/flag_red.gif | Bin 0 -> 591 bytes .../quickstart/themes/PradoSoft/sitemap_color.gif | Bin 0 -> 336 bytes demos/quickstart/themes/PradoSoft/style.css | 17 +++ 17 files changed, 253 insertions(+), 6 deletions(-) create mode 100644 demos/quickstart/protected/controls/RequiresVersion.php create mode 100644 demos/quickstart/protected/controls/RequiresVersion.tpl create mode 100644 demos/quickstart/protected/controls/SinceVersion.php create mode 100644 demos/quickstart/protected/controls/SinceVersion.tpl create mode 100644 demos/quickstart/protected/pages/Controls/ClientScriptLoader.page create mode 100644 demos/quickstart/themes/PradoSoft/flag_red.gif create mode 100644 demos/quickstart/themes/PradoSoft/sitemap_color.gif (limited to 'demos/quickstart') diff --git a/demos/quickstart/protected/controls/RequiresVersion.php b/demos/quickstart/protected/controls/RequiresVersion.php new file mode 100644 index 00000000..9e598d3a --- /dev/null +++ b/demos/quickstart/protected/controls/RequiresVersion.php @@ -0,0 +1,16 @@ +setViewState('Version',$value); + } + + public function getVersion() + { + return $this->getViewState('Version'); + } +} + +?> \ No newline at end of file diff --git a/demos/quickstart/protected/controls/RequiresVersion.tpl b/demos/quickstart/protected/controls/RequiresVersion.tpl new file mode 100644 index 00000000..be58f8a8 --- /dev/null +++ b/demos/quickstart/protected/controls/RequiresVersion.tpl @@ -0,0 +1 @@ +
Requires Prado versions <%= $this->Version %> or later.
\ No newline at end of file diff --git a/demos/quickstart/protected/controls/SinceVersion.php b/demos/quickstart/protected/controls/SinceVersion.php new file mode 100644 index 00000000..cfeeffbb --- /dev/null +++ b/demos/quickstart/protected/controls/SinceVersion.php @@ -0,0 +1,16 @@ +setViewState('Version',$value); + } + + public function getVersion() + { + return $this->getViewState('Version'); + } +} + +?> \ No newline at end of file diff --git a/demos/quickstart/protected/controls/SinceVersion.tpl b/demos/quickstart/protected/controls/SinceVersion.tpl new file mode 100644 index 00000000..6f2aed76 --- /dev/null +++ b/demos/quickstart/protected/controls/SinceVersion.tpl @@ -0,0 +1 @@ +Available from Prado versions <%= $this->Version %> onwards.
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Advanced/Scripts3.page b/demos/quickstart/protected/pages/Advanced/Scripts3.page index d535d170..86e8bab9 100644 --- a/demos/quickstart/protected/pages/Advanced/Scripts3.page +++ b/demos/quickstart/protected/pages/Advanced/Scripts3.page @@ -1,9 +1,14 @@The javascript libraries distributed with Prado can be found in the +framework/Web/Javascripts/source directory. The packages.php +file in that directory defines a list of available package names available +to be loaded. They can be loaded as follows. +
The dependencies for each library are automatically resolved. Components that require a particular library will also automatically load the necessary libraries. -For example, if you add a TDatePicker component on the page, the datepicker +For example, if you add a TDatePicker component on the page, the datepicker and its dependencies will be automatically included on the page.
See TClientScript for options of adding your custom Javascript code to the page.
+Use TClientScriptLoader to publish and combine multiple existing javascript files (e.g. javascript libraries distributed with Prado or otherwise) +as packages.
For greater control on what and when to publish, use the +registerJavascriptPackages($base, $packages, $debug=null, $gzip=true) +method in the TClientScriptManager class, which an instance can be obtained +using $this->getPage()->getClientScript() or its equivalents. +For example, if multiple controls will use the same set of javascript libraries, +write a class to handle the registration of packages required by those controls. + +The dependencies for each library are automatically resolved. That is, +
+Many of the libraries, such as validator and datepicker will automatically +when controls that uses these libraries are visible on the page. For example, all the +validators +if they have their EnableClientScript set to true will include both the prado +and validator javascript libraries. +The dependencies for each library are automatically resolved. That is, specifying, say the "ajax", will also include the "prado" library.
+The TClientScriptLoader publish a collection of javascript files as assets. +For example, suppose we have a directory name "mylib" in +the protected/pages directory of our application.
+The PackagePath property can be an existing asset directory +or a namespace path to the directory containing javascript files. +For example, to publish the javascript files in the mylib +directory, we can specify the PackagePath as follows. +The first tag TClientScriptLoader relies on the asset template tag and +assumes that the page template containing the TClientScriptLoader tag instance +is in the protected/pages directory. +The second TClientScriptLoader tag uses the namespace notation to +specify the path. +
+ ++When the files in the PackagePath are published as assets, a script loader + php file "clientscripts.php" is automatically 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 grouped by using a "packages.php" file +with the following format. This "packages.php" is optional, if absent the file names +without ".js" extension are used. The "packages.php" must be in the directory given by +PackagePath. +
+ +The first element of the array returned by the packages.php should +contain an array of javascripts files relative to the packages.php +that corresponds to a particular grouping. For example, in the above packages.php, +the grouping 'package1' combines two javascript files, namely, 'file1.js' +and 'file2.js'. +
+ +The second element of the array returned by the packages.php should +contain an array of grouping dependencies ordered in the way that the groups should be combined. +For example, grouping 'package1' only depends on the 'package1' grouping files +(i.e. 'file1.js' and 'file2.js'). While 'package2' depends +on both 'package1' and 'package2' groupings. That is, 'package2' +will combine, in order, 'file1.js', 'file2.js', 'file3.js', and 'file4.js'. +
+ +To load a particular javascript file or package, set the PackageScripts +property with value 'package1' to load the 'package1' scripts. +A maximum of 25 packages separated by commas is allowed. +Dependencies of the packages are automatically resolved by the script loader php file. +
+ +Each <com:TClientScriptLoader> generates an HTML <script> +element to load the required javascript files.
+ +The DebugMode property when false +removes comments and white spaces 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. +
+Active Records are objects that wrap a row in a database table or view,
encapsulates the database access and adds domain logic on that data.
The basics of an Active Record is a business object class, e.g., a
diff --git a/demos/quickstart/protected/pages/Database/DAO.page b/demos/quickstart/protected/pages/Database/DAO.page
index ab522090..f7b969a2 100644
--- a/demos/quickstart/protected/pages/Database/DAO.page
+++ b/demos/quickstart/protected/pages/Database/DAO.page
@@ -1,6 +1,7 @@
Data Access Objects (DAO) separates a data resource's client interface from its data access mechanisms. It adapts a specific data resource's access API to a generic client interface. As a result, data access mechanisms can be changed independently of the code that uses the data.
Active Record classes can be used together with
Data Mappers moves data between objects and a database while keeping them
independent of each other and the mapper itself. If you started with
Active Records, you may eventually
diff --git a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
index 4e40b33a..b4784116 100644
--- a/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
+++ b/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
@@ -1,5 +1,6 @@
This tutorial introduces the Prado web application framework's
ActiveRecord
and Active Controls to build a Chat
diff --git a/demos/quickstart/protected/pages/Tutorial/CurrencyConverter.page b/demos/quickstart/protected/pages/Tutorial/CurrencyConverter.page
index 7f552ae1..43e3bfe5 100644
--- a/demos/quickstart/protected/pages/Tutorial/CurrencyConverter.page
+++ b/demos/quickstart/protected/pages/Tutorial/CurrencyConverter.page
@@ -298,6 +298,9 @@ public function convert_clicked($sender, $param)
In this simple application we may further improve the user experience
by increasing the responsiveness of the application. One way to achieve
a faster response is calculate and present the results without reloading
diff --git a/demos/quickstart/themes/PradoSoft/flag_red.gif b/demos/quickstart/themes/PradoSoft/flag_red.gif
new file mode 100644
index 00000000..5020ebc8
Binary files /dev/null and b/demos/quickstart/themes/PradoSoft/flag_red.gif differ
diff --git a/demos/quickstart/themes/PradoSoft/sitemap_color.gif b/demos/quickstart/themes/PradoSoft/sitemap_color.gif
new file mode 100644
index 00000000..256a4b9f
Binary files /dev/null and b/demos/quickstart/themes/PradoSoft/sitemap_color.gif differ
diff --git a/demos/quickstart/themes/PradoSoft/style.css b/demos/quickstart/themes/PradoSoft/style.css
index ddfc7622..468d1386 100644
--- a/demos/quickstart/themes/PradoSoft/style.css
+++ b/demos/quickstart/themes/PradoSoft/style.css
@@ -657,4 +657,21 @@ div.last-modified
{
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
+}
+
+p.since-version, p.requires-version
+{
+ border: 1px solid #ccf;
+ padding: 0.8em 0.8em 0.8em 35px;
+ background-repeat: no-repeat;
+ background-position: 10px 50%;
+ background-image: url(sitemap_color.gif);
+ background-color: #efe;
+}
+
+p.requires-version
+{
+ background-image: url(flag_red.gif);
+ border-color: pink;
+ background-color: #ffe9e9;
}
\ No newline at end of file
--
cgit v1.2.3
Data Access Objects (DAO)
+Active Record Scaffold Views
+Data Mapper
+Building an AJAX Chat Application
+ Improve User Experience With Active Controls
+
+