Skip to content
Browse files

Generate topic HTML files from current topic markup.

  • Loading branch information...
1 parent c480ad5 commit 86d5c0489143eb64781063603a13033b276dab46 @joshthecoder joshthecoder committed
View
1 .gitignore
@@ -1,2 +1 @@
dist
-Resources/topics
View
47 Resources/topics/analytics.html
@@ -0,0 +1,47 @@
+<h1>Analytics</h1>
+<h2 id="introduction">Introduction</h2>
+<p>Titanium allows you to fire five different types of analytics events
+to our cloud services. The results from these events can be viewed
+through our optional Analytics product (coming soon!).</p>
+<h2 id="user">User</h2>
+<p>User events allow you to generate simple analytics events that just
+require an event name. You can also pass in a JSON-based data object
+to attach to this event.</p>
+<div class="codehilite"><pre><span class="c1">// Fire a user event and pass along a little extra information.</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">Analytics</span><span class="p">.</span><span class="nx">userEvent</span><span class="p">(</span><span class="s1">&#39;my_event&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;login&#39;</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
+</pre></div>
+
+
+<h2 id="navigation">Navigation</h2>
+<p>Navigation Events allow you to track transitions from one part of
+your app to another. You can pass in the from location, the to location,
+the navigation event name, and an optional JSON data object.",</p>
+<div class="codehilite"><pre><span class="c1">// Pass in from location, to location, event name and a JSON data object</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">Analytics</span><span class="p">.</span><span class="nx">navEvent</span><span class="p">(</span><span class="s1">&#39;home&#39;</span><span class="p">,</span> <span class="s1">&#39;edit_account&#39;</span><span class="p">,</span> <span class="s1">&#39;view_account&#39;</span><span class="p">,</span>
+ <span class="p">{</span><span class="s1">&#39;account_id&#39;</span><span class="o">:</span><span class="mi">123</span><span class="p">});</span>
+</pre></div>
+
+
+<h2 id="settings">Settings</h2>
+<p>Settings Events allow you track a specific setting or configuration
+in your application. You can pass in the settings event name and an
+optional JSON data object</p>
+<div class="codehilite"><pre><span class="c1">// pass in a setting name and a JSON data object</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">Analytics</span><span class="p">.</span><span class="nx">settingsEvent</span><span class="p">(</span><span class="s1">&#39;volume&#39;</span><span class="p">,</span> <span class="p">{</span><span class="s1">&#39;value&#39;</span><span class="o">:</span><span class="mi">5</span><span class="p">});</span>
+</pre></div>
+
+
+<h2 id="timed">Timed</h2>
+<p>Timed Events allow you track how long an specific activity or task takes
+to complete in your application. You can pass in the timed event name,
+start time, stop time, duration, and an optional JSON data object. The
+start time and end time values should be in miliseconds via the JavaScript
+Date object.</p>
+<div class="codehilite"><pre><span class="c1">// pass in a timed event name and a JSON data object</span>
+<span class="kd">var</span> <span class="nx">startTime</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">();</span>
+
+<span class="c1">// Do some task like register for service and then do....</span>
+<span class="kd">var</span> <span class="nx">endTime</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">();</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">Analytics</span><span class="p">.</span><span class="nx">timedEvent</span><span class="p">(</span><span class="s1">&#39;register&#39;</span><span class="p">,</span> <span class="nx">startTime</span><span class="p">,</span> <span class="nx">endTime</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span>
+ <span class="p">{</span><span class="s1">&#39;email&#39;</span><span class="o">:</span><span class="s1">&#39;bob@aol.com&#39;</span><span class="p">});</span>
+</pre></div>
View
112 Resources/topics/application.html
@@ -0,0 +1,112 @@
+<h1>Application</h1>
+<h2 id="useful_methods">Useful methods</h2>
+<p>The API module also contains information about the currently-running Titanium
+application, which may be retrieved via <tt>Titanium.API.getApplication</tt>.
+The <tt>Application</tt> object that is returned by this method has a multitude of
+<a href="href=" title="http://developer.appcelerator.com/apidoc/desktop/1.0/Titanium.API.Application.html">useful properties</a>.</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">app</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">application</span><span class="p">;</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">app</span><span class="p">.</span><span class="nx">getDataPath</span><span class="p">());</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">app</span><span class="p">.</span><span class="nx">getGUid</span><span class="p">());</span>
+</pre></div>
+
+
+<p>The App module also contains some very useful API points for dealing
+with the currently-running application. In particular you may wan to
+convert an <tt>app://</tt> URL into a path.</p>
+<div class="codehilite"><pre><span class="c1">// The two alerts should be the same.</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">appURLToPath</span><span class="p">(</span><span class="s2">&quot;app://images/kitten.png&quot;</span><span class="p">));</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">application</span><span class="p">.</span><span class="nx">resourcesPath</span><span class="p">,</span>
+ <span class="s2">&quot;images&quot;</span><span class="p">,</span> <span class="s2">&quot;kitten.png&quot;</span><span class="p">));</span>
+</pre></div>
+
+
+<p>One of the main benefits of the App module though is that it can
+return values from the <tt>tiapp.xml</tt> file. This might be useful for
+displaying the application version to the user or presenting a link to
+your URL.</p>
+<div class="codehilite"><pre><span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Welcome to &quot;</span> <span class="o">+</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">getName</span><span class="p">()</span> <span class="o">+</span>
+ <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">getVersion</span><span class="p">());</span>
+</pre></div>
+
+
+<h2 id="application_properties">Application properties</h2>
+<p>Application properties provide a light-weight alternative to HTML5
+databases or the Titanium Database module. They come in two varieties:
+system properties and user properties. System properties are read-only
+properties that are defined via the <tt>tiapp.xml</tt> file, while user properties
+can be stored at any file path.</p>
+<h3 id="system_properties">System properties</h3>
+<p>In the KitchenSink <tt>tiapp.xml</tt>, the following properties are defined
+as children of the <code>&lt;ti:app&gt;</code> node:</p>
+<div class="codehilite"><pre><span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;myString&quot;</span> <span class="na">type=</span><span class="s">&quot;string&quot;</span><span class="nt">&gt;</span>I am a String<span class="nt">&lt;/property&gt;</span>
+<span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;myDouble&quot;</span> <span class="na">type=</span><span class="s">&quot;double&quot;</span><span class="nt">&gt;</span>1.23<span class="nt">&lt;/property&gt;</span>
+<span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;myBool&quot;</span> <span class="na">type=</span><span class="s">&quot;boolean&quot;</span><span class="nt">&gt;</span>true<span class="nt">&lt;/property&gt;</span>
+<span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;myInt&quot;</span> <span class="na">type=</span><span class="s">&quot;int&quot;</span><span class="nt">&gt;</span>1<span class="nt">&lt;/property&gt;</span>
+<span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;myList&quot;</span> <span class="na">type=</span><span class="s">&quot;list&quot;</span><span class="nt">&gt;</span>1,2,3<span class="nt">&lt;/property&gt;</span>
+<span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&quot;myDefaultString&quot;</span><span class="nt">&gt;</span>I am a default string<span class="nt">&lt;/property&gt;</span>
+</pre></div>
+
+
+<p>It is possible to access these properties by getting an instance of
+the system properties object:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">properties</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">getSystemProperties</span><span class="p">();</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">properties</span><span class="p">.</span><span class="nx">getString</span><span class="p">(</span><span class="s2">&quot;myString&quot;</span><span class="p">));</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">properties</span><span class="p">.</span><span class="nx">getInt</span><span class="p">(</span><span class="s2">&quot;myInt&quot;</span><span class="p">));</span>
+</pre></div>
+
+
+<p>System properties are read-only, because an application may not have write
+access to it's installation directory (where <tt>tiapp.xml</tt> resides). To
+store properties, it's recommended that you write a user properties file to the
+application data directory.</p>
+<h3 id="user_properties">User properties</h3>
+<p>User properties have the same interface as system properties, but can be stored
+in any file on the filesystem. Generally speaking, it's best to store these in
+in the application data directory, which is a per-user are to store application
+files. On Linux this is in <tt>~/.titanium/appdata/</tt>, on OS X,
+<tt>~/Library/Application Support/Titanium/appdata</tt> and on Windows in
+<tt>%appdata%/Titanium/appdata</tt>.</p>
+<p>Here is an example of reading and writing to a user properties file:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">file</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">application</span><span class="p">.</span><span class="nx">dataPath</span><span class="p">,</span> <span class="s2">&quot;demo.properties&quot;</span><span class="p">);</span>
+
+<span class="c1">// Load the file if it exists.</span>
+<span class="kd">var</span> <span class="nx">properties</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+<span class="k">if</span> <span class="p">(</span><span class="nx">file</span><span class="p">.</span><span class="nx">exists</span><span class="p">())</span>
+ <span class="nx">properties</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">loadProperties</span><span class="p">(</span><span class="nx">file</span><span class="p">);</span>
+
+<span class="c1">// If the file doesn&#39;t exist, yet just create a new properties object.</span>
+<span class="k">if</span> <span class="p">(</span><span class="nx">properties</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span>
+ <span class="nx">properties</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">createProperties</span><span class="p">({</span>
+ <span class="nx">val1</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
+ <span class="nx">val2</span><span class="o">:</span> <span class="mf">1.1</span><span class="p">,</span>
+ <span class="nx">val3</span><span class="o">:</span> <span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">],</span>
+ <span class="nx">val4</span><span class="o">:</span> <span class="s2">&quot;123&quot;</span>
+ <span class="p">});</span>
+
+<span class="c1">// Update the properties object and save it.</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">properties</span><span class="p">.</span><span class="nx">getString</span><span class="p">(</span><span class="s1">&#39;val4&#39;</span><span class="p">));</span>
+<span class="nx">properties</span><span class="p">.</span><span class="nx">setString</span><span class="p">(</span><span class="s1">&#39;val4&#39;</span><span class="p">,</span> <span class="s1">&#39;321&#39;</span><span class="p">);</span>
+<span class="nx">properties</span><span class="p">.</span><span class="nx">saveTo</span><span class="p">(</span><span class="nx">file</span><span class="p">);</span>
+</pre></div>
+
+
+<h2 id="exiting_and_restarting">Exiting and restarting</h2>
+<p>It is possible to exit and restart your application. This is useful
+for creating a custom exit button. The application will also exit when
+the last top-level window closes. It is alos possible to prevent your
+application from exiting by listening for the <tt>EXIT</tt> event.
+One complication with this approach is that the <tt>EXIT</tt> event is
+fired after the last window closes, so you might need to recreate the
+main window. A better approach is to simply catch <tt>CLOSE</tt> events.</p>
+<div class="codehilite"><pre><span class="c1">// Exit KitchenSink</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">EXIT</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">)</span>
+<span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">confirm</span><span class="p">(</span><span class="s2">&quot;Are you sure you want to exit?&quot;</span><span class="p">))</span>
+ <span class="nx">event</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
+<span class="p">});</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">exit</span><span class="p">();</span>
+
+<span class="c1">// Restart KitchenSink</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">App</span><span class="p">.</span><span class="nx">restart</span><span class="p">();</span>
+</pre></div>
View
95 Resources/topics/basics.html
@@ -0,0 +1,95 @@
+<h1>Basics</h1>
+<h2 id="the_titanium_object">The Titanium Object</h2>
+<p>The Titanium object is top-level namespace for the entire Titanium API. It
+is an object shared between all JavaScript contexts. Each frame, including
+the top-level frame of each window, has its own JavaScript context. This
+makes sharing data between frames a snap:</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">DataDump</span> <span class="o">=</span> <span class="p">{}</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">DataDump</span><span class="p">.</span><span class="nx">value</span> <span class="o">=</span> <span class="s2">&quot;foo&quot;</span><span class="p">;</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">DataDump</span><span class="p">.</span><span class="nx">value</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Note: Since it's simple to write to the Titanium object, you should be careful
+not to overwrite Titanium namespaces and methods, unless you know what you're
+doing.</p>
+<p>Almost all instantiated objects in Titanium are accessor-objects. This means
+that properties can be accessed and modified in two styles. For example, take
+this use use of <em>API.Application.getName()</em>:</p>
+<div class="codehilite"><pre><span class="nx">alert</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">getApplication</span><span class="p">().</span><span class="nx">getName</span><span class="p">());</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">getApplication</span><span class="p">().</span><span class="nx">name</span><span class="p">);</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">application</span><span class="p">.</span><span class="nx">name</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Likewise a similar method can be used for modifiers:</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setTitle</span><span class="p">(</span><span class="s2">&quot;Title1&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">title</span> <span class="o">=</span> <span class="s2">&quot;Title2&quot;</span><span class="p">;</span>
+</pre></div>
+
+
+<h2 id="logging">Logging</h2>
+<p>Titanium provides an API for logging. There are two supported methods.</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">critical</span><span class="p">(</span><span class="s2">&quot;critical message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">debug</span><span class="p">(</span><span class="s2">&quot;debug message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s2">&quot;error message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">fatal</span><span class="p">(</span><span class="s2">&quot;fatal message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">notice</span><span class="p">(</span><span class="s2">&quot;notice message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">trace</span><span class="p">(</span><span class="s2">&quot;trace message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">warn</span><span class="p">(</span><span class="s2">&quot;warning message&quot;</span><span class="p">);</span>
+
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">CRITICAL</span><span class="p">,</span><span class="s2">&quot;critical message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">DEBUG</span><span class="p">,</span><span class="s2">&quot;debug message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">ERROR</span><span class="p">,</span><span class="s2">&quot;error message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">FATAL</span><span class="p">,</span><span class="s2">&quot;fatal message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">INFO</span><span class="p">,</span><span class="s2">&quot;info message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">NOTICE</span><span class="p">,</span><span class="s2">&quot;notice message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">TRACE</span><span class="p">,</span><span class="s2">&quot;trace message&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">WARN</span><span class="p">,</span><span class="s2">&quot;warn message&quot;</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Note: You can view the log output via the web inspector (or
+a terminal window if you launched your app from the command line).
+The Web Inspector only logs WARN messages or higher.</p>
+<p>If you want to control the level of logging that is displayed via stdout,
+you can set the logging level.</p>
+<div class="codehilite"><pre><span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;The current log level is: &quot;</span> <span class="o">+</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">getLogLevel</span><span class="p">());</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">setLogLevel</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">FATAL</span><span class="p">);</span>
+<span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;The current log level is: &quot;</span> <span class="o">+</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">getLogLevel</span><span class="p">());</span>
+</pre></div>
+
+
+<h2 id="environment_variables">Environment Variables</h2>
+<p>Titanium allows you to access environment variables via the
+<em>Titanium.API.getEnvironment</em> function. The object returned
+by this function is live representation of all environment variables,
+which allows you to query and update the environment easily.</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">env</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">getEnvironment</span><span class="p">();</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">env</span><span class="p">[</span><span class="s1">&#39;PATH&#39;</span><span class="p">]);</span>
+
+<span class="c1">// Modify the PATH environment variable.</span>
+<span class="kd">var</span> <span class="nx">sep</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">platform</span> <span class="o">==</span> <span class="s2">&quot;win32&quot;</span> <span class="o">?</span> <span class="s2">&quot;;&quot;</span> <span class="o">:</span> <span class="s2">&quot;:&quot;</span><span class="p">;</span>
+<span class="nx">env</span><span class="p">[</span><span class="s1">&#39;PATH&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="nx">env</span><span class="p">[</span><span class="s1">&#39;PATH&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="nx">sep</span> <span class="o">+</span> <span class="s2">&quot;/home/titanium/bin&quot;</span><span class="p">;</span>
+<span class="nx">alert</span><span class="p">(</span><span class="nx">env</span><span class="p">[</span><span class="s1">&#39;PATH&#39;</span><span class="p">]);</span>
+</pre></div>
+
+
+<h2 id="events">Events</h2>
+<p>Many objects in Titanium can fire and handle events. Sometimes you
+may need to inercept all events after they've bubbled up to the
+top-level object. This is possible by installing an event handler
+on the Titanium object.</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">addEventListener</span><span class="p">(</span><span class="s2">&quot;CustomEvent&quot;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">)</span>
+<span class="p">{</span>
+ <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Top-level got &quot;</span> <span class="o">+</span> <span class="nx">event</span><span class="p">.</span><span class="nx">type</span> <span class="o">+</span> <span class="s2">&quot; event!&quot;</span><span class="p">);</span>
+<span class="p">});</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">API</span><span class="p">.</span><span class="nx">fireEvent</span><span class="p">(</span><span class="s2">&quot;CustomEvent&quot;</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Not only will <em>Titanium.API.addEventListener</em> listen for events
+fired with <em>Titanium.API.fireEvent</em>, but it will also listen for
+events originating from <em>all</em> Titanium objects (unless
+<em>preventDefault</em> or <em>stopPropagation</em> was called on that
+event).</p>
View
87 Resources/topics/database.html
@@ -0,0 +1,87 @@
+<h1>Database</h1>
+<h2 id="introduction">Introduction</h2>
+<p>There are two ways to use databases in Titanium: HTML 5 databases
+and the database API. In some cases you access the same database
+file with both APIs as well. Currently both APIs use SQLite backends.</p>
+<h2 id="opening_a_database">Opening a Database</h2>
+<p>There are two ways to open Titanim databases, <tt>Titanium.Database.open</tt>
+and <tt>Titanium.Database.openFile</tt>. <tt>open</tt> will create (if necessarY0
+and open a database in the same directory and schema as WebKit HTML 5 databases.
+Use this method if you'd like to use a single database with both APIs.</p>
+<div class="codehilite"><pre><span class="c1">// Create a WebKit-compatible database given, the database name.</span>
+<span class="kd">var</span> <span class="nx">db</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Database</span><span class="p">.</span><span class="nx">open</span><span class="p">(</span><span class="s1">&#39;mydatabase&#39;</span><span class="p">);</span>
+</pre></div>
+
+
+<p>You may also create a database using <tt>Titanium.Database.openFile</tt>
+which can be given a file path or <tt>Titanium.Filesystem.File</tt> object.
+If the database file does not exist, the method will create it and open it.</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">db</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Database</span><span class="p">.</span><span class="nx">openFile</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getApplicationDataDirectory</span><span class="p">(),</span> <span class="s1">&#39;mydatabase.db&#39;</span><span class="p">));</span>
+</pre></div>
+
+
+<p>Note: It's recommended that you store all data in the application data
+directory and not the application Resources or contents directory, as those
+may not be writeable.</p>
+<h2 id="simple_queries">Simple Queries</h2>
+<p>Once a database is open you may execute simple queries on it. For instance,
+to create a table:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">db</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Database</span><span class="p">.</span><span class="nx">openFile</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getApplicationDataDirectory</span><span class="p">(),</span> <span class="s1">&#39;mydatabase.db&#39;</span><span class="p">));</span>
+<span class="nx">db</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="s2">&quot;CREATE TABLE IF NOT EXISTS test(id INTEGER, name TEXT)&quot;</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Note: Be sure your query is SQLite-compatible! SQLite has different data
+types than MySQL, check them out <a href="http://www.sqlite.org/datatype3.html">here</a>.</p>
+<p>Find a way to detect databases that already exist.</p>
+<p>Inserting and retrieving data works in a very similar way:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">db</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Database</span><span class="p">.</span><span class="nx">openFile</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getApplicationDataDirectory</span><span class="p">(),</span> <span class="s1">&#39;mydatabase.db&#39;</span><span class="p">));</span>
+
+<span class="nx">db</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="s2">&quot;CREATE TABLE IF NOT EXISTS test(id INTEGER, name TEXT)&quot;</span><span class="p">);</span>
+<span class="nx">db</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="s2">&quot;INSERT INTO test VALUES(123, &#39;a&#39;)&quot;</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">resultSet</span> <span class="o">=</span> <span class="nx">db</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="s2">&quot;SELECT * FROM test&quot;</span><span class="p">);</span>
+<span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Found &quot;</span> <span class="o">+</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">rowCount</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot; rows&quot;</span><span class="p">);</span>
+<span class="k">while</span> <span class="p">(</span><span class="nx">resultSet</span><span class="p">.</span><span class="nx">isValidRow</span><span class="p">())</span>
+<span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">text</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>
+ <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&amp;</span><span class="nx">lt</span><span class="p">;</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">fieldCount</span><span class="p">();</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span>
+ <span class="nx">text</span> <span class="o">+=</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">fieldName</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;:&quot;</span>
+ <span class="o">+</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">field</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="p">;</span>
+ <span class="nx">alert</span><span class="p">(</span><span class="nx">text</span><span class="p">);</span>
+ <span class="nx">resultSet</span><span class="p">.</span><span class="nx">next</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+
+
+<h2 id="advanced_queries">Advanced Queries</h2>
+<p>You should never used unescaped input in SQL queries. In these situations
+Titanium provides a query template mechanism:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">db</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Database</span><span class="p">.</span><span class="nx">openFile</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getFile</span><span class="p">(</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Filesystem</span><span class="p">.</span><span class="nx">getApplicationDataDirectory</span><span class="p">(),</span> <span class="s1">&#39;mydatabase.db&#39;</span><span class="p">));</span>
+
+<span class="kd">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">prompt</span><span class="p">(</span><span class="s2">&quot;Enter entry id&quot;</span><span class="p">);</span>
+<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">id</span><span class="p">)</span>
+ <span class="k">return</span><span class="p">;</span>
+<span class="kd">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">prompt</span><span class="p">(</span><span class="s2">&quot;Enter entry value&quot;</span><span class="p">);</span>
+<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">value</span><span class="p">)</span>
+ <span class="k">return</span><span class="p">;</span>
+
+<span class="nx">db</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="s2">&quot;CREATE TABLE IF NOT EXISTS test(id INTEGER, name TEXT)&quot;</span><span class="p">);</span>
+<span class="nx">db</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="s2">&quot;INSERT INTO test VALUES(?, ?)&quot;</span><span class="p">,</span> <span class="nx">id</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">resultSet</span> <span class="o">=</span> <span class="nx">db</span><span class="p">.</span><span class="nx">execute</span><span class="p">(</span><span class="s2">&quot;SELECT * FROM test&quot;</span><span class="p">);</span>
+<span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Found &quot;</span> <span class="o">+</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">rowCount</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot; rows&quot;</span><span class="p">);</span>
+<span class="k">while</span> <span class="p">(</span><span class="nx">resultSet</span><span class="p">.</span><span class="nx">isValidRow</span><span class="p">())</span>
+<span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">text</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">;</span>
+ <span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&amp;</span><span class="nx">lt</span><span class="p">;</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">fieldCount</span><span class="p">();</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span>
+ <span class="nx">text</span> <span class="o">+=</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">fieldName</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;:&quot;</span>
+ <span class="o">+</span> <span class="nx">resultSet</span><span class="p">.</span><span class="nx">field</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="p">;</span>
+ <span class="nx">alert</span><span class="p">(</span><span class="nx">text</span><span class="p">);</span>
+ <span class="nx">resultSet</span><span class="p">.</span><span class="nx">next</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
View
161 Resources/topics/menus.html
@@ -0,0 +1,161 @@
+<h1>Menus</h1>
+<h2 id="menu_structure">Menu Structure</h2>
+<p>Menus are composed of two different types of objects. <tt>Titanium.UI.Menu</tt>
+and <tt>Titanium.UI.MenuItem</tt>. A <tt>Menu</tt> is a container for
+<tt>MenuItem</tt>s, while <tt>MenuItems</tt>s represent a single menu entry.
+There are three types of menu items: normal menu items, check menu items and
+separator items. A check menu item is a stateful menu item that can either be
+on or off, while a separator item is a non-interactive item which simply inserts
+a separator line in the menu.</p>
+<p>Titanium menus and menu items are <em>live</em>, meaning that you can add them
+to any number of menus and use them in any number of places and all instances
+will update immediately. For instance, you may construct a menu object, set it
+on the current window and the tray item, and then update the first menu item.
+The menu item will immediately change on both the tray icon and the window.</p>
+<h2 id="simple_menus">Simple Menus</h2>
+<p>Here is some code which constructs a simple menu:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">createMenuItem</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createMenuItem</span><span class="p">;</span>
+<span class="kd">var</span> <span class="nx">createMenu</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createMenu</span><span class="p">;</span>
+
+<span class="kd">var</span> <span class="nx">makeItem</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span>
+<span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">item</span> <span class="o">=</span> <span class="nx">createMenuItem</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span>
+ <span class="p">{</span>
+ <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Selected the &#39;&quot;</span> <span class="o">+</span> <span class="nx">name</span> <span class="o">+</span> <span class="s2">&quot;&#39; item&quot;</span><span class="p">);</span>
+ <span class="p">});</span>
+ <span class="k">return</span> <span class="nx">item</span><span class="p">;</span>
+<span class="p">};</span>
+
+<span class="kd">var</span> <span class="nx">mainMenu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">createMenuItem</span><span class="p">(</span><span class="s2">&quot;Characters&quot;</span><span class="p">));</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">createMenuItem</span><span class="p">(</span><span class="s2">&quot;Plot Twists&quot;</span><span class="p">));</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">createMenuItem</span><span class="p">(</span><span class="s2">&quot;Endings&quot;</span><span class="p">));</span>
+
+<span class="kd">var</span> <span class="nx">menu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;George, the spy&quot;</span><span class="p">));</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Henriette, the scientist&quot;</span><span class="p">));</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Ferdinand, the politician&quot;</span><span class="p">));</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">getItemAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">setSubmenu</span><span class="p">(</span><span class="nx">menu</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">menu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Doublecross&quot;</span><span class="p">));</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Deux ex machina&quot;</span><span class="p">));</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Dinosaurs&quot;</span><span class="p">));</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">getItemAt</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="nx">setSubmenu</span><span class="p">(</span><span class="nx">menu</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">menu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Sad&quot;</span><span class="p">));</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addSeparatorItem</span><span class="p">();</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Happy&quot;</span><span class="p">));</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">makeItem</span><span class="p">(</span><span class="s2">&quot;Surreal&quot;</span><span class="p">));</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">getItemAt</span><span class="p">(</span><span class="mi">2</span><span class="p">).</span><span class="nx">setSubmenu</span><span class="p">(</span><span class="nx">menu</span><span class="p">);</span>
+
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">menu</span> <span class="o">=</span> <span class="nx">mainMenu</span><span class="p">;</span>
+</pre></div>
+
+
+<p>A menu can also be cleared:</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">menu</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+</pre></div>
+
+
+<h2 id="items_with_icons">Items with Icons</h2>
+<p>It's pretty easy to create a menu item with an image. </p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">createMenuItem</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createMenuItem</span><span class="p">;</span>
+<span class="kd">var</span> <span class="nx">createMenu</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createMenu</span><span class="p">;</span>
+
+<span class="kd">var</span> <span class="nx">mainMenu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">createMenuItem</span><span class="p">(</span><span class="s2">&quot;Characters&quot;</span><span class="p">));</span>
+
+<span class="kd">var</span> <span class="nx">menu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">getItemAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">setSubmenu</span><span class="p">(</span><span class="nx">menu</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">imageItem</span> <span class="o">=</span> <span class="nx">createMenuItem</span><span class="p">(</span><span class="s2">&quot;Swap image&quot;</span><span class="p">,</span>
+ <span class="kd">function</span><span class="p">()</span>
+ <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">imageItem</span><span class="p">.</span><span class="nx">getIcon</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;app://images/icon1.png&quot;</span><span class="p">)</span>
+ <span class="nx">imageItem</span><span class="p">.</span><span class="nx">setIcon</span><span class="p">(</span><span class="s2">&quot;app://images/icon2.png&quot;</span><span class="p">);</span>
+ <span class="k">else</span>
+ <span class="nx">imageItem</span><span class="p">.</span><span class="nx">setIcon</span><span class="p">(</span><span class="s2">&quot;app://images/icon1.png&quot;</span><span class="p">);</span>
+ <span class="p">},</span>
+ <span class="s2">&quot;app://images/icon1.png&quot;</span>
+<span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">imageItem</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another item&quot;</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another another item&quot;</span><span class="p">);</span>
+
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setMenu</span><span class="p">(</span><span class="nx">mainMenu</span><span class="p">);</span>
+</pre></div>
+
+
+<p>As you can see it's possible to set the menu image during construction
+of the menu item or to change it later via the <tt>setIcon</tt> method.</p>
+<h2 id="check_menu_items">Check Menu Items</h2>
+<p>Check menu items are stateful menu items which have
+distinct 'on' and 'off' states which toggle when the
+item is selected.</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">createMenu</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createMenu</span><span class="p">;</span>
+<span class="kd">var</span> <span class="nx">mainMenu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Characters&quot;</span><span class="p">);</span>
+<span class="kd">var</span> <span class="nx">menu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">getItemAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">setSubmenu</span><span class="p">(</span><span class="nx">menu</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">checkItem</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createCheckMenuItem</span><span class="p">(</span><span class="s2">&quot;Check state&quot;</span><span class="p">,</span>
+ <span class="kd">function</span><span class="p">()</span>
+ <span class="p">{</span>
+ <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;Previous state of the item: &quot;</span> <span class="o">+</span> <span class="nx">checkItem</span><span class="p">.</span><span class="nx">getState</span><span class="p">());</span>
+ <span class="p">}</span>
+<span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">checkItem</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another item&quot;</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addSeparatorItem</span><span class="p">();</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another another item&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setMenu</span><span class="p">(</span><span class="nx">mainMenu</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Sometimes you need more advanced control over whether or not the
+check should change states. There are two ways to do this. The first
+is to use event handling:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">createMenu</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createMenu</span><span class="p">;</span>
+<span class="kd">var</span> <span class="nx">mainMenu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Characters&quot;</span><span class="p">);</span>
+<span class="kd">var</span> <span class="nx">menu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">getItemAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">setSubmenu</span><span class="p">(</span><span class="nx">menu</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">checkItem</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createCheckMenuItem</span><span class="p">(</span><span class="s2">&quot;Check state&quot;</span><span class="p">,</span>
+ <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">)</span>
+ <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">confirm</span><span class="p">(</span><span class="s2">&quot;Should the item change state?&quot;</span><span class="p">))</span>
+ <span class="nx">event</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span>
+ <span class="p">}</span>
+<span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">checkItem</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another item&quot;</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another another item&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setMenu</span><span class="p">(</span><span class="nx">mainMenu</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Another approach is to disable auto-checking on the item. The essentially
+means that you'll have to manage the state of the item yourself. This is
+also useful if you'd like to turn a series of check items into radio buttons.</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">createMenu</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createMenu</span><span class="p">;</span>
+<span class="kd">var</span> <span class="nx">mainMenu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Characters&quot;</span><span class="p">);</span>
+<span class="kd">var</span> <span class="nx">menu</span> <span class="o">=</span> <span class="nx">createMenu</span><span class="p">();</span>
+<span class="nx">mainMenu</span><span class="p">.</span><span class="nx">getItemAt</span><span class="p">(</span><span class="mi">0</span><span class="p">).</span><span class="nx">setSubmenu</span><span class="p">(</span><span class="nx">menu</span><span class="p">);</span>
+<span class="kd">var</span> <span class="nx">checkItem</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createCheckMenuItem</span><span class="p">(</span><span class="s2">&quot;Check state&quot;</span><span class="p">,</span>
+ <span class="kd">function</span><span class="p">()</span>
+ <span class="p">{</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">confirm</span><span class="p">(</span><span class="s2">&quot;Should the item change state?&quot;</span><span class="p">))</span>
+ <span class="nx">checkItem</span><span class="p">.</span><span class="nx">setState</span><span class="p">(</span><span class="o">!</span><span class="nx">checkItem</span><span class="p">.</span><span class="nx">getState</span><span class="p">())</span>
+ <span class="p">}</span>
+<span class="p">);</span>
+<span class="nx">checkItem</span><span class="p">.</span><span class="nx">setAutoCheck</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">appendItem</span><span class="p">(</span><span class="nx">checkItem</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another item&quot;</span><span class="p">);</span>
+<span class="nx">menu</span><span class="p">.</span><span class="nx">addItem</span><span class="p">(</span><span class="s2">&quot;Another another item&quot;</span><span class="p">);</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setMenu</span><span class="p">(</span><span class="nx">mainMenu</span><span class="p">);</span>
+</pre></div>
View
40 Resources/topics/notification.html
@@ -0,0 +1,40 @@
+<h1>Notifications</h1>
+<h2 id="creating_notifications">Creating Notifications</h2>
+<p>Desktop notifications are provided by Growl on OS X, Snarl on Windows
+and libnotify on Linux. If a notification provider cannot be found,
+notifications will be shown with an HTML / CSS backup.</p>
+<p>A simple notification:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">cb</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
+<span class="p">{</span>
+ <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;I&#39;ve been clicked.&quot;</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">notification</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Notification</span><span class="p">.</span><span class="nx">createNotification</span><span class="p">({</span>
+ <span class="s1">&#39;title&#39;</span><span class="o">:</span> <span class="s2">&quot;A nice notification&quot;</span><span class="p">,</span>
+ <span class="s1">&#39;message&#39;</span><span class="o">:</span> <span class="s2">&quot;This notifications was brought to you by the letter &#39;N&#39;.&quot;</span><span class="p">,</span>
+ <span class="s1">&#39;timeout&#39;</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span>
+ <span class="s1">&#39;callback&#39;</span><span class="o">:</span> <span class="nx">cb</span>
+<span class="p">});</span>
+<span class="nx">notification</span><span class="p">.</span><span class="nx">show</span><span class="p">();</span>
+</pre></div>
+
+
+<p>Not all platforms support notification callback or specifying a custom
+timeout. You can also supply an icon with your notification:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">cb</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span>
+<span class="p">{</span>
+ <span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;I&#39;ve been clicked.&quot;</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="kd">var</span> <span class="nx">notification</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">Notification</span><span class="p">.</span><span class="nx">createNotification</span><span class="p">({</span>
+ <span class="s1">&#39;title&#39;</span><span class="o">:</span> <span class="s2">&quot;A nice notification&quot;</span><span class="p">,</span>
+ <span class="s1">&#39;message&#39;</span><span class="o">:</span> <span class="s2">&quot;This notifications was brought to you by the letter &#39;N&#39;.&quot;</span><span class="p">,</span>
+ <span class="s1">&#39;timeout&#39;</span><span class="o">:</span> <span class="mi">10</span><span class="p">,</span>
+ <span class="s1">&#39;callback&#39;</span><span class="o">:</span> <span class="nx">cb</span><span class="p">,</span>
+ <span class="s1">&#39;icon&#39;</span><span class="o">:</span> <span class="s1">&#39;app://images/icon2.png&#39;</span>
+<span class="p">});</span>
+<span class="nx">notification</span><span class="p">.</span><span class="nx">show</span><span class="p">();</span>
+</pre></div>
+
+
+<p>The icon supplied should be an absolute <tt>app://</tt>, <tt>ti://</tt> or <tt>file://</tt> URL.</p>
View
115 Resources/topics/windows.html
@@ -0,0 +1,115 @@
+<h1>Windows</h1>
+<h2 id="the_current_window">The Current Window</h2>
+<p>All Titanium windows are
+<a href="http://developer.appcelerator.com/apidoc/desktop/1.0/Titanium.UI.UserWindow">UI.UserWindow</a>
+objects. Code running in context of an HTML page can easily access the current window:</p>
+<div class="codehilite"><pre><span class="nx">alert</span><span class="p">(</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">);</span>
+</pre></div>
+
+
+<p>From there it is easy to modify the window at will:</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setTitle</span><span class="p">(</span><span class="nx">prompt</span><span class="p">(</span><span class="s2">&quot;New window title:&quot;</span><span class="p">));</span>
+</pre></div>
+
+
+<p>All Titanium applications have an initial window, which can be set up
+in the <tt>tiapp.xml</tt> file (check out KitchenSink's <tt>tiapp.xml</tt>
+file or the <a href="http://developer.appcelerator.com/doc/desktop/tiapp.xml">guide</a>.
+Once a window has been opened, it can be closed once, freeing its resources
+and can never be opened again. If you'd just like to hide a window, try the following:</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">hide</span><span class="p">();</span>
+<span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span>
+<span class="p">{</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">show</span><span class="p">();</span>
+<span class="p">},</span> <span class="mi">3000</span><span class="p">);</span>
+</pre></div>
+
+
+<h2 id="modifying_windows">Modifying Windows</h2>
+<p>Most window properties can be changed:</p>
+<div class="codehilite"><pre><span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setFullscreen</span><span class="p">(</span>
+ <span class="o">!</span><span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">isFullscreen</span><span class="p">());</span>
+
+<span class="kd">var</span> <span class="nx">newWidth</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">prompt</span><span class="p">(</span><span class="s2">&quot;New window width:&quot;</span><span class="p">));</span>
+
+<span class="c1">// Keep KitchenSink functional.</span>
+<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">newWidth</span><span class="p">)</span> <span class="o">&amp;</span><span class="nx">amp</span><span class="p">;</span><span class="o">&amp;</span><span class="nx">amp</span><span class="p">;</span> <span class="nx">newWidth</span> <span class="o">&gt;</span> <span class="mi">300</span><span class="p">)</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setWidth</span><span class="p">(</span><span class="nx">newWidth</span><span class="p">);</span>
+
+<span class="kd">var</span> <span class="nx">newHeight</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">prompt</span><span class="p">(</span><span class="s2">&quot;New window height:&quot;</span><span class="p">));</span>
+
+<span class="c1">// Keep KitchenSink functional.</span>
+<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">newHeight</span><span class="p">)</span> <span class="o">&amp;</span><span class="nx">amp</span><span class="p">;</span><span class="o">&amp;</span><span class="nx">amp</span><span class="p">;</span> <span class="nx">newHeight</span> <span class="o">&gt;</span> <span class="mi">300</span><span class="p">)</span>
+ <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setHeight</span><span class="p">(</span><span class="nx">newHeight</span><span class="p">);</span>
+
+<span class="c1">// Modify the bounds of the window all at once</span>
+<span class="kd">var</span> <span class="nx">bounds</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">bounds</span><span class="p">;</span>
+<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;Previous bounds: &quot;</span> <span class="o">+</span>
+ <span class="s2">&quot; x: &quot;</span> <span class="o">+</span> <span class="nx">bounds</span><span class="p">.</span><span class="nx">x</span> <span class="o">+</span>
+ <span class="s2">&quot; y: &quot;</span> <span class="o">+</span> <span class="nx">bounds</span><span class="p">.</span><span class="nx">y</span> <span class="o">+</span>
+ <span class="s2">&quot; width: &quot;</span> <span class="o">+</span> <span class="nx">bounds</span><span class="p">.</span><span class="nx">width</span> <span class="o">+</span>
+ <span class="s2">&quot; height: &quot;</span> <span class="o">+</span> <span class="nx">bounds</span><span class="p">.</span><span class="nx">height</span><span class="p">);</span>
+
+<span class="nx">bounds</span><span class="p">.</span><span class="nx">width</span> <span class="o">=</span> <span class="mi">900</span><span class="p">;</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setBounds</span><span class="p">(</span><span class="nx">bounds</span><span class="p">);</span>
+</pre></div>
+
+
+<p>Some properties can only be changed before a window is originally open though.
+In particular, a window may only change its use of chrome before it is opened.</p>
+<div class="codehilite"><pre><span class="c1">// Should have no effect.</span>
+<span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">currentWindow</span><span class="p">.</span><span class="nx">setUsingChrome</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>
+
+<span class="c1">// This should work.</span>
+<span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createWindow</span><span class="p">(</span><span class="s2">&quot;app://new_window.html&quot;</span><span class="p">);</span>
+<span class="nx">w</span><span class="p">.</span><span class="nx">setUsingChrome</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>
+<span class="nx">w</span><span class="p">.</span><span class="nx">open</span><span class="p">();</span>
+</pre></div>
+
+
+<h2 id="transparent_windows">Transparent Windows</h2>
+<p>There are two types of transparency in Titanium. Full window transparency
+specified with the transparency property and background transparency specified
+with the transparent-background property.</p>
+<h3 id="the_transparency_setting">The Transparency Setting</h3>
+<p>The transparent element should contain a value between 0.0 and 1.0 and
+specifies the opacity of the total window. A window with a transparency
+value of 0.7 would look like:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createWindow</span><span class="p">({</span>
+ <span class="nx">url</span><span class="o">:</span> <span class="s2">&quot;app://new_window.html&quot;</span><span class="p">,</span>
+ <span class="nx">transparency</span><span class="o">:</span> <span class="mf">0.85</span><span class="p">,</span>
+ <span class="nx">height</span><span class="o">:</span> <span class="mi">200</span>
+<span class="p">});</span>
+<span class="nx">w</span><span class="p">.</span><span class="nx">open</span><span class="p">();</span>
+</pre></div>
+
+
+<p>The transparency setting of a window can be modified after it has been
+opened. The following example will cause the new window to fade away when
+closed:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createWindow</span><span class="p">({</span>
+ <span class="nx">url</span><span class="o">:</span> <span class="s2">&quot;app://fading_window.html&quot;</span><span class="p">,</span>
+ <span class="nx">height</span><span class="o">:</span> <span class="mi">200</span>
+<span class="p">});</span>
+<span class="nx">w</span><span class="p">.</span><span class="nx">open</span><span class="p">();</span>
+</pre></div>
+
+
+<h3 id="the_transparenct_background_setting">The Transparenct Background Setting</h3>
+<p>The transparent-background property specifies that the WebView in a
+window has a background which is transparent. Elements in the WebView
+may specify different opacities to create non-rectangular windows. Here is
+an example of a non-rectangular Titanium window with a
+transparent-background value of true:</p>
+<div class="codehilite"><pre><span class="kd">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nx">Titanium</span><span class="p">.</span><span class="nx">UI</span><span class="p">.</span><span class="nx">createWindow</span><span class="p">({</span>
+ <span class="nx">url</span><span class="o">:</span> <span class="s2">&quot;app://new_window.html&quot;</span><span class="p">,</span>
+ <span class="nx">transparentBackground</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
+ <span class="nx">height</span><span class="o">:</span> <span class="mi">200</span>
+<span class="p">});</span>
+<span class="nx">w</span><span class="p">.</span><span class="nx">open</span><span class="p">();</span>
+</pre></div>
+
+
+<p>Note that currently the transparent-background property disables all chrome
+and overrides the transparency property. The transparent-background property
+cannot be changed once a window is open.</p>

0 comments on commit 86d5c04

Please sign in to comment.
Something went wrong with that request. Please try again.