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 all commits
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.
40 changes: 38 additions & 2 deletions src/extensions/default/RecentProjects/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ 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");
}

/**
Expand Down Expand Up @@ -148,13 +152,45 @@ define(function (require, exports, module) {
}
});
closeDropdown();
})
.mouseenter(function (e) {
var $target = $(e.currentTarget),
$del = renderDelete()
.click(function () {
// 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) {
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 Down Expand Up @@ -203,4 +239,4 @@ define(function (require, exports, module) {
.after("<span class='dropdown-arrow'></span>");
$dropdownToggle = $("#project-dropdown-toggle").click(toggle);
});
});
});
14 changes: 14 additions & 0 deletions src/extensions/default/RecentProjects/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
background-image: url("down-arrow.svg");
}

.trash-icon {
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 +30,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