From 0f10839fc137aae192d4354e31561ff73b0b4ba8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 16 Aug 2012 03:57:44 -0400 Subject: [PATCH] added function getRefreshButton --- client.js | 64 ++++++++++++++++++++++++++-------------- lib/client/keyBinding.js | 5 +--- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/client.js b/client.js index 13afdbca..d2acae51 100644 --- a/client.js +++ b/client.js @@ -367,13 +367,25 @@ CloudClient.Util = (function(){ this.getById = function(pId){return document.getElementById(pId);}; + /* + * Function search element by class name + * @pClass - className + * @pElement - element + */ this.getByClass = (CloudCommander.OLD_BROWSER)? - function(pClass){ - return window.jQuery('.'+pClass); + function(pClass, pElement){ + var lClass = '.' + pClass; + var lResult; + + if(pElement) + lResult = pElement.find(lClass); + else lResult = $.find(lClass); + + return lResult; } - :function(pClass){ - return document.getElementsByClassName(pClass); + :function(pClass, pElement){ + return (pElement || document).getElementsByClassName(pClass); }; /* private members */ @@ -433,18 +445,8 @@ CloudClient.Util = (function(){ var lCurrent; if(pPosition && pPosition.top){ - lCurrent = Util.getByClass(CloudFunc.REFRESHICON); - - if (lCurrent.length) - lCurrent = lCurrent[0].parentElement; - else { - this.addCloudStatus({ - code : -3, - msg : 'Error Refresh icon not found' - }); - - lRet_b = false; - } + lCurrent = this.getRefreshButton(); + if(!lCurrent) lRet_b = false; } else { @@ -458,13 +460,14 @@ CloudClient.Util = (function(){ * heppen */ if(lRet_b){ - var lParent = lLoadingImage.parentElement; - if(!lParent || - (lParent && lParent !== lCurrent)) - lCurrent.appendChild(lLoadingImage); - - lLoadingImage.className = 'icon loading'; /* показываем загрузку*/ + var lParent = lLoadingImage.parentElement; + if(!lParent || + (lParent && lParent !== lCurrent)) + lCurrent.appendChild(lLoadingImage); + + lLoadingImage.className = 'icon loading'; /* показываем загрузку*/ } + return lRet_b; }, @@ -513,6 +516,23 @@ CloudClient.Util = (function(){ return lCurrent; }; + this.getRefreshButton = function(){ + var lPanel = this.getPanel(); + var lRefresh = this.getByClassName(CloudFunc.REFRESHICON, lPanel); + + if (lRefresh.length) + lRefresh = lRefresh[0].parentElement; + else { + this.addCloudStatus({ + code : -3, + msg : 'Error Refresh icon not found' + }); + lRefresh = false; + } + + return lRefresh; + }; + this.setCurrentFile = function(pCurrentFile){ var lRet_b = true; diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index a1176a42..b78c955c 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -288,10 +288,7 @@ CloudCommander.keyBinding = (function(){ /* Программно нажимаем на кнопку перезагрузки * содержимого каталога */ - var lRefreshIcon = Util - .getByClass(CloudFunc.REFRESHICON); - - if(lRefreshIcon)lRefreshIcon = lRefreshIcon[0]; + var lRefreshIcon = Util.getRefreshButton(); if(lRefreshIcon){ /* находим файл который сейчас выделен */ lCurrentFile = Util.getCurrentFile();