From e38e88ac7d452a4b78e7dfa9a5fb036b40bde852 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 Jan 2014 08:17:22 -0500 Subject: [PATCH] refactor(client) initModules --- lib/client.js | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3dc3d1b4..f941401e 100644 --- a/lib/client.js +++ b/lib/client.js @@ -11,6 +11,7 @@ var Util, DOM, CloudFunc; function CloudCmdProto(Util, DOM, CloudFunc) { var Key, Config, Modules, Extensions, FileTemplate, PathTemplate, LinkTemplate, Listeners, + Images = DOM.Images, Info = DOM.CurrentInfo, CloudCmd = this, Storage = DOM.Storage; @@ -45,7 +46,7 @@ var Util, DOM, CloudFunc; lLink += '?json'; if (lLink || lCurrentLink.target !== '_blank') { - DOM.Images.showLoad(pNeedRefresh ? {top:true} : null); + Images.showLoad(pNeedRefresh ? {top:true} : null); /* загружаем содержимое каталога */ CloudCmd.ajaxLoad(lLink, { refresh: pNeedRefresh }); @@ -187,45 +188,48 @@ var Util, DOM, CloudFunc; }); CloudCmd.getModules(function(pModules) { - pModules = pModules || []; + pModules = pModules || []; - var i, n, lStorage = 'storage', - lShowLoadFunc = Util.retFunc( DOM.Images.showLoad, {top:true} ), + var i, n, module, storageObj, mod, name, path, + STORAGE = 'storage', + showLoadFunc = Images.showLoad.bind(null, { + top:true + }), - lDoBefore = { - 'edit' : lShowLoadFunc, - 'view' : lShowLoadFunc, - 'menu' : lShowLoadFunc + doBefore = { + 'edit' : showLoadFunc, + 'view' : showLoadFunc, + 'menu' : showLoadFunc }, - lLoad = function(pName, pPath, pDoBefore) { + load = function(name, path, func) { loadModule({ - path : pPath, - name : pName, - dobefore : pDoBefore + name : name, + path : path, + dobefore : func }); }; for (i = 0, n = pModules.length; i < n ; i++) { - var lModule = pModules[i]; + module = pModules[i]; - if ( Util.isString(lModule) ) - lLoad(null, lModule, lDoBefore[lModule]); + if (Util.isString(module)) + load(null, module, doBefore[module]); } - var lStorageObj = Util.findObjByNameInArr( pModules, lStorage ), - lMod = Util.getNamesFromObjArray( lStorageObj ); + storageObj = Util.findObjByNameInArr(pModules, STORAGE), + mod = Util.getNamesFromObjArray(storageObj); for (i = 0, n = lMod.length; i < n; i++) { - var lName = lMod[i], - lPath = lStorage + '/_' + lName.toLowerCase(); + name = mod[i], + path = STORAGE + '/_' + lName.toLowerCase(); - lLoad(lName, lPath); + load(lName, lPath); } Util.exec(pCallBack); - + }); }