This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Reorder Working Set with Drag and Drop #1846
Closed
Closed
Changes from 21 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
2cfd1fd
Scroll Line functionality added
TomMalbran 1f79b12
Changing keyboard shortcut
TomMalbran ef03ba1
Code clean-up
TomMalbran eea9b5a
Fixes after initial review
TomMalbran 44e2e39
Minor change
TomMalbran ecc0627
Reorder working set functionality
TomMalbran 563ce4a
Fixing branch
TomMalbran 55bcc84
Minor changes
TomMalbran 11bdc68
Minor changes
TomMalbran ec73084
Minor changes
TomMalbran 4f9d31f
Code refactoring and bug fixed
TomMalbran a46841c
Code optimizations
TomMalbran 6baa878
Adding the reorder on DocumentManager
TomMalbran 83280ac
Now it saves the reorder changes
TomMalbran 5dbe02c
Minor fixes
TomMalbran 96b0f58
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran e26a21a
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran be9b0e9
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran 883789f
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran b468ae8
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran bce6891
Fixing error with Context Menu
TomMalbran 2610dbc
Added test back in that was commend out for issue #389. This test is …
83ef3dd
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran 4f01dd5
Fixes after review
TomMalbran 21569eb
Fixes after review
TomMalbran dc0a7a3
Adding dragging from close icon
TomMalbran fd481e8
Update dirty flag in lightning bolt icon for all dirty flag change no…
RaymondLim 4144abe
Scroll into view and better fix for the boottom shadow
TomMalbran 49d0b80
Fixing indentations
TomMalbran 4d6fe5e
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran b462c33
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran e59cfa5
add settings icon
GarthDB 7dbfe65
Merge pull request #1907 from jeffslofish/issue-389
gruehle a46cb10
F2 to rename
zanqi 4a62012
make mdoe string more presentable
redmunds 8a27cda
Merge pull request #1922 from zanqi/renaming
peterflynn 32ffe5d
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran 83146d2
Merge pull request #1911 from adobe/rlim/dirty-dot-issue
6c33fbd
Merge remote-tracking branch 'upstream/master' into tom/reorder
TomMalbran c62b99d
Adding scrolling while dragging and other fixes
TomMalbran c5da9b8
get more info out of mimetype modes
redmunds 30255fc
code review fixes
redmunds a81b744
add special cases for: less, php
redmunds 5d31007
Merge pull request #1936 from adobe/garthdb/url-mapping
redmunds 25c986b
Merge pull request #1931 from adobe/glenn/extensions-folder
RaymondLim 4b066af
Merge pull request #1923 from adobe/randy/statusbar-mode
RaymondLim 6d44121
Working set view drag & drop to reorder files
TomMalbran 77b0085
Fixing merge issues
TomMalbran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
|
||
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
/*global define, $ */ | ||
/*global define, $, window */ | ||
|
||
/** | ||
* WorkingSetView generates the UI for the list of the files user is editing based on the model provided by EditorManager. | ||
|
@@ -37,6 +37,7 @@ define(function (require, exports, module) { | |
var DocumentManager = require("document/DocumentManager"), | ||
CommandManager = require("command/CommandManager"), | ||
Commands = require("command/Commands"), | ||
Menus = require("command/Menus"), | ||
EditorManager = require("editor/EditorManager"), | ||
FileViewController = require("project/FileViewController"), | ||
NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem, | ||
|
@@ -151,6 +152,102 @@ define(function (require, exports, module) { | |
return (docIfOpen && docIfOpen.isDirty); | ||
} | ||
|
||
/** | ||
* Starts the drag and drop working set view reorder. | ||
* @private | ||
* @param {!Event} event - jQuery event | ||
*/ | ||
function _reorderListItem(event) { | ||
var $listItem = $(event.currentTarget), | ||
$prevListItem = $listItem.prev(), | ||
$nextListItem = $listItem.next(), | ||
selected = $listItem.hasClass("selected"), | ||
prevSelected = $prevListItem.hasClass("selected"), | ||
nextSelected = $nextListItem.hasClass("selected"), | ||
index = DocumentManager.findInWorkingSet($listItem.data(_FILE_KEY).fullPath), | ||
height = $listItem.height(), | ||
startPageY = event.pageY, | ||
moved = false; | ||
|
||
$listItem.css("position", "relative").css("z-index", 1); | ||
|
||
$(window.document).on("mousemove.workingSet", function (e) { | ||
var top = e.pageY - startPageY; | ||
|
||
// Drag if the item is not the first and moving it up or | ||
// if the item is not the last and moving down | ||
if (($prevListItem.length && top < 0) || ($nextListItem.length && top > 0)) { | ||
// Reorder the list once the item is halfway to the new position | ||
if (Math.abs(top) > height / 2) { | ||
if (top < 0) { | ||
// If moving up, place the previows item after the moving item | ||
$prevListItem.insertAfter($listItem); | ||
startPageY -= height; | ||
top = top + height; | ||
DocumentManager.switchFilesIndex(index, --index); | ||
} else { | ||
// If moving down, place the next item before the moving item | ||
$nextListItem.insertBefore($listItem); | ||
startPageY += height; | ||
top = top - height; | ||
DocumentManager.switchFilesIndex(index, ++index); | ||
} | ||
|
||
if (!selected) { | ||
// Remove the shadows as it will appear and they should not | ||
ViewUtils.removeScrollerShadow($openFilesContainer[0], null); | ||
} | ||
|
||
// Update the previows and next items | ||
$prevListItem = $listItem.prev(); | ||
$nextListItem = $listItem.next(); | ||
} | ||
} else { | ||
// Set the top to 0 as the event probably didnt fired at the exact start/end of the list | ||
top = 0; | ||
} | ||
|
||
// Once the movement is greater than 2 pixels, it is assumed that the user wantes to reorder files and not open | ||
if (!moved && Math.abs(top) > 2) { | ||
// Hides the selection to optimize the movement | ||
$openFilesContainer.find(".sidebar-selection").css("display", "none"); | ||
$openFilesContainer.find(".sidebar-selection-triangle").css("display", "none"); | ||
// Hide the close icon | ||
$listItem.find(".file-status-icon").css("display", "none"); | ||
// Close all menus | ||
Menus.closeAll(); | ||
moved = true; | ||
} | ||
|
||
// Move the item | ||
$listItem.css("top", top + "px"); | ||
}); | ||
|
||
$(window.document).on("mouseup.workingSet", function (e) { | ||
// Removes the styles, placing the item in the chocen place | ||
$listItem.removeAttr("style"); | ||
$(window.document).off("mousemove.workingSet mouseup.workingSet"); | ||
|
||
if (!moved) { | ||
// If file wasnt moved, open the file | ||
FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); | ||
} else { | ||
// Restore the file selection | ||
_fireSelectionChanged(); | ||
// Display the status icon again | ||
$listItem.find(".file-status-icon").css("display", "block"); | ||
|
||
if (!selected) { | ||
// Add the scroller shadow in the case they were removed | ||
ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); | ||
} | ||
} | ||
|
||
// Dispatch event | ||
$(DocumentManager).triggerHandler("workingSetReorder"); | ||
}); | ||
} | ||
|
||
/** | ||
* Builds the UI for a new list item and inserts in into the end of the list | ||
* @private | ||
|
@@ -175,7 +272,12 @@ define(function (require, exports, module) { | |
_updateListItemSelection($newItem, curDoc); | ||
|
||
$newItem.mousedown(function (e) { | ||
FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); | ||
// Try to reorder only with the right click and just open the file in other cases | ||
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 mean left click, not right click, correct? |
||
if (e.which === 1) { | ||
_reorderListItem(e); | ||
} else { | ||
FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); | ||
} | ||
e.preventDefault(); | ||
}); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This API call should be more descriptive to distinguish this from the project tree. Also since both indexes are specified, I think it's more of a swap than a switch. Maybe swapWorkingSetIndexes.