diff --git a/lib/client.js b/lib/client.js index b09cad9d..23021ce7 100644 --- a/lib/client.js +++ b/lib/client.js @@ -152,39 +152,39 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; * @pParams = {name, path, func, dobefore, arg} */ function loadModule(pParams){ - if(!pParams) return; - - var lName = pParams.name, - lPath = pParams.path, - lFunc = pParams.func, - lDoBefore = pParams.dobefore; - - if( Util.isString(pParams) ) - lPath = pParams; - - if(lPath && !lName){ - lName = lPath[0].toUpperCase() + lPath.substring(1); - lName = Util.removeStr(lName, '.js'); + if(pParams){ + var lName = pParams.name, + lPath = pParams.path, + lFunc = pParams.func, + lDoBefore = pParams.dobefore; - var lSlash = lName.indexOf('/'); - if(lSlash > 0){ - var lAfterSlash = lName.substr(lSlash); - lName = Util.removeStr(lName, lAfterSlash); - } - } - - if( !Util.isContainStr(lPath, '.js') ) - lPath += '.js'; - - if(!CloudCmd[lName]) - CloudCmd[lName] = function(pArg){ - Util.exec(lDoBefore); + if( Util.isString(pParams) ) + lPath = pParams; + + if(lPath && !lName){ + lName = lPath[0].toUpperCase() + lPath.substring(1); + lName = Util.removeStr(lName, '.js'); - return DOM.jsload(CloudCmd.LIBDIRCLIENT + lPath, lFunc || - function(){ - Util.exec(CloudCmd[lName].init, pArg); - }); - }; + var lSlash = lName.indexOf('/'); + if(lSlash > 0){ + var lAfterSlash = lName.substr(lSlash); + lName = Util.removeStr(lName, lAfterSlash); + } + } + + if( !Util.isContainStr(lPath, '.js') ) + lPath += '.js'; + + if(!CloudCmd[lName]) + CloudCmd[lName] = function(pArg){ + Util.exec(lDoBefore); + + return DOM.jsload(CloudCmd.LIBDIRCLIENT + lPath, lFunc || + function(){ + Util.exec(CloudCmd[lName].init, pArg); + }); + }; + } } /** Конструктор CloudClient, который * выполняет весь функционал по @@ -216,7 +216,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; loadModule({ /* привязываем клавиши к функциям */ path : 'keyBinding.js', - func : function(){ + func : function(){ KeyBinding = CloudCmd.KeyBinding; KeyBinding.init(); } @@ -248,7 +248,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; for(var i = 0, n = pModules.length; i < n ; i++){ var lModule = pModules[i]; - if(Util.isString(lModule)) + if( Util.isString(lModule) ) lLoad(null, lModule, lDoBefore[lModule]); } @@ -273,14 +273,14 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; lFuncs =[ null, - null, /* f1 */ - DOM.renameCurrent, /* f2 */ - CloudCmd.Viewer, /* f3 */ - CloudCmd.Editor, /* f4 */ - DOM.copyCurrent, /* f5 */ - DOM.moveCurrent, /* f6 */ - DOM.promptNewFolder, /* f7 */ - DOM.promptDeleteCurrent,/* f8 */ + null, /* f1 */ + DOM.renameCurrent, /* f2 */ + CloudCmd.Viewer, /* f3 */ + CloudCmd.Editor, /* f4 */ + DOM.copyCurrent, /* f5 */ + DOM.moveCurrent, /* f6 */ + DOM.promptNewFolder, /* f7 */ + DOM.promptDeleteCurrent, /* f8 */ ]; for(var i = 1; i <= 8; i++){ @@ -310,7 +310,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; } /* загружаем общие функции для клиента и сервера */ - DOM.jsload(CloudCmd.LIBDIR + 'cloudfunc.js',function(){ + DOM.jsload(CloudCmd.LIBDIR + 'cloudfunc.js', function(){ DOM.addListener("popstate", function(pEvent) { var lPath = pEvent.state + '?json'; @@ -320,9 +320,6 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; return true; }); - /* берём из обьекта window общий с сервером функционал */ - CloudFunc = window.CloudFunc; - /* меняем ссылки на ajax'овые */ CloudCmd._changeLinks(CloudFunc.LEFTPANEL); CloudCmd._changeLinks(CloudFunc.RIGHTPANEL);