From 7d5b253337eb1012cef8f78ccc7c262bc5ab0f62 Mon Sep 17 00:00:00 2001 From: sandeepjain88 Date: Thu, 26 Sep 2013 10:51:40 +0530 Subject: [PATCH 1/2] Recent Projects - Pressing delete key removes project from list --- src/extensions/default/RecentProjects/main.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/extensions/default/RecentProjects/main.js b/src/extensions/default/RecentProjects/main.js index 654cfad26e0..793dfbc9f2f 100644 --- a/src/extensions/default/RecentProjects/main.js +++ b/src/extensions/default/RecentProjects/main.js @@ -178,6 +178,35 @@ define(function (require, exports, module) { removeDeleteButton(); } + /** + * Deletes the selected item and + * move the focus to next item in list. + * + * @return {boolean} TRUE if project is removed + */ + function removeSelectedItem(e) { + var recentProjects = getRecentProjects(), + $cacheItem = $dropdownItem, + index = recentProjects.indexOf($cacheItem.data("path")); + + // When focus is not on project item + if (index === -1) { + return false; + } + + // remove project + recentProjects.splice(index, 1); + prefs.setValue("recentProjects", recentProjects); + checkHovers(e.pageX, e.pageY); + + if (recentProjects.length === 1) { + $dropdown.find(".divider").remove(); + } + selectNextItem(+1); + $cacheItem.closest("li").remove(); + return true; + } + /** * Handles the Key Down events * @param {KeyboardEvent} event @@ -202,6 +231,13 @@ define(function (require, exports, module) { } keyHandled = true; break; + case KeyEvent.DOM_VK_BACK_SPACE: + case KeyEvent.DOM_VK_DELETE: + keyHandled = true; + if ($dropdownItem) { + removeSelectedItem(event); + } + break; } if (keyHandled) { From 5ea1a681d48be616b379787669f112aa2c32fe9b Mon Sep 17 00:00:00 2001 From: Sandeep Jain Date: Wed, 9 Oct 2013 21:15:50 +0530 Subject: [PATCH 2/2] Allow event propogation even when there is no dropdown item. --- src/extensions/default/RecentProjects/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/default/RecentProjects/main.js b/src/extensions/default/RecentProjects/main.js index 793dfbc9f2f..4a936453bf0 100644 --- a/src/extensions/default/RecentProjects/main.js +++ b/src/extensions/default/RecentProjects/main.js @@ -233,9 +233,9 @@ define(function (require, exports, module) { break; case KeyEvent.DOM_VK_BACK_SPACE: case KeyEvent.DOM_VK_DELETE: - keyHandled = true; if ($dropdownItem) { removeSelectedItem(event); + keyHandled = true; } break; }