Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Added button to remove projects from the recent project dropdown. #1757

Merged
merged 3 commits into from
Oct 17, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/extensions/default/RecentProjects/close_btn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 42 additions & 6 deletions src/extensions/default/RecentProjects/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Copy link
Contributor

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.

recentProjects[i] = FileUtils.canonicalizeFolderPath(ProjectManager.updateWelcomeProjectPath(recentProjects[i]));
}
return recentProjects;
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -148,13 +152,45 @@ define(function (require, exports, module) {
}
});
closeDropdown();
});
$("<li></li>")
})
.mouseenter(function (e) {
var $target = $(e.currentTarget),
$del = renderDelete()
.click(function () {
Copy link
Contributor

Choose a reason for hiding this comment

The 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
}
Expand All @@ -164,7 +200,7 @@ define(function (require, exports, module) {
})
.appendTo($dropdown);

$dropdown.css({
$dropdown.css({
left: toggleOffset.left,
top: toggleOffset.top + $dropdownToggle.outerHeight()
})
Expand Down
15 changes: 15 additions & 0 deletions src/extensions/default/RecentProjects/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
background-image: url("down-arrow.png");
}

.trash-icon {
display: inline;
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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;
Expand All @@ -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;
}
Expand Down