Ox.App: clean up code and documentation
This commit is contained in:
parent
79bea33e51
commit
0fc6e09927
1 changed files with 22 additions and 23 deletions
|
@ -3,12 +3,12 @@
|
|||
/*@
|
||||
Ox.App <f> Basic application instance that communicates with a JSON API
|
||||
([options]) -> <o> App object
|
||||
load <!> app loaded
|
||||
load <!> App loaded
|
||||
options <o> Options object
|
||||
timeout <n> request timeout
|
||||
type <s> HTTP Request type, i.e. 'GET' or 'POST'
|
||||
url <s> JSON API url
|
||||
self <o> Shared private variable
|
||||
name <s> App name
|
||||
timeout <n> Request timeout
|
||||
type <s> HTTP Request type, i.e. 'GET' or 'POST'
|
||||
url <s> JSON API URL
|
||||
@*/
|
||||
|
||||
Ox.App = function(options) {
|
||||
|
@ -24,17 +24,14 @@ Ox.App = function(options) {
|
|||
},
|
||||
that = Ox.Element({}, Ox.extend({}, self));
|
||||
|
||||
//@ api <o> api endpoint
|
||||
//@ api <o> API endpoint
|
||||
that.api = Ox.API({
|
||||
type: self.options.type,
|
||||
timeout: self.options.timeout,
|
||||
url: self.options.url
|
||||
}, function() {
|
||||
that.api.init(getUserData(), function(result) {
|
||||
//Ox.UI.hideLoadingScreen();
|
||||
that.triggerEvent({
|
||||
load: result.data
|
||||
});
|
||||
that.triggerEvent({load: result.data});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -43,15 +40,9 @@ Ox.App = function(options) {
|
|||
|
||||
function getUserData() {
|
||||
return {
|
||||
document: {
|
||||
referrer: document.referrer
|
||||
},
|
||||
history: {
|
||||
length: history.length
|
||||
},
|
||||
location: {
|
||||
href: location.href
|
||||
},
|
||||
document: {referrer: document.referrer},
|
||||
history: {length: history.length},
|
||||
location: {href: location.href},
|
||||
navigator: {
|
||||
cookieEnabled: navigator.cookieEnabled,
|
||||
plugins: Ox.toArray(navigator.plugins).map(function(plugin) {
|
||||
|
@ -72,13 +63,21 @@ Ox.App = function(options) {
|
|||
};
|
||||
}
|
||||
|
||||
function update() {
|
||||
// ...
|
||||
}
|
||||
|
||||
/*@
|
||||
options <f> get/set options, see Ox.getset
|
||||
() -> <o> get options
|
||||
(options) -> <o> update/set options
|
||||
options <f> Gets or sets options (see Ox.getset)
|
||||
() -> <o> All options
|
||||
(key) -> <*> The value of option[key]
|
||||
(key, value) -> <o> Sets one option, returns App object
|
||||
({key: value, ...}) -> <o> Sets multiple options, returns App object
|
||||
key <s> The name of the option
|
||||
value <*> The value of the option
|
||||
@*/
|
||||
that.options = function() {
|
||||
return Ox.getset(self.options, Array.prototype.slice.call(arguments), self.change, that);
|
||||
return Ox.getset(self.options, arguments, update, that);
|
||||
};
|
||||
|
||||
return that;
|
||||
|
|
Loading…
Reference in a new issue