From abfea74565ee0f73e66520d9496dd3be19d6cefa Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 8 Apr 2012 20:22:27 +0200 Subject: [PATCH] misc. minor changes and documentation updates --- readme/html/OxDoc.html | 60 ++++++++++++++++++++++++- source/Ox.UI/js/Calendar/Ox.Calendar.js | 6 +-- source/Ox.UI/js/Code/Ox.DocPage.js | 2 +- source/Ox.UI/js/List/Ox.TreeList.js | 11 ++--- source/Ox.UI/js/Panel/Ox.SplitPanel.js | 32 ++++++------- source/Ox.UI/js/Panel/Ox.TabPanel.js | 15 +++++++ source/Ox/js/Collection.js | 2 + source/Ox/js/JavaScript.js | 4 +- 8 files changed, 102 insertions(+), 30 deletions(-) diff --git a/readme/html/OxDoc.html b/readme/html/OxDoc.html index 5de13260..e6bd40ff 100644 --- a/readme/html/OxDoc.html +++ b/readme/html/OxDoc.html @@ -38,6 +38,64 @@

Ox.doc - A JavaScript Documentation Language

+

At its core, Ox.doc is list of lines like this:

+
//@ name <type> summary
+

...

+
/*@
+name <type> summary
+    Longer description
+    that may contain HTML.
+@*/
+
+ +

If you are documenting an object with properties, these lines can be nested:

+
/*@
+My.team <object> Some sports team
+    name <string> The team's name
+    lastMatch <object> The most recent result
+        for <number> Goals for
+        against <number> Goals against
+    won <boolean> If true, last match was a win
+@*/
+ +

The same goes for functions and events:

+
/*@
+My.readURL <function> Reads data from a remote URL
+    (url, callback) -> <o> Request handler
+        cancel <function> The handler's only property. Takes no arguments. Cancels the request.
+    url <string> Remote URL
+    callback <function> Callback function
+        result <object> Result object
+            status <number> HTTP status code
+            data <string> Data read from URL, or empty string
+    stalled <event> Fires when the connection is stalled
+        reason <string> Potential cause of the network problem
+@*/
+ + +

+ +
/*@
+foo <o> Demo object
+    array     <a> An array (and we don't care about the type of its elements)
+    boolean   <b> True or false
+    date      <d> Date object
+    element   <e> DOM element
+    function  <f> A function
+    number    <n> A number
+    object    <o> An object
+    regexp    <r> Regular Expression
+    string    <s> A string
+    undefined <u> undefined
+        Makes most sense for the result of a function that doesn't return,
+        or as the last of multiple types, to indicate a property may be missing
+    any_value <*> anything
+    event     <!> A custom event
+    example1  <[n]|u> An array of numbers, or undefined
+    example2  <s|'foo'> A string, default 'foo'
+@*/
+
+

foo bar

//@ My.TYPES <number> Request timeout, in seconds
@@ -68,7 +126,7 @@ My.readURL <f> Reads data from a remote URL
         timeout <n|60> Timeout in seconds
         type <s|'GET'> Request type ('GET', 'POST', 'PUT' or 'DELETE')
     callback <f> Callback function
-        result <o> Result object
+        result <o> Result object
             status <n> HTTP status code
             data <s> Data read from URL, or empty string
 @*/
diff --git a/source/Ox.UI/js/Calendar/Ox.Calendar.js b/source/Ox.UI/js/Calendar/Ox.Calendar.js
index b23c5319..0d5ec623 100644
--- a/source/Ox.UI/js/Calendar/Ox.Calendar.js
+++ b/source/Ox.UI/js/Calendar/Ox.Calendar.js
@@ -4,9 +4,9 @@
 
 /*@
 Ox.Calendar  Basic calendar object
-    () ->               Calendar object
-    (options) ->        Calendar object
-    (options, self) ->  Calendar object
+    () ->               Calendar object
+    (options) ->        Calendar object
+    (options, self) ->  Calendar object
     options  Options object
         date     UTC Date on which the calendar is centered
         events  <[o]|[]> Event objects to be displayed
diff --git a/source/Ox.UI/js/Code/Ox.DocPage.js b/source/Ox.UI/js/Code/Ox.DocPage.js
index 46f5878a..50c1a0b9 100644
--- a/source/Ox.UI/js/Code/Ox.DocPage.js
+++ b/source/Ox.UI/js/Code/Ox.DocPage.js
@@ -149,7 +149,7 @@ Ox.DocPage = function(options, self) {
                                     });
                                 })
                         )
-                        .append('' + Ox.toTitleCase(section) + '')
+                        .append('' + Ox.toTitleCase(section) + '')
                     );
                     if (section == 'examples') {
                         item.examples.forEach(function(example) {
diff --git a/source/Ox.UI/js/List/Ox.TreeList.js b/source/Ox.UI/js/List/Ox.TreeList.js
index f08e08af..7cd0d441 100644
--- a/source/Ox.UI/js/List/Ox.TreeList.js
+++ b/source/Ox.UI/js/List/Ox.TreeList.js
@@ -103,11 +103,6 @@ Ox.TreeList = function(options, self) {
                                 'symbol' + (data.expanded ? 'Down' : 'Right')
                             )
                         })
-                        .css({
-                            width: '10px',
-                            height: '10px',
-                            padding: '3px'
-                        })
                 )
                 .appendTo($item);
         }
@@ -251,9 +246,11 @@ Ox.TreeList = function(options, self) {
 
     self.setOption = function(key, value) {
         if (key == 'data') {
-            
+            // ...
+        } else if (key == 'selected') {
+            self.$list.options({selected: value});
         } else if (key == 'width') {
-            
+            // ...
         }
     };
 
diff --git a/source/Ox.UI/js/Panel/Ox.SplitPanel.js b/source/Ox.UI/js/Panel/Ox.SplitPanel.js
index f79495d2..eb57089c 100644
--- a/source/Ox.UI/js/Panel/Ox.SplitPanel.js
+++ b/source/Ox.UI/js/Panel/Ox.SplitPanel.js
@@ -1,10 +1,10 @@
 // vim: et:ts=4:sw=4:sts=4:ft=javascript
 'use strict';
 /*@
-Ox.SplitPanel  SpliPanel Object
-    () ->               SpliPanel Object
-    (options) ->        SpliPanel Object
-    (options, self) ->  SpliPanel Object
+Ox.SplitPanel  SpliPanel Object
+    () ->               SpliPanel Object
+    (options) ->        SpliPanel Object
+    (options, self) ->  SpliPanel Object
     options  Options object
         elements <[o]|[]> Array of two or three element objects
             collapsible  If true, can be collapsed (if outer element)
@@ -174,6 +174,18 @@ Ox.SplitPanel = function(options, self) {
         });
     }
 
+    /*@
+    getSize  get size of panel
+        (id) ->  id or position of panel, returns size
+        id  The element's id or position
+    @*/
+    // fixme: what is this? there is that.size()
+    that.getSize = function(id) {
+        var pos = Ox.isNumber(id) ? id : getPositionById(id),
+            element = self.options.elements[pos];
+		return element.element[self.dimensions[0]]() * !that.isCollapsed(pos);
+    };
+
     /*@
     isCollapsed  panel collapsed state
         (id) ->  id or position of panel, returns collapsed state
@@ -266,18 +278,6 @@ Ox.SplitPanel = function(options, self) {
 		}
     };
 
-    /*@
-    getSize  get size of panel
-        (id) ->  id or position of panel, returns size
-        id  The element's id or position
-    @*/
-    // fixme: what is this? there is that.size()
-    that.getSize = function(id) {
-        var pos = Ox.isNumber(id) ? id : getPositionById(id),
-            element = self.options.elements[pos];
-		return element.element[self.dimensions[0]]() * !that.isCollapsed(pos);
-    };
-
     /*@
     toggle  Toggles collapsed state of an outer element
         (id) ->  The SplitPanel
diff --git a/source/Ox.UI/js/Panel/Ox.TabPanel.js b/source/Ox.UI/js/Panel/Ox.TabPanel.js
index 96aa8e08..97029dbc 100644
--- a/source/Ox.UI/js/Panel/Ox.TabPanel.js
+++ b/source/Ox.UI/js/Panel/Ox.TabPanel.js
@@ -1,5 +1,20 @@
 // vim: et:ts=4:sw=4:sts=4:ft=javascript
 
+/*@
+Ox.TabPanel  Tabbed panel
+    (options) ->  Panel
+    (options, self) ->  Panel
+    options  Options
+        content  Content per tab
+            Either ({id1: $element1, id2: $element2}} or
+            function(id) { return $element; })
+        size  Height of the tab bar
+        tabs [o] Tabs
+            id  Tab id
+            title  Tab title
+    self  Shared private variable
+@*/
+
 'use strict';
 
 Ox.TabPanel = function(options, self) {
diff --git a/source/Ox/js/Collection.js b/source/Ox/js/Collection.js
index 9e752a49..d7c4d927 100644
--- a/source/Ox/js/Collection.js
+++ b/source/Ox/js/Collection.js
@@ -597,6 +597,8 @@ Ox.some  Tests if one or more elements of a collection satisfy a given condit
     true
     > Ox.some("foo", function(v) { return v == 'f'; })
     true
+    > Ox.some([false, 0, null, '', void 0])
+    false
 @*/
 Ox.some = function(obj, fn) {
     return Ox.filter(Ox.values(obj), fn || function(v) {
diff --git a/source/Ox/js/JavaScript.js b/source/Ox/js/JavaScript.js
index 0a67b9e8..f383b7cd 100644
--- a/source/Ox/js/JavaScript.js
+++ b/source/Ox/js/JavaScript.js
@@ -34,8 +34,8 @@ Ox.doc  Generates documentation for annotated JavaScript
             
     (source)  Array of documentation objects
     source  JavaScript source code
-    # > Ox.doc("//@ Ox.foo  just some string")
-    # [{"name": "Ox.foo", "summary": "just some string", "type": "string"}]
+    > Ox.doc("//@ My.FOO  Magic constant\nMy.FOO = 23;")
+    [{"name": "Ox.foo", "summary": "just some string", "type": "string"}]
 @*/
 
 Ox.doc = (function() {