forked from 0x2620/oxjs
app.launch
This commit is contained in:
parent
6117bc31c3
commit
1a1f8c9107
2 changed files with 85 additions and 17 deletions
|
|
@ -27,28 +27,34 @@ Core functions
|
|||
Ox.getset = function(obj, args, callback, context) {
|
||||
/*
|
||||
generic getter and setter function
|
||||
Ox.getset(obj) returns obj
|
||||
Ox.getset(obj, str) returns obj.str
|
||||
Ox.getset(obj, {key: val, ...}, callback, context) sets obj.key to val,
|
||||
calls callback(key, val),
|
||||
returns context
|
||||
Ox.getset(obj) returns obj
|
||||
Ox.getset(obj, [key]) returns obj.key
|
||||
Ox.getset(obj, [key, val], callback, context)
|
||||
Ox.getset(obj, [{key: val, ...}], callback, context) sets obj.key to val,
|
||||
calls callback(key, val),
|
||||
returns context
|
||||
*/
|
||||
var obj_ = obj,
|
||||
args = args || {},
|
||||
callback = callback || function() {},
|
||||
args_ = {},
|
||||
args = args || [],
|
||||
callback = callback || {},
|
||||
context = context || {},
|
||||
length = args.length,
|
||||
ret;
|
||||
if (length == 0) {
|
||||
// getset()
|
||||
ret = obj;
|
||||
} else if (length == 1 && typeof arguments[0] == "string") {
|
||||
} else if (length == 1 && Ox.isString(args[0])) {
|
||||
// getset(str)
|
||||
ret = obj[args[0]]
|
||||
} else {
|
||||
// getset(str, val) or getset({str: val, ...})
|
||||
// translate (str, val) to ({str: val})
|
||||
args = Ox.makeObject(args);
|
||||
if (length == 1) {
|
||||
args = args[0];
|
||||
} else {
|
||||
args_[args[0]] = args[1];
|
||||
args = args_;
|
||||
}
|
||||
obj = $.extend(obj, args);
|
||||
$.each(args, function(key, value) {
|
||||
if (!obj_ || !obj_[key] || obj_[key] !== value) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue