|
|
@@ -1,4 +1,5 @@
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<!-- Reviewed: no -->
|
|
|
<sect1 id="zend.dojo.build-layers">
|
|
|
<title>Zend_Dojo build layer support</title>
|
|
|
|
|
|
@@ -12,7 +13,7 @@
|
|
|
layer takes all Dojo dependencies and compiles them to a single
|
|
|
file, optionally stripping whitespace and comments, and performing
|
|
|
code heuristics to allow further minification of variable names.
|
|
|
- Additionally, it can do CSS minification.
|
|
|
+ Additionally, it can do <acronym>CSS</acronym> minification.
|
|
|
</para>
|
|
|
|
|
|
<para>
|
|
|
@@ -22,7 +23,7 @@
|
|
|
when the script is loaded. As an example:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="javascript"><![CDATA[
|
|
|
+ <programlisting language="javascript"><![CDATA[
|
|
|
dojo.provide("custom.main");
|
|
|
|
|
|
dojo.require("dijit.layout.TabContainer");
|
|
|
@@ -41,7 +42,7 @@ dojo.require("dijit.form.TextBox");
|
|
|
module:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="html"><![CDATA[
|
|
|
+ <programlisting language="html"><![CDATA[
|
|
|
<html>
|
|
|
<head>
|
|
|
<script type="text/javascript" src="/js/dojo/dojo.js"></script>
|
|
|
@@ -56,9 +57,9 @@ dojo.require("dijit.form.TextBox");
|
|
|
following:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$view->dojo()->registerModulePath('custom', '../custom/')
|
|
|
- ->requireModule('custom.main');
|
|
|
+ ->requireModule('custom.main');
|
|
|
]]></programlisting>
|
|
|
|
|
|
<para>
|
|
|
@@ -95,7 +96,7 @@ $view->dojo()->registerModulePath('custom', '../custom/')
|
|
|
<filename>public/js/</filename>, you could do the following:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build = new Zend_Dojo_BuildLayer(array(
|
|
|
'view' => $view,
|
|
|
'layerName' => 'custom.main',
|
|
|
@@ -112,12 +113,12 @@ file_put_contents($filename, $layerContents);
|
|
|
<para>
|
|
|
When should you do the above? For it to work correctly, you need to
|
|
|
do it after all view scripts and the layout have been rendered, to
|
|
|
- ensure that the <code>dojo()</code> helper is fully populated. One
|
|
|
+ ensure that the <methodname>dojo()</methodname> helper is fully populated. One
|
|
|
easy way to do so is using a front controller plugin, with a
|
|
|
- <code>dispatchLoopShutdown()</code> hook:
|
|
|
+ <methodname>dispatchLoopShutdown()</methodname> hook:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
class App_Plugin_DojoLayer extends Zend_Controller_Plugin_Abstract
|
|
|
{
|
|
|
public $layerScript = APPLICATION_PATH . '/../public/js/custom/main.js';
|
|
|
@@ -183,7 +184,7 @@ class App_Plugin_DojoLayer extends Zend_Controller_Plugin_Abstract
|
|
|
<methodname>setView()</methodname> method:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build->setView($view);
|
|
|
]]></programlisting>
|
|
|
</sect4>
|
|
|
@@ -197,7 +198,7 @@ $build->setView($view);
|
|
|
<methodname>setLayerName()</methodname> method:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build->setLayerName("custom.main");
|
|
|
]]></programlisting>
|
|
|
</sect4>
|
|
|
@@ -207,8 +208,8 @@ $build->setLayerName("custom.main");
|
|
|
|
|
|
<para>
|
|
|
<code>dojo.addOnLoad</code> is a useful utility for
|
|
|
- specifying actions that should trigger when the DOM has
|
|
|
- finished loading. The <code>dojo()</code> view helper can
|
|
|
+ specifying actions that should trigger when the <acronym>DOM</acronym> has
|
|
|
+ finished loading. The <methodname>dojo()</methodname> view helper can
|
|
|
create these statements via its
|
|
|
<methodname>addOnLoad()</methodname> and
|
|
|
<methodname>onLoadCapture*()</methodname> methods. In some
|
|
|
@@ -218,11 +219,11 @@ $build->setLayerName("custom.main");
|
|
|
|
|
|
<para>
|
|
|
By default, these are not rendered; to enable them, pass the
|
|
|
- <code>consumeOnLoad</code> configuration key during
|
|
|
+ <property>consumeOnLoad</property> configuration key during
|
|
|
instantiation:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build = new Zend_Dojo_BuildLayer(array(
|
|
|
'view' => $view,
|
|
|
'layerName' => 'custom.main',
|
|
|
@@ -236,7 +237,7 @@ $build = new Zend_Dojo_BuildLayer(array(
|
|
|
instantiation:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build->setConsumeOnLoad(true);
|
|
|
]]></programlisting>
|
|
|
</sect4>
|
|
|
@@ -245,7 +246,7 @@ $build->setConsumeOnLoad(true);
|
|
|
<title>Including captured JavaScript in the generated layer</title>
|
|
|
|
|
|
<para>
|
|
|
- The <code>dojo()</code> view helper includes methods for
|
|
|
+ The <methodname>dojo()</methodname> view helper includes methods for
|
|
|
capturing arbitrary JavaScript to include in the
|
|
|
<script> tag containing the various
|
|
|
<code>dojo.require</code> and <code>dojo.addOnLoad</code>
|
|
|
@@ -256,11 +257,11 @@ $build->setConsumeOnLoad(true);
|
|
|
|
|
|
<para>
|
|
|
By default, these are not rendered; to enable them, pass the
|
|
|
- <code>consumeJavascript</code> configuration key during
|
|
|
+ <property>consumeJavascript</property> configuration key during
|
|
|
instantiation:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build = new Zend_Dojo_BuildLayer(array(
|
|
|
'view' => $view,
|
|
|
'layerName' => 'custom.main',
|
|
|
@@ -274,7 +275,7 @@ $build = new Zend_Dojo_BuildLayer(array(
|
|
|
instantiation:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build->setConsumeJavascript(true);
|
|
|
]]></programlisting>
|
|
|
</sect4>
|
|
|
@@ -297,7 +298,7 @@ $build->setConsumeJavascript(true);
|
|
|
output to a file:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
$build = new Zend_Dojo_BuildLayer(array(
|
|
|
'view' => $view,
|
|
|
'layerName' => 'custom.main',
|
|
|
@@ -315,11 +316,13 @@ file_put_contents($filename, $profile);
|
|
|
as follows:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
class App_Plugin_DojoLayer extends Zend_Controller_Plugin_Abstract
|
|
|
{
|
|
|
- public $layerScript = APPLICATION_PATH . '/../public/js/custom/main.js';
|
|
|
- public $buildProfile = APPLICATION_PATH . '/../misc/scripts/custom.profile.js';
|
|
|
+ public $layerScript = APPLICATION_PATH
|
|
|
+ . '/../public/js/custom/main.js';
|
|
|
+ public $buildProfile = APPLICATION_PATH
|
|
|
+ . '/../misc/scripts/custom.profile.js';
|
|
|
protected $_build;
|
|
|
|
|
|
public function dispatchLoopShutdown()
|
|
|
@@ -359,7 +362,7 @@ class App_Plugin_DojoLayer extends Zend_Controller_Plugin_Abstract
|
|
|
<para>
|
|
|
As an example, you may want to specify what type of
|
|
|
optimizations should be performed, whether or not to optimize
|
|
|
- CSS files in the layer, whether or not to copy tests into the
|
|
|
+ <acronym>CSS</acronym> files in the layer, whether or not to copy tests into the
|
|
|
build, etc. For a listing of available options, you should read
|
|
|
the <ulink url="http://docs.dojocampus.org/build/index">Dojo
|
|
|
Build documentation</ulink> and <ulink
|
|
|
@@ -372,16 +375,16 @@ class App_Plugin_DojoLayer extends Zend_Controller_Plugin_Abstract
|
|
|
<methodname>addProfileOption()</methodname>,
|
|
|
<methodname>addProfileOptions()</methodname>, or
|
|
|
<methodname>setProfileOptions()</methodname> methods. The first
|
|
|
- method adds a single key/value option pair, the second will add
|
|
|
+ method adds a single key and value option pair, the second will add
|
|
|
several, and the third will overwrite any options with the list
|
|
|
- of key/value pairs provided.
|
|
|
+ of key and value pairs provided.
|
|
|
</para>
|
|
|
|
|
|
<para>
|
|
|
By default, the following options are set:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="javascript"><![CDATA[
|
|
|
+ <programlisting language="javascript"><![CDATA[
|
|
|
{
|
|
|
action: "release",
|
|
|
optimize: "shrinksafe",
|
|
|
@@ -393,7 +396,7 @@ class App_Plugin_DojoLayer extends Zend_Controller_Plugin_Abstract
|
|
|
]]></programlisting>
|
|
|
|
|
|
<para>
|
|
|
- You can pass in whatever key/value pairs you want; the Dojo
|
|
|
+ You can pass in whatever key and value pairs you want; the Dojo
|
|
|
build script will ignore those it does not understand.
|
|
|
</para>
|
|
|
|
|
|
@@ -401,7 +404,7 @@ class App_Plugin_DojoLayer extends Zend_Controller_Plugin_Abstract
|
|
|
As an example of setting options:
|
|
|
</para>
|
|
|
|
|
|
- <programlisting role="php"><![CDATA[
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
// A single option:
|
|
|
$build->addProfileOption('version', 'zend-1.3.1');
|
|
|
|