forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDefaultMenus.js
More file actions
1 lines (1 loc) · 12.4 KB
/
DefaultMenus.js
File metadata and controls
1 lines (1 loc) · 12.4 KB
1
define(function(require,exports,module){var AppInit=require("utils/AppInit"),Commands=require("command/Commands"),Menus=require("command/Menus"),Strings=require("strings"),MainViewManager=require("view/MainViewManager"),CommandManager=require("command/CommandManager");function _setContextMenuItemsVisible(enabled,items){items.forEach(function(item){const command=CommandManager.get(item);command&&command.setEnabled(enabled)})}function _setMenuItemsVisible(){var file=MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE);file&&file.exists(function(err,isPresent){if(err)return err;_setContextMenuItemsVisible(isPresent,[Commands.FILE_RENAME,Commands.NAVIGATE_SHOW_IN_FILE_TREE,Commands.NAVIGATE_SHOW_IN_OS,Commands.NAVIGATE_OPEN_IN_TERMINAL,Commands.NAVIGATE_OPEN_IN_POWERSHELL,Commands.NAVIGATE_OPEN_IN_DEFAULT_APP])})}const isBrowser=!Phoenix.isNativeApp,isDesktop=Phoenix.isNativeApp,fileNewShortcut=isDesktop?"Ctrl-N":"",fileNewWindowShortcut=isDesktop?"Ctrl-Shift-N":"",fileCloseShortcut=isDesktop?"Ctrl-W":"",fileCloseAllShortcut=isDesktop?"Ctrl-Shift-W":"",openFileShortcut=isDesktop?"Ctrl-O":"",openFolderShortcut=isBrowser?"Ctrl-O":"",reopenClosedShortcut=isBrowser?"":"Ctrl-Shift-T",nextDocShortcut=isBrowser?"Alt-PageDown":"Ctrl-PageDown",prevDocShortcut=isBrowser?"Alt-PageUp":"Ctrl-PageUp";AppInit.htmlReady(function(){var menu;(menu=Menus.addMenu(Strings.FILE_MENU,Menus.AppMenuBar.FILE_MENU)).addMenuItem(Commands.FILE_NEW,fileNewShortcut),menu.addMenuItem(Commands.FILE_NEW_FOLDER),menu.addMenuItem(Commands.FILE_NEW_WINDOW,fileNewWindowShortcut),menu.addMenuDivider(),Phoenix.isNativeApp&&menu.addMenuItem(Commands.FILE_OPEN,openFileShortcut),menu.addMenuItem(Commands.FILE_OPEN_FOLDER,openFolderShortcut),menu.addMenuItem(Commands.FILE_CLOSE,fileCloseShortcut),menu.addMenuItem(Commands.FILE_CLOSE_ALL,fileCloseAllShortcut),menu.addMenuItem(Commands.FILE_REOPEN_CLOSED,reopenClosedShortcut),menu.addMenuDivider(),menu.addMenuItem(Commands.FILE_SAVE),menu.addMenuItem(Commands.FILE_SAVE_ALL),Phoenix.isNativeApp&&menu.addMenuItem(Commands.FILE_SAVE_AS),menu.addMenuItem(Commands.FILE_DUPLICATE_FILE),menu.addMenuItem(Commands.FILE_DOWNLOAD_PROJECT,void 0,void 0,void 0,{hideWhenCommandDisabled:!0}),menu.addMenuDivider(),menu.addMenuItem(Commands.FILE_EXTENSION_MANAGER),Phoenix.isNativeApp&&(menu.addMenuDivider(),menu.addMenuItem(Commands.FILE_QUIT)),(menu=Menus.addMenu(Strings.EDIT_MENU,Menus.AppMenuBar.EDIT_MENU)).addMenuItem(Commands.EDIT_UNDO),menu.addMenuItem(Commands.EDIT_REDO),menu.addMenuDivider(),menu.addMenuItem(Commands.EDIT_CUT),menu.addMenuItem(Commands.EDIT_COPY),!window.Phoenix.isNativeApp&&window.Phoenix.browser.desktop.isFirefox||menu.addMenuItem(Commands.EDIT_PASTE),menu.addMenuDivider(),menu.addMenuItem(Commands.EDIT_SELECT_ALL),menu.addMenuItem(Commands.EDIT_SELECT_LINE),menu.addMenuItem(Commands.EDIT_SPLIT_SEL_INTO_LINES),menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_PREV_LINE),menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_NEXT_LINE),menu.addMenuDivider(),menu.addMenuItem(Commands.EDIT_INDENT),menu.addMenuItem(Commands.EDIT_UNINDENT),menu.addMenuItem(Commands.EDIT_DUPLICATE),menu.addMenuItem(Commands.EDIT_DELETE_LINES),menu.addMenuItem(Commands.EDIT_LINE_UP),menu.addMenuItem(Commands.EDIT_LINE_DOWN),menu.addMenuDivider(),menu.addMenuItem(Commands.EDIT_LINE_COMMENT),menu.addMenuItem(Commands.EDIT_BLOCK_COMMENT),menu.addMenuDivider(),menu.addMenuItem(Commands.SHOW_CODE_HINTS),menu.addMenuDivider(),menu.addMenuItem(Commands.TOGGLE_CLOSE_BRACKETS),menu.addMenuItem(Commands.EDIT_EMMET),(menu=Menus.addMenu(Strings.FIND_MENU,Menus.AppMenuBar.FIND_MENU)).addMenuItem(Commands.CMD_FIND),menu.addMenuItem(Commands.CMD_FIND_NEXT),menu.addMenuItem(Commands.CMD_FIND_PREVIOUS),menu.addMenuItem(Commands.CMD_ADD_NEXT_MATCH),menu.addMenuItem(Commands.CMD_FIND_ALL_AND_SELECT),menu.addMenuItem(Commands.CMD_SKIP_CURRENT_MATCH),menu.addMenuDivider(),menu.addMenuItem(Commands.CMD_FIND_IN_FILES),menu.addMenuItem(Commands.CMD_FIND_ALL_REFERENCES),menu.addMenuDivider(),menu.addMenuItem(Commands.CMD_REPLACE),menu.addMenuItem(Commands.CMD_REPLACE_IN_FILES),(menu=Menus.addMenu(Strings.VIEW_MENU,Menus.AppMenuBar.VIEW_MENU)).addMenuItem(Commands.CMD_THEMES_OPEN_SETTINGS),menu.addMenuDivider(),menu.addMenuItem(Commands.CMD_SPLITVIEW_NONE),menu.addMenuItem(Commands.CMD_SPLITVIEW_VERTICAL),menu.addMenuItem(Commands.CMD_SPLITVIEW_HORIZONTAL),menu.addMenuDivider(),menu.addMenuItem(Commands.VIEW_HIDE_SIDEBAR),menu.addMenuItem(Commands.TOGGLE_SEARCH_AUTOHIDE),menu.addMenuDivider();let subMenu=menu.addSubMenu(Strings.CMD_ZOOM_UI,Commands.VIEW_ZOOM_SUBMENU);subMenu.addMenuItem(Commands.VIEW_ZOOM_IN),subMenu.addMenuItem(Commands.VIEW_ZOOM_OUT),subMenu.addMenuItem(Commands.VIEW_INCREASE_FONT_SIZE),subMenu.addMenuItem(Commands.VIEW_DECREASE_FONT_SIZE),subMenu.addMenuItem(Commands.VIEW_RESTORE_FONT_SIZE),menu.addMenuDivider(),menu.addMenuItem(Commands.TOGGLE_ACTIVE_LINE),menu.addMenuItem(Commands.TOGGLE_LINE_NUMBERS),menu.addMenuItem(Commands.TOGGLE_WORD_WRAP),menu.addMenuItem(Commands.TOGGLE_RULERS),menu.addMenuDivider(),menu.addMenuItem(Commands.VIEW_TOGGLE_PROBLEMS),Phoenix.isNativeApp&&menu.addMenuItem(Commands.VIEW_TERMINAL),menu.addMenuItem(Commands.VIEW_TOGGLE_INSPECTION),(menu=Menus.addMenu(Strings.NAVIGATE_MENU,Menus.AppMenuBar.NAVIGATE_MENU)).addMenuItem(Commands.NAVIGATE_QUICK_OPEN),menu.addMenuItem(Commands.NAVIGATE_GOTO_LINE),menu.addMenuItem(Commands.NAVIGATE_GOTO_DEFINITION),menu.addMenuItem(Commands.NAVIGATE_GOTO_DEFINITION_PROJECT),menu.addMenuItem(Commands.NAVIGATE_JUMPTO_DEFINITION),menu.addMenuItem(Commands.NAVIGATE_GOTO_NEXT_PROBLEM),menu.addMenuItem(Commands.NAVIGATE_GOTO_PREV_PROBLEM),menu.addMenuDivider(),menu.addMenuItem(Commands.NAVIGATE_NEXT_DOC),menu.addMenuItem(Commands.NAVIGATE_PREV_DOC),menu.addMenuItem(Commands.NAVIGATE_NEXT_DOC_LIST_ORDER,nextDocShortcut),menu.addMenuItem(Commands.NAVIGATE_PREV_DOC_LIST_ORDER,prevDocShortcut),menu.addMenuDivider(),menu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE),menu.addMenuDivider(),menu.addMenuItem(Commands.TOGGLE_QUICK_EDIT),menu.addMenuItem(Commands.QUICK_EDIT_PREV_MATCH),menu.addMenuItem(Commands.QUICK_EDIT_NEXT_MATCH),menu.addMenuItem(Commands.CSS_QUICK_EDIT_NEW_RULE),menu.addMenuDivider(),menu.addMenuItem(Commands.TOGGLE_QUICK_DOCS),(menu=Menus.addMenu(Strings.HELP_MENU,Menus.AppMenuBar.HELP_MENU)).addMenuItem(Commands.HELP_DOCS),menu.addMenuItem(Commands.HELP_SUPPORT),menu.addMenuDivider(),menu.addMenuItem(Commands.HELP_GET_PRO),menu.addMenuItem(Commands.HELP_VIEW_LICENSE),menu.addMenuDivider(),brackets.config.suggest_feature_url&&menu.addMenuItem(Commands.HELP_SUGGEST),brackets.config.report_issue_url&&menu.addMenuItem(Commands.HELP_REPORT_ISSUE),brackets.config.get_involved_url&&menu.addMenuItem(Commands.HELP_GET_INVOLVED);var hasAboutItem=!0;menu.addMenuDivider(),menu.addMenuItem(Commands.HELP_YOUTUBE),menu.addMenuItem(Commands.HELP_TWITTER),brackets.config.homepage_url&&menu.addMenuItem(Commands.HELP_HOMEPAGE),menu.addMenuItem(Commands.HELP_ABOUT),Menus.addMenu(Strings.DEBUG_MENU,Menus.AppMenuBar.DEBUG_MENU,Menus.BEFORE,Menus.AppMenuBar.HELP_MENU);var workingset_cmenu=Menus.registerContextMenu(Menus.ContextMenuIds.WORKING_SET_CONTEXT_MENU);if(workingset_cmenu.addMenuItem(Commands.FILE_SAVE),workingset_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE),Phoenix.isNativeApp){let subMenu=workingset_cmenu.addSubMenu(Strings.CMD_OPEN_IN,Commands.OPEN_IN_SUBMENU_WS);subMenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS),subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_TERMINAL),subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_INTEGRATED_TERMINAL),"win"===brackets.platform&&subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_POWERSHELL),subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_DEFAULT_APP)}workingset_cmenu.addMenuDivider(),workingset_cmenu.addMenuItem(Commands.FILE_COPY),workingset_cmenu.addMenuItem(Commands.FILE_COPY_PATH),workingset_cmenu.addMenuItem(Commands.FILE_DUPLICATE),workingset_cmenu.addMenuItem(Commands.FILE_DOWNLOAD,void 0,void 0,void 0,{hideWhenCommandDisabled:!0}),workingset_cmenu.addMenuDivider(),workingset_cmenu.addMenuItem(Commands.FILE_RENAME),workingset_cmenu.addMenuItem(Commands.FILE_DELETE),workingset_cmenu.addMenuDivider(),workingset_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE),workingset_cmenu.addMenuItem(Commands.CMD_REPLACE_IN_SUBTREE),workingset_cmenu.addMenuDivider(),workingset_cmenu.addMenuItem(Commands.FILE_CLOSE);var splitview_menu=Menus.registerContextMenu(Menus.ContextMenuIds.SPLITVIEW_MENU);splitview_menu.addMenuItem(Commands.CMD_SPLITVIEW_NONE),splitview_menu.addMenuItem(Commands.CMD_SPLITVIEW_VERTICAL),splitview_menu.addMenuItem(Commands.CMD_SPLITVIEW_HORIZONTAL),splitview_menu.addMenuDivider(),splitview_menu.addMenuItem(Commands.CMD_WORKINGSET_SORT_BY_ADDED),splitview_menu.addMenuItem(Commands.CMD_WORKINGSET_SORT_BY_NAME),splitview_menu.addMenuItem(Commands.CMD_WORKINGSET_SORT_BY_TYPE),splitview_menu.addMenuDivider(),splitview_menu.addMenuItem(Commands.CMD_WORKING_SORT_TOGGLE_AUTO),splitview_menu.addMenuItem(Commands.FILE_SHOW_FOLDERS_FIRST),splitview_menu.addMenuDivider(),splitview_menu.addMenuItem(Commands.CMD_TOGGLE_SHOW_WORKING_SET),splitview_menu.addMenuItem(Commands.CMD_TOGGLE_SHOW_FILE_TABS);var project_cmenu=Menus.registerContextMenu(Menus.ContextMenuIds.PROJECT_MENU);if(project_cmenu.addMenuItem(Commands.FILE_NEW),project_cmenu.addMenuItem(Commands.FILE_NEW_FOLDER),Phoenix.isNativeApp){let subMenu=project_cmenu.addSubMenu(Strings.CMD_OPEN_IN,Commands.OPEN_IN_SUBMENU);subMenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS),subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_TERMINAL),subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_INTEGRATED_TERMINAL),"win"===brackets.platform&&subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_POWERSHELL),subMenu.addMenuItem(Commands.NAVIGATE_OPEN_IN_DEFAULT_APP)}project_cmenu.addMenuDivider(),project_cmenu.addMenuItem(Commands.FILE_CUT),project_cmenu.addMenuItem(Commands.FILE_COPY),project_cmenu.addMenuItem(Commands.FILE_COPY_PATH),project_cmenu.addMenuItem(Commands.FILE_DUPLICATE),project_cmenu.addMenuItem(Commands.FILE_PASTE),project_cmenu.addMenuItem(Commands.FILE_DOWNLOAD,void 0,void 0,void 0,{hideWhenCommandDisabled:!0}),project_cmenu.addMenuDivider(),project_cmenu.addMenuItem(Commands.FILE_RENAME),project_cmenu.addMenuItem(Commands.FILE_DELETE),project_cmenu.addMenuDivider(),project_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE),project_cmenu.addMenuItem(Commands.CMD_REPLACE_IN_SUBTREE),project_cmenu.addMenuDivider(),project_cmenu.addMenuItem(Commands.FILE_REFRESH);var editor_cmenu=Menus.registerContextMenu(Menus.ContextMenuIds.EDITOR_MENU);editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_EDIT),editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_DOCS),editor_cmenu.addMenuItem(Commands.NAVIGATE_JUMPTO_DEFINITION),editor_cmenu.addMenuItem(Commands.CMD_FIND_ALL_REFERENCES),editor_cmenu.addMenuDivider(),editor_cmenu.addMenuItem(Commands.EDIT_CUT),editor_cmenu.addMenuItem(Commands.EDIT_COPY),!window.Phoenix.isNativeApp&&window.Phoenix.browser.desktop.isFirefox||editor_cmenu.addMenuItem(Commands.EDIT_PASTE),editor_cmenu.addMenuDivider(),editor_cmenu.addMenuItem(Commands.EDIT_SELECT_ALL);var inline_editor_cmenu=Menus.registerContextMenu(Menus.ContextMenuIds.INLINE_EDITOR_MENU);inline_editor_cmenu.addMenuItem(Commands.TOGGLE_QUICK_EDIT),inline_editor_cmenu.addMenuItem(Commands.EDIT_SELECT_ALL),inline_editor_cmenu.addMenuDivider(),inline_editor_cmenu.addMenuItem(Commands.QUICK_EDIT_PREV_MATCH),inline_editor_cmenu.addMenuItem(Commands.QUICK_EDIT_NEXT_MATCH),$("#editor-holder").on("contextmenu",function(e){$(e.target).closest(".tab-bar-container").length||require(["editor/EditorManager"],function(EditorManager){if(0===$(e.target).parents(".CodeMirror-gutter").length){var editor=EditorManager.getFocusedEditor(),inlineWidget=EditorManager.getFocusedInlineWidget();editor&&(inlineWidget?inline_editor_cmenu.open(e):editor_cmenu.open(e))}})}),$("#project-files-container").on("contextmenu",function(e){project_cmenu.open(e)}),Menus.ContextMenu.assignContextMenuToSelector(".working-set-splitview-btn",splitview_menu),$(window).contextmenu(function(e){e.preventDefault()}),$(window.document).on("mousedown",".dropdown",function(e){e.preventDefault()}),$(window.document).on("mouseenter","#titlebar .dropdown",function(e){var open=$(this).siblings(".open");open.length>0&&(open.removeClass("open"),$(this).addClass("open"))}),Menus.getContextMenu(Menus.ContextMenuIds.WORKING_SET_CONTEXT_MENU).on("beforeContextMenuOpen",_setMenuItemsVisible),Menus.getContextMenu(Menus.ContextMenuIds.PROJECT_MENU).on("beforeContextMenuOpen",_setMenuItemsVisible)})});