forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWorkingSetView.js
More file actions
1 lines (1 loc) · 23.8 KB
/
WorkingSetView.js
File metadata and controls
1 lines (1 loc) · 23.8 KB
1
define(function(require,exports,module){var AppInit=require("utils/AppInit"),DocumentManager=require("document/DocumentManager"),MainViewManager=require("view/MainViewManager"),ProjectManager=require("project/ProjectManager"),CommandManager=require("command/CommandManager"),Commands=require("command/Commands"),Menus=require("command/Menus"),FileViewController=require("project/FileViewController"),ViewUtils=require("utils/ViewUtils"),KeyEvent=require("utils/KeyEvent"),paneListTemplate=require("text!htmlContent/working-set.html"),Strings=require("strings"),_=require("thirdparty/lodash"),Mustache=require("thirdparty/mustache/mustache"),_views={},_iconProviders=[],_contextEntry,_classProviders=[],$workingFilesContainer,LEFT_BUTTON=1,MIDDLE_BUTTON=2,_FILE_KEY="file",NOMANSLAND="nomansland",NOMOVEITEM="nomoveitem",ABOVEITEM="aboveitem",BELOWITEM="belowitem",TOPSCROLL="topscroll",BOTSCROLL="bottomscroll",BELOWVIEW="belowview",ABOVEVIEW="aboveview",_DRAG_MOVE_DETECTION_START=3;function refresh(rebuild){_.forEach(_views,function(view){var top=view.$openFilesContainer.scrollTop();rebuild?view._rebuildViewList(!0):view._redraw(),view.$openFilesContainer.scrollTop(top)})}function syncSelectionIndicator(){_.forEach(_views,function(view){view.$openFilesContainer.triggerHandler("scroll")})}function _updateListItemSelection(listItem,selectedFile){var shouldBeSelected=selectedFile&&$(listItem).data(_FILE_KEY).fullPath===selectedFile.fullPath;ViewUtils.toggleClass($(listItem),"selected",shouldBeSelected)}function _isOpenAndDirty(file){var docIfOpen=DocumentManager.getOpenDocumentForPath(file.fullPath);return docIfOpen&&docIfOpen.isDirty}function _hasSelectionFocus(){return FileViewController.getFileSelectionFocus()===FileViewController.WORKING_SET_VIEW}function _suppressSortRedrawForAllViews(suppress){_.forEach(_views,function(view){view.suppressSortRedraw=suppress})}function _suppressScrollShadowsOnAllViews(disable){_.forEach(_views,function(view){disable?ViewUtils.removeScrollerShadow(view.$openFilesContainer[0],null):view.$openFilesContainer[0].scrollHeight>view.$openFilesContainer[0].clientHeight&&ViewUtils.addScrollerShadow(view.$openFilesContainer[0],null,!0)})}function _deactivateAllViews(deactivate){_.forEach(_views,function(view){deactivate?view.$el.hasClass("active")&&(view.$el.removeClass("active").addClass("reactivate"),view.$openFilesList.trigger("selectionHide")):(view.$el.hasClass("reactivate")&&view.$el.removeClass("reactivate").addClass("active"),view._fireSelectionChanged(!1))})}function _viewFromEl($el){$el.hasClass("working-set-view")||($el=$el.parents(".working-set-view"));var id=$el.attr("id").match(/working\-set\-list\-([\w]+[\w\d\-\.\:\_]*)/).pop();return _views[id]}function _makeDraggable($el){var interval,sourceFile=$el.data(_FILE_KEY);function endScroll($el){interval&&(window.clearInterval(interval),interval=void 0)}function scroll($container,$el,dir,callback){var container=$container[0],maxScroll=container.scrollHeight-container.clientHeight;maxScroll&&dir&&!interval&&(interval=window.setInterval(function(){var scrollTop=$container.scrollTop();-1===dir&&scrollTop<=0||1===dir&&scrollTop>=maxScroll?endScroll($el):($container.scrollTop(scrollTop+7*dir),callback($el))},50))}$el.mousedown(function(e){var scrollDir=0,dragged=!1,startPageY=e.pageY,lastPageY=startPageY,lastHit={where:NOMANSLAND},tryClosing=$(e.target).hasClass("can-close"),currentFile=MainViewManager.getCurrentlyViewedFile(),activePaneId=MainViewManager.getActivePaneId(),activeView=_views[activePaneId],sourceView=_viewFromEl($el),currentView=sourceView,startingIndex=$el.index(),itemHeight,offset,$copy,$ghost,draggingCurrentFile;function initDragging(){itemHeight=$el.height(),offset=$el.offset(),$copy=$el.clone(),$ghost=$("<div class='open-files-container wsv-drag-ghost' style='overflow: hidden; display: inline-block;'>").append($("<ul>").append($copy).css("padding","0")),(draggingCurrentFile=$el.hasClass("selected")&&sourceView.paneId===activePaneId)&&_hasSelectionFocus()&&$ghost.addClass("dragging-current-file"),$ghost.css({top:offset.top,left:offset.left,width:$el.width()+8}),$ghost.appendTo($("body"))}function updateContext(hit){currentView=_viewFromEl(hit.which)}function hitTest(e){var pageY=$ghost.offset().top,direction=e.pageY-lastPageY,result={where:NOMANSLAND},lookCount=0,hasScroller=!1,onTopScroller=!1,onBottomScroller=!1,$container,$hit,$item,$view,gTop,gHeight,gBottom,containerOffset,scrollerTopArea,scrollerBottomArea;if(e.pageX<0||e.pageX>$workingFilesContainer.width())return result;do{$ghost.hide(),$view=($hit=$(window.document.elementFromPoint(e.pageX,pageY))).closest(".working-set-view"),$item=$hit.closest("#working-set-list-container li"),$ghost.show(),($container=$view.children(".open-files-container")).length&&(scrollerTopArea={top:(containerOffset=$container.offset()).top-14,bottom:containerOffset.top+7},scrollerBottomArea={top:containerOffset.top+$container.height()-7,bottom:containerOffset.top+$container.height()+14}),$item[0]===$el[0]&&(direction>0?($item=$item.next()).length&&(pageY+=itemHeight):($item=$item.prev()).length&&(pageY-=itemHeight)),$item.length||(pageY+=itemHeight)}while(!$item.length&&++lookCount<2);function mouseIsInTopHalf($elem){var top=$elem.offset().top,height=$elem.height();return pageY<top+height/2}function ghostIsAbove($elem){var top=$elem.offset().top,checkVal=gTop;return direction>0&&(checkVal+=gHeight),checkVal<=top+itemHeight/2}function ghostIsBelow($elem){var top=$elem.offset().top,checkVal=gTop;return direction>0&&(checkVal+=gHeight),checkVal>=top+itemHeight/2}function elIsClearBelow($a,$b){var aTop,bTop;return $a.offset().top>=$b.offset().top+$b.height()}function draggingBelowWorkingSet(){return 0===$hit.length||elIsClearBelow($hit,$workingFilesContainer)}function targetIsContainer(){return $hit.is(".working-set-view")||$hit.is(".open-files-container")||$hit.is("ul")&&$hit.parent().is(".open-files-container")}function targetIsNoDrop(){return $hit.is(".working-set-header")||$hit.is(".working-set-header-title")||$hit.is(".scroller-shadow")||$hit.is(".scroller-shadow")}function findViewFor($elem){return $elem.is(".working-set-view")?$elem:$elem.parents(".working-set-view")}if(0===$item.length&&($hit.is("a")||$hit.is("span"))&&($item=$hit.parents("#working-set-list-container li")),gTop=$ghost.offset().top,gHeight=$ghost.height(),gBottom=gTop+gHeight,onTopScroller=(hasScroller=$item.length&&$container.length&&$container[0].scrollHeight>$container[0].clientHeight)&&scrollerTopArea&&(gTop>=scrollerTopArea.top&&gTop<=scrollerTopArea.bottom||gBottom>=scrollerTopArea.top&&gBottom<=scrollerTopArea.bottom),onBottomScroller=hasScroller&&scrollerBottomArea&&(gTop>=scrollerBottomArea.top&&gTop<=scrollerBottomArea.bottom||gBottom>=scrollerBottomArea.top&&gBottom<=scrollerBottomArea.bottom),$item.length)onTopScroller&&(direction<=0||lastHit.where===TOPSCROLL)?result={where:TOPSCROLL,which:$item}:onBottomScroller&&(direction>=0||lastHit.where===BOTSCROLL)?result={where:BOTSCROLL,which:$item}:ghostIsAbove($item)?result={where:ABOVEITEM,which:$item}:ghostIsBelow($item)&&(result={where:BELOWITEM,which:$item});else if($el.parent()[0]!==$hit[0]){if($view=$el.parents(".working-set-view"),targetIsNoDrop()){if(!(direction<0))return result;if(ghostIsBelow($hit))return result}if(draggingBelowWorkingSet())return result;if(targetIsContainer())return result=mouseIsInTopHalf($hit)?{where:ABOVEVIEW,which:findViewFor($hit)}:{where:BELOWVIEW,which:findViewFor($hit)};var $prev=$view.prev(),$next=$view.next();direction<0?$prev.length&&(result={where:BELOWVIEW,which:$prev}):direction>0?$next.length&&(result={where:ABOVEVIEW,which:$next}):result=mouseIsInTopHalf($view)?{where:ABOVEVIEW,which:$view}:{where:BELOWVIEW,which:$view}}else result={where:NOMOVEITEM,which:$hit};return result}function scrollCurrentViewToBottom(){var $container=currentView.$openFilesContainer,container=$container[0],maxScroll=container.scrollHeight-container.clientHeight;maxScroll&&$container.scrollTop(maxScroll)}function preDropCleanup(){window.onmousewheel=window.document.onmousewheel=null,$(window).off(".wsvdragging"),dragged&&($workingFilesContainer.removeClass("dragging"),$workingFilesContainer.find(".drag-show-as-selected").removeClass("drag-show-as-selected"),endScroll($el),_deactivateAllViews(!1),$ghost.remove(),$el.css("opacity",""),0===$el.next().length&&scrollCurrentViewToBottom())}function postDropCleanup(noRefresh){dragged&&(_suppressSortRedrawForAllViews(!1),_suppressScrollShadowsOnAllViews(!1)),noRefresh||refresh(!0),MainViewManager.focusActivePane()}function drop(){preDropCleanup(),sourceView.paneId===currentView.paneId&&startingIndex===$el.index()?dragged?postDropCleanup(!0):tryClosing||e.which===MIDDLE_BUTTON?CommandManager.execute(Commands.FILE_CLOSE,{file:sourceFile,paneId:sourceView.paneId}).always(function(){postDropCleanup()}):(FileViewController.setFileViewFocus(FileViewController.WORKING_SET_VIEW),CommandManager.execute(Commands.FILE_OPEN,{fullPath:sourceFile.fullPath,paneId:currentView.paneId}).always(function(){postDropCleanup()})):sourceView.paneId===currentView.paneId?(MainViewManager._moveWorkingSetItem(sourceView.paneId,startingIndex,$el.index()),postDropCleanup()):MainViewManager._getPane(currentView.paneId).getViewForPath(sourceFile.fullPath)?postDropCleanup():MainViewManager._moveView(sourceView.paneId,currentView.paneId,sourceFile,$el.index()).always(function(){draggingCurrentFile?CommandManager.execute(Commands.FILE_OPEN,{fullPath:sourceFile.fullPath,paneId:currentView.paneId}).always(function(){postDropCleanup()}):postDropCleanup()})}$(window).on("mousemove.wsvdragging",function(e){function drag(e){switch(dragged||(initDragging(),_suppressSortRedrawForAllViews(!0),_suppressScrollShadowsOnAllViews(!0),_deactivateAllViews(!0),$workingFilesContainer.addClass("dragging"),draggingCurrentFile||FileViewController.getFileSelectionFocus()!==FileViewController.WORKING_SET_VIEW||$(activeView._findListItemFromFile(currentFile)).addClass("drag-show-as-selected"),dragged=!0),scrollDir=0,(lastHit=hitTest(e)).where){case NOMANSLAND:case BELOWVIEW:case ABOVEVIEW:$el.css({opacity:".75"}),$ghost.css("opacity",".25");break;default:$el.css({opacity:".0001"}),$ghost.css("opacity","")}switch(lastHit.where){case TOPSCROLL:case ABOVEITEM:lastHit.where===TOPSCROLL&&(scrollDir=-1),$el.insertBefore(lastHit.which),updateContext(lastHit);break;case BOTSCROLL:case BELOWITEM:lastHit.where===BOTSCROLL&&(scrollDir=1),$el.insertAfter(lastHit.which),updateContext(lastHit);break;case BELOWVIEW:$el.appendTo(lastHit.which.find("ul")),updateContext(lastHit);break;case ABOVEVIEW:$el.prependTo(lastHit.which.find("ul")),updateContext(lastHit)}scrollDir?scroll(currentView.$openFilesContainer,$el,scrollDir,function(){drag(e)}):endScroll($el)}$ghost&&$ghost.css("top",$ghost.offset().top+(e.pageY-lastPageY)),(dragged||Math.abs(e.pageY-startPageY)>_DRAG_MOVE_DETECTION_START)&&drag(e),lastPageY=e.pageY,e.stopPropagation()}),e.preventDefault(),$(window).on("mouseup.wsvdragging",function(){drop()}),$(window).on("keydown.wsvdragging",function(e){e.keyCode===KeyEvent.DOM_VK_ESCAPE&&(preDropCleanup(),postDropCleanup(),e.stopPropagation())}),window.onmousewheel=window.document.onmousewheel=function(e){e.preventDefault()},Menus.closeAll(),e.which!==LEFT_BUTTON||e.ctrlKey&&"mac"===brackets.platform?drop():e.stopPropagation()})}function WorkingSetView($container,paneId){var id="working-set-list-"+paneId;this.$header=null,this.$openFilesList=null,this.$container=$container,this.$el=$container.append(Mustache.render(paneListTemplate,_.extend({id:id},Strings))).find("#"+id),this.suppressSortRedraw=!1,this.paneId=paneId,this.init()}function createWorkingSetViewForPane($container,paneId){var view=_views[paneId];view||(view=new WorkingSetView($container,paneId),_views[view.paneId]=view)}function addIconProvider(callback,priority=0){callback&&(callback.priority=priority,_iconProviders.push(callback),_iconProviders.sort(function(cb1,cb2){return cb2.priority-cb1.priority}),refresh(!0))}function addClassProvider(callback,priority=0){callback&&(callback.priority=priority,_classProviders.push(callback),_classProviders.sort(function(cb1,cb2){return cb2.priority-cb1.priority}),refresh(!0))}function useIconProviders(data,$element){for(let provider of _iconProviders)try{let icon=provider(data);if(icon){$element.prepend($(icon));break}}catch(e){console.error("Failed to create workingset file icon: ",e)}}function useClassProviders(data,$element){let succeededPriority=null;for(let provider of _classProviders)try{if(null!==succeededPriority&&succeededPriority!==provider.priority)break;let classToApply=provider(data);classToApply&&($element.addClass(classToApply),succeededPriority=provider.priority)}catch(e){console.error("Failed to apply workingset file class: ",e)}}function getContext(){return _contextEntry}WorkingSetView.prototype._updateVisibility=function(){var fileList=MainViewManager.getWorkingSet(this.paneId);1!==MainViewManager.getPaneCount()||fileList&&0!==fileList.length?(this.$openFilesContainer.show(),this.$workingSetListViewHeader.show(),this._checkForDuplicateAndNonProjectFiles()):(this.$openFilesContainer.hide(),this.$workingSetListViewHeader.hide())},WorkingSetView.prototype._handlePaneLayoutChange=function(){var $titleEl=this.$el.find(".working-set-header-title"),title=Strings.WORKING_FILES;this._updateVisibility(),MainViewManager.getPaneCount()>1&&(title=MainViewManager.getPaneTitle(this.paneId)),$titleEl.text(title)},WorkingSetView.prototype._findListItemFromFile=function(file){var result=null,items;file&&this.$openFilesContainer.find("ul").children().each(function(){var $listItem=$(this);if($listItem.data(_FILE_KEY).fullPath===file.fullPath)return result=$listItem,!1});return result},WorkingSetView.prototype._makeEventName=function(name){return name+".paneList"+this.paneId},WorkingSetView.prototype._scrollSelectedFileIntoView=function(){if(_hasSelectionFocus()){var file=MainViewManager.getCurrentlyViewedFile(this.paneId),$selectedFile=this._findListItemFromFile(file);$selectedFile&&ViewUtils.scrollElementIntoView(this.$openFilesContainer,$selectedFile,!1)}},WorkingSetView.prototype._fireSelectionChanged=function(scrollIntoView){var reveal=void 0===scrollIntoView||!0===scrollIntoView;reveal&&this._scrollSelectedFileIntoView(),_hasSelectionFocus()&&this.$el.hasClass("active")?this.$openFilesList.trigger("selectionChanged",reveal):this.$openFilesList.trigger("selectionHide"),this.$openFilesContainer.trigger("contentChanged")},WorkingSetView.prototype._adjustForScrollbars=function(){this.$openFilesContainer[0].scrollHeight>this.$openFilesContainer[0].clientHeight?this.$openFilesContainer.hasClass("vertical-scroll")||this.$openFilesContainer.addClass("vertical-scroll"):this.$openFilesContainer.removeClass("vertical-scroll")},WorkingSetView.prototype._addDirectoryNameToExternalProjectFiles=function(externalProjectFiles){externalProjectFiles.length&&this.$openFilesContainer.find("ul > li").each(function(){const $li=$(this);let filePath=$li.data(_FILE_KEY).fullPath;const io=externalProjectFiles.indexOf(filePath);if(-1!==io){const displayPath=Phoenix.app.getDisplayPath(filePath);let dirPath=path.dirname(filePath);const displayDirPath=Phoenix.app.getDisplayPath(dirPath);let sep;sep=Phoenix.isNativeApp&&"win"===brackets.platform?"\\":"/";let dirSplit=displayDirPath.split(sep).filter(segment=>""!==segment),truncatedPath=displayDirPath;if(dirSplit.length>3){const rootDirName=dirSplit[0],secondLastSegment=dirSplit[dirSplit.length-2],lastSeg=dirSplit[dirSplit.length-1];truncatedPath=Phoenix.isNativeApp&&"win"===brackets.platform?`${rootDirName}${sep}…${sep}${secondLastSegment}${sep}${lastSeg}`:Phoenix.isNativeApp?`${sep}${rootDirName}${sep}…${sep}${secondLastSegment}${sep}${lastSeg}`:Phoenix.isNativeApp||displayDirPath.startsWith("/")?`${sep}${rootDirName}${sep}…${sep}${secondLastSegment}${sep}${lastSeg}`:`${rootDirName}${sep}…${sep}${secondLastSegment}${sep}${lastSeg}`}const $dir=$(`<span title='${displayPath}' class='directory'/>`).html(" — "+truncatedPath);$li.children("a").append($dir)}})},WorkingSetView.prototype._addDirectoryNamesToWorkingTreeFiles=function(filesList){if(!(filesList.length<=1)){var displayPaths=ViewUtils.getDirNamesForDuplicateFiles(filesList);this.$openFilesContainer.find("ul > li").each(function(){var $li=$(this),io=filesList.indexOf($li.data(_FILE_KEY));if(-1!==io){var dirSplit=displayPaths[io].split("/");dirSplit.length>3&&(displayPaths[io]=dirSplit[0]+"/…/"+dirSplit[dirSplit.length-1]);var $dir=$("<span class='directory'/>").html(" — "+displayPaths[io]);$li.children("a").append($dir)}})}},WorkingSetView.prototype._checkForDuplicateAndNonProjectFiles=function(){let self=this,map={},externalProjectFiles=[],fileList=MainViewManager.getWorkingSet(MainViewManager.ALL_PANES);this.$openFilesContainer.find("ul > li > a > span.directory").remove(),fileList.forEach(function(file){const displayName=path.basename(file.fullPath);map[displayName]||(map[displayName]=[]),ProjectManager.isWithinProject(file)?map[displayName].push(file):externalProjectFiles.push(file.fullPath)}),self._addDirectoryNameToExternalProjectFiles(externalProjectFiles),_.forEach(map,function(value){value.length>1&&self._addDirectoryNamesToWorkingTreeFiles(value)})},WorkingSetView.prototype._redraw=function(){this._updateViewState(),this._updateVisibility(),this._updateItemClasses(),this._adjustForScrollbars(),this._fireSelectionChanged()},WorkingSetView.prototype._handleActivePaneChange=function(){this._redraw()},WorkingSetView.prototype._updateFileStatusIcon=function(listElement,isDirty,canClose){var $fileStatusIcon=listElement.find(".file-status-icon"),showIcon=isDirty||canClose;showIcon||0===$fileStatusIcon.length?showIcon&&0===$fileStatusIcon.length&&($fileStatusIcon=$("<div class='file-status-icon'></div>").prependTo(listElement)):($fileStatusIcon.remove(),$fileStatusIcon=null),$fileStatusIcon&&(ViewUtils.toggleClass($fileStatusIcon,"dirty",isDirty),ViewUtils.toggleClass($fileStatusIcon,"can-close",canClose))},WorkingSetView.prototype._updateItemClasses=function(){_classProviders.length>0&&this.$openFilesContainer.find("ul > li").each(function(){var $li=$(this),file=$li.data(_FILE_KEY),data={fullPath:file.fullPath,name:file.name,isFile:file.isFile};_classProviders.forEach(function(provider){$li.addClass(provider(data))})})},WorkingSetView.prototype._createNewListItem=function(file){var self=this,selectedFile=MainViewManager.getCurrentlyViewedFile(this.paneId),data={fullPath:file.fullPath,name:file.name,isFile:file.isFile},$link=$("<a href='#'></a>").html(ViewUtils.getFileEntryDisplay(file));for(let provider of _iconProviders)try{let icon=provider(data);if(icon){$link.prepend($(icon));break}}catch(e){console.error("Failed to create workingset file icon: ",e)}var $newItem=$("<li></li>").append($link).data(_FILE_KEY,file);this.$openFilesContainer.find("ul").append($newItem),_classProviders.forEach(function(provider){$newItem.addClass(provider(data))}),this._updateFileStatusIcon($newItem,_isOpenAndDirty(file),!1),_updateListItemSelection($newItem,selectedFile),_makeDraggable($newItem),$newItem.hover(function(){self._updateFileStatusIcon($(this),_isOpenAndDirty(file),!0)},function(){self._updateFileStatusIcon($(this),_isOpenAndDirty(file),!1)})},WorkingSetView.prototype._rebuildViewList=function(forceRedraw){var self=this,fileList=MainViewManager.getWorkingSet(this.paneId);this.$openFilesContainer.find("ul").empty(),fileList.forEach(function(file){self._createNewListItem(file)}),forceRedraw&&self._redraw()},WorkingSetView.prototype._updateViewState=function(){var paneId=MainViewManager.getActivePaneId();_hasSelectionFocus()&&paneId===this.paneId?(this.$el.addClass("active"),this.$openFilesContainer.addClass("active")):(this.$el.removeClass("active"),this.$openFilesContainer.removeClass("active"))},WorkingSetView.prototype._updateListSelection=function(){var file=MainViewManager.getCurrentlyViewedFile(this.paneId);this._updateViewState(),this.$openFilesContainer.find("ul").children().each(function(){_updateListItemSelection(this,file)}),this._scrollSelectedFileIntoView(),this._fireSelectionChanged()},WorkingSetView.prototype._handleFileAdded=function(e,fileAdded,index,paneId){paneId===this.paneId?this._rebuildViewList(!0):this._checkForDuplicateAndNonProjectFiles()},WorkingSetView.prototype._handleFileListAdded=function(e,files,paneId){paneId===this.paneId?this._rebuildViewList(!0):this._checkForDuplicateAndNonProjectFiles()},WorkingSetView.prototype._handleFileRemoved=function(e,file,suppressRedraw,paneId){if(paneId===this.paneId){if(!suppressRedraw){var $listItem=this._findListItemFromFile(file);if($listItem){var $nextListItem=$listItem.next();if($nextListItem&&$nextListItem.length>0){var canClose=1===$listItem.find(".can-close").length,isDirty=_isOpenAndDirty($nextListItem.data(_FILE_KEY));this._updateFileStatusIcon($nextListItem,isDirty,canClose)}$listItem.remove()}this._redraw()}}else this._checkForDuplicateAndNonProjectFiles()},WorkingSetView.prototype._handleRemoveList=function(e,files,paneId){var self=this;paneId===this.paneId?(files.forEach(function(file){var $listItem=self._findListItemFromFile(file);$listItem&&$listItem.remove()}),this._redraw()):this._checkForDuplicateAndNonProjectFiles()},WorkingSetView.prototype._handleWorkingSetSort=function(e,paneId){this.suppressSortRedraw||paneId!==this.paneId||this._rebuildViewList(!0)},WorkingSetView.prototype._handleDirtyFlagChanged=function(e,doc){var listItem=this._findListItemFromFile(doc.file);if(listItem){var canClose=1===$(listItem).find(".can-close").length;this._updateFileStatusIcon(listItem,doc.isDirty,canClose)}},WorkingSetView.prototype._handleWorkingSetUpdate=function(e,paneId){this.paneId===paneId?this._rebuildViewList(!0):this._checkForDuplicateAndNonProjectFiles()},WorkingSetView.prototype.init=function(){this.$openFilesContainer=this.$el.find(".open-files-container"),this.$workingSetListViewHeader=this.$el.find(".working-set-header"),this.$openFilesList=this.$el.find("ul"),MainViewManager.on(this._makeEventName("workingSetAdd"),_.bind(this._handleFileAdded,this)),MainViewManager.on(this._makeEventName("workingSetAddList"),_.bind(this._handleFileListAdded,this)),MainViewManager.on(this._makeEventName("workingSetRemove"),_.bind(this._handleFileRemoved,this)),MainViewManager.on(this._makeEventName("workingSetRemoveList"),_.bind(this._handleRemoveList,this)),MainViewManager.on(this._makeEventName("workingSetSort"),_.bind(this._handleWorkingSetSort,this)),MainViewManager.on(this._makeEventName("activePaneChange"),_.bind(this._handleActivePaneChange,this)),MainViewManager.on(this._makeEventName("paneLayoutChange"),_.bind(this._handlePaneLayoutChange,this)),MainViewManager.on(this._makeEventName("workingSetUpdate"),_.bind(this._handleWorkingSetUpdate,this)),DocumentManager.on(this._makeEventName("dirtyFlagChange"),_.bind(this._handleDirtyFlagChanged,this)),FileViewController.on(this._makeEventName("documentSelectionFocusChange")+" "+this._makeEventName("fileViewFocusChange"),_.bind(this._updateListSelection,this)),ViewUtils.addScrollerShadow(this.$openFilesContainer[0],null,!0),ViewUtils.sidebarList(this.$openFilesContainer),this.$openFilesContainer.css("overflow-x","hidden"),this.$openFilesContainer.on("contextmenu.workingSetView",function(e){_contextEntry=$(e.target).closest("li").data(_FILE_KEY),Menus.getContextMenu(Menus.ContextMenuIds.WORKING_SET_CONTEXT_MENU).open(e)}),this._redraw()},WorkingSetView.prototype.destroy=function(){ViewUtils.removeScrollerShadow(this.$openFilesContainer[0],null),this.$openFilesContainer.off(".workingSetView"),this.$el.remove(),MainViewManager.off(this._makeEventName("")),DocumentManager.off(this._makeEventName("")),FileViewController.off(this._makeEventName(""))},AppInit.htmlReady(function(){$workingFilesContainer=$("#working-set-list-container"),MainViewManager.on("paneDestroy",function(e,paneId){var view=_views[paneId];delete _views[view.paneId],view.destroy()})}),exports.createWorkingSetViewForPane=createWorkingSetViewForPane,exports.refresh=refresh,exports.addIconProvider=addIconProvider,exports.addClassProvider=addClassProvider,exports.syncSelectionIndicator=syncSelectionIndicator,exports.getContext=getContext,exports.useIconProviders=useIconProviders,exports.useClassProviders=useClassProviders});