From 18dbff9d22900e29758e8015e49dbb792b1c8c3f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Dec 2012 06:50:04 -0500 Subject: [PATCH] Added ability to delete files (not for real for now) thru keys panel (F8) --- ChangeLog | 4 ++++ lib/client.js | 16 ++++++++-------- lib/client/dom.js | 21 ++++++++++++++++----- lib/client/keyBinding.js | 2 +- lib/client/menu.js | 2 +- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3007bf8f..825d17ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -176,6 +176,10 @@ Editor window could not be cloused. * Fixed IP on windows. +* Added ability to delete files (not for real for now) +thru keys panel (F8). + + 2012.10.01, Version 0.1.7 * Changed name of menu files, fixed npm and jitsu diff --git a/lib/client.js b/lib/client.js index a500906c..ae3e3767 100644 --- a/lib/client.js +++ b/lib/client.js @@ -386,14 +386,14 @@ function initKeysPanel(pCallBack){ lFuncs =[ null, - null, /* f1 */ - null, /* f2 */ - cloudcmd.Viewer, /* f3 */ - cloudcmd.Editor, /* f4 */ - null, /* f5 */ - null, /* f6 */ - null, /* f7 */ - null, /* f8 */ + null, /* f1 */ + null, /* f2 */ + cloudcmd.Viewer, /* f3 */ + cloudcmd.Editor, /* f4 */ + null, /* f5 */ + null, /* f6 */ + null, /* f7 */ + DOM.promptRemoveCurrent,/* f8 */ ]; for(var i = 1; i <= 8; i++){ diff --git a/lib/client/dom.js b/lib/client/dom.js index 4b19067b..13272b85 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -270,13 +270,24 @@ var CloudCommander, Util, DOM, CloudFunc; * * @pCurrentFile */ - DOM.delete = function(pCurrentFile){ - var lMsg = 'Are you sure thet you wont delete ', - lName = DOM.getCurrentName(pCurrentFile), - lRet = confirm(lMsg + lName + '?'); + DOM.promptRemoveCurrent = function(pCurrentFile){ + var lRet, + lCurrent, + lName, + lMsg = 'Are you sure thet you wont delete '; + + /* dom element passed and it is not event */ + if(pCurrentFile && !pCurrentFile.type) + lCurrent = pCurrentFile; + + lName = DOM.getCurrentName(lCurrent); + + lRet = confirm(lMsg + lName + '?'); if(lRet) - DOM.removeCurrent(pCurrentFile); + DOM.removeCurrent(lCurrent); + + return lRet; }; /** diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 51cc700d..89f16980 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -117,7 +117,7 @@ var CloudCommander, Util, DOM; event.preventDefault();//запрет на дальнейшее действие } else if(lKeyCode === KEY.Delete) - DOM.delete(lCurrentFile); + DOM.promptRemoveCurrent(lCurrentFile); /* if f3 or shift+f3 or alt+f3 pressed */ else if(lKeyCode === KEY.F3){ diff --git a/lib/client/menu.js b/lib/client/menu.js index 4ed5b91d..ab18b7b1 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -59,7 +59,7 @@ var CloudCommander, Util, DOM, CloudFunc, $; delete: {name: 'Delete', callback: function(key, opt){ - DOM.delete(); + DOM.promptRemoveCurrent(); }}, upload: {