-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Added button to remove projects from the recent project dropdown. #1757
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ define(function (require, exports, module) { | |
var prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_KEY), | ||
recentProjects = prefs.getValue("recentProjects") || [], | ||
i; | ||
for (i = 0; i < recentProjects.length; i++) { | ||
for (i = 0; i < recentProjects.length; i++) { | ||
recentProjects[i] = FileUtils.canonicalizeFolderPath(ProjectManager.updateWelcomeProjectPath(recentProjects[i])); | ||
} | ||
return recentProjects; | ||
|
@@ -66,7 +66,7 @@ define(function (require, exports, module) { | |
prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_KEY), | ||
recentProjects = getRecentProjects(), | ||
index = recentProjects.indexOf(root); | ||
if (index !== -1) { | ||
if (index !== -1) { | ||
recentProjects.splice(index, 1); | ||
} | ||
recentProjects.unshift(root); | ||
|
@@ -95,8 +95,12 @@ define(function (require, exports, module) { | |
|
||
var folderSpan = $("<span></span>").addClass("recent-folder").text(folder), | ||
restSpan = $("<span></span>").addClass("recent-folder-path").text(" - " + rest); | ||
return $("<a></a>").addClass("recent-folder-link").append(folderSpan).append(restSpan); | ||
return $("<a></a>").addClass("recent-folder-link").append(folderSpan).append(restSpan).data("path", path); | ||
} | ||
|
||
function renderDelete() { | ||
return $("<div id='recent-folder-delete'></div>").addClass("trash-icon"); | ||
} | ||
|
||
/** | ||
* Show or hide the recent projects dropdown. | ||
|
@@ -148,13 +152,45 @@ define(function (require, exports, module) { | |
} | ||
}); | ||
closeDropdown(); | ||
}); | ||
$("<li></li>") | ||
}) | ||
.mouseenter(function (e) { | ||
var $target = $(e.currentTarget), | ||
$del = renderDelete() | ||
.click(function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .click() function call should be indented. |
||
// remove the project from the preferences. | ||
var prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_KEY), | ||
recentProjects = getRecentProjects(), | ||
index = recentProjects.indexOf($(this).data("path")), | ||
newProjects = [], | ||
i; | ||
for (i = 0; i < recentProjects.length; i++) { | ||
if(i !== index) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need a space between "if" and "(". I think JSLint would catch that, so be sure JSLint is turned on. |
||
newProjects.push(recentProjects[i]); | ||
} | ||
} | ||
prefs.setValue("recentProjects", newProjects); | ||
closeDropdown(); | ||
}); | ||
|
||
$(this).append($del); | ||
|
||
$del.css("right", 5); | ||
$del.css("top", $target.position().top + 11); | ||
$del.css("display", "inline-block"); | ||
$del.data("path", $(this).data("path")); | ||
}) | ||
.mouseleave(function () { | ||
$("#recent-folder-delete").remove(); | ||
}); | ||
|
||
$("<li></li>") | ||
.append($link) | ||
.appendTo($dropdown); | ||
hasProject = true; | ||
} | ||
}); | ||
|
||
|
||
if (hasProject) { | ||
$("<li class='divider'>").appendTo($dropdown); | ||
} | ||
|
@@ -164,7 +200,7 @@ define(function (require, exports, module) { | |
}) | ||
.appendTo($dropdown); | ||
|
||
$dropdown.css({ | ||
$dropdown.css({ | ||
left: toggleOffset.left, | ||
top: toggleOffset.top + $dropdownToggle.outerHeight() | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,14 @@ | |
background-image: url("down-arrow.png"); | ||
} | ||
|
||
.trash-icon { | ||
display: inline; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're dynamically changing display to 'inline-block', so you probably don't need to set it to 'inline' here. |
||
width: 16px; | ||
height: 16px; | ||
background-image: url("close_btn.svg"); | ||
position: absolute; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you're not re-positioning icon (e.g. left/top), then I don't think you need position:absolute. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see that you're positioning it dynamically. Nevermind. :) |
||
} | ||
|
||
#project-dropdown-toggle:hover { | ||
color: #a0a0a0; | ||
text-decoration: none; | ||
|
@@ -23,6 +31,13 @@ | |
white-space: nowrap; | ||
} | ||
|
||
#project-dropdown.dropdown-menu .recent-folder-link | ||
{ | ||
display: block; | ||
margin: 5px 0; | ||
padding: 5px 26px 5px 10px; | ||
} | ||
|
||
.recent-folder, #open-folder-link { | ||
color: #333; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to use 4 spaces instead of Tabs. This applies to all edits.