From 45f59f18c22d9a05bcab8dd4aeac72b24147da00 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 14:51:42 +0000 Subject: [PATCH] feature(cloudcmd) do not hide path and header when files are scrolling --- cloudcmd.js | 4 ++-- css/style.css | 6 ++++-- html/index.html | 2 +- html/path.html | 2 +- lib/client.js | 22 +++++++++++----------- lib/client/dom.js | 15 ++++++++++++++- lib/cloudfunc.js | 22 ++++++++++++++-------- 7 files changed, 47 insertions(+), 26 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 42b02abe..364d0d96 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -260,8 +260,8 @@ else { p.name = INDEX_PATH, lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate), - lList = '' + - ''; + lList = '
' + lPanel + '
' + + ''; main.sendResponse(p, indexProcessing({ additional : lList, diff --git a/css/style.css b/css/style.css index 66de819d..878d05cb 100644 --- a/css/style.css +++ b/css/style.css @@ -176,7 +176,6 @@ body { width: 46%; padding: 20px; margin: 0; - overflow-y: auto; border: 1.5px solid; border-color: rgb(49, 123, 249); border-color: rgba(49, 123, 249, .40); @@ -210,7 +209,10 @@ body { width: 23%; } -.panel, li { +.files { + overflow-y: auto; + padding: 0; + margin: 0; list-style-type: none; cursor: default; } diff --git a/html/index.html b/html/index.html index adcd949c..3b140811 100644 --- a/html/index.html +++ b/html/index.html @@ -84,7 +84,7 @@ Height = (Height / 100).toFixed() * 100; style = document.createElement('style'); - style.innerText = '.panel {' + + style.innerText = '.files {' + 'height:' + Height +'px;' + '}'; diff --git a/html/path.html b/html/path.html index ca997182..e876eea1 100644 --- a/html/path.html +++ b/html/path.html @@ -1 +1 @@ -
  • {{ path }}
  • \ No newline at end of file +
    {{ path }}
    \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index 2fe6e784..5564d13e 100644 --- a/lib/client.js +++ b/lib/client.js @@ -255,11 +255,9 @@ var Util, DOM, CloudFunc, CloudCmd; Util.exec(pCallBack); /* выделяем строку с первым файлом */ - var lFmHeader = DOM.getByClass('fm-header'); - if (lFmHeader && lFmHeader[0]) { - var lCurrent = lFmHeader[0].nextSibling; - DOM.setCurrentFile(lCurrent); - } + var lFiles = DOM.getFiles(); + if (lFiles) + DOM.setCurrentFile(lFiles[0]); Util.exec(CloudCmd.Key); } @@ -392,7 +390,8 @@ var Util, DOM, CloudFunc, CloudCmd; * @param pJSON - данные о файлах */ function createFileTable(pJSON) { - var panel = DOM.getPanel(), + var files, + panel = DOM.getPanel(), /* getting current element if was refresh */ lPath = DOM.getCurrentDirPath(panel), @@ -416,25 +415,26 @@ var Util, DOM, CloudFunc, CloudCmd; panel.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate, pLinkTemplate); + files = DOM.getFiles(panel); /* если нажали на ссылку на верхний каталог*/ var lFound; /* searching current file */ if (lWasRefresh_b) { - var n = panel.childNodes.length; - for(i = 2; i < n ; i++) { - var lVarCurrent = panel.childNodes[i], + var n = files.length; + for(i = 0; i < n ; i++) { + var lVarCurrent = files[i], lVarName = DOM.getCurrentName(lVarCurrent); lFound = lVarName === lName; if (lFound) { - lCurrent = panel.childNodes[i]; + lCurrent = files[i]; break; } } } if (!lFound) /* .. */ - lCurrent = panel.childNodes[2]; + lCurrent = files[0]; DOM.setCurrentFile(lCurrent); diff --git a/lib/client/dom.js b/lib/client/dom.js index 40261a7a..d342e14d 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1863,7 +1863,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param pPanel_o = {active: true} */ this.getPanel = function(pActive) { - var lPanel = this.getCurrentFile().parentElement; + var lPanel = this.getCurrentFile().parentElement.parentElement; /* if {active : false} getting passive panel */ if (pActive && !pActive.active) { @@ -1885,6 +1885,19 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lPanel; }; + this.getFiles = function() { + var files = DOM.getByClass('files')[0]; + + return files; + }; + + this.getFiles = function(element) { + var files = DOM.getByClass('files', element)[0], + ret = files.children || []; + + return ret; + }; + /** prevent default event */ this.preventDefault = function(pEvent) { var lRet, diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index f3b16e70..ea9afccb 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -339,20 +339,24 @@ var Util; lFileTable = Util.render(pPathTemplate, { link: FS + lRefreshPath, path: lHtmlPath + }), + + lHeader = Util.render(pTemplate, { + className : 'fm-header', + type : '', + name : 'name', + size : 'size', + owner : 'owner', + mode : 'mode' }); - lFileTable += Util.render(pTemplate, { - className : 'fm-header', - type : '', - name : 'name', - size : 'size', - owner : 'owner', - mode : 'mode' - }); + lHeader = Util.replaceStr(lHeader, 'li', 'div'); + lFileTable += lHeader; /* сохраняем путь */ CloudFunc.Path = lPath; + lFileTable += ''; + return lFileTable; }; }