1
0
Fork 0
forked from 0x2620/oxjs

some documentation

This commit is contained in:
j 2011-05-16 10:24:46 +02:00
commit bdb8d98787
45 changed files with 775 additions and 255 deletions

View file

@ -1,32 +1,21 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
/*
============================================================================
Application
============================================================================
*/
// fixme: get rid of launch, fire load event
/*@
Ox.App <f> Basic application instance that communicates with a JSON API
() -> <f> App object
(options) -> <f> App object
(options, self) -> <f> App object
options <o> Options object
timeout <n> request timeout
type <s> 'GET' or 'POST'
url <s> JSON API url
self <o> Shared private variable
load <!> app loaded
@*/
Ox.App = (function() {
/***
Ox.App
Basic application instance that communicates with a JSON API.
The JSON API must support at least the following actions:
api returns all api methods
init returns data (site, user, ...)
Options
timeout API timeout in msec
type 'GET' or 'POST'
url URL of the API
Methods
api[action] make a request
api.cancel cancel a request
options get or set options
Events
load app loaded
***/
return function(options) {
options = options || {};
@ -61,6 +50,12 @@ Ox.App = (function() {
url: self.options.url
});
/*@
api <o> bakcend API
[action] <f> all api requests available on backend
cancel <f> cancel a request
options <f> get or set options
@*/
that.api.api(function(result) {
Ox.forEach(result.data.actions, function(val, key) {
that.api[key] = function(data, callback) {

View file

@ -1,12 +1,15 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
/*@
Ox.Clipboard <f> Basic clipboard handler
() -> <o> Clipboard object
(options) -> <o> Clipboard object
(options, self) -> <o> Clipboard object
copy(data) <f> copy data to clipboard
paste <f> paste data from clipboard
options <o> Options object
self <o> Shared private variable
@*/
Ox.Clipboard = function() {
/***
Ox.Clipboard
Basic clipboard handler
Methods
copy(data) copy data to clipboard
paste paste data from clipboard
***/
var clipboard = {};
return {
_print: function() {

View file

@ -4,6 +4,14 @@
// 0, 1, 2, etc, so that append would append 0, and appendTo
// would append (length - 1)?
/*@
Ox.Container <f> Container
() -> <o> Container object
(options) -> <o> Container object
(options, self) -> <o> Container object
options <o> Options object
self <o> Shared private variable
@*/
Ox.Container = function(options, self) {
// fixme: to be deprecated
var that = new Ox.Element({}, self)

View file

@ -1,3 +1,11 @@
/*@
Ox.DocPage <f> DocPage
() -> <o> DocPage object
(options) -> <o> DocPage object
(options, self) -> <o> DocPage object
options <o> Options object
self <o> Shared private variable
@*/
Ox.DocPage = function(options, self) {
self = self || {};
@ -162,4 +170,4 @@ Ox.DocPage = function(options, self) {
return that;
};
};

View file

@ -1,5 +1,19 @@
/*@
Ox.DocPanel <f> Documentation Panel
() -> <f> Documentation Panel
(options) -> <f> Documentation Panel
(options, self) -> <f> Documentation Panel
options <o> Options object
collapsible <b|true> can be collabsed
files <a|[]> files to parse for docs
getModule <f> returns module for given item
getSection <f> returns section for given item
path <s|''> path prefix
resizable <b|true> is resizable
resize <a|[128, 256, 384]> resize positions
size <s|256> default size
self <o> shared private variable
load <!> fired once all docs are loaded
@*/
Ox.DocPanel = function(options, self) {
@ -43,6 +57,7 @@ Ox.DocPanel = function(options, self) {
loadList(function(docItems) {
self.items = docItems;
that.triggerEvent('load', {});
});
function loadList(callback) {
@ -58,6 +73,7 @@ Ox.DocPanel = function(options, self) {
}
});
});
function makeTree(docItems) {
var treeItems = [];
docItems.forEach(function(docItem) {
@ -145,6 +161,7 @@ Ox.DocPanel = function(options, self) {
});
}
}
that.triggerEvent('select', data);
}
function sortByTitle(a, b) {
@ -156,7 +173,14 @@ Ox.DocPanel = function(options, self) {
}
return ret;
}
/*@
selectItem <f> select item
(id) -> <u> select an item
id <s> if of item to select
@*/
that.selectItem = function(id) {
self.$list.triggerEvent('select', {'ids': [id]});
}
return that;
};
};

View file

@ -1,4 +1,14 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
/*@
Ox.LoadingIcon <f:Ox.Element> Loading Icon Element
() -> <f> Loading Icon Element
(options) -> <f> Loading Icon Element
(options, self) -> <f> Loading Icon Element
options <o> Options object
size <s|medium> size of icon
self <o> Shared private variable
@*/
Ox.LoadingIcon = function(options, self) {
var self = self || {},
that = new Ox.Element('<img>', self)
@ -12,12 +22,20 @@ Ox.LoadingIcon = function(options, self) {
.addClass(
'OxLoadingIcon Ox' + Ox.toTitleCase(self.options.size)
);
/*@
start <f> Start loading animation
() -> <f> Loading Icon Element
@*/
that.start = function() {
that.animate({
opacity: 1
}, 250);
return that;
};
/*@
stop <f> Stop loading animation
() -> <f> Loading Icon Element
@*/
that.stop = function() {
that.animate({
opacity: 0

View file

@ -1,18 +1,14 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
Ox.Request = function(options) {
/*@
Ox.Request <o> Basic request handler object
FIXME: options is not a property, just documenting defaults
options <o> Options object
timeout <n|60000> request timeout
type <s|POST> request type, possible values POST, GET, PUT, DELETE
url <s> request url
@*/
/***
Ox.Request
Basic request handler
Options
timeout
Methods
cancel() cancel request
clearCache() clear cache
options() get or set options
requests() return number of active requests
send() send request
***/
Ox.Request = function(options) {
var cache = {},
//dfd = $.Deferred(),
@ -27,7 +23,12 @@ Ox.Request = function(options) {
};
return {
/*@
cancel <f> cancel pending requests
() -> <u> cancel all requests
(f) -> <u> cancel all requests where function returns true
(n) -> <u> cancel request by id
@*/
cancel: function() {
if (arguments.length == 0) {
// cancel all requests
@ -44,19 +45,42 @@ Ox.Request = function(options) {
delete requests[arguments[0]];
}
},
/*@
clearCache <f> clear cached results
() -> <u>
@*/
clearCache: function() {
cache = {};
},
/*@
options <f> get/set options
() -> <o> get options
(options) -> <o> set options
options <o> Options Object
@*/
options: function(options) {
return Ox.getset(self.options, options, $.noop(), this);
},
/*@
requests <f> pending requests
() -> <n> returns number of requests
@*/
requests: function() {
return Ox.len(requests);
},
/*@
send <f> send request
(options) -> <n> returns request id
options <o> Options Object
age <n|-1> cache age
id <n|Ox.uid()> request id
timeout <n|self.options.timeout> overwrite default timeout
type <n|self.options.timeout> overwrite default type
url <n|self.options.timeout> overwrite default url
@*/
send: function(options) {
var options = $.extend({

View file

@ -1,14 +1,15 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
// fixme: this should be Ox.Theme, and provide Ox.Theme.set(), Ox.Theme.load, etc.
/**
if name is given as argument, switch to this theme.
return current theme otherwise.
Ox.theme()
get theme
Ox.theme('foo')
set theme to 'foo'
*/
/*@
Ox.Theme <f> get/set theme
() -> <s> Get current theme
(theme) -> <s> Set current theme
theme <s> name of theme
> Ox.Theme()
'classic'
> Ox.Theme('modern')
'modern'
@*/
Ox.Theme = function(theme) {