From 9f96bd2afdd2cb99c7c458375d1fee3b8f68d09b Mon Sep 17 00:00:00 2001 From: Alex Bardanov Date: Fri, 12 Sep 2014 10:10:16 +0300 Subject: [PATCH] v0.4.4 - updated context menu --- package.json | 2 +- services/contextMenu.js | 43 ++++++++++++++++++++++++++++++++++------- viewmodels/documents.js | 2 ++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4a422bf..0532535 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "title": "Documents Toolbar", "description": "Adds toolbar with tabs of open documents on the top of the editor. Now with drag and drop!", "homepage": "https://github.com/dnbard/brackets-documents-toolbar", - "version": "0.4.3", + "version": "0.4.4", "author": "Alex Bardanov ", "license": "MIT", "engines": { diff --git a/services/contextMenu.js b/services/contextMenu.js index e7c73a9..ca63ce8 100644 --- a/services/contextMenu.js +++ b/services/contextMenu.js @@ -1,6 +1,7 @@ var CommandMenus = require('command/Menus'), CommandManager = require('command/CommandManager'), - ProjectManager = require('project/ProjectManager'); + ProjectManager = require('project/ProjectManager'), + AppInit = require('utils/AppInit'); define(function(require, exports, module){ var instance = new ContextMenuService(), @@ -36,6 +37,11 @@ define(function(require, exports, module){ return self.context._name.indexOf(query) >= 0; } + this.addNewRuleCommand = CommandManager.register('!', 'dte_addRule', function(){ + var viewModel = ModalService.showHandler(); + viewModel.getOrCreateRule(self.context._name); + }); + this.clearRuleCommand = CommandManager.register('Clear custom colors', 'dte_clearRule', function(){ var colorRules = storage.getKey(storageRulesKey) || {}; @@ -45,13 +51,36 @@ define(function(require, exports, module){ $(DocumentManager).trigger('workingSetSort'); }); - this.addNewRuleCommand = CommandManager.register('!', 'dte_addRule', function(){ - var viewModel = ModalService.showHandler(); - viewModel.getOrCreateRule(self.context._name); - }); + AppInit.appReady(function(){ + setTimeout(function(){ + self.menu.addMenuItem(CommandManager.get('file.saveAs')); + self.menu.addMenuItem(CommandManager.get('file.save')); + self.menu.addMenuItem(CommandManager.get('file.rename')); + self.menu.addMenuItem(CommandManager.get('navigate.showInFileTree')); + self.menu.addMenuItem(CommandManager.get('navigate.showInOS')); + self.menu.addMenuDivider(); + self.menu.addMenuItem(CommandManager.get('cmd.findInSubtree')); + self.menu.addMenuItem(CommandManager.get('cmd.replaceInSubtree')); + self.menu.addMenuDivider(); + self.menu.addMenuItem(CommandManager.get('file.close')); + self.menu.addMenuItem(CommandManager.get('file.close_above')); + self.menu.addMenuItem(CommandManager.get('file.close_others')); + self.menu.addMenuItem(CommandManager.get('file.close_below')); + self.menu.addMenuDivider(); + + if (CommandManager.get('git.addToIgnore')){ + self.menu.addMenuItem(CommandManager.get('git.addToIgnore')); + } - this.menu.addMenuItem(this.addNewRuleCommand); - this.menu.addMenuItem(this.clearRuleCommand); + if (CommandManager.get('git.removeFromIgnore')){ + self.menu.addMenuItem(CommandManager.get('git.removeFromIgnore')); + self.menu.addMenuDivider(); + } + + self.menu.addMenuItem(self.addNewRuleCommand); + self.menu.addMenuItem(self.clearRuleCommand); + }, 100); + }); } diff --git a/viewmodels/documents.js b/viewmodels/documents.js index 3b00e7b..47008ae 100644 --- a/viewmodels/documents.js +++ b/viewmodels/documents.js @@ -45,6 +45,8 @@ define(function(require, exports, module){ this.showContextMenu = ko.observable(false); this.onDocumentContextMenu = function(context, event){ + self.onDocumentClick(context, event); + contextMenu.open(context, event); }