From 1892a263f45bf291af5078f4f65e6f64d7316b5e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 25 Jul 2013 14:48:04 +0000 Subject: [PATCH] feature(index) add "f9 - menu" button --- ChangeLog | 2 ++ README.md | 1 + html/index.html | 1 + lib/client.js | 5 +++-- lib/client/edit.js | 1 + lib/client/key.js | 10 ++++------ lib/client/menu.js | 31 ++++++++++++++++++++----------- 7 files changed, 32 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a693695..ff7cec9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -136,6 +136,8 @@ getJSONfromFileTable. * chore(css) .cmd-button {width: 10% -> 8%} +* feature(index) add "f9 - menu" button + 2012.04.22, v0.2.0 diff --git a/README.md b/README.md index 941fe70b..f2a4d6b0 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ There is a short list: - **F6** - rename/move - **F7** - new dir - **F8, Delete** - remove current file +- **F9** = menu - **Ctrl + r** - reload dir content - **Ctrl + d** - clear local cache (wich contains dir contents) - **Alt + q** - disable key bindings diff --git a/html/index.html b/html/index.html index 29788776..d40145bd 100644 --- a/html/index.html +++ b/html/index.html @@ -24,6 +24,7 @@ + diff --git a/lib/client.js b/lib/client.js index 3a33cf40..1fc1f2f1 100644 --- a/lib/client.js +++ b/lib/client.js @@ -234,14 +234,15 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.moveCurrent, /* f6 */ DOM.promptNewDir, /* f7 */ DOM.promptDeleteSelected, /* f8 */ + CloudCmd.Menu, /* f9 */ ]; - for (i = 1; i <= 8; i++) { + for (i = 1; i <= 9; i++) { lButton = 'f' + i, lEl = DOM.getById('f' + i); lKeysPanel[lButton] = lEl; - if( i === 1 || i === 3 || i === 4) + if (i === 1 || i === 3 || i === 4 || i === 9) Events.addOneTime('click', lFuncs[i], lEl); else Events.addClick(lFuncs[i], lEl); diff --git a/lib/client/edit.js b/lib/client/edit.js index 5bf5b2a7..2f692b08 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -29,6 +29,7 @@ var CloudCmd, Util, DOM, JsDiff, ace; ]); DOM.Events.addKey(listener); + DOM.setButtonKey('f4', Edit.show); delete Edit.init; }; diff --git a/lib/client/key.js b/lib/client/key.js index 751cdfdb..38cb11ab 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -38,7 +38,7 @@ var CloudCmd, Util, DOM; F6 : 117, F7 : 118, F8 : 119, - F10 : 121, + F9 : 120, TRA : 192 /* Typewritten Reverse Apostrophe (`) */ }; @@ -161,11 +161,9 @@ var CloudCmd, Util, DOM; DOM.promptDeleteCurrent(lCurrent); break; - case Key.F10: - if(lShift){ - Util.exec(CloudCmd.Menu); - DOM.preventDefault(pEvent); - } + case Key.F9: + Util.exec(CloudCmd.Menu); + DOM.preventDefault(pEvent); break; case Key.TRA: diff --git a/lib/client/menu.js b/lib/client/menu.js index ac7d3e98..8ce57b4c 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -2,10 +2,12 @@ * https://github.com/medialize/jQuery-contextMenu */ var CloudCmd, Util, DOM, CloudFunc, $; + (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; var Key = CloudCmd.Key, + Events = DOM.Events, MenuSeted = false, Menu = {}, Position, @@ -212,7 +214,6 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.anyLoadInParallel(lFiles, function(){ Util.timeEnd('menu load'); - $.contextMenu.handle.keyStop = $.noop; Util.exec(pCallBack); }); } @@ -224,7 +225,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; * layer wich hides all elements of * Cloud Commander so it could not handle * onclick events. To get every thing work - * how expected we remove invisible layer + * how expected we hide invisible layer * so for observer it is nothing special * is not going on. All magic happening in * DOM tree. @@ -232,7 +233,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; function clickProcessing(){ var lLayer = DOM.getById('context-menu-layer'); if(lLayer){ - document.body.removeChild(lLayer); + DOM.hide(lLayer); var lElement = document.elementFromPoint(Position.x, Position.y), lTag = lElement.tagName; @@ -247,6 +248,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.setCurrentFile(lElement); } + DOM.show(lLayer); Key.setBind(); } } @@ -290,20 +292,27 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.jqueryLoad ]); - DOM.Events.addKey( lListener ); + Events.addKey( lListener ); + + DOM.setButtonKey('f9', function(){ + var lCurrent = DOM.getCurrentFile(), + lEvent = Events.create('contextmenu'); + + Events.dispatch(lEvent, lCurrent); + }); function lListener(pEvent){ - var lF10 = Key.F10, + var lCurrent, + lF9 = Key.F9, lESC = Key.ESC, lKey = pEvent.keyCode, - lShift = pEvent.shiftKey, lIsBind = Key.isBind(); - if( lIsBind ){ - if(lKey === lF10 && lShift){ - $( DOM.getCurrentFile() ).contextMenu(); - DOM.preventDefault(pEvent); - } + if (lIsBind && lKey === lF9) { + lCurrent = DOM.getCurrentFile(); + $(lCurrent).contextmenu(); + + DOM.preventDefault(pEvent); } else if (lKey === lESC) Key.setBind();