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
|
Ox.App <f> Basic application instance that communicates with a JSON API
|
||||||
([options]) -> <o> App object
|
([options]) -> <o> App object
|
||||||
load <!> app loaded
|
load <!> App loaded
|
||||||
options <o> Options object
|
options <o> Options object
|
||||||
timeout <n> request timeout
|
name <s> App name
|
||||||
|
timeout <n> Request timeout
|
||||||
type <s> HTTP Request type, i.e. 'GET' or 'POST'
|
type <s> HTTP Request type, i.e. 'GET' or 'POST'
|
||||||
url <s> JSON API url
|
url <s> JSON API URL
|
||||||
self <o> Shared private variable
|
|
||||||
@*/
|
@*/
|
||||||
|
|
||||||
Ox.App = function(options) {
|
Ox.App = function(options) {
|
||||||
|
@ -24,17 +24,14 @@ Ox.App = function(options) {
|
||||||
},
|
},
|
||||||
that = Ox.Element({}, Ox.extend({}, self));
|
that = Ox.Element({}, Ox.extend({}, self));
|
||||||
|
|
||||||
//@ api <o> api endpoint
|
//@ api <o> API endpoint
|
||||||
that.api = Ox.API({
|
that.api = Ox.API({
|
||||||
type: self.options.type,
|
type: self.options.type,
|
||||||
timeout: self.options.timeout,
|
timeout: self.options.timeout,
|
||||||
url: self.options.url
|
url: self.options.url
|
||||||
}, function() {
|
}, function() {
|
||||||
that.api.init(getUserData(), function(result) {
|
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() {
|
function getUserData() {
|
||||||
return {
|
return {
|
||||||
document: {
|
document: {referrer: document.referrer},
|
||||||
referrer: document.referrer
|
history: {length: history.length},
|
||||||
},
|
location: {href: location.href},
|
||||||
history: {
|
|
||||||
length: history.length
|
|
||||||
},
|
|
||||||
location: {
|
|
||||||
href: location.href
|
|
||||||
},
|
|
||||||
navigator: {
|
navigator: {
|
||||||
cookieEnabled: navigator.cookieEnabled,
|
cookieEnabled: navigator.cookieEnabled,
|
||||||
plugins: Ox.toArray(navigator.plugins).map(function(plugin) {
|
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
|
options <f> Gets or sets options (see Ox.getset)
|
||||||
() -> <o> get options
|
() -> <o> All options
|
||||||
(options) -> <o> update/set 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() {
|
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;
|
return that;
|
||||||
|
|
Loading…
Reference in a new issue