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

Added support for closing files on middle click #3901

Merged
merged 5 commits into from
May 28, 2013
Merged
Changes from 4 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
19 changes: 18 additions & 1 deletion src/project/WorkingSetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ define(function (require, exports, module) {
return (docIfOpen && docIfOpen.isDirty);
}

/**
* @private
* @param {$.Event} event The Click Event to respond to.
*/
function _handleMiddleMouseClick(event) {
var file = $(event.target).closest("li").data(_FILE_KEY);

CommandManager.execute(Commands.FILE_CLOSE, {file: file});
}

/**
* Builds the UI for a new list item and inserts in into the end of the list
* @private
Expand All @@ -361,7 +371,7 @@ define(function (require, exports, module) {
$openFilesContainer.find("ul").append($newItem);

// working set item might never have been opened; if so, then it's definitely not dirty

// Update the listItem's apperance
_updateFileStatusIcon($newItem, isOpenAndDirty(file), false);
_updateListItemSelection($newItem, curDoc);
Expand All @@ -370,6 +380,13 @@ define(function (require, exports, module) {
_reorderListItem(e, $(this));
e.preventDefault();
});

$newItem.on("click", function (e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you change it to .click() so that it is consistent in coding style with existing code? We have .hover and .mousedown.

if (e.which === 2) {
_handleMiddleMouseClick(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does work, but I think this should be done in mouse up events rather than right here. Try with tabs in the browsers and other editors. All of them work on mouse ups.

}
e.preventDefault();
});

$newItem.hover(
function () {
Expand Down