mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(menu) getItem
This commit is contained in:
parent
fd7b798527
commit
dfaa4f8054
1 changed files with 11 additions and 12 deletions
|
|
@ -96,29 +96,28 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
/**
|
||||
* get menu item
|
||||
*/
|
||||
function getItem(pName, pCallBack) {
|
||||
var lRet,
|
||||
name = pName,
|
||||
function getItem(name, callback) {
|
||||
var ret,
|
||||
icon = name && name.toLowerCase();
|
||||
|
||||
icon = Util.removeStr(icon, ['(', ')']);
|
||||
icon = Util.replaceStr(icon, ' ', '-');
|
||||
|
||||
lRet = {
|
||||
name : pName,
|
||||
ret = {
|
||||
name : name,
|
||||
icon : icon
|
||||
};
|
||||
|
||||
if (Util.isFunction(pCallBack))
|
||||
lRet.callback = pCallBack;
|
||||
if (Util.isFunction(callback))
|
||||
ret.callback = callback;
|
||||
|
||||
else if (Util.isObject(pCallBack))
|
||||
if (pCallBack.name)
|
||||
lRet.items = pCallBack;
|
||||
else if (Util.isObject(callback))
|
||||
if (callback.name)
|
||||
ret.items = callback;
|
||||
else
|
||||
lRet.items = getAllItems(pCallBack);
|
||||
ret.items = getAllItems(callback);
|
||||
|
||||
return lRet;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue