Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/desktop/env.js b/desktop/env.js
index 68fac96..1dbc45a 100644
--- a/desktop/env.js
+++ b/desktop/env.js
@@ -86,7 +86,8 @@ debug( '========================================================================
global.desktop = {
config: config,
settings: Settings,
- editorContextMenu: EditorContextMenu,
- generalContextMenu: GeneralContextMenu
+ contextMenus: {
+ editor: EditorContextMenu,
+ general: GeneralContextMenu
+ }
};
-
diff --git a/public_desktop/desktop-app.js b/public_desktop/desktop-app.js
index d8e0be9..739b553 100644
--- a/public_desktop/desktop-app.js
+++ b/public_desktop/desktop-app.js
@@ -106,11 +106,11 @@ function startDesktopApp() {
}
if ( showEditorMenu ) {
- menu = buildEditorContextMenu(selection);
+ menu = desktop.contextMenus.editor(selection);
}
else {
var selectedText = window.getSelection().toString();
- menu = buildGeneralContextMenu(selectedText);
+ menu = desktop.contextMenus.general(selectedText);
}
// The 'contextmenu' event is emitted after 'selectionchange' has fired but possibly before the
@@ -131,21 +131,6 @@ function startDesktopApp() {
debug = gGebug( 'desktop:browser' );
-
- debug( 'Setting up Context Menus' );
- try {
- var buildEditorContextMenu = desktop.editorContextMenu;
- var buildGeneralContextMenu = desktop.generalContextMenu;
- } catch (e) {
- debug( "Error loading context menus", e.message);
- loadContextMenu = false;
- }
-
- if ( loadContextMenu ) {
- resetSelection();
- document.addEventListener( 'mousedown', resetSelection );
- }
-
// Everything is ready, start Calypso
debug( 'Received app configuration, starting in browser' );
@@ -157,7 +142,12 @@ function startDesktopApp() {
document.addEventListener( 'keydown', keyboardHandler );
document.addEventListener( 'click', preventNewWindow );
- if ( loadContextMenu ) {
+ if ( loadContextMenu ) {
+ debug( 'Setting up Context Menus' );
+
+ resetSelection();
+
+ document.addEventListener( 'mousedown', resetSelection );
document.addEventListener( 'contextmenu', contextMenu );
// listen for tinymce IPC event for context menu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.