Skip to content
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 37ca2bf41fbd9510a34c379cdf71a3ba02291f4d Martin Robinson committed Mar 25, 2010
1 .gitignore
@@ -0,0 +1 @@
+dist
219 LICENSE.txt
@@ -0,0 +1,219 @@
+Copyright 2008-2009 Appcelerator, Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ (or the full text of the license is below)
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
19 README
@@ -0,0 +1,19 @@
+# Titanium Desktop - The Kitchen Sink
+
+This project includes a wide variety of the APIs available in Titanium Desktop. The projects are
+archived based on the mobile SDK version they pertain to.
+
+## Questions? Comments?
+
+For API docs and tutorials, head over to http://developer.appcelerator.com, our official documentataion
+and support hub.
+
+---
+
+Appcelerator, Appcelerator Titanium and associated marks and logos are
+trademarks of Appcelerator, Inc.
+
+Titanium is Copyright (c) 2010 by Appcelerator, Inc. All Rights Reserved.
+
+Titanium is licensed under the Apache Public License (Version 2). Please
+see the LICENSE file for the full license.
BIN Resources/.DS_Store
Binary file not shown.
260 Resources/css/index.css
@@ -0,0 +1,260 @@
+/********************************
+ * navigation scrollable
+ ********************************/
+#module_nav
+{
+ background-color:#fbfbfb;
+ -webkit-border-bottom-left-radius:10px;
+ -webkit-border-bottom-right-radius:10px;
+ border:1px solid #bababa;
+ border-top:1px solid #e8e8e8 !important;
+ border-top:none;
+ padding:10px;
+ width:100%;
+ margin:auto;
+}
+
+div.scrollable
+{
+ position:relative;
+ overflow:hidden;
+ height:25px;
+ width:600px;
+ float:left;
+}
+
+div.scrollable div.items
+{
+ width:20000em;
+ position:absolute;
+}
+
+div.scrollable div.items div
+{
+ float:left;
+}
+
+.api_scroller
+{
+ height:25px;
+ float:left;
+}
+
+#api_prev
+{
+ float:left;
+}
+
+#module_list div
+{
+ height:21px;
+ float:left;
+ padding-left: 5px;
+ padding-right: 5px;
+ padding-top: 1px;
+ padding-bottom: 1px;
+ margin: 0px;
+ background-color:#ffffff;
+ border:1px solid #ccc;
+ cursor:pointer;
+ text-align:center;
+ -moz-border-radius:4px;
+ -webkit-border-radius:4px;
+}
+
+#module_list div.active
+{
+ border:1px solid #000;
+}
+
+/********************************
+ * content styles
+ ********************************/
+body
+{
+ background-color:#f2f2f2;
+ padding:0px;
+ margin:0px;
+ font-family:'Myriad Pro','Helvetica Neue', 'Arial';
+ color:#000;
+ -webkit-user-select:none;
+ overflow:hidden;
+}
+.note
+{
+ font-size:14px;
+ font-weight:normal;
+ font-style:italic;
+ color:#777;
+}
+#header_border
+{
+ border-top:1px solid #444444;
+ margin-bottom:10px;
+}
+#content
+{
+ background-color:#fff;
+ border:1px solid #d6d6d6;
+ -webkit-border-radius:10px;
+ height:92%;
+ padding-top:10px;
+ padding-bottom:10px;
+ padding-left:5px;
+ padding-right:5px;
+ margin-left:10px;
+ margin-right:10px;
+}
+#content_heading
+{
+ border-bottom:1px solid #eee;
+}
+#api_heading
+{
+ font-size:20px;
+}
+#api_location
+{
+ color:#aaa;
+ font-size:14px;
+ font-weight:normal;
+ margin-left:10px;
+}
+#api_content
+{
+ padding: 0px;
+ padding-left: 20px;
+ padding-right: 20px;
+ margin: 0px;
+ color: #666;
+ font-weight: normal;
+ font-size: 14px;
+ font-family: 'Helvetica';
+}
+
+#api_content code
+{
+ font-size:14px !important;
+ line-height:15px !important;
+}
+#api_content h3
+{
+ font-size:22px;
+ font-weight:bold;
+}
+#api_list
+{
+ border-right: 1px solid #bababa;
+ margin-top:10px;
+ padding-right: 20px;
+}
+
+.topic_list
+{
+ color:#9f9696;
+ font-size:14px;
+ cursor:pointer;
+ height:22px;
+ line-height:24px;
+ margin-bottom:6px;
+ padding-left:7px;
+ width:150px;
+}
+.topic_list.active
+{
+ background-color:#3581d4;
+ color:#ffffff;
+ -webkit-box-shadow: #999 0px 2px 5px;
+}
+
+.section_item
+{
+ color:#9f9696;
+ font-size:12px;
+ cursor:pointer;
+ height:20px;
+ line-height:20px;
+ margin-bottom:6px;
+ padding-left:20px;
+ width:150px;
+}
+
+
+/********************************
+ * button styles
+ ********************************/
+button
+{
+ -khtml-appearance: none;
+ -webkit-border-image: url(../images/button-bezel.png) 2 2 2 2 stretch stretch;
+ -webkit-transition: -webkit-box-shadow 0.2s linear;
+ background: none;
+ padding: 3px 8px;
+ color: #111;
+ text-shadow: 0px 1px 1px #fff;
+ font-weight: bold;
+ font-size:12px;
+ cursor:pointer;
+}
+
+button.default
+{
+ color: #1C4257;
+ -webkit-border-image: url(../images/default-button-bezel.png) 2 2 2 2 stretch stretch;
+}
+
+button:hover:not(:disabled)
+{
+ -webkit-box-shadow: 0 0 7px #D4D4D4;
+}
+
+button.default:hover
+{
+ -webkit-box-shadow: 0 0 7px #A1CAE2;
+}
+
+button:active:not(:disabled)
+{
+ -webkit-border-image: url(../images/button-bezel-highlighted.png) 2 2 2 2 stretch stretch;
+}
+
+button.default:active
+{
+ -webkit-border-image: url(../images/default-button-bezel-highlighted.png) 2 2 2 2 stretch stretch;
+}
+
+button:disabled
+{
+ opacity: 0.5;
+}
+
+.scrolling
+{
+ overflow-y: auto;
+ overflow-x: hidden;
+}
+
+::-webkit-scrollbar
+{
+ width: 13px;
+ height: 13px;
+}
+
+::-webkit-scrollbar-thumb:vertical
+{
+ height: 56px;
+ -webkit-border-image: url(../images/scroll_thumb.png) 8 0 8 0 stretch stretch;
+ border-width: 8 0 8 0;
+}
+
+::-webkit-scrollbar-thumb:horizontal
+{
+ width: 56px;
+ -webkit-border-image: url(../images/scroll_thumb_horizontal.png) 0 8 0 8;
+ border-width: 0 8 0 8;
+}
+
+::-webkit-scrollbar-corner
+{
+ display:none;
+}
34 Resources/fading_window.html
@@ -0,0 +1,34 @@
+<html>
+<style>
+ html { background: transparent; }
+ body { background: transparent; opacity:0.8; }
+ #container {
+ margin: 0 auto;
+ padding:100px;
+ background-color: blue;
+ opacity: 0.9;
+ text-align:center;
+ }
+</style>
+<script>
+function fadeOutWindow()
+{
+ setInterval(function() {
+ var next = Titanium.UI.currentWindow.getTransparency() - 0.02;
+ if (next < 0.05)
+ Titanium.UI.currentWindow.close();
+ else
+ Titanium.UI.currentWindow.setTransparency(next);
+ }, 20);
+}
+</script>
+<head>
+ <script src="js/index.js" type="text/javascript"/>
+ <link rel="stylesheet" type="text/css" href="css/index.css" />
+</head>
+<body style="background: transparent;" onload="setupDragging();">
+ <div id="container">
+ <button onclick="fadeOutWindow();">Heroes just fade away...</button>
+ </div>
+</body>
+</html>
BIN Resources/images/button-bezel-highlighted.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/button-bezel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/default-button-bezel-highlighted.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/default-button-bezel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/next.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/previous.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/scroll_thumb.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/scroll_thumb_horizontal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/images/titanium.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 Resources/index.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+ <script src="http://cdn.jquerytools.org/1.1.2/full/jquery.tools.min.js" type="text/javascript"/>
+ <script src="js/index.js" type="text/javascript"/>
+ <script src="js/syntax.js" type="text/javascript"/>
+ <link rel="stylesheet" type="text/css" href="css/index.css" />
+</head>
+<body>
+ <!-- HEADER -->
+ <div id="header_border"></div>
+
+ <!-- CONTENT -->
+ <div id="content">
+
+ <!-- MODULE NAVIGATION -->
+ <!--
+ <div id="nav">
+ <button class="api_scroller prevPage" id="api_prev">&#x25C0;</button>
+ <div class="scrollable">
+ <div id="module_list" class="items">
+ </div>
+ </div>
+ <button class="api_scroller nextPage" id="api_prev">&#x25B6</button>
+ </div>
+ -->
+
+ <div style="clear:both;">
+ <table>
+ <tr>
+ <td valign="top">
+ <div id="api_list" class="scrolling"></div>
+ </td>
+ <td valign="top">
+ <div id="api_content" class="scrolling"></div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+ <!-- BOTTOM NAV -->
+</body>
+</html>
188 Resources/js/index.js
@@ -0,0 +1,188 @@
+KitchenSink = {};
+KitchenSink.topics = {}
+KitchenSink.topicNames = []
+
+function Topic(doc)
+{
+ this.name = doc.documentElement.attributes['name'].value;
+ this.doc = doc;
+ this.sections = [];
+
+ //
+ //var iterator = this.doc.evaluate(".//pre[@class='api_code']", this.doc, null,
+ // XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
+ //var thisNode = iterator.iterateNext();
+ //while (thisNode)
+ //{
+ // alert(thisNode);
+ // //thisNode.parentNode.insertBefore(thisNode, button);
+ // thisNode.appendChild(button);
+ // thisNode = iterator.iterateNext();
+ //}
+
+ this.html = ''
+ var iterator = this.doc.evaluate(".//div[@class='section']", this.doc, null,
+ XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
+ thisNode = iterator.iterateNext();
+ while (thisNode)
+ {
+ var sectionName = thisNode.attributes['name'].value;
+ var anchorName = sectionName.replace(/ /g, "_");
+ this.sections.push([sectionName, anchorName]);
+
+ this.html += '<h2 id="' + anchorName + '">' + sectionName + '</h2>';
+ this.html += '<div class="section">';
+ this.html += new XMLSerializer().serializeToString(thisNode);
+ this.html += '</div>';
+ thisNode = iterator.iterateNext();
+ }
+}
+
+KitchenSink.registerTopic = function(topicFile)
+{
+ try
+ {
+ var doc = (new DOMParser()).parseFromString(
+ topicFile.read().toString(), "text/xml");
+ if (doc === null)
+ return;
+ var topic = new Topic(doc);
+ }
+ catch (exception)
+ {
+ // Failed to parse the XML, bail out.
+ console.log(exception);
+ return;
+ }
+
+ KitchenSink.topics[topic.name] = topic;
+ KitchenSink.topicNames.push(topic.name);
+};
+
+KitchenSink.loadTopic = function(topic)
+{
+ KitchenSink.activeTopic = topic;
+ $('#api_heading').html(topic.name);
+ $('#api_content').css('opacity','0');
+ $('#api_content').get(0).scrollTop = 0;
+ $('#api_content').html(KitchenSink.activeTopic.html);
+
+ var i = 0;
+ KitchenSink.code = [];
+ $('.api_code').each(function()
+ {
+ try
+ {
+ KitchenSink.code.push(new Function(
+ this.children[0].innerText));
+ $(this).after('<button onclick="KitchenSink.code[' + i
+ + ']();">Run Example</button><br/>');
+ }
+ catch (exception)
+ {
+ alert("could not parse: " + this.children[0].innerText);
+ }
+ i++;
+ });
+
+ $.beautyOfCode.init({
+ brushes: ["JScript"],
+ ready: function()
+ {
+ $(".api_code,.syntax").beautifyCode(
+ "javascript", {gutter: false});
+ }
+ });
+
+ $('#api_content').fadeTo(200, '1.0');
+ Titanium.UI.currentWindow.setTitle("Desktop KitchenSink: " +
+ KitchenSink.activeTopic.name);
+}
+
+// Load all JS files for examples
+KitchenSink.loadResourceFiles = function()
+{
+ var examplesDir = Titanium.Filesystem.getFile(
+ Titanium.API.application.getResourcesPath(), 'topics');
+ var exampleFiles = examplesDir.getDirectoryListing();
+
+ for (var i = 0; i < exampleFiles.length; i++)
+ {
+ if (exampleFiles[i].isFile())
+ {
+ KitchenSink.registerTopic(exampleFiles[i]);
+ }
+ }
+
+ var getSectionListHTML = function(topic, topicId)
+ {
+ return html;
+ }
+
+ KitchenSink.topicNames.sort();
+ var html = '';
+ for (var i = 0; i < KitchenSink.topicNames.length; i++)
+ {
+ // Add the topic item.
+ var topicId = "topic_" + i;
+ var topic = KitchenSink.topics[KitchenSink.topicNames[i]];
+ html += '<div class="topic_list" id="';
+ html += topicId;
+ html += '">' + topic.name + "</div>";
+
+ // Add the section items.
+ html += '<div class="section_list"'
+ + ' id="section_list_' + topicId + '">';
+ for (var j = 0; j < topic.sections.length; j++)
+ {
+ html += '<div class="section_item" name="' + topic.sections[j][1] + '">';
+ html += topic.sections[j][0];
+ html += '</div>';
+ }
+ html += '</div>';
+ }
+ $('#api_list').html(html);
+
+ var loadTopicByElement = function(topicElement)
+ {
+ $('.topic_list').removeClass('active');
+ $('.section_list').hide();
+ $(topicElement).addClass('active');
+ $('#section_list_' + topicElement.id).show();
+ KitchenSink.loadTopic(KitchenSink.topics[topicElement.innerHTML]);
+ }
+
+ loadTopicByElement(document.getElementById("topic_0"));
+ $('.topic_list').click(function()
+ {
+ loadTopicByElement(this);
+ });
+ $('.section_item').click(function()
+ {
+ var content = $('#api_content');
+ var target = $('#' + this.attributes['name'].value);
+ content.scrollTop(
+ target.offset().top // The offset of the div within the page
+ - content.offset().top + // The offset of the content area within the page
+ content.scrollTop()); // The amount of scrolled area above the "viewport"
+ });
+};
+
+window.onload = function()
+{
+ $(function()
+ {
+ function resizeContentDiv()
+ {
+ document.getElementById('api_content').style.height =
+ Titanium.UI.currentWindow.height - 50;
+ document.getElementById('api_list').style.height =
+ Titanium.UI.currentWindow.height - 50;
+ }
+ resizeContentDiv();
+ Titanium.UI.currentWindow.addEventListener(Titanium.RESIZED, resizeContentDiv);
+ });
+ KitchenSink.loadResourceFiles();
+};
+
+
235 Resources/js/syntax.js
@@ -0,0 +1,235 @@
+jQuery.beautyOfCode = {
+
+ settings: {
+ // should the syntax highlighter and brushes
+ // be loaded dynamically
+ autoLoad: true,
+ // the base url to alex' hosted sources
+ // http://alexgorbatchev.com/wiki/SyntaxHighlighter:Hosting
+ baseUrl: 'http://alexgorbatchev.com/pub/sh/2.0.320/',
+ // the baseurl for the hosted scripts
+ scripts: 'scripts/',
+ // the baseurl for the hosted styles
+ styles: 'styles/',
+ // themes from http://alexgorbatchev.com/wiki/SyntaxHighlighter:Themes
+ theme: 'Default',
+ // the brushes that should be loaded - case sensitive!
+ // http://alexgorbatchev.com/wiki/SyntaxHighlighter:Brushes
+ brushes: ['Xml', 'JScript', 'CSharp', 'Plain'],
+ // overrides for configurations and defaults
+ // http://alexgorbatchev.com/wiki/SyntaxHighlighter:Configuration
+ config: {},
+ defaults: {},
+ // function to be called, when all scripts are loaded
+ ready: function() {
+ jQuery.beautyOfCode.beautifyAll();
+ }
+ },
+
+ init: function(settings) {
+ settings = jQuery.extend({},
+ jQuery.beautyOfCode.settings, settings);
+
+ if (!settings.config.clipboardSwf)
+ settings.config.clipboardSwf = settings.baseUrl + settings.scripts + 'clipboard.swf';
+
+ $(document).ready(function() {
+ if (!settings.autoLoad) {
+ settings.ready();
+ }
+ else {
+ jQuery.beautyOfCode.utils.loadCss(settings.baseUrl + settings.styles + 'shCore.css');
+ jQuery.beautyOfCode.utils.loadCss(settings.baseUrl + settings.styles + 'shTheme' + settings.theme + '.css', 'shTheme');
+
+ var scripts = new Array();
+ scripts.push(settings.baseUrl + settings.scripts + 'shCore.js');
+ jQuery.each(settings.brushes,
+ function(i, item) {
+ scripts.push(settings.baseUrl + settings.scripts + 'shBrush' + item + ".js")
+ });
+
+ jQuery.beautyOfCode.utils.loadAllScripts(
+ scripts,
+ function() {
+ if (settings && settings.config)
+ jQuery.extend(SyntaxHighlighter.config, settings.config);
+
+ if (settings && settings.defaults)
+ jQuery.extend(SyntaxHighlighter.defaults, settings.defaults);
+
+ settings.ready();
+ });
+ }
+ });
+ },
+
+ beautifyAll: function() {
+ jQuery("pre.code:has(code[class])").beautifyCode();
+ },
+ utils: {
+ loadScript: function(url, complete) {
+ jQuery.ajax({
+ url: url,
+ complete: function() {
+ complete();
+ },
+ type: 'GET',
+ dataType: 'script',
+ cache: true
+ });
+ },
+ loadAllScripts: function(urls, complete) {
+ if (!urls || urls.length == 0)
+ {
+ complete();
+ return;
+ }
+ var first = urls[0];
+ jQuery.beautyOfCode.utils.loadScript(
+ first,
+ function() {
+ jQuery.beautyOfCode.utils.loadAllScripts(
+ urls.slice(1, urls.length),
+ complete
+ );
+ }
+ );
+ },
+ loadCss: function(url, id) {
+ var headNode = jQuery("head")[0];
+ if (url && headNode)
+ {
+ var styleNode = document.createElement('link');
+ styleNode.setAttribute('rel', 'stylesheet');
+ styleNode.setAttribute('href', url);
+ if (id) styleNode.id = id;
+ headNode.appendChild(styleNode);
+ }
+ },
+ addCss: function(css, id) {
+ var headNode = jQuery("head")[0];
+ if (css && headNode)
+ {
+ var styleNode = document.createElement('style');
+
+ styleNode.setAttribute('type', 'text/css');
+
+ if (id) styleNode.id = id;
+
+ if (styleNode.styleSheet)
+ // for IE
+ styleNode.styleSheet.cssText = css;
+ else
+ // for everyone else
+ $(styleNode).text(css);
+
+ headNode.appendChild(styleNode);
+ }
+ },
+ addCssForBrush: function(brush, highlighter) {
+ if (brush.isCssInitialized)
+ return;
+
+ jQuery.beautyOfCode.utils.addCss(highlighter.Style);
+
+ brush.isCssInitialized = true;
+ },
+ parseParams: function(params) {
+ var trimmed = jQuery.map(params, jQuery.trim);
+
+ var paramObject = {};
+
+ var getOptionValue = function(name, list) {
+ var regex = new RegExp('^' + name + '\\[([^\\]]+)\\]$', 'gi');
+ var matches = null;
+
+ for (var i = 0; i < list.length; i++)
+ if ((matches = regex.exec(list[i])) != null)
+ return matches[1];
+
+ return null;
+ }
+
+ var handleValue = function(flag) {
+ var flagValue = getOptionValue('boc-' + flag, trimmed);
+ if (flagValue) paramObject[flag] = flagValue;
+ };
+
+ handleValue('class-name');
+ handleValue('first-line');
+ handleValue('tab-size');
+
+ var highlight = getOptionValue('boc-highlight', trimmed);
+ if (highlight) paramObject['highlight'] = jQuery.map(highlight.split(','), jQuery.trim);
+
+ var handleFlag = function(flag) {
+ if (jQuery.inArray('boc-' + flag, trimmed) != -1)
+ paramObject[flag] = true;
+ else if (jQuery.inArray('boc-no-' + flag, trimmed) != -1)
+ paramObject[flag] = false;
+ };
+
+ handleFlag('smart-tabs');
+ handleFlag('ruler');
+ handleFlag('gutter');
+ handleFlag('toolbar');
+ handleFlag('collapse');
+ handleFlag('auto-links');
+ handleFlag('light');
+ handleFlag('wrap-lines');
+ handleFlag('html-script');
+
+ return paramObject;
+ }
+ }
+};
+
+jQuery.fn.beautifyCode = function(brush, params) {
+ var saveBrush = brush;
+ var saveParams = params;
+
+ // iterate all elements
+ this.each(function(i, item) {
+ var $item = jQuery(item);
+
+ // for now, only supports <pre><code>...</code></pre>
+ // support for only pre, or only code could be added
+ var $code = $item.children("code");
+ var code = $code[0];
+ var classItems = code.className.split(" ");
+
+ var brush = saveBrush ? saveBrush: classItems[0];
+ var elementParams = jQuery.beautyOfCode.utils.parseParams(classItems);
+
+ var params = jQuery.extend({},
+ SyntaxHighlighter.defaults, saveParams, elementParams);
+
+ // Instantiate a brush
+ if (params['html-script'] == 'true')
+ {
+ highlighter = new SyntaxHighlighter.HtmlScript(brush);
+ }
+ else
+ {
+ var brush = SyntaxHighlighter.utils.findBrush(brush);
+
+ if (brush)
+ highlighter = new brush();
+ else
+ return;
+ }
+
+ // i'm not sure if this is still neccessary
+ jQuery.beautyOfCode.utils.addCssForBrush(brush, highlighter);
+
+ // IE Bug?: code in pre has to be skipped
+ // in order to preserve line breaks.
+ if ($item.is("pre") && ($code = $item.children("code")))
+ $item.text($code.text());
+
+ highlighter.highlight($item.html(), params);
+ highlighter.source = item;
+
+ $item.replaceWith(highlighter.div);
+ });
+}
50 Resources/new_window.html
@@ -0,0 +1,50 @@
+<html>
+<style>
+ html { background: transparent; }
+ body { background: transparent; opacity:0.8; }
+ #container {
+ margin: 0 auto;
+ width: 400px;
+ height: 100px;
+ padding-top: 100px;
+ background-color: blue;
+ opacity: 0.9;
+ text-align:center;
+ border-radius: 50px;
+ }
+</style>
+<script>
+document.onmousemove = function()
+{
+ if (!dragging)
+ return;
+
+ Titanium.UI.currentWindow.setX(
+ Titanium.UI.currentWindow.getX() + event.clientX - xstart);
+ Titanium.UI.currentWindow.setY(
+ Titanium.UI.currentWindow.getY() + event.clientY - ystart);
+
+}
+
+document.onmousedown = function()
+{
+ dragging = true;
+ xstart = event.clientX;
+ ystart = event.clientY;
+}
+
+document.onmouseup = function()
+{
+ dragging = false;
+}
+</script>
+<head>
+ <script src="js/index.js" type="text/javascript"/>
+ <link rel="stylesheet" type="text/css" href="css/index.css" />
+</head>
+<body style="background: transparent;" onload="setupDragging();">
+ <div id="container">
+ <button onclick="Titanium.UI.currentWindow.close()">Hey cool! A new window, now go the heck away.</button>
+ </div>
+</body>
+</html>
BIN Resources/titanium.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN Resources/topics/.windows.xml.swp
Binary file not shown.
71 Resources/topics/analytics.xml
@@ -0,0 +1,71 @@
+<div class="module" name="Analytics">
+<div class="section" name="Introduction">
+ <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>
+</div>
+
+<div class="section" name="User">
+
+ <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>
+
+ <pre class="api_code"><code>
+ // Fire a user event and pass along a little extra information.
+ Titanium.Analytics.userEvent('my_event', {'login': true});
+ </code></pre>
+</div>
+
+<div class="section" name="Navigation">
+ <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>
+
+ <pre class="api_code"><code>
+ // Pass in from location, to location, event name and a JSON data object
+ Titanium.Analytics.navEvent('home', 'edit_account', 'view_account',
+ {'account_id':123});
+ </code></pre>
+</div>
+
+<div class="section" name="Settings">
+ <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>
+
+ <pre class="api_code"><code>
+ // pass in a setting name and a JSON data object
+ Titanium.Analytics.settingsEvent('volume', {'value':5});
+ </code></pre>
+
+</div>
+
+<div class="section" name="Timed">
+ <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>
+
+ <pre class="api_code"><code>
+ // pass in a timed event name and a JSON data object
+ var startTime = new Date();
+
+ // Do some task like register for service and then do....
+ var endTime = new Date();
+ Titanium.Analytics.timedEvent('register', startTime, endTime, null,
+ {'email':'bob@aol.com'});
+ </code></pre>
+</div>
+</div>
125 Resources/topics/basics.xml
@@ -0,0 +1,125 @@
+<div class="module" name="Basics">
+<div class="section" name="The Titanium Object">
+ <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>
+ <pre class="api_code"><code>
+ Titanium.DataDump = {}
+ Titanium.DataDump.value = "foo";
+ alert(Titanium.DataDump.value);
+ </code></pre>
+
+ <div class="note">
+ 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.
+ </div>
+
+ <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 <tt>API.Application.getName()</tt>:
+ <pre class="api_code"><code>
+ alert(Titanium.API.getApplication().getName());
+ alert(Titanium.API.getApplication().name);
+ alert(Titanium.API.application.name);
+ </code></pre>
+ Likewise a similar method can be used for modifiers:
+ <pre class="api_code"><code>
+ Titanium.UI.currentWindow.setTitle("Title1");
+ Titanium.UI.currentWindow.title = "Title2";
+ </code></pre>
+ </p>
+</div>
+<div class="section" name="Logging">
+ <p>
+ Titanium provides an API for logging. There are two supported methods.
+ </p>
+
+ <pre class="api_code"><code>
+ Titanium.API.critical("critical message");
+ Titanium.API.debug("debug message");
+ Titanium.API.error("error message");
+ Titanium.API.fatal("fatal message");
+ Titanium.API.notice("notice message");
+ Titanium.API.trace("trace message");
+ Titanium.API.warn("warning message");
+ </code></pre>
+
+ <pre class="api_code"><code>
+ Titanium.API.log(Titanium.API.CRITICAL,"critical message");
+ Titanium.API.log(Titanium.API.DEBUG,"debug message");
+ Titanium.API.log(Titanium.API.ERROR,"error message");
+ Titanium.API.log(Titanium.API.FATAL,"fatal message");
+ Titanium.API.log(Titanium.API.INFO,"info message");
+ Titanium.API.log(Titanium.API.NOTICE,"notice message");
+ Titanium.API.log(Titanium.API.TRACE,"trace message");
+ Titanium.API.log(Titanium.API.WARN,"warn message");
+ </code></pre>
+
+ <div class="note"><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></div>
+
+ <div>
+ If you want to control the level of logging that is displayed via stdout,
+ you can set the logging level.
+ </div>
+
+ <pre class="api_code"><code>
+ alert("The current log level is: " + Titanium.API.getLogLevel());
+ Titanium.API.setLogLevel(Titanium.API.FATAL);
+ alert("The current log level is: " + Titanium.API.getLogLevel());
+ </code></pre>
+</div>
+
+<div class="section" name="Environment Variables">
+ <p>
+ Titanium allows you to access environment variables via the
+ <tt>Titanium.API.getEnvironment</tt> 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>
+
+ <pre class="api_code"><code>
+ var env = Titanium.API.getEnvironment();
+ alert(env['PATH']);
+
+ // Modify the PATH environment variable.
+ var sep = Titanium.platform == "win32" ? ";" : ":";
+ env['PATH'] = env['PATH'] + sep + "/home/titanium/bin";
+ alert(env['PATH']);
+ </code></pre>
+</div>
+
+<div class="section" name="Events">
+ <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>
+
+ <pre class="api_code"><code>
+ Titanium.API.addEventListener("CustomEvent", function(event)
+ {
+ alert("Top-level got " + event.type + " event!");
+ });
+ Titanium.API.fireEvent("CustomEvent");
+ </code></pre>
+
+ <p>
+ Not only will <tt>Titanium.API.addEventListener</tt> listen for events
+ fired with <tt>Titanium.API.fireEvent</tt>, but it will also listen for
+ events originating from <em>all</em> Titanium objects (unless
+ <tt>preventDefault</tt> or <tt>stopPropagation</tt> was called on that
+ event).
+ </p>
+</div>
+
+</div>
62 Resources/topics/codec.xml
@@ -0,0 +1,62 @@
+<div class="module" name="Codec">
+<div class="section" name="User">
+ <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>
+
+ <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>
+
+ <pre class="api_code"><code>
+// Fire a user event and pass along a little extra information.
+Titanium.Analytics.userEvent('my_event', {'login': true});
+ </code></pre>
+</div>
+
+<div class="section" name="Navigation">
+ 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.",
+
+ <pre class="api_code"><code>
+// pass in from location, to location, event name and a JSON data object
+Titanium.Analytics.navEvent('home', 'edit_account', 'view_account',
+ {'account_id':123});
+ </code></pre>
+</div>
+
+<div class="section" name="Settings">
+ 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
+
+ <pre class="api_code"><code>
+// pass in a setting name and a JSON data object
+Titanium.Analytics.settingsEvent('volume', {'value':5});
+ </code></pre>
+
+</div>
+
+<div class="section" name="Timed">
+ 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.
+
+ <pre class="api_code"><code>
+// pass in a timed event name and a JSON data object
+var startTime = new Date();
+
+// Do some task like register for service and then do....
+var endTime = new Date();
+Titanium.Analytics.timedEvent('register', startTime, endTime, null,
+ {'email':'bob@aol.com'});
+ </code></pre>
+</div>
+</div>
62 Resources/topics/css.xml
@@ -0,0 +1,62 @@
+<div class="module" name="CSS">
+<div class="section" name="User">
+ <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>
+
+ <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>
+
+ <pre class="api_code"><code>
+// Fire a user event and pass along a little extra information.
+Titanium.Analytics.userEvent('my_event', {'login': true});
+ </code></pre>
+</div>
+
+<div class="section" name="Navigation">
+ 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.",
+
+ <pre class="api_code"><code>
+// pass in from location, to location, event name and a JSON data object
+Titanium.Analytics.navEvent('home', 'edit_account', 'view_account',
+ {'account_id':123});
+ </code></pre>
+</div>
+
+<div class="section" name="Settings">
+ 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
+
+ <pre class="api_code"><code>
+// pass in a setting name and a JSON data object
+Titanium.Analytics.settingsEvent('volume', {'value':5});
+ </code></pre>
+
+</div>
+
+<div class="section" name="Timed">
+ 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.
+
+ <pre class="api_code"><code>
+// pass in a timed event name and a JSON data object
+var startTime = new Date();
+
+// Do some task like register for service and then do....
+var endTime = new Date();
+Titanium.Analytics.timedEvent('register', startTime, endTime, null,
+ {'email':'bob@aol.com'});
+ </code></pre>
+</div>
+</div>
62 Resources/topics/database.xml
@@ -0,0 +1,62 @@
+<div class="module" name="Database">
+<div class="section" name="User">
+ <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>
+
+ <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>
+
+ <pre class="api_code"><code>
+// Fire a user event and pass along a little extra information.
+Titanium.Analytics.userEvent('my_event', {'login': true});
+ </code></pre>
+</div>
+
+<div class="section" name="Navigation">
+ 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.",
+
+ <pre class="api_code"><code>
+// pass in from location, to location, event name and a JSON data object
+Titanium.Analytics.navEvent('home', 'edit_account', 'view_account',
+ {'account_id':123});
+ </code></pre>
+</div>
+
+<div class="section" name="Settings">
+ 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
+
+ <pre class="api_code"><code>
+// pass in a setting name and a JSON data object
+Titanium.Analytics.settingsEvent('volume', {'value':5});
+ </code></pre>
+
+</div>
+
+<div class="section" name="Timed">
+ 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.
+
+ <pre class="api_code"><code>
+// pass in a timed event name and a JSON data object
+var startTime = new Date();
+
+// Do some task like register for service and then do....
+var endTime = new Date();
+Titanium.Analytics.timedEvent('register', startTime, endTime, null,
+ {'email':'bob@aol.com'});
+ </code></pre>
+</div>
+</div>
62 Resources/topics/platform.xml
@@ -0,0 +1,62 @@
+<div class="module" name="Platform">
+<div class="section" name="User">
+ <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>
+
+ <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>
+
+ <pre class="api_code"><code>
+// Fire a user event and pass along a little extra information.
+Titanium.Analytics.userEvent('my_event', {'login': true});
+ </code></pre>
+</div>
+
+<div class="section" name="Navigation">
+ 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.",
+
+ <pre class="api_code"><code>
+// pass in from location, to location, event name and a JSON data object
+Titanium.Analytics.navEvent('home', 'edit_account', 'view_account',
+ {'account_id':123});
+ </code></pre>
+</div>
+
+<div class="section" name="Settings">
+ 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
+
+ <pre class="api_code"><code>
+// pass in a setting name and a JSON data object
+Titanium.Analytics.settingsEvent('volume', {'value':5});
+ </code></pre>
+
+</div>
+
+<div class="section" name="Timed">
+ 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.
+
+ <pre class="api_code"><code>
+// pass in a timed event name and a JSON data object
+var startTime = new Date();
+
+// Do some task like register for service and then do....
+var endTime = new Date();
+Titanium.Analytics.timedEvent('register', startTime, endTime, null,
+ {'email':'bob@aol.com'});
+ </code></pre>
+</div>
+</div>
145 Resources/topics/the_application.xml
@@ -0,0 +1,145 @@
+<div class="module" name="The Application">
+<div class="section" name="Useful methods">
+ <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="https://developer.appcelerator.com/apidoc/desktop/1.0/Titanium.API.Application.html" target="ti:systembrowser">useful properties</a>.
+ </p>
+
+ <pre class="api_code"><code>
+ var app = Titanium.API.application;
+ alert(app.getDataPath());
+ alert(app.getGUid());
+ </code></pre>
+
+ <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>
+
+ <pre class="api_code"><code>
+ // The two alerts should be the same.
+ alert(Titanium.App.appURLToPath("app://images/kitten.png"));
+ alert(Titanium.Filesystem.getFile(Titanium.API.application.resourcesPath,
+ "images", "kitten.png"));
+ </code></pre>
+
+ <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>
+
+ <pre class="api_code"><code>
+ alert("Welcome to " + Titanium.App.getName() +
+ " " + Titanium.App.getVersion());
+ </code></pre>
+</div>
+
+<div class="section" name="Application properties">
+ <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>
+
+ <h4>System properties</h4>
+ <p>
+ In the KitchenSink <tt>tiapp.xml</tt>, the following properties are defined
+ as children of the <tt>&lt;ti:app&gt;</tt> node:
+ </p>
+ <pre class="syntax"><code>
+ &lt;property name="myString" type="string"&gt;I am a String&lt;/property&gt;
+ &lt;property name="myDouble" type="double"&gt;1.23lt&lt;/property&gt;
+ &lt;property name="myBool" type="boolean"&gt;truelt&lt;/property&gt;
+ &lt;property name="myInt" type="int"&gt;1&lt;/property&gt;
+ &lt;property name="myList" type="list"&gt;1,2,3&lt;/property&gt;
+ &lt;property name="myDefaultString"&gt;I am a default string&lt;/property&gt;
+ </code></pre>
+
+ <p>
+ It is possible to access these properties by getting an instance of
+ the system properties object:
+ <pre class="api_code"><code>
+ var properties = Titanium.App.getSystemProperties();
+ alert(properties.getString("myString"));
+ alert(properties.getInt("myInt"));
+ </code></pre>
+ 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>
+
+ <h4>User properties</h4>
+ <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:
+ <pre class="api_code"><code>
+ var file = Titanium.Filesystem.getFile(
+ Titanium.API.application.dataPath, "demo.properties");
+
+ // Load the file if it exists.
+ var properties = null;
+ if (file.exists())
+ properties = Titanium.App.loadProperties(file);
+
+ // If the file doesn't exist, yet just create a new properties object.
+ if (properties === null)
+ properties = Titanium.App.createProperties({
+ val1: true,
+ val2: 1.1,
+ val3: ['a', 'b', 'c'],
+ val4: "123"
+ });
+
+ // Update the properties object and save it.
+ alert(properties.getString('val4'));
+ properties.setString('val4', '321');
+ properties.saveTo(file);
+ </code></pre>
+ </p>
+</div>
+
+
+<div class="section" name="Exiting and restarting">
+ <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>
+
+ <pre class="api_code"><code>
+ // Exit KitchenSink
+ Titanium.API.addEventListener(Titanium.EXIT, function(event)
+ {
+ if (!confirm("Are you sure you want to exit?"))
+ event.preventDefault();
+ });
+ Titanium.App.exit();
+ </code></pre>
+
+ <pre class="api_code"><code>
+ // Restart KitchenSink
+ Titanium.App.restart();
+ </code></pre>
+</div>
+
+</div>
148 Resources/topics/windows.xml
@@ -0,0 +1,148 @@
+<div class="module" name="Windows">
+<div class="section" name="The Current Window">
+ <p>
+ All Titanium windows are
+ <a href="https://developer.appcelerator.com/apidoc/desktop/1.0/Titanium.UI.UserWindow" target="ti:systembrowser"><tt>UI.UserWindow</tt></a>
+ objects. Code running in context of an HTML page can easily access the
+ current window:
+ <pre class="api_code"><code>
+ alert(Titanium.UI.currentWindow);
+ </code></pre>
+
+ From there it is easy to modify the window at will:
+ <pre class="api_code"><code>
+ Titanium.UI.currentWindow.setTitle(prompt("New window title:"));
+ </code></pre>
+
+ 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="https://developer.appcelerator.com/doc/desktop/tiapp.xml" target="ti:systembrowser">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:
+ <pre class="api_code"><code>
+ Titanium.UI.currentWindow.hide();
+ setTimeout(function()
+ {
+ Titanium.UI.currentWindow.show();
+ }, 3000);
+ </code></pre>
+ </p>
+</div>
+
+<div class="section" name="Modifying Windows">
+ <p>
+ Most window properties can be changed:
+ </p>
+
+ <pre class="api_code"><code>
+ Titanium.UI.currentWindow.setFullscreen(
+ !Titanium.UI.currentWindow.isFullscreen());
+ </code></pre>
+
+ <pre class="api_code"><code>
+ var newWidth = parseInt(prompt("New window width:"));
+
+ // Keep KitchenSink functional.
+ if (!isNaN(newWidth) &amp;&amp; newWidth > 300)
+ Titanium.UI.currentWindow.setWidth(newWidth);
+ </code></pre>
+
+ <pre class="api_code"><code>
+ var newHeight = parseInt(prompt("New window height:"));
+
+ // Keep KitchenSink functional.
+ if (!isNaN(newHeight) &amp;&amp; newHeight > 300)
+ Titanium.UI.currentWindow.setHeight(newHeight);
+ </code></pre>
+
+ <pre class="api_code"><code>
+ // Modify the bounds of the window all at once
+ var bounds = Titanium.UI.currentWindow.bounds;
+ console.log("Previous bounds: " +
+ " x: " + bounds.x +
+ " y: " + bounds.y +
+ " width: " + bounds.width +
+ " height: " + bounds.height);
+
+ bounds.width = 900;
+ Titanium.UI.currentWindow.setBounds(bounds);
+ </code></pre>
+
+ <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.
+
+ <pre class="api_code"><code>
+ // Should have no effect.
+ Titanium.UI.currentWindow.setUsingChrome(false);
+
+ // This should work.
+ var w = Titanium.UI.createWindow("app://new_window.html");
+ w.setUsingChrome(false);
+ w.open();
+ </code></pre>
+ </p>
+</div>
+
+<div class="section" name="Transparent Windows">
+ <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>
+
+ <h4>The Transparency Setting</h4>
+ <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>
+
+ <pre class="api_code"><code>
+ var w = Titanium.UI.createWindow({
+ url: "app://new_window.html",
+ transparency: 0.85,
+ height: 200
+ });
+ w.open();
+ </code></pre>
+
+ <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>
+ <pre class="api_code"><code>
+ var w = Titanium.UI.createWindow({
+ url: "app://fading_window.html",
+ height: 200
+ });
+ w.open();
+ </code></pre>
+
+ <h4>The Transparenct Background Setting</h4>
+ <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>
+
+ <pre class="api_code"><code>
+ var w = Titanium.UI.createWindow({
+ url: "app://new_window.html",
+ transparentBackground: true,
+ height: 200
+ });
+ w.open();
+ </code></pre>
+
+ <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>
+
+</div>
25 manifest
@@ -0,0 +1,25 @@
+#appname:Desktop Kitchen Sink
+#appid:com.appcelerator.kitchensink.desktop
+#publisher:Appcelerator, Inc.
+#image:titanium.png
+#url:www.appcelerator.com
+#guid:f8d97bd7-14e4-4e91-b030-42537834175f
+#desc:An API reference for Titanium Desktop
+#type:desktop
+runtime:1.0.0
+tiplatform:1.0.0
+tiapp:1.0.0
+javascript:1.0.0
+tifilesystem:1.0.0
+tiui:1.0.0
+api:1.0.0
+tidesktop:1.0.0
+timonkey:1.0.0
+tigrowl:1.0.0
+tidatabase:1.0.0
+tiprocess:1.0.0
+ticodec:1.0.0
+tinetwork:1.0.0
+tinotification:1.0.0
+tiworker:1.0.0
+timedia:1.0.0
35 tiapp.xml
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<ti:app xmlns:ti='http://ti.appcelerator.org'>
+<!-- These values are edited/maintained by Titanium Developer -->
+<id>com.appcelerator.kitchensink.desktop</id>
+<name>Desktop Kitchen Sink</name>
+<version>1.0.0</version>
+<publisher>Appcelerator, Inc.</publisher>
+<url>www.appcelerator.com</url>
+<icon>titanium.png</icon>
+<copyright>2010 by Appcelerator, Inc.</copyright>
+<description>An API reference for Titanium Desktop</description>
+<analytics>false</analytics>
+
+<!-- Global application properties -->
+<property name="myString" type="string">I am a String</property>
+<property name="myDouble" type="double">1.23</property>
+<property name="myBool" type="boolean">true</property>
+<property name="myInt" type="int">1</property>
+<property name="myList" type="list">1,2,3</property>
+<property name="myDefaultString">I am a default string</property>
+
+<window>
+ <id>initial</id>
+ <title>Desktop Kitchen Sink</title>
+ <url>app://index.html</url>
+ <width>900</width>
+ <height>600</height>
+ <fullscreen>false</fullscreen>
+ <resizable>true</resizable>
+ <chrome scrollbars="true">true</chrome>
+ <maximizable>true</maximizable>
+ <minimizable>true</minimizable>
+ <closeable>true</closeable>
+</window>
+</ti:app>

0 comments on commit 37ca2bf

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