From b67744e495b073109097d0a1d533eac5663243f0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 7 Nov 2012 04:26:09 -0500 Subject: [PATCH] moved bind function to util.js from dom.js --- client.js | 14 +++++++------- lib/client/dom.js | 19 ++++++------------- lib/client/editor/_codemirror.js | 2 +- lib/util.js | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/client.js b/client.js index 1f1def13..377090b8 100644 --- a/client.js +++ b/client.js @@ -200,6 +200,7 @@ CloudClient._loadDir = function(pLink,pNeedRefresh){ * выполнить загрузку */ return function(){ + var lRet = true; /* показываем гиф загрузки возле пути папки сверху*/ /* ctrl+r нажата? */ @@ -240,7 +241,7 @@ CloudClient._loadDir = function(pLink,pNeedRefresh){ * возвращаем false на событие * onclick */ - return true; + return lRet; }; }; @@ -297,7 +298,7 @@ CloudClient._setCurrent = function(){ var lCurrentFile = DOM.getCurrentFile(); if(lCurrentFile){ if (DOM.isCurrentFile(this) && - typeof pFromEnter !== 'boolean'){ + !Util.isBoolean(pFromEnter)){ //var lParent = this; //setTimeout(function(){ @@ -312,18 +313,17 @@ CloudClient._setCurrent = function(){ // },1000); } else{ - /* устанавливаем курсор на файл, - * на который нажали */ + /* устанавливаем курсор на файл, на который нажали */ DOM.setCurrentFile(this); } } - /* если мы попали сюда с энтера*/ + /* если мы попали сюда с энтера */ if(pFromEnter===true){ - var lResult = Util.exec( DOM.bind(this.ondblclick, this) ); + var lResult = Util.exec( Util.bind(this.ondblclick, this) ); /* enter pressed on file */ if(!lResult){ var lA = DOM.getCurrentLink(this); - Util.exec( DOM.bind(lA.ondblclick, this) ); + Util.exec( Util.bind(lA.ondblclick, this) ); } }/* если мы попали сюда от клика мышки */ else diff --git a/lib/client/dom.js b/lib/client/dom.js index a0b28205..c4997093 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -127,12 +127,7 @@ var CloudCommander, $, Util, DOM; } else $.ajax(pParams); }; - - /* setting function context (DOM) */ - DOM.bind = function(pFunction, pContext){ - return pFunction.bind(pContext); - }; - + /* * Function gets id by src * from http://domain.com/1.js to @@ -159,8 +154,7 @@ var CloudCommander, $, Util, DOM; return DOM.loadOnload(pFunc_a); } - else if( Util.isFunction(pFunc_a) ) - return pFunc_a(); + else return Util.exec(pFunc_a); }; DOM.anyLoadOnLoad = function(pParams_a, pFunc){ @@ -178,8 +172,7 @@ var CloudCommander, $, Util, DOM; DOM.anyload(lParam); - }else if( Util.isFunction(pFunc) ) - pFunc(); + }else Util.exec(pFunc); } }; @@ -295,8 +288,7 @@ var CloudCommander, $, Util, DOM; status : 404 }); - if( Util.isFunction(lOnError) ) - lFunc(); + Util.exec(lOnError); }); if(pParams_o.style){ @@ -316,7 +308,8 @@ var CloudCommander, $, Util, DOM; /* если js-файл уже загружен * запускаем функцию onload */ - else if( Util.isFunction(lFunc) ) lFunc(); + else + Util.exec(lFunc); return element; }, diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index b049185a..565ae2fd 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -204,7 +204,7 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror; /* if f4 or f3 pressed */ var lF3 = cloudcmd.KEY.F3; var lF4 = cloudcmd.KEY.F4; - var lShow = DOM.bind( CodeMirrorEditor.show, CodeMirrorEditor ); + var lShow = Util.bind( CodeMirrorEditor.show, CodeMirrorEditor ); if(!pEvent.shiftKey){ switch(pEvent.keyCode) diff --git a/lib/util.js b/lib/util.js index b5fc1cf6..4d402e26 100644 --- a/lib/util.js +++ b/lib/util.js @@ -6,6 +6,20 @@ var Util, exports; Util = exports || {}; + /** setting function context + * @param {function} pFunction + * @param {object} pContext + */ + Util.bind = function(pFunction, pContext){ + var lRet = false; + + if( Util.isFunction(pFunction) ) + lRet = pFunction.bind(pContext); + + return lRet; + }; + + /* STRINGS */ /** * function check is strings are equal