From f96ce05974a6aa0bd7b1dd8f9d9b9a3bb6f6c7e1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 7 Aug 2012 09:29:23 -0400 Subject: [PATCH] added ability to move with Page Up and Page Down --- lib/client/keyBinding.js | 52 +++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 8d2f87cc..ae5f69ea 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -11,8 +11,8 @@ CloudCommander.keyBinding=(function(){ }; var key_event=function(event){ - var lCurrentFile; - var lName, lTop; + var lCurrentFile, + lName, lTop, i; /* если клавиши можно обрабатывать*/ if(CloudCommander.keyBinded){ /* если нажали таб: @@ -129,11 +129,11 @@ CloudCommander.keyBinding=(function(){ .scrollByLines(2) || '!'); } } - /* если нажали клавишу page up или Home + /* если нажали клавишу Home * переходим к самому верхнему * элементу */ - else if(/*event.keyCode===33 ||*/ event.keyCode===36){ + else if(event.keyCode === 36){ lCurrentFile = Util.getCurrentFile(); /* убираем выделение с текущего файла*/ lCurrentFile.className=''; @@ -146,11 +146,11 @@ CloudCommander.keyBinding=(function(){ /* move scrollbar to top */ Util.getPanel().scrollByLines(-100000000000000); - } - /* если нажали клавишу page down или End + } + /* если нажали клавишу End * выделяем последний элемент */ - else if(/*event.keyCode===34 ||*/ event.keyCode===35){ + else if( event.keyCode === 35){ lCurrentFile = Util.getCurrentFile(); /* снимаем выделение с текущего файла*/ lCurrentFile.className=''; @@ -161,8 +161,44 @@ CloudCommander.keyBinding=(function(){ /* move scrollbar to bottom*/ Util.getPanel().scrollByLines(100000000000000); } + /* если нажали клавишу page down + * проматываем экран + */ + else if(event.keyCode === 34){ + Util.getPanel().scrollByPages(1); + + lCurrentFile = Util.getCurrentFile(); + for(i=0; i<30; i++){ + if(!lCurrentFile.nextSibling) break; + + lCurrentFile = lCurrentFile.nextSibling; + } + Util.getCurrentFile().className = ''; + lCurrentFile.className = CloudCommander.CURRENT_FILE; + } + /* если нажали клавишу page up + * проматываем экран + */ + else if(event.keyCode === 33){ + Util.getPanel().scrollByPages(-1); + + lCurrentFile = Util.getCurrentFile(); + for(i=0; i<30; i++){ + if(!lCurrentFile.previousSibling) break; + else try{ + lCurrentFile + .previousSibling + .previousSibling + .previousSibling + .previousSibling; + } catch(pError){break}; + lCurrentFile = lCurrentFile.previousSibling; + } + Util.getCurrentFile().className = ''; + lCurrentFile.className = CloudCommander.CURRENT_FILE; + } /* если нажали Enter - открываем папку*/ - else if(event.keyCode===13){ + else if(event.keyCode === 13){ lCurrentFile = Util.getByClass(CloudCommander.CURRENT_FILE); /* если ненайдены выделенные файлы - выходим*/ if(!lCurrentFile.length)return;