From 2cfd1fd1a7ad5f4cdb706a7fe895246a1b592482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sat, 13 Oct 2012 20:28:54 -0300 Subject: [PATCH 01/30] Scroll Line functionality added --- src/command/Commands.js | 2 ++ src/command/Menus.js | 3 +++ src/nls/root/strings.js | 2 ++ src/view/ViewCommandHandlers.js | 29 +++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) diff --git a/src/command/Commands.js b/src/command/Commands.js index d5fcdee5895..e6c4a60ec0a 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -73,6 +73,8 @@ define(function (require, exports, module) { exports.VIEW_INCREASE_FONT_SIZE = "view.increaseFontSize"; exports.VIEW_DECREASE_FONT_SIZE = "view.decreaseFontSize"; exports.VIEW_RESTORE_FONT_SIZE = "view.restoreFontSize"; + exports.VIEW_SCROLL_LINE_UP = "view.scrollLineUp"; + exports.VIEW_SCROLL_LINE_DOWN = "view.scrollLineDown"; exports.TOGGLE_JSLINT = "debug.jslint"; // Navigate diff --git a/src/command/Menus.js b/src/command/Menus.js index 9352780f742..99de847dcdf 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -906,6 +906,9 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.VIEW_DECREASE_FONT_SIZE, [{key: "Ctrl--", displayKey: "Ctrl-\u2212"}]); menu.addMenuItem(Commands.VIEW_RESTORE_FONT_SIZE, "Ctrl-0"); menu.addMenuDivider(); + menu.addMenuItem(Commands.VIEW_SCROLL_LINE_UP, [{key: "Ctrl-Alt-Up", displayKey: "Ctrl-Alt-\u2191"}]); + menu.addMenuItem(Commands.VIEW_SCROLL_LINE_DOWN, [{key: "Ctrl-Alt-Down", displayKey: "Ctrl-Alt-\u2193"}]); + menu.addMenuDivider(); menu.addMenuItem(Commands.TOGGLE_JSLINT); /* diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 38b47794af4..00bfdcdf6b7 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -191,6 +191,8 @@ define({ "CMD_INCREASE_FONT_SIZE" : "Increase Font Size", "CMD_DECREASE_FONT_SIZE" : "Decrease Font Size", "CMD_RESTORE_FONT_SIZE" : "Restore Font Size", + "CMD_SCROLL_LINE_UP" : "Scroll one line Up", + "CMD_SCROLL_LINE_DOWN" : "Scroll one line down", // Navigate menu Commands "NAVIGATE_MENU" : "Navigate", diff --git a/src/view/ViewCommandHandlers.js b/src/view/ViewCommandHandlers.js index 2e67402ed37..c75b3700f8a 100644 --- a/src/view/ViewCommandHandlers.js +++ b/src/view/ViewCommandHandlers.js @@ -126,7 +126,36 @@ define(function (require, exports, module) { _removeDynamicFontSize(true); } + /** + * @private + * Scroll de code one line up or down. + * @param {number} -1 to scroll one line up; 1 to scroll one line down. + */ + function _scrollLine(direction) { + var editor = EditorManager.getCurrentFullEditor(); + var scrollPos = editor.getScrollPos(); + var lhStyle = $(".CodeMirror-scroll").css("line-height"); + var lhValue = parseFloat(lhStyle.substring(0, lhStyle.length - 2)); + var lhUnits = lhStyle.substring(lhStyle.length - 2, lhStyle.length); + + if (lhUnits === 'em') { + lhValue *= 10; + } + + editor.setScrollPos(scrollPos.x, scrollPos.y + (lhValue * direction)); + } + + function _handleScrollLineUp() { + _scrollLine(-1); + } + + function _handleScrollLineDown() { + _scrollLine(1); + } + CommandManager.register(Strings.CMD_INCREASE_FONT_SIZE, Commands.VIEW_INCREASE_FONT_SIZE, _handleIncreaseFontSize); CommandManager.register(Strings.CMD_DECREASE_FONT_SIZE, Commands.VIEW_DECREASE_FONT_SIZE, _handleDecreaseFontSize); CommandManager.register(Strings.CMD_RESTORE_FONT_SIZE, Commands.VIEW_RESTORE_FONT_SIZE, _handleRestoreFontSize); + CommandManager.register(Strings.CMD_SCROLL_LINE_UP, Commands.VIEW_SCROLL_LINE_UP, _handleScrollLineUp); + CommandManager.register(Strings.CMD_SCROLL_LINE_DOWN, Commands.VIEW_SCROLL_LINE_DOWN, _handleScrollLineDown); }); From 1f79b12bb7de4c31293e6dd0abb80cd9f35e62dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 14 Oct 2012 02:33:07 -0300 Subject: [PATCH 02/30] Changing keyboard shortcut --- src/command/Menus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command/Menus.js b/src/command/Menus.js index 99de847dcdf..eda2165fd38 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -906,8 +906,8 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.VIEW_DECREASE_FONT_SIZE, [{key: "Ctrl--", displayKey: "Ctrl-\u2212"}]); menu.addMenuItem(Commands.VIEW_RESTORE_FONT_SIZE, "Ctrl-0"); menu.addMenuDivider(); - menu.addMenuItem(Commands.VIEW_SCROLL_LINE_UP, [{key: "Ctrl-Alt-Up", displayKey: "Ctrl-Alt-\u2191"}]); - menu.addMenuItem(Commands.VIEW_SCROLL_LINE_DOWN, [{key: "Ctrl-Alt-Down", displayKey: "Ctrl-Alt-\u2193"}]); + menu.addMenuItem(Commands.VIEW_SCROLL_LINE_UP, [{key: "Ctrl-Up", displayKey: "Ctrl-\u2191"}]); + menu.addMenuItem(Commands.VIEW_SCROLL_LINE_DOWN, [{key: "Ctrl-Down", displayKey: "Ctrl-\u2193"}]); menu.addMenuDivider(); menu.addMenuItem(Commands.TOGGLE_JSLINT); From ef03ba1bdce595205aacd93c8bb5477acee9ac1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 14 Oct 2012 02:38:15 -0300 Subject: [PATCH 03/30] Code clean-up --- src/view/ViewCommandHandlers.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/view/ViewCommandHandlers.js b/src/view/ViewCommandHandlers.js index c75b3700f8a..8e00aff444e 100644 --- a/src/view/ViewCommandHandlers.js +++ b/src/view/ViewCommandHandlers.js @@ -146,16 +146,16 @@ define(function (require, exports, module) { } function _handleScrollLineUp() { - _scrollLine(-1); - } - - function _handleScrollLineDown() { - _scrollLine(1); - } + _scrollLine(-1); + } + + function _handleScrollLineDown() { + _scrollLine(1); + } CommandManager.register(Strings.CMD_INCREASE_FONT_SIZE, Commands.VIEW_INCREASE_FONT_SIZE, _handleIncreaseFontSize); CommandManager.register(Strings.CMD_DECREASE_FONT_SIZE, Commands.VIEW_DECREASE_FONT_SIZE, _handleDecreaseFontSize); CommandManager.register(Strings.CMD_RESTORE_FONT_SIZE, Commands.VIEW_RESTORE_FONT_SIZE, _handleRestoreFontSize); CommandManager.register(Strings.CMD_SCROLL_LINE_UP, Commands.VIEW_SCROLL_LINE_UP, _handleScrollLineUp); - CommandManager.register(Strings.CMD_SCROLL_LINE_DOWN, Commands.VIEW_SCROLL_LINE_DOWN, _handleScrollLineDown); + CommandManager.register(Strings.CMD_SCROLL_LINE_DOWN, Commands.VIEW_SCROLL_LINE_DOWN, _handleScrollLineDown); }); From eea9b5ae4402940896c7200b74091d42763fd76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 14 Oct 2012 04:16:25 -0300 Subject: [PATCH 04/30] Fixes after initial review --- src/nls/root/strings.js | 4 ++-- src/view/ViewCommandHandlers.js | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 00bfdcdf6b7..6088694b133 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -191,8 +191,8 @@ define({ "CMD_INCREASE_FONT_SIZE" : "Increase Font Size", "CMD_DECREASE_FONT_SIZE" : "Decrease Font Size", "CMD_RESTORE_FONT_SIZE" : "Restore Font Size", - "CMD_SCROLL_LINE_UP" : "Scroll one line Up", - "CMD_SCROLL_LINE_DOWN" : "Scroll one line down", + "CMD_SCROLL_LINE_UP" : "Scroll Line Up", + "CMD_SCROLL_LINE_DOWN" : "Scroll Line Down", // Navigate menu Commands "NAVIGATE_MENU" : "Navigate", diff --git a/src/view/ViewCommandHandlers.js b/src/view/ViewCommandHandlers.js index 8e00aff444e..96da0e17924 100644 --- a/src/view/ViewCommandHandlers.js +++ b/src/view/ViewCommandHandlers.js @@ -128,21 +128,17 @@ define(function (require, exports, module) { /** * @private - * Scroll de code one line up or down. + * Scroll the viewport one line up or down. * @param {number} -1 to scroll one line up; 1 to scroll one line down. */ function _scrollLine(direction) { var editor = EditorManager.getCurrentFullEditor(); var scrollPos = editor.getScrollPos(); - var lhStyle = $(".CodeMirror-scroll").css("line-height"); - var lhValue = parseFloat(lhStyle.substring(0, lhStyle.length - 2)); - var lhUnits = lhStyle.substring(lhStyle.length - 2, lhStyle.length); - - if (lhUnits === 'em') { - lhValue *= 10; - } + var lineCount = editor.lineCount(); + var totalHeight = editor.totalHeight(); + var scrollDeltaY = Math.round(totalHeight / lineCount); - editor.setScrollPos(scrollPos.x, scrollPos.y + (lhValue * direction)); + editor.setScrollPos(scrollPos.x, scrollPos.y + (scrollDeltaY * direction)); } function _handleScrollLineUp() { From 44e2e390f1374d357a16362fe56559bde69b15b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 14 Oct 2012 04:26:35 -0300 Subject: [PATCH 05/30] Minor change --- src/view/ViewCommandHandlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/ViewCommandHandlers.js b/src/view/ViewCommandHandlers.js index 96da0e17924..f063a2ff93d 100644 --- a/src/view/ViewCommandHandlers.js +++ b/src/view/ViewCommandHandlers.js @@ -136,7 +136,7 @@ define(function (require, exports, module) { var scrollPos = editor.getScrollPos(); var lineCount = editor.lineCount(); var totalHeight = editor.totalHeight(); - var scrollDeltaY = Math.round(totalHeight / lineCount); + var scrollDeltaY = totalHeight / lineCount; editor.setScrollPos(scrollPos.x, scrollPos.y + (scrollDeltaY * direction)); } From ecc062746cded405253c5d547b29e8bd583606c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 14 Oct 2012 23:52:38 -0300 Subject: [PATCH 06/30] Reorder working set functionality --- src/project/WorkingSetView.js | 86 +++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index f34a8b5ee80..6dce6a6be66 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -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. @@ -151,6 +151,82 @@ define(function (require, exports, module) { return (docIfOpen && docIfOpen.isDirty); } + + /** + * Drags the list item afterfor reordening. + * @private + */ + function _dragListItem(event) { + var $item = event.data.$item; + var $prevListItem = event.data.$prevListItem; + var $nextListItem = event.data.$nextListItem; + var top = event.pageY - event.data.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) > event.data.height / 2) { + if (top < 0) { + // If moving up, place the previows item after the moving item + $prevListItem.insertAfter($item); + event.data.startPageY -= event.data.height; + top = top + event.data.height; + } else { + // If moving down, place the next item before the moving item + $nextListItem.insertBefore($item); + event.data.startPageY += event.data.height; + top = top - event.data.height; + } + + // Update the previows and next items + event.data.$prevListItem = $item.prev(); + event.data.$nextListItem = $item.next(); + } + } else { + top = 0; + } + + // Move the item + $item.css("top", top + "px"); + + // Update the selection position + _fireSelectionChanged(); + } + + /** + * Drops the list item afterfor reordening. + * @private + */ + function _dropListItem(event) { + // Removes the styles, placing the item in the chocen place + event.data.$item.removeAttr("style"); + $(window.document).off("mousemove", _dragListItem) + .off("mouseup", _dropListItem); + + // Update the selection position + _fireSelectionChanged(); + } + + /** + * Starts the drag and drop working set view reorder. + * @private + */ + function _reorderListItem(event) { + var $item = $(event.currentTarget); + var data = { + $item: $item, + startPageY: event.pageY, + $prevListItem: $item.prev(), + $nextListItem: $item.next(), + height: $item.height() + }; + + $item.css("position", "relative"); + $(window.document).on("mousemove", data, _dragListItem) + .on("mouseup", data, _dropListItem); + } + /** * Builds the UI for a new list item and inserts in into the end of the list * @private @@ -175,6 +251,7 @@ define(function (require, exports, module) { _updateListItemSelection($newItem, curDoc); $newItem.mousedown(function (e) { + _reorderListItem(e); FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); e.preventDefault(); }); @@ -189,6 +266,7 @@ define(function (require, exports, module) { ); } + /** * Deletes all the list items in the view and rebuilds them from the working set model * @private @@ -370,13 +448,13 @@ define(function (require, exports, module) { $(DocumentManager).on("dirtyFlagChange", function (event, doc) { _handleDirtyFlagChanged(doc); }); - + $(DocumentManager).on("fileNameChange", function (event, oldName, newName) { _handleFileNameChanged(oldName, newName); }); - + $(FileViewController).on("documentSelectionFocusChange fileViewFocusChange", _handleDocumentSelectionChange); - + // Show scroller shadows when open-files-container scrolls ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); ViewUtils.sidebarList($openFilesContainer); From 563ce4a78f550a294783b3676d532a498ddc2dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 15 Oct 2012 01:24:47 -0300 Subject: [PATCH 07/30] Fixing branch --- src/command/Commands.js | 2 - src/command/Menus.js | 3 -- src/nls/root/strings.js | 2 - src/project/WorkingSetView.js | 81 +++++++++++++++++++-------------- src/view/ViewCommandHandlers.js | 25 ---------- 5 files changed, 48 insertions(+), 65 deletions(-) diff --git a/src/command/Commands.js b/src/command/Commands.js index e6c4a60ec0a..d5fcdee5895 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -73,8 +73,6 @@ define(function (require, exports, module) { exports.VIEW_INCREASE_FONT_SIZE = "view.increaseFontSize"; exports.VIEW_DECREASE_FONT_SIZE = "view.decreaseFontSize"; exports.VIEW_RESTORE_FONT_SIZE = "view.restoreFontSize"; - exports.VIEW_SCROLL_LINE_UP = "view.scrollLineUp"; - exports.VIEW_SCROLL_LINE_DOWN = "view.scrollLineDown"; exports.TOGGLE_JSLINT = "debug.jslint"; // Navigate diff --git a/src/command/Menus.js b/src/command/Menus.js index eda2165fd38..9352780f742 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -906,9 +906,6 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.VIEW_DECREASE_FONT_SIZE, [{key: "Ctrl--", displayKey: "Ctrl-\u2212"}]); menu.addMenuItem(Commands.VIEW_RESTORE_FONT_SIZE, "Ctrl-0"); menu.addMenuDivider(); - menu.addMenuItem(Commands.VIEW_SCROLL_LINE_UP, [{key: "Ctrl-Up", displayKey: "Ctrl-\u2191"}]); - menu.addMenuItem(Commands.VIEW_SCROLL_LINE_DOWN, [{key: "Ctrl-Down", displayKey: "Ctrl-\u2193"}]); - menu.addMenuDivider(); menu.addMenuItem(Commands.TOGGLE_JSLINT); /* diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 6088694b133..38b47794af4 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -191,8 +191,6 @@ define({ "CMD_INCREASE_FONT_SIZE" : "Increase Font Size", "CMD_DECREASE_FONT_SIZE" : "Decrease Font Size", "CMD_RESTORE_FONT_SIZE" : "Restore Font Size", - "CMD_SCROLL_LINE_UP" : "Scroll Line Up", - "CMD_SCROLL_LINE_DOWN" : "Scroll Line Down", // Navigate menu Commands "NAVIGATE_MENU" : "Navigate", diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 6dce6a6be66..d61b42abeb3 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -151,77 +151,93 @@ define(function (require, exports, module) { return (docIfOpen && docIfOpen.isDirty); } - /** * Drags the list item afterfor reordening. * @private */ function _dragListItem(event) { var $item = event.data.$item; - var $prevListItem = event.data.$prevListItem; - var $nextListItem = event.data.$nextListItem; + var $prevListItem = event.data.$prevListItem; + var $nextListItem = event.data.$nextListItem; var top = event.pageY - event.data.startPageY; - // Drag if the item is not the first and moving it up or - // if the item is not the last and moving down + // 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) > event.data.height / 2) { + if (Math.abs(top) > event.data.height / 2) { if (top < 0) { // If moving up, place the previows item after the moving item - $prevListItem.insertAfter($item); + $prevListItem.insertAfter($item); event.data.startPageY -= event.data.height; top = top + event.data.height; } else { - // If moving down, place the next item before the moving item + // If moving down, place the next item before the moving item $nextListItem.insertBefore($item); event.data.startPageY += event.data.height; top = top - event.data.height; } - + // Update the previows and next items event.data.$prevListItem = $item.prev(); event.data.$nextListItem = $item.next(); + event.data.ordered = true; + + if (!event.data.selected) { + _fireSelectionChanged(); + } } } else { - top = 0; - } - - // Move the item - $item.css("top", top + "px"); - - // Update the selection position - _fireSelectionChanged(); + // Set the top to 0 as the event probably didnt fired at the exact start/end of the list + top = 0; + } + + // Move the item + $item.css("top", top + "px"); + + // Update the selection position + if (event.data.selected) { + _fireSelectionChanged(); + } } - /** + /** * Drops the list item afterfor reordening. * @private */ function _dropListItem(event) { - // Removes the styles, placing the item in the chocen place - event.data.$item.removeAttr("style"); - $(window.document).off("mousemove", _dragListItem) + var $item = event.data.$item; + + // Removes the styles, placing the item in the chocen place + $item.removeAttr("style"); + $(window.document).off("mousemove", _dragListItem) .off("mouseup", _dropListItem); - - // Update the selection position - _fireSelectionChanged(); + + if (!event.data.ordered) { + // If file wasnt moved, open the file + FileViewController.openAndSelectDocument($item.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + } else if (event.data.selected) { + // Update the selection position + _fireSelectionChanged(); + } } - /** + /** * Starts the drag and drop working set view reorder. * @private */ function _reorderListItem(event) { - var $item = $(event.currentTarget); - var data = { + var $item = $(event.currentTarget); + var data = { $item: $item, - startPageY: event.pageY, + startPageY: event.pageY, $prevListItem: $item.prev(), $nextListItem: $item.next(), - height: $item.height() - }; - + selected: $item.hasClass("selected"), + height: $item.height(), + ordered: false + }; + $item.css("position", "relative"); $(window.document).on("mousemove", data, _dragListItem) .on("mouseup", data, _dropListItem); @@ -252,7 +268,7 @@ define(function (require, exports, module) { $newItem.mousedown(function (e) { _reorderListItem(e); - FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); + e.preventDefault(); }); @@ -266,7 +282,6 @@ define(function (require, exports, module) { ); } - /** * Deletes all the list items in the view and rebuilds them from the working set model * @private diff --git a/src/view/ViewCommandHandlers.js b/src/view/ViewCommandHandlers.js index f063a2ff93d..2e67402ed37 100644 --- a/src/view/ViewCommandHandlers.js +++ b/src/view/ViewCommandHandlers.js @@ -126,32 +126,7 @@ define(function (require, exports, module) { _removeDynamicFontSize(true); } - /** - * @private - * Scroll the viewport one line up or down. - * @param {number} -1 to scroll one line up; 1 to scroll one line down. - */ - function _scrollLine(direction) { - var editor = EditorManager.getCurrentFullEditor(); - var scrollPos = editor.getScrollPos(); - var lineCount = editor.lineCount(); - var totalHeight = editor.totalHeight(); - var scrollDeltaY = totalHeight / lineCount; - - editor.setScrollPos(scrollPos.x, scrollPos.y + (scrollDeltaY * direction)); - } - - function _handleScrollLineUp() { - _scrollLine(-1); - } - - function _handleScrollLineDown() { - _scrollLine(1); - } - CommandManager.register(Strings.CMD_INCREASE_FONT_SIZE, Commands.VIEW_INCREASE_FONT_SIZE, _handleIncreaseFontSize); CommandManager.register(Strings.CMD_DECREASE_FONT_SIZE, Commands.VIEW_DECREASE_FONT_SIZE, _handleDecreaseFontSize); CommandManager.register(Strings.CMD_RESTORE_FONT_SIZE, Commands.VIEW_RESTORE_FONT_SIZE, _handleRestoreFontSize); - CommandManager.register(Strings.CMD_SCROLL_LINE_UP, Commands.VIEW_SCROLL_LINE_UP, _handleScrollLineUp); - CommandManager.register(Strings.CMD_SCROLL_LINE_DOWN, Commands.VIEW_SCROLL_LINE_DOWN, _handleScrollLineDown); }); From 55bcc845863248fc4079ba51508716e2d23133f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 15 Oct 2012 01:31:42 -0300 Subject: [PATCH 08/30] Minor changes --- src/project/WorkingSetView.js | 86 ++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 6dce6a6be66..8986e9bb197 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -151,77 +151,93 @@ define(function (require, exports, module) { return (docIfOpen && docIfOpen.isDirty); } - /** * Drags the list item afterfor reordening. * @private */ function _dragListItem(event) { var $item = event.data.$item; - var $prevListItem = event.data.$prevListItem; - var $nextListItem = event.data.$nextListItem; + var $prevListItem = event.data.$prevListItem; + var $nextListItem = event.data.$nextListItem; var top = event.pageY - event.data.startPageY; - // Drag if the item is not the first and moving it up or - // if the item is not the last and moving down + // 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) > event.data.height / 2) { + if (Math.abs(top) > event.data.height / 2) { if (top < 0) { // If moving up, place the previows item after the moving item - $prevListItem.insertAfter($item); + $prevListItem.insertAfter($item); event.data.startPageY -= event.data.height; top = top + event.data.height; } else { - // If moving down, place the next item before the moving item + // If moving down, place the next item before the moving item $nextListItem.insertBefore($item); event.data.startPageY += event.data.height; top = top - event.data.height; } - + // Update the previows and next items event.data.$prevListItem = $item.prev(); event.data.$nextListItem = $item.next(); + event.data.ordered = true; + + if (!event.data.selected) { + _fireSelectionChanged(); + } } } else { - top = 0; - } - - // Move the item - $item.css("top", top + "px"); - - // Update the selection position - _fireSelectionChanged(); + // Set the top to 0 as the event probably didnt fired at the exact start/end of the list + top = 0; + } + + // Move the item + $item.css("top", top + "px"); + + // Update the selection position + if (event.data.selected) { + _fireSelectionChanged(); + } } - /** + /** * Drops the list item afterfor reordening. * @private */ function _dropListItem(event) { - // Removes the styles, placing the item in the chocen place - event.data.$item.removeAttr("style"); - $(window.document).off("mousemove", _dragListItem) + var $item = event.data.$item; + + // Removes the styles, placing the item in the chocen place + $item.removeAttr("style"); + $(window.document).off("mousemove", _dragListItem) .off("mouseup", _dropListItem); - - // Update the selection position - _fireSelectionChanged(); + + if (!event.data.ordered) { + // If file wasnt moved, open the file + FileViewController.openAndSelectDocument($item.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + } else if (event.data.selected) { + // Update the selection position + _fireSelectionChanged(); + } } - /** + /** * Starts the drag and drop working set view reorder. * @private */ function _reorderListItem(event) { - var $item = $(event.currentTarget); - var data = { + var $item = $(event.currentTarget); + var data = { $item: $item, - startPageY: event.pageY, + startPageY: event.pageY, $prevListItem: $item.prev(), $nextListItem: $item.next(), - height: $item.height() - }; - + selected: $item.hasClass("selected"), + height: $item.height(), + ordered: false + }; + $item.css("position", "relative"); $(window.document).on("mousemove", data, _dragListItem) .on("mouseup", data, _dropListItem); @@ -252,7 +268,6 @@ define(function (require, exports, module) { $newItem.mousedown(function (e) { _reorderListItem(e); - FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); e.preventDefault(); }); @@ -266,7 +281,6 @@ define(function (require, exports, module) { ); } - /** * Deletes all the list items in the view and rebuilds them from the working set model * @private @@ -448,13 +462,13 @@ define(function (require, exports, module) { $(DocumentManager).on("dirtyFlagChange", function (event, doc) { _handleDirtyFlagChanged(doc); }); - + $(DocumentManager).on("fileNameChange", function (event, oldName, newName) { _handleFileNameChanged(oldName, newName); }); - + $(FileViewController).on("documentSelectionFocusChange fileViewFocusChange", _handleDocumentSelectionChange); - + // Show scroller shadows when open-files-container scrolls ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); ViewUtils.sidebarList($openFilesContainer); From ec7308476e09d07afad31cb1364f057c7e6ef916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 15 Oct 2012 01:50:09 -0300 Subject: [PATCH 09/30] Minor changes --- src/project/WorkingSetView.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index f64a863e6db..41774c9a988 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -268,7 +268,6 @@ define(function (require, exports, module) { $newItem.mousedown(function (e) { _reorderListItem(e); - e.preventDefault(); }); @@ -463,7 +462,7 @@ define(function (require, exports, module) { $(DocumentManager).on("dirtyFlagChange", function (event, doc) { _handleDirtyFlagChanged(doc); }); - + $(DocumentManager).on("fileNameChange", function (event, oldName, newName) { _handleFileNameChanged(oldName, newName); }); From 4f9d31fd8c03586787c60ea55d2f1974f2f63d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 15 Oct 2012 21:02:52 -0300 Subject: [PATCH 10/30] Code refactoring and bug fixed --- src/project/WorkingSetView.js | 161 ++++++++++++++++------------------ 1 file changed, 78 insertions(+), 83 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 41774c9a988..8744f6c58dd 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -152,95 +152,90 @@ define(function (require, exports, module) { } /** - * Drags the list item afterfor reordening. + * Starts the drag and drop working set view reorder. * @private + * @param {!Event} event - jQuery event */ - function _dragListItem(event) { - var $item = event.data.$item; - var $prevListItem = event.data.$prevListItem; - var $nextListItem = event.data.$nextListItem; - var top = event.pageY - event.data.startPageY; + 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"), + height = $listItem.height(), + startPageY = event.pageY, + ordered = false; - // 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) > event.data.height / 2) { - if (top < 0) { - // If moving up, place the previows item after the moving item - $prevListItem.insertAfter($item); - event.data.startPageY -= event.data.height; - top = top + event.data.height; - } else { - // If moving down, place the next item before the moving item - $nextListItem.insertBefore($item); - event.data.startPageY += event.data.height; - top = top - event.data.height; - } - - // Update the previows and next items - event.data.$prevListItem = $item.prev(); - event.data.$nextListItem = $item.next(); - event.data.ordered = true; - - if (!event.data.selected) { - _fireSelectionChanged(); + $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; + } else { + // If moving down, place the next item before the moving item + $nextListItem.insertBefore($listItem); + startPageY += height; + top = top - height; + } + + if (!selected) { + // Update the selection when the previows or next element were selected + if ((top > 0 && prevSelected) || (top < 0 && nextSelected)) { + _fireSelectionChanged(); + } + // 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(); + prevSelected = $prevListItem.hasClass("selected"); + nextSelected = $nextListItem.hasClass("selected"); + ordered = true; } + } else { + // Set the top to 0 as the event probably didnt fired at the exact start/end of the list + top = 0; } - } else { - // Set the top to 0 as the event probably didnt fired at the exact start/end of the list - top = 0; - } - - // Move the item - $item.css("top", top + "px"); - - // Update the selection position - if (event.data.selected) { - _fireSelectionChanged(); - } - } - - /** - * Drops the list item afterfor reordening. - * @private - */ - function _dropListItem(event) { - var $item = event.data.$item; - - // Removes the styles, placing the item in the chocen place - $item.removeAttr("style"); - $(window.document).off("mousemove", _dragListItem) - .off("mouseup", _dropListItem); - - if (!event.data.ordered) { - // If file wasnt moved, open the file - FileViewController.openAndSelectDocument($item.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); - } else if (event.data.selected) { + + // Move the item + $listItem.css("top", top + "px"); + // Update the selection position - _fireSelectionChanged(); - } - } - - /** - * Starts the drag and drop working set view reorder. - * @private - */ - function _reorderListItem(event) { - var $item = $(event.currentTarget); - var data = { - $item: $item, - startPageY: event.pageY, - $prevListItem: $item.prev(), - $nextListItem: $item.next(), - selected: $item.hasClass("selected"), - height: $item.height(), - ordered: false - }; + if (selected) { + _fireSelectionChanged(); + } + }); - $item.css("position", "relative"); - $(window.document).on("mousemove", data, _dragListItem) - .on("mouseup", data, _dropListItem); + $(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") + .off("mouseup.workingSet"); + + if (!ordered) { + // If file wasnt moved, open the file + FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + } else if (selected) { + // Update the selection position + _fireSelectionChanged(); + } else { + // Add the scroller shadow in the case they were removed + ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); + } + }); } /** @@ -477,4 +472,4 @@ define(function (require, exports, module) { } exports.create = create; -}); +}); \ No newline at end of file From a46841c4aabeb871da070ae60c10e4a60441fbd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 15 Oct 2012 21:39:39 -0300 Subject: [PATCH 11/30] Code optimizations --- src/project/WorkingSetView.js | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 8744f6c58dd..47318b58e80 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -165,7 +165,7 @@ define(function (require, exports, module) { nextSelected = $nextListItem.hasClass("selected"), height = $listItem.height(), startPageY = event.pageY, - ordered = false; + moved = false; $listItem.css("position", "relative").css("z-index", 1); @@ -190,10 +190,6 @@ define(function (require, exports, module) { } if (!selected) { - // Update the selection when the previows or next element were selected - if ((top > 0 && prevSelected) || (top < 0 && nextSelected)) { - _fireSelectionChanged(); - } // Remove the shadows as it will appear and they should not ViewUtils.removeScrollerShadow($openFilesContainer[0], null); } @@ -201,22 +197,23 @@ define(function (require, exports, module) { // Update the previows and next items $prevListItem = $listItem.prev(); $nextListItem = $listItem.next(); - prevSelected = $prevListItem.hasClass("selected"); - nextSelected = $nextListItem.hasClass("selected"); - ordered = true; } } 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"); + $listItem.find(".file-status-icon").css("display", "none"); + moved = true; + } + // Move the item $listItem.css("top", top + "px"); - - // Update the selection position - if (selected) { - _fireSelectionChanged(); - } }); $(window.document).on("mouseup.workingSet", function (e) { @@ -225,15 +222,19 @@ define(function (require, exports, module) { $(window.document).off("mousemove.workingSet") .off("mouseup.workingSet"); - if (!ordered) { + if (!moved) { // If file wasnt moved, open the file FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); - } else if (selected) { - // Update the selection position - _fireSelectionChanged(); } else { - // Add the scroller shadow in the case they were removed - ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); + // 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); + } } }); } From 6baa87869266eb30b8e4865a5de85cea1be48d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 15 Oct 2012 23:39:03 -0300 Subject: [PATCH 12/30] Adding the reorder on DocumentManager --- src/document/DocumentManager.js | 21 ++++++++++++++++++++- src/project/WorkingSetView.js | 5 ++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/document/DocumentManager.js b/src/document/DocumentManager.js index 1e19bd4e568..72eeb64529f 100644 --- a/src/document/DocumentManager.js +++ b/src/document/DocumentManager.js @@ -299,6 +299,24 @@ define(function (require, exports, module) { } + /** + * Changes the position of the file from oldIndex to NewIndex and at the same time the file + * in newIndex to oldIndex. Returns the newIndex + * @param {!number} index - old file index + * @param {!number} index - new file index + */ + function switchFilesIndex(oldIndex, newIndex) { + var length = _workingSet.length - 1; + var aux; + + if (oldIndex >= 0 && oldIndex <= length && newIndex >= 0 && newIndex <= length) { + aux = _workingSet[oldIndex]; + _workingSet[oldIndex] = _workingSet[newIndex]; + _workingSet[newIndex] = aux; + } + } + + /** * Indicate that changes to currentDocument are temporary for now, and should not update the MRU * ordering of the working set. Useful for next/previous keyboard navigation (until Ctrl is released) @@ -1125,7 +1143,8 @@ define(function (require, exports, module) { exports.addListToWorkingSet = addListToWorkingSet; exports.removeFromWorkingSet = removeFromWorkingSet; exports.getNextPrevFile = getNextPrevFile; - exports.beginDocumentNavigation = beginDocumentNavigation; + exports.switchFilesIndex = switchFilesIndex; + exports.beginDocumentNavigation = beginDocumentNavigation; exports.finalizeDocumentNavigation = finalizeDocumentNavigation; exports.closeFullEditor = closeFullEditor; exports.closeAll = closeAll; diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 47318b58e80..511e6aa1556 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -163,7 +163,8 @@ define(function (require, exports, module) { selected = $listItem.hasClass("selected"), prevSelected = $prevListItem.hasClass("selected"), nextSelected = $nextListItem.hasClass("selected"), - height = $listItem.height(), + index = DocumentManager.findInWorkingSet($listItem.data(_FILE_KEY).fullPath), + height = $listItem.height(), startPageY = event.pageY, moved = false; @@ -182,11 +183,13 @@ define(function (require, exports, module) { $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) { From 83280accad48269b749a286942bc46d91a6a15d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Tue, 16 Oct 2012 06:13:15 -0300 Subject: [PATCH 13/30] Now it saves the reorder changes --- src/document/DocumentManager.js | 4 ++-- src/project/WorkingSetView.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/document/DocumentManager.js b/src/document/DocumentManager.js index 72eeb64529f..ee8bc2ccb05 100644 --- a/src/document/DocumentManager.js +++ b/src/document/DocumentManager.js @@ -1144,7 +1144,7 @@ define(function (require, exports, module) { exports.removeFromWorkingSet = removeFromWorkingSet; exports.getNextPrevFile = getNextPrevFile; exports.switchFilesIndex = switchFilesIndex; - exports.beginDocumentNavigation = beginDocumentNavigation; + exports.beginDocumentNavigation = beginDocumentNavigation; exports.finalizeDocumentNavigation = finalizeDocumentNavigation; exports.closeFullEditor = closeFullEditor; exports.closeAll = closeAll; @@ -1153,7 +1153,7 @@ define(function (require, exports, module) { // Setup preferences _prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID); - $(exports).bind("currentDocumentChange workingSetAdd workingSetAddList workingSetRemove workingSetRemoveList fileNameChange", _savePreferences); + $(exports).bind("currentDocumentChange workingSetAdd workingSetAddList workingSetRemove workingSetRemoveList fileNameChange workingSetReorder", _savePreferences); // Performance measurements PerfUtils.createPerfMeasurement("DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH", "DocumentManager.getDocumentForPath()"); diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 511e6aa1556..812b320843a 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -131,6 +131,9 @@ define(function (require, exports, module) { $fileStatusIcon.toggleClass("dirty", Boolean(isDirty)); $fileStatusIcon.toggleClass("can-close", Boolean(canClose)); } + + // Dispatch event + $(exports).triggerHandler("workingSetReorder"); } /** @@ -164,7 +167,7 @@ define(function (require, exports, module) { prevSelected = $prevListItem.hasClass("selected"), nextSelected = $nextListItem.hasClass("selected"), index = DocumentManager.findInWorkingSet($listItem.data(_FILE_KEY).fullPath), - height = $listItem.height(), + height = $listItem.height(), startPageY = event.pageY, moved = false; @@ -183,13 +186,13 @@ define(function (require, exports, module) { $prevListItem.insertAfter($listItem); startPageY -= height; top = top + height; - DocumentManager.switchFilesIndex(index, --index); + 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); + DocumentManager.switchFilesIndex(index, ++index); } if (!selected) { @@ -239,6 +242,9 @@ define(function (require, exports, module) { ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); } } + + // Dispatch event + $(DocumentManager).triggerHandler("workingSetReorder"); }); } From 5dbe02cc63fa7581f4ae3261670fb24799c3df14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Tue, 16 Oct 2012 06:16:10 -0300 Subject: [PATCH 14/30] Minor fixes --- src/project/WorkingSetView.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 812b320843a..ddca78daa17 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -131,9 +131,6 @@ define(function (require, exports, module) { $fileStatusIcon.toggleClass("dirty", Boolean(isDirty)); $fileStatusIcon.toggleClass("can-close", Boolean(canClose)); } - - // Dispatch event - $(exports).triggerHandler("workingSetReorder"); } /** @@ -482,4 +479,4 @@ define(function (require, exports, module) { } exports.create = create; -}); \ No newline at end of file +}); From bce68913141724446ffd917368477470da5887ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sat, 20 Oct 2012 20:13:53 -0300 Subject: [PATCH 15/30] Fixing error with Context Menu --- src/project/WorkingSetView.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 1a5cd39263e..4168f34e12e 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -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, @@ -211,7 +212,10 @@ define(function (require, exports, module) { // 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; } @@ -222,8 +226,7 @@ define(function (require, exports, module) { $(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") - .off("mouseup.workingSet"); + $(window.document).off("mousemove.workingSet mouseup.workingSet"); if (!moved) { // If file wasnt moved, open the file @@ -269,7 +272,12 @@ define(function (require, exports, module) { _updateListItemSelection($newItem, curDoc); $newItem.mousedown(function (e) { - _reorderListItem(e); + // Try to reorder only with the right click and just open the file in other cases + if (e.which === 1) { + _reorderListItem(e); + } else { + FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); + } e.preventDefault(); }); From 2610dbc728eee7105e710b66c1e4f23e152d21b6 Mon Sep 17 00:00:00 2001 From: Jeffrey Fisher Date: Sat, 20 Oct 2012 22:41:21 -0700 Subject: [PATCH 16/30] Added test back in that was commend out for issue #389. This test is now passing and the issue must have been fixed at some point without adding this test back in. --- test/spec/CSSUtils-test.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/spec/CSSUtils-test.js b/test/spec/CSSUtils-test.js index c49de23a0f4..99a45705d63 100644 --- a/test/spec/CSSUtils-test.js +++ b/test/spec/CSSUtils-test.js @@ -914,9 +914,8 @@ define(function (require, exports, module) { result = matchAgain({ clazz: "foo" }); expect(result.length).toBe(1); - // TODO (issue #389): false positive match from @keyframes animation identifier - // result = matchAgain({ tag: "slide" }); - // expect(result.length).toBe(0); + result = matchAgain({ tag: "slide" }); + expect(result.length).toBe(0); result = matchAgain({ tag: "from" }); expect(result.length).toBe(0); From 4f01dd52b5b00c8d45eb439cb24beab03ad9f02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 21 Oct 2012 18:39:52 -0300 Subject: [PATCH 17/30] Fixes after review --- src/document/DocumentManager.js | 17 ++++++++--------- src/project/WorkingSetView.js | 29 +++++++++++++++++++---------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/document/DocumentManager.js b/src/document/DocumentManager.js index 9ab4f1b8c8a..39a5fea0dc9 100644 --- a/src/document/DocumentManager.js +++ b/src/document/DocumentManager.js @@ -300,19 +300,18 @@ define(function (require, exports, module) { /** - * Changes the position of the file from oldIndex to NewIndex and at the same time the file - * in newIndex to oldIndex. Returns the newIndex + * Mutually exchanges the files at the indexes passed by parameters. * @param {!number} index - old file index * @param {!number} index - new file index */ - function switchFilesIndex(oldIndex, newIndex) { + function swapWorkingSetIndexes(index1, index2) { var length = _workingSet.length - 1; - var aux; + var temp; - if (oldIndex >= 0 && oldIndex <= length && newIndex >= 0 && newIndex <= length) { - aux = _workingSet[oldIndex]; - _workingSet[oldIndex] = _workingSet[newIndex]; - _workingSet[newIndex] = aux; + if (index1 >= 0 && index2 <= length && index1 >= 0 && index2 <= length) { + temp = _workingSet[index1]; + _workingSet[index1] = _workingSet[index2]; + _workingSet[index2] = temp; } } @@ -1139,7 +1138,7 @@ define(function (require, exports, module) { exports.addListToWorkingSet = addListToWorkingSet; exports.removeFromWorkingSet = removeFromWorkingSet; exports.getNextPrevFile = getNextPrevFile; - exports.switchFilesIndex = switchFilesIndex; + exports.swapWorkingSetIndexes = swapWorkingSetIndexes; exports.beginDocumentNavigation = beginDocumentNavigation; exports.finalizeDocumentNavigation = finalizeDocumentNavigation; exports.closeFullEditor = closeFullEditor; diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 4168f34e12e..2a3b06c9620 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -171,7 +171,7 @@ define(function (require, exports, module) { $listItem.css("position", "relative").css("z-index", 1); - $(window.document).on("mousemove.workingSet", function (e) { + $openFilesContainer.on("mousemove.workingSet", function (e) { var top = e.pageY - startPageY; // Drag if the item is not the first and moving it up or @@ -184,16 +184,20 @@ define(function (require, exports, module) { $prevListItem.insertAfter($listItem); startPageY -= height; top = top + height; - DocumentManager.switchFilesIndex(index, --index); + DocumentManager.swapWorkingSetIndexes(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); + DocumentManager.swapWorkingSetIndexes(index, ++index); } if (!selected) { + // Update the selection when the previows or next element were selected + if ((top > 0 && prevSelected) || (top < 0 && nextSelected)) { + _fireSelectionChanged(); + } // Remove the shadows as it will appear and they should not ViewUtils.removeScrollerShadow($openFilesContainer[0], null); } @@ -201,6 +205,8 @@ define(function (require, exports, module) { // Update the previows and next items $prevListItem = $listItem.prev(); $nextListItem = $listItem.next(); + prevSelected = $prevListItem.hasClass("selected"); + nextSelected = $nextListItem.hasClass("selected"); } } else { // Set the top to 0 as the event probably didnt fired at the exact start/end of the list @@ -209,9 +215,6 @@ define(function (require, exports, module) { // 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 @@ -221,25 +224,31 @@ define(function (require, exports, module) { // Move the item $listItem.css("top", top + "px"); + + // Update the selection position + if (selected) { + _fireSelectionChanged(); + } }); - $(window.document).on("mouseup.workingSet", function (e) { + $openFilesContainer.on("mouseup.workingSet mouseleave.workingSet", function (e) { // Removes the styles, placing the item in the chocen place $listItem.removeAttr("style"); - $(window.document).off("mousemove.workingSet mouseup.workingSet"); + $openFilesContainer.off("mousemove.workingSet mouseup.workingSet mouseleave.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); + } else { + // Restore the file selection + _fireSelectionChanged(); } } From 21569eb0a14f00aa506856f5c5d0343feb9c8590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 21 Oct 2012 18:42:32 -0300 Subject: [PATCH 18/30] Fixes after review --- src/project/WorkingSetView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 2a3b06c9620..7e9b367d53b 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -281,7 +281,7 @@ define(function (require, exports, module) { _updateListItemSelection($newItem, curDoc); $newItem.mousedown(function (e) { - // Try to reorder only with the right click and just open the file in other cases + // Try to reorder only with the left click and just open the file in other cases if (e.which === 1) { _reorderListItem(e); } else { From dc0a7a3d12c9b9652acd211adf5fb3d5a819cc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sun, 21 Oct 2012 20:38:37 -0300 Subject: [PATCH 19/30] Adding dragging from close icon --- src/project/WorkingSetView.js | 156 ++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 74 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 7e9b367d53b..85297a2eae5 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -91,75 +91,24 @@ define(function (require, exports, module) { _fireSelectionChanged(); } - /** - * Updates the appearance of the list element based on the parameters provided - * @private - * @param {!HTMLLIElement} listElement - * @param {bool} isDirty - * @param {bool} canClose - */ - function _updateFileStatusIcon(listElement, isDirty, canClose) { - var $fileStatusIcon = listElement.find(".file-status-icon"); - var showIcon = isDirty || canClose; - - // remove icon if its not needed - if (!showIcon && $fileStatusIcon.length !== 0) { - $fileStatusIcon.remove(); - $fileStatusIcon = null; - - // create icon if its needed and doesn't exist - } else if (showIcon && $fileStatusIcon.length === 0) { - - $fileStatusIcon = $("
") - .prependTo(listElement) - .mousedown(function (e) { - // stopPropagation of mousedown for fileStatusIcon so the parent
  • item, which - // selects documents on mousedown, doesn't select the document in the case - // when the click is on fileStatusIcon - e.stopPropagation(); - }) - .click(function () { - // Clicking the "X" button is equivalent to File > Close; it doesn't merely - // remove a file from the working set - var file = listElement.data(_FILE_KEY); - CommandManager.execute(Commands.FILE_CLOSE, {file: file}); - }); - } - - // Set icon's class - if ($fileStatusIcon) { - // cast to Boolean needed because toggleClass() distinguishes true/false from truthy/falsy - $fileStatusIcon.toggleClass("dirty", Boolean(isDirty)); - $fileStatusIcon.toggleClass("can-close", Boolean(canClose)); - } - } - - /** - * Updates the appearance of the list element based on the parameters provided. - * @private - * @param {!HTMLLIElement} listElement - * @param {?Document} selectedDoc - */ - function _updateListItemSelection(listItem, selectedDoc) { - var shouldBeSelected = (selectedDoc && $(listItem).data(_FILE_KEY).fullPath === selectedDoc.file.fullPath); - - // cast to Boolean needed because toggleClass() distinguishes true/false from truthy/falsy - $(listItem).toggleClass("selected", Boolean(shouldBeSelected)); - } - - function isOpenAndDirty(file) { - var docIfOpen = DocumentManager.getOpenDocumentForPath(file.fullPath); - return (docIfOpen && docIfOpen.isDirty); - } - - /** + /** * Starts the drag and drop working set view reorder. * @private * @param {!Event} event - jQuery event + * @paran {!HTMLLIElement} $listItem - jQuery element + * @param {?bool} fromClose - true if reorder was called from the close icon */ - function _reorderListItem(event) { - var $listItem = $(event.currentTarget), - $prevListItem = $listItem.prev(), + function _reorderListItem(event, $listItem, fromClose) { + // Only drag with the left mouse button + if (event.which !== 1) { + // Open the file if it wasnt called from the close button + if (!fromClose) { + FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + } + return; + } + + var $prevListItem = $listItem.prev(), $nextListItem = $listItem.next(), selected = $listItem.hasClass("selected"), prevSelected = $prevListItem.hasClass("selected"), @@ -236,10 +185,10 @@ define(function (require, exports, module) { $listItem.removeAttr("style"); $openFilesContainer.off("mousemove.workingSet mouseup.workingSet mouseleave.workingSet"); - if (!moved) { - // If file wasnt moved, open the file + if (!moved && !fromClose) { + // If file wasnt moved and wasnt called from the close icon, open the file FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); - } else { + } else if (moved) { // Display the status icon again $listItem.find(".file-status-icon").css("display", "block"); @@ -257,6 +206,70 @@ define(function (require, exports, module) { }); } + /** + * Updates the appearance of the list element based on the parameters provided + * @private + * @param {!HTMLLIElement} listElement + * @param {bool} isDirty + * @param {bool} canClose + */ + function _updateFileStatusIcon(listElement, isDirty, canClose) { + var $fileStatusIcon = listElement.find(".file-status-icon"); + var showIcon = isDirty || canClose; + + // remove icon if its not needed + if (!showIcon && $fileStatusIcon.length !== 0) { + $fileStatusIcon.remove(); + $fileStatusIcon = null; + + // create icon if its needed and doesn't exist + } else if (showIcon && $fileStatusIcon.length === 0) { + + $fileStatusIcon = $("
    ") + .prependTo(listElement) + .mousedown(function (e) { + // Try to drag if that is what is wanted + _reorderListItem(e, $(this).parent(), true); + + // stopPropagation of mousedown for fileStatusIcon so the parent
  • item, which + // selects documents on mousedown, doesn't select the document in the case + // when the click is on fileStatusIcon + e.stopPropagation(); + }) + .click(function () { + // Clicking the "X" button is equivalent to File > Close; it doesn't merely + // remove a file from the working set + var file = listElement.data(_FILE_KEY); + CommandManager.execute(Commands.FILE_CLOSE, {file: file}); + }); + } + + // Set icon's class + if ($fileStatusIcon) { + // cast to Boolean needed because toggleClass() distinguishes true/false from truthy/falsy + $fileStatusIcon.toggleClass("dirty", Boolean(isDirty)); + $fileStatusIcon.toggleClass("can-close", Boolean(canClose)); + } + } + + /** + * Updates the appearance of the list element based on the parameters provided. + * @private + * @param {!HTMLLIElement} listElement + * @param {?Document} selectedDoc + */ + function _updateListItemSelection(listItem, selectedDoc) { + var shouldBeSelected = (selectedDoc && $(listItem).data(_FILE_KEY).fullPath === selectedDoc.file.fullPath); + + // cast to Boolean needed because toggleClass() distinguishes true/false from truthy/falsy + $(listItem).toggleClass("selected", Boolean(shouldBeSelected)); + } + + function isOpenAndDirty(file) { + var docIfOpen = DocumentManager.getOpenDocumentForPath(file.fullPath); + return (docIfOpen && docIfOpen.isDirty); + } + /** * Builds the UI for a new list item and inserts in into the end of the list * @private @@ -281,12 +294,7 @@ define(function (require, exports, module) { _updateListItemSelection($newItem, curDoc); $newItem.mousedown(function (e) { - // Try to reorder only with the left click and just open the file in other cases - if (e.which === 1) { - _reorderListItem(e); - } else { - FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); - } + _reorderListItem(e, $(this)); e.preventDefault(); }); From fd481e8d44b9932d9054fc5f67ba62624bdb9421 Mon Sep 17 00:00:00 2001 From: RaymondLim Date: Mon, 22 Oct 2012 09:44:51 -0700 Subject: [PATCH 20/30] Update dirty flag in lightning bolt icon for all dirty flag change notification. --- src/LiveDevelopment/LiveDevelopment.js | 27 +++++++++++--------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/LiveDevelopment/LiveDevelopment.js b/src/LiveDevelopment/LiveDevelopment.js index a5733db55da..e8291a25dbe 100644 --- a/src/LiveDevelopment/LiveDevelopment.js +++ b/src/LiveDevelopment/LiveDevelopment.js @@ -501,27 +501,22 @@ define(function LiveDevelopment(require, exports, module) { /** Triggered by a document saved from the DocumentManager */ function _onDocumentSaved(event, doc) { - if (doc && Inspector.connected() && _classForDocument(doc) !== CSSDocument) { - if (agents.network && agents.network.wasURLRequested(doc.url)) { - // Reload HTML page - Inspector.Page.reload(); - - // Reload unsaved changes - _onReconnect(); - - // Set status back to active - _setStatus(STATUS_ACTIVE); - } + if (doc && Inspector.connected() && _classForDocument(doc) !== CSSDocument && + agents.network && agents.network.wasURLRequested(doc.url)) { + // Reload HTML page + Inspector.Page.reload(); + + // Reload unsaved changes + _onReconnect(); } } /** Triggered by a change in dirty flag from the DocumentManager */ function _onDirtyFlagChange(event, doc) { - if (Inspector.connected() && doc && doc.isDirty && _classForDocument(doc) !== CSSDocument) { - if (agents.network && agents.network.wasURLRequested(doc.url)) { - // Set status to out of sync - _setStatus(STATUS_OUT_OF_SYNC); - } + if (doc && Inspector.connected() && _classForDocument(doc) !== CSSDocument && + agents.network && agents.network.wasURLRequested(doc.url)) { + // Set status to out of sync if dirty. Otherwise, set it to active status. + _setStatus(doc.isDirty ? STATUS_OUT_OF_SYNC : STATUS_ACTIVE); } } From 4144abe628c36a706eb8ae489f13e5d2e0f7a6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 22 Oct 2012 19:50:02 -0300 Subject: [PATCH 21/30] Scroll into view and better fix for the boottom shadow --- src/project/WorkingSetView.js | 55 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 85297a2eae5..76f14a19816 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -108,15 +108,18 @@ define(function (require, exports, module) { return; } - var $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; + var $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, + scrollElement = $openFilesContainer.get(0), + hasBottomShadow = scrollElement.scrollHeight > scrollElement.scrollTop + scrollElement.clientHeight, + addBottomShadow = false; $listItem.css("position", "relative").css("z-index", 1); @@ -142,13 +145,9 @@ define(function (require, exports, module) { DocumentManager.swapWorkingSetIndexes(index, ++index); } - if (!selected) { - // Update the selection when the previows or next element were selected - if ((top > 0 && prevSelected) || (top < 0 && nextSelected)) { - _fireSelectionChanged(); - } - // Remove the shadows as it will appear and they should not - ViewUtils.removeScrollerShadow($openFilesContainer[0], null); + // Update the selection when the previows or next element were selected + if (!selected && ((top > 0 && prevSelected) || (top < 0 && nextSelected))) { + _fireSelectionChanged(); } // Update the previows and next items @@ -156,6 +155,15 @@ define(function (require, exports, module) { $nextListItem = $listItem.next(); prevSelected = $prevListItem.hasClass("selected"); nextSelected = $nextListItem.hasClass("selected"); + + // If the last item of the list was selected and the previows was moved to its location, then + // the it will show a bottom shadow even if it shouldnt because of the way the scrollHeight is + // handle with relative position. This will remove that shadow and add it on drop. + if (!addBottomShadow && !hasBottomShadow && !$nextListItem.length && prevSelected) { + ViewUtils.removeScrollerShadow($openFilesContainer[0], null); + ViewUtils.addScrollerShadow($openFilesContainer[0], null, false); + addBottomShadow = true; + } } } else { // Set the top to 0 as the event probably didnt fired at the exact start/end of the list @@ -166,7 +174,6 @@ define(function (require, exports, module) { if (!moved && Math.abs(top) > 2) { // Hide the close icon $listItem.find(".file-status-icon").css("display", "none"); - // Close all menus Menus.closeAll(); moved = true; } @@ -192,12 +199,14 @@ define(function (require, exports, module) { // 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); - } else { - // Restore the file selection + if (selected) { + // Update the file selection _fireSelectionChanged(); + ViewUtils.scrollElementIntoView($openFilesContainer, $listItem, false); + } + if (addBottomShadow) { + // Restore the shadows + ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); } } @@ -269,7 +278,7 @@ define(function (require, exports, module) { var docIfOpen = DocumentManager.getOpenDocumentForPath(file.fullPath); return (docIfOpen && docIfOpen.isDirty); } - + /** * Builds the UI for a new list item and inserts in into the end of the list * @private From 49d0b80f126aca50a883b9219ed4581f70c1da37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Mon, 22 Oct 2012 20:56:00 -0300 Subject: [PATCH 22/30] Fixing indentations --- src/project/WorkingSetView.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 76f14a19816..7fdb10b3fb6 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -118,7 +118,7 @@ define(function (require, exports, module) { startPageY = event.pageY, moved = false, scrollElement = $openFilesContainer.get(0), - hasBottomShadow = scrollElement.scrollHeight > scrollElement.scrollTop + scrollElement.clientHeight, + hasBottomShadow = scrollElement.scrollHeight > scrollElement.scrollTop + scrollElement.clientHeight, addBottomShadow = false; $listItem.css("position", "relative").css("z-index", 1); @@ -159,11 +159,11 @@ define(function (require, exports, module) { // If the last item of the list was selected and the previows was moved to its location, then // the it will show a bottom shadow even if it shouldnt because of the way the scrollHeight is // handle with relative position. This will remove that shadow and add it on drop. - if (!addBottomShadow && !hasBottomShadow && !$nextListItem.length && prevSelected) { - ViewUtils.removeScrollerShadow($openFilesContainer[0], null); - ViewUtils.addScrollerShadow($openFilesContainer[0], null, false); - addBottomShadow = true; - } + if (!addBottomShadow && !hasBottomShadow && !$nextListItem.length && prevSelected) { + ViewUtils.removeScrollerShadow($openFilesContainer[0], null); + ViewUtils.addScrollerShadow($openFilesContainer[0], null, false); + addBottomShadow = true; + } } } else { // Set the top to 0 as the event probably didnt fired at the exact start/end of the list @@ -199,10 +199,10 @@ define(function (require, exports, module) { // Display the status icon again $listItem.find(".file-status-icon").css("display", "block"); - if (selected) { + if (selected) { // Update the file selection _fireSelectionChanged(); - ViewUtils.scrollElementIntoView($openFilesContainer, $listItem, false); + ViewUtils.scrollElementIntoView($openFilesContainer, $listItem, false); } if (addBottomShadow) { // Restore the shadows From e59cfa55babbcfbdee204212289552a471aa7670 Mon Sep 17 00:00:00 2001 From: Garth Braithwaite Date: Tue, 23 Oct 2012 10:02:48 -0700 Subject: [PATCH 23/30] add settings icon --- src/styles/images/settings_small.svg | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/styles/images/settings_small.svg diff --git a/src/styles/images/settings_small.svg b/src/styles/images/settings_small.svg new file mode 100644 index 00000000000..7686a2cd8a1 --- /dev/null +++ b/src/styles/images/settings_small.svg @@ -0,0 +1,18 @@ + + + + + + + + + + From a46cb10337442de7cebba57724733a4a1f9c2267 Mon Sep 17 00:00:00 2001 From: Zanqi Liang Date: Tue, 23 Oct 2012 18:42:52 -0400 Subject: [PATCH 24/30] F2 to rename --- src/command/Menus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/Menus.js b/src/command/Menus.js index 21b868f5059..b618ce14ce5 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -966,7 +966,7 @@ define(function (require, exports, module) { var project_cmenu = registerContextMenu(ContextMenuIds.PROJECT_MENU); project_cmenu.addMenuItem(Commands.FILE_NEW); project_cmenu.addMenuItem(Commands.FILE_NEW_FOLDER); - project_cmenu.addMenuItem(Commands.FILE_RENAME); + project_cmenu.addMenuItem(Commands.FILE_RENAME, "F2"); var working_set_cmenu = registerContextMenu(ContextMenuIds.WORKING_SET_MENU); working_set_cmenu.addMenuItem(Commands.FILE_CLOSE); From 4a620121b97863c74fa96e83fed5ec20182e1942 Mon Sep 17 00:00:00 2001 From: Randy Edmunds Date: Tue, 23 Oct 2012 15:42:59 -0700 Subject: [PATCH 25/30] make mdoe string more presentable --- src/editor/EditorManager.js | 2 +- src/widgets/StatusBar.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index cad78b89af6..d4ed9d02639 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -614,7 +614,7 @@ define(function (require, exports, module) { } function _updateModeInfo(editor) { - $modeInfo.text(editor.getModeForSelection()); + $modeInfo.text(StatusBar.getModeDisplayString(editor.getModeForSelection())); } function _updateFileInfo(editor) { diff --git a/src/widgets/StatusBar.js b/src/widgets/StatusBar.js index 3281c25d548..291f8fb445f 100644 --- a/src/widgets/StatusBar.js +++ b/src/widgets/StatusBar.js @@ -180,12 +180,44 @@ define(function (require, exports, module) { // hide on init hide(); } + + function getModeDisplayString(mode) { + // mode is either a string or an object with a name property string + var s = (typeof mode === "string") ? mode : mode.name, + slash, + result; + + s = s.toLowerCase(); + + // Handle special cases + if (s === "javascript") { + return "JavaScript"; + } else if (s === "html") { + return "HTML"; + } else if (s === "css") { + return "CSS"; + } + + // Generic case. First strip / and everything after + slash = s.indexOf("/"); + + if (slash !== -1) { + s = s.substr(0, slash); + } + + // Uppercase first char and rest is (already) lowercase + result = s[0].toUpperCase(); + result += s.substr(1); + + return result; + } exports.init = init; exports.showBusyIndicator = showBusyIndicator; exports.hideBusyIndicator = hideBusyIndicator; exports.addIndicator = addIndicator; exports.updateIndicator = updateIndicator; + exports.getModeDisplayString = getModeDisplayString; exports.hide = hide; exports.show = show; }); \ No newline at end of file From c62b99dbde8a13852428b128450247dacc04e122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Wed, 24 Oct 2012 05:53:47 -0300 Subject: [PATCH 26/30] Adding scrolling while dragging and other fixes --- src/project/WorkingSetView.js | 145 ++++++++++++++++++++++++---------- 1 file changed, 102 insertions(+), 43 deletions(-) diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 7fdb10b3fb6..a91d01a55ad 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -99,15 +99,6 @@ define(function (require, exports, module) { * @param {?bool} fromClose - true if reorder was called from the close icon */ function _reorderListItem(event, $listItem, fromClose) { - // Only drag with the left mouse button - if (event.which !== 1) { - // Open the file if it wasnt called from the close button - if (!fromClose) { - FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); - } - return; - } - var $prevListItem = $listItem.prev(), $nextListItem = $listItem.next(), selected = $listItem.hasClass("selected"), @@ -116,14 +107,20 @@ define(function (require, exports, module) { index = DocumentManager.findInWorkingSet($listItem.data(_FILE_KEY).fullPath), height = $listItem.height(), startPageY = event.pageY, - moved = false, + listItemTop = startPageY - $listItem.offset().top, + listItemBottom = $listItem.offset().top + height - startPageY, + offsetTop = $openFilesContainer.offset().top, scrollElement = $openFilesContainer.get(0), - hasBottomShadow = scrollElement.scrollHeight > scrollElement.scrollTop + scrollElement.clientHeight, - addBottomShadow = false; - - $listItem.css("position", "relative").css("z-index", 1); + containerHeight = scrollElement.clientHeight, + maxScroll = scrollElement.scrollHeight - containerHeight, + hasScroll = scrollElement.scrollHeight > containerHeight, + hasBottomShadow = scrollElement.scrollHeight > scrollElement.scrollTop + containerHeight, + addBottomShadow = false, + interval = false, + moved = false; - $openFilesContainer.on("mousemove.workingSet", function (e) { + // Drag the List Item + function drag(e) { var top = e.pageY - startPageY; // Drag if the item is not the first and moving it up or @@ -131,14 +128,14 @@ define(function (require, exports, module) { 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 moving up, place the previows item after the moving item if (top < 0) { - // If moving up, place the previows item after the moving item $prevListItem.insertAfter($listItem); startPageY -= height; top = top + height; DocumentManager.swapWorkingSetIndexes(index, --index); + // If moving down, place the next item before the moving item } else { - // If moving down, place the next item before the moving item $nextListItem.insertBefore($listItem); startPageY += height; top = top - height; @@ -165,19 +162,11 @@ define(function (require, exports, module) { addBottomShadow = true; } } + // Set the top to 0 as the event probably didnt fired at the exact start/end of the list } 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) { - // Hide the close icon - $listItem.find(".file-status-icon").css("display", "none"); - Menus.closeAll(); - moved = true; - } - // Move the item $listItem.css("top", top + "px"); @@ -185,20 +174,69 @@ define(function (require, exports, module) { if (selected) { _fireSelectionChanged(); } - }); + + // Once the movement is greater than 3 pixels, it is assumed that the user wantes to reorder files and not open + if (!moved && Math.abs(top) > 3) { + Menus.closeAll(); + moved = true; + } + } - $openFilesContainer.on("mouseup.workingSet mouseleave.workingSet", function (e) { - // Removes the styles, placing the item in the chocen place + function endScroll() { + window.clearInterval(interval); + interval = false; + } + + // Scroll view if the mouse is over the first or last pixels of the container + function scroll(e) { + var dir = 0; + // Mouse over the first visible pixels and moving up + if (e.pageY - listItemTop < offsetTop + 7) { + dir = -1; + // Mouse over the last visible pixels and moving down + } else if (e.pageY + listItemBottom > offsetTop + containerHeight - 7) { + dir = 1; + } + + if (dir && !interval) { + // Scroll and drag as long as needed + interval = window.setInterval(function () { + var scrollTop = $openFilesContainer.scrollTop(); + // End scroll if there isn't more to scroll + if ((dir === -1 && scrollTop <= 0) || (dir === 1 && scrollTop >= maxScroll)) { + endScroll(); + } else { + $openFilesContainer.scrollTop(scrollTop + 7 * dir); + startPageY -= 7 * dir; + drag(e); + } + }, 100); + } else if (!dir && interval) { + endScroll(); + } + } + + // Drop List Item + function drop() { + // Enable Mousewheel + window.onmousewheel = window.document.onmousewheel = null; + + // Removes the styles, placing the item in the chosen place $listItem.removeAttr("style"); - $openFilesContainer.off("mousemove.workingSet mouseup.workingSet mouseleave.workingSet"); - if (!moved && !fromClose) { - // If file wasnt moved and wasnt called from the close icon, open the file - FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + // End the scrolling if needed + if (interval) { + window.clearInterval(interval); + } + + // If file wasnt moved open or close it + if (!moved) { + if (!fromClose) { + FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + } else { + CommandManager.execute(Commands.FILE_CLOSE, {file: $listItem.data(_FILE_KEY)}); + } } else if (moved) { - // Display the status icon again - $listItem.find(".file-status-icon").css("display", "block"); - if (selected) { // Update the file selection _fireSelectionChanged(); @@ -212,6 +250,32 @@ define(function (require, exports, module) { // Dispatch event $(DocumentManager).triggerHandler("workingSetReorder"); + } + + + // Only drag with the left mouse button, end the drop in other cases + if (event.which !== 1) { + drop(); + return; + } + + // Disable Mousewheel while dragging + window.onmousewheel = window.document.onmousewheel = function (e) { e.preventDefault(); }; + + // Style the element + $listItem.css("position", "relative").css("z-index", 1); + + // Envent Handlers + $openFilesContainer.on("mousemove.workingSet", function (e) { + if (hasScroll) { + scroll(e); + } + drag(e); + }); + $openFilesContainer.on("mouseup.workingSet mouseleave.workingSet", function (e) { + $openFilesContainer.off("mousemove.workingSet mouseup.workingSet mouseleave.workingSet"); + drop(); + }); } @@ -237,19 +301,14 @@ define(function (require, exports, module) { $fileStatusIcon = $("
    ") .prependTo(listElement) .mousedown(function (e) { - // Try to drag if that is what is wanted + // Try to drag if that is what is wanted if not it will be the equivalent to File > Close; + // it doesn't merely remove a file from the working set _reorderListItem(e, $(this).parent(), true); // stopPropagation of mousedown for fileStatusIcon so the parent
  • item, which // selects documents on mousedown, doesn't select the document in the case // when the click is on fileStatusIcon e.stopPropagation(); - }) - .click(function () { - // Clicking the "X" button is equivalent to File > Close; it doesn't merely - // remove a file from the working set - var file = listElement.data(_FILE_KEY); - CommandManager.execute(Commands.FILE_CLOSE, {file: file}); }); } From c5da9b8f221840e2063286739db9fa7eea4ea29c Mon Sep 17 00:00:00 2001 From: Randy Edmunds Date: Wed, 24 Oct 2012 11:12:12 -0700 Subject: [PATCH 27/30] get more info out of mimetype modes --- src/widgets/StatusBar.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/widgets/StatusBar.js b/src/widgets/StatusBar.js index 291f8fb445f..d2191a89e3a 100644 --- a/src/widgets/StatusBar.js +++ b/src/widgets/StatusBar.js @@ -196,11 +196,26 @@ define(function (require, exports, module) { return "HTML"; } else if (s === "css") { return "CSS"; + } else if (s === "text/plain") { + return "Text"; } - // Generic case. First strip / and everything after - slash = s.indexOf("/"); + // Generic case + + // Strip "text/" or "application/" from beginning + if (s.indexOf("text/") === 0) { + s = s.substr(5); + } else if (s.indexOf("application/") === 0) { + s = s.substr(12); + } + // Strip "x-" from beginning + if (s.indexOf("x-") === 0) { + s = s.substr(2); + } + + // Strip any remaining "/" sections from end + slash = s.indexOf("/"); if (slash !== -1) { s = s.substr(0, slash); } From 30255fc58dae81c0630cf403d08e27b7b29e292b Mon Sep 17 00:00:00 2001 From: Randy Edmunds Date: Wed, 24 Oct 2012 13:14:05 -0700 Subject: [PATCH 28/30] code review fixes --- src/widgets/StatusBar.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/widgets/StatusBar.js b/src/widgets/StatusBar.js index d2191a89e3a..26b41b3aa02 100644 --- a/src/widgets/StatusBar.js +++ b/src/widgets/StatusBar.js @@ -198,21 +198,17 @@ define(function (require, exports, module) { return "CSS"; } else if (s === "text/plain") { return "Text"; + } else if (s === "xml") { + return "XML"; } // Generic case // Strip "text/" or "application/" from beginning - if (s.indexOf("text/") === 0) { - s = s.substr(5); - } else if (s.indexOf("application/") === 0) { - s = s.substr(12); - } + s = s.replace(/^(text\/|application\/)/, ""); // Strip "x-" from beginning - if (s.indexOf("x-") === 0) { - s = s.substr(2); - } + s = s.replace(/^x-/, ""); // Strip any remaining "/" sections from end slash = s.indexOf("/"); From a81b7449729e90da8ed72ecb68a68a8d08362a26 Mon Sep 17 00:00:00 2001 From: Randy Edmunds Date: Wed, 24 Oct 2012 13:28:04 -0700 Subject: [PATCH 29/30] add special cases for: less, php --- src/widgets/StatusBar.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widgets/StatusBar.js b/src/widgets/StatusBar.js index 26b41b3aa02..3c4f594cd63 100644 --- a/src/widgets/StatusBar.js +++ b/src/widgets/StatusBar.js @@ -196,8 +196,12 @@ define(function (require, exports, module) { return "HTML"; } else if (s === "css") { return "CSS"; + } else if (s === "less") { + return "LESS"; } else if (s === "text/plain") { return "Text"; + } else if (s === "php") { + return "PHP"; } else if (s === "xml") { return "XML"; } From 6d4412113fba40db0c9398ff1e6eef38909e1c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Wed, 24 Oct 2012 21:54:04 -0300 Subject: [PATCH 30/30] Working set view drag & drop to reorder files --- src/document/DocumentManager.js | 20 +++- src/project/WorkingSetView.js | 203 ++++++++++++++++++++++++++++++-- 2 files changed, 214 insertions(+), 9 deletions(-) diff --git a/src/document/DocumentManager.js b/src/document/DocumentManager.js index 78f5b05cebb..39a5fea0dc9 100644 --- a/src/document/DocumentManager.js +++ b/src/document/DocumentManager.js @@ -299,6 +299,23 @@ define(function (require, exports, module) { } + /** + * Mutually exchanges the files at the indexes passed by parameters. + * @param {!number} index - old file index + * @param {!number} index - new file index + */ + function swapWorkingSetIndexes(index1, index2) { + var length = _workingSet.length - 1; + var temp; + + if (index1 >= 0 && index2 <= length && index1 >= 0 && index2 <= length) { + temp = _workingSet[index1]; + _workingSet[index1] = _workingSet[index2]; + _workingSet[index2] = temp; + } + } + + /** * Indicate that changes to currentDocument are temporary for now, and should not update the MRU * ordering of the working set. Useful for next/previous keyboard navigation (until Ctrl is released) @@ -1121,6 +1138,7 @@ define(function (require, exports, module) { exports.addListToWorkingSet = addListToWorkingSet; exports.removeFromWorkingSet = removeFromWorkingSet; exports.getNextPrevFile = getNextPrevFile; + exports.swapWorkingSetIndexes = swapWorkingSetIndexes; exports.beginDocumentNavigation = beginDocumentNavigation; exports.finalizeDocumentNavigation = finalizeDocumentNavigation; exports.closeFullEditor = closeFullEditor; @@ -1130,7 +1148,7 @@ define(function (require, exports, module) { // Setup preferences _prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID); - $(exports).bind("currentDocumentChange workingSetAdd workingSetAddList workingSetRemove workingSetRemoveList fileNameChange", _savePreferences); + $(exports).bind("currentDocumentChange workingSetAdd workingSetAddList workingSetRemove workingSetRemoveList fileNameChange workingSetReorder", _savePreferences); // Performance measurements PerfUtils.createPerfMeasurement("DOCUMENT_MANAGER_GET_DOCUMENT_FOR_PATH", "DocumentManager.getDocumentForPath()"); diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index 1f7c326efae..45485e0f9a9 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -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, @@ -90,6 +91,194 @@ define(function (require, exports, module) { _fireSelectionChanged(); } + /** + * Starts the drag and drop working set view reorder. + * @private + * @param {!Event} event - jQuery event + * @paran {!HTMLLIElement} $listItem - jQuery element + * @param {?bool} fromClose - true if reorder was called from the close icon + */ + function _reorderListItem(event, $listItem, fromClose) { + var $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, + listItemTop = startPageY - $listItem.offset().top, + listItemBottom = $listItem.offset().top + height - startPageY, + offsetTop = $openFilesContainer.offset().top, + scrollElement = $openFilesContainer.get(0), + containerHeight = scrollElement.clientHeight, + maxScroll = scrollElement.scrollHeight - containerHeight, + hasScroll = scrollElement.scrollHeight > containerHeight, + hasBottomShadow = scrollElement.scrollHeight > scrollElement.scrollTop + containerHeight, + addBottomShadow = false, + interval = false, + moved = false; + + // Drag the List Item + function drag(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 moving up, place the previows item after the moving item + if (top < 0) { + $prevListItem.insertAfter($listItem); + startPageY -= height; + top = top + height; + DocumentManager.swapWorkingSetIndexes(index, --index); + // If moving down, place the next item before the moving item + } else { + $nextListItem.insertBefore($listItem); + startPageY += height; + top = top - height; + DocumentManager.swapWorkingSetIndexes(index, ++index); + } + + // Update the selection when the previows or next element were selected + if (!selected && ((top > 0 && prevSelected) || (top < 0 && nextSelected))) { + _fireSelectionChanged(); + } + + // Update the previows and next items + $prevListItem = $listItem.prev(); + $nextListItem = $listItem.next(); + prevSelected = $prevListItem.hasClass("selected"); + nextSelected = $nextListItem.hasClass("selected"); + + // If the last item of the list was selected and the previows was moved to its location, then + // the it will show a bottom shadow even if it shouldnt because of the way the scrollHeight is + // handle with relative position. This will remove that shadow and add it on drop. + if (!addBottomShadow && !hasBottomShadow && !$nextListItem.length && prevSelected) { + ViewUtils.removeScrollerShadow($openFilesContainer[0], null); + ViewUtils.addScrollerShadow($openFilesContainer[0], null, false); + addBottomShadow = true; + } + } + // Set the top to 0 as the event probably didnt fired at the exact start/end of the list + } else { + top = 0; + } + + // Move the item + $listItem.css("top", top + "px"); + + // Update the selection position + if (selected) { + _fireSelectionChanged(); + } + + // Once the movement is greater than 3 pixels, it is assumed that the user wantes to reorder files and not open + if (!moved && Math.abs(top) > 3) { + Menus.closeAll(); + moved = true; + } + } + + function endScroll() { + window.clearInterval(interval); + interval = false; + } + + // Scroll view if the mouse is over the first or last pixels of the container + function scroll(e) { + var dir = 0; + // Mouse over the first visible pixels and moving up + if (e.pageY - listItemTop < offsetTop + 7) { + dir = -1; + // Mouse over the last visible pixels and moving down + } else if (e.pageY + listItemBottom > offsetTop + containerHeight - 7) { + dir = 1; + } + + if (dir && !interval) { + // Scroll and drag as long as needed + interval = window.setInterval(function () { + var scrollTop = $openFilesContainer.scrollTop(); + // End scroll if there isn't more to scroll + if ((dir === -1 && scrollTop <= 0) || (dir === 1 && scrollTop >= maxScroll)) { + endScroll(); + } else { + $openFilesContainer.scrollTop(scrollTop + 7 * dir); + startPageY -= 7 * dir; + drag(e); + } + }, 100); + } else if (!dir && interval) { + endScroll(); + } + } + + // Drop List Item + function drop() { + // Enable Mousewheel + window.onmousewheel = window.document.onmousewheel = null; + + // Removes the styles, placing the item in the chosen place + $listItem.removeAttr("style"); + + // End the scrolling if needed + if (interval) { + window.clearInterval(interval); + } + + // If file wasnt moved open or close it + if (!moved) { + if (!fromClose) { + FileViewController.openAndSelectDocument($listItem.data(_FILE_KEY).fullPath, FileViewController.WORKING_SET_VIEW); + } else { + CommandManager.execute(Commands.FILE_CLOSE, {file: $listItem.data(_FILE_KEY)}); + } + } else if (moved) { + if (selected) { + // Update the file selection + _fireSelectionChanged(); + ViewUtils.scrollElementIntoView($openFilesContainer, $listItem, false); + } + if (addBottomShadow) { + // Restore the shadows + ViewUtils.addScrollerShadow($openFilesContainer[0], null, true); + } + } + + // Dispatch event + $(DocumentManager).triggerHandler("workingSetReorder"); + } + + + // Only drag with the left mouse button, end the drop in other cases + if (event.which !== 1) { + drop(); + return; + } + + // Disable Mousewheel while dragging + window.onmousewheel = window.document.onmousewheel = function (e) { e.preventDefault(); }; + + // Style the element + $listItem.css("position", "relative").css("z-index", 1); + + // Envent Handlers + $openFilesContainer.on("mousemove.workingSet", function (e) { + if (hasScroll) { + scroll(e); + } + drag(e); + }); + $openFilesContainer.on("mouseup.workingSet mouseleave.workingSet", function (e) { + $openFilesContainer.off("mousemove.workingSet mouseup.workingSet mouseleave.workingSet"); + drop(); + + }); + } + /** * Updates the appearance of the list element based on the parameters provided * @private @@ -112,16 +301,14 @@ define(function (require, exports, module) { $fileStatusIcon = $("
    ") .prependTo(listElement) .mousedown(function (e) { + // Try to drag if that is what is wanted if not it will be the equivalent to File > Close; + // it doesn't merely remove a file from the working set + _reorderListItem(e, $(this).parent(), true); + // stopPropagation of mousedown for fileStatusIcon so the parent
  • item, which // selects documents on mousedown, doesn't select the document in the case // when the click is on fileStatusIcon e.stopPropagation(); - }) - .click(function () { - // Clicking the "X" button is equivalent to File > Close; it doesn't merely - // remove a file from the working set - var file = listElement.data(_FILE_KEY); - CommandManager.execute(Commands.FILE_CLOSE, {file: file}); }); } @@ -175,7 +362,7 @@ define(function (require, exports, module) { _updateListItemSelection($newItem, curDoc); $newItem.mousedown(function (e) { - FileViewController.openAndSelectDocument(file.fullPath, FileViewController.WORKING_SET_VIEW); + _reorderListItem(e, $(this)); e.preventDefault(); });