diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index 56bf14bbed6..f1d575cd4a1 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -470,6 +470,7 @@ define(function (require, exports, module) { * Semi-private: should only be called within this module or by Document. * @param {!Document} document Document whose main/full Editor to create * @param {!Pane} pane Pane in which the editor will be hosted + * @return {!Editor} */ function _createFullEditorForDocument(document, pane) { // Create editor; make it initially invisible @@ -477,6 +478,7 @@ define(function (require, exports, module) { editor.setVisible(false); pane.addView(editor); $(exports).triggerHandler("_fullEditorCreatedForDocument", [document, editor, pane.id]); + return editor; } @@ -535,8 +537,6 @@ define(function (require, exports, module) { editor = document._masterEditor; if (!editor) { - createdNewEditor = true; - // Performance (see #4757) Chrome wastes time messing with selection // that will just be changed at end, so clear it for now if (window.getSelection && window.getSelection().empty) { // Chrome @@ -544,23 +544,24 @@ define(function (require, exports, module) { } // Editor doesn't exist: populate a new Editor with the text - _createFullEditorForDocument(document, pane); - } else if (editor.$el.parent() !== pane.$el) { + editor = _createFullEditorForDocument(document, pane); + createdNewEditor = true; + } else if (editor.$el.parent()[0] !== pane.$content[0]) { // editor does exist but is not a child of the pane so add it to the // pane (which will switch the view's container as well) pane.addView(editor); } // show the view - pane.showView(document._masterEditor); + pane.showView(editor); if (MainViewManager.getActivePaneId() === pane.id) { // give it focus - document._masterEditor.focus(); + editor.focus(); } if (createdNewEditor) { - _restoreEditorViewState(document._masterEditor); + _restoreEditorViewState(editor); } } diff --git a/src/project/FileViewController.js b/src/project/FileViewController.js index 243cfd79f88..733e4a33092 100644 --- a/src/project/FileViewController.js +++ b/src/project/FileViewController.js @@ -129,8 +129,10 @@ define(function (require, exports, module) { return; } - _fileSelectionFocus = fileSelectionFocus; - $(exports).triggerHandler("fileViewFocusChange"); + if (_fileSelectionFocus !== fileSelectionFocus) { + _fileSelectionFocus = fileSelectionFocus; + $(exports).triggerHandler("fileViewFocusChange"); + } } /** diff --git a/src/project/WorkingSetView.js b/src/project/WorkingSetView.js index d07211aa764..225923b99ed 100644 --- a/src/project/WorkingSetView.js +++ b/src/project/WorkingSetView.js @@ -34,7 +34,8 @@ define(function (require, exports, module) { "use strict"; // Load dependent modules - var DocumentManager = require("document/DocumentManager"), + var AppInit = require("utils/AppInit"), + DocumentManager = require("document/DocumentManager"), MainViewManager = require("view/MainViewManager"), CommandManager = require("command/CommandManager"), Commands = require("command/Commands"), @@ -69,6 +70,12 @@ define(function (require, exports, module) { var _classProviders = []; + /** + * #working-set-list-container + * @type {jQuery} + */ + var $workingFilesContainer; + /** * Constants for event.which values * @enum {number} @@ -97,6 +104,12 @@ define(function (require, exports, module) { BELOWVIEW = "belowview", ABOVEVIEW = "aboveview"; + /** + * Drag an item has to move 3px before dragging starts + * @constant + */ + var _DRAG_MOVE_DETECTION_START = 3; + /** * Refreshes all Pane View List Views */ @@ -129,7 +142,6 @@ define(function (require, exports, module) { */ function _updateListItemSelection(listItem, selectedFile) { var shouldBeSelected = (selectedFile && $(listItem).data(_FILE_KEY).fullPath === selectedFile.fullPath); - ViewUtils.toggleClass($(listItem), "selected", shouldBeSelected); } @@ -263,19 +275,43 @@ define(function (require, exports, module) { dragged = false, startPageY = e.pageY, lastPageY = startPageY, - itemHeight = $el.height(), + lastHit = { where: NOMANSLAND }, tryClosing = $(e.target).hasClass("can-close"), - offset = $el.offset(), - $copy = $el.clone(), - $ghost = $("
").append($("