From bf6ff4addb915efc09f1606977b0843bee0a340f Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sat, 21 Nov 2009 03:14:28 +0000 Subject: [PATCH] MINOR Moved tree context menu javascript from LeftAndMain.js into LeftAndMain_left.js git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92694 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/LeftAndMain.js | 57 ---------------------------------- javascript/LeftAndMain_left.js | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 57 deletions(-) diff --git a/javascript/LeftAndMain.js b/javascript/LeftAndMain.js index d4cb5f30..b4841afd 100644 --- a/javascript/LeftAndMain.js +++ b/javascript/LeftAndMain.js @@ -425,63 +425,6 @@ returnFalse = function() { return false; } -var _CURRENT_CONTEXT_MENU = null; - -/** - * Create a new context menu - * @param event The event object - * @param owner The DOM element that this context-menu was requested from - * @param menuItems A map of title -> method; context-menu operations to get called - */ -function createContextMenu(event, owner, menuItems) { - if(_CURRENT_CONTEXT_MENU) { - document.body.removeChild(_CURRENT_CONTEXT_MENU); - _CURRENT_CONTEXT_MENU = null; - } - - var menu = document.createElement("ul"); - menu.className = 'contextMenu'; - menu.style.position = 'absolute'; - menu.style.left = event.clientX + 'px'; - menu.style.top = event.clientY + 'px'; - - var menuItemName, menuItemTag, menuATag; - for(menuItemName in menuItems) { - menuItemTag = document.createElement("li"); - - menuATag = document.createElement("a"); - menuATag.href = "#"; - menuATag.onclick = menuATag.oncontextmenu = contextmenu_onclick; - menuATag.innerHTML = menuItemName; - menuATag.handler = menuItems[menuItemName]; - menuATag.owner = owner; - - menuItemTag.appendChild(menuATag); - menu.appendChild(menuItemTag); - } - - document.body.appendChild(menu); - - document.body.onclick = contextmenu_close; - - _CURRENT_CONTEXT_MENU = menu; - - return menu; -} - -function contextmenu_close() { - if(_CURRENT_CONTEXT_MENU) { - document.body.removeChild(_CURRENT_CONTEXT_MENU); - _CURRENT_CONTEXT_MENU = null; - } -} - -function contextmenu_onclick() { - this.handler(this.owner); - contextmenu_close(); - return false; -} - /** * Find and enable TinyMCE on all htmleditor fields * Pulled in from old tinymce.template.js diff --git a/javascript/LeftAndMain_left.js b/javascript/LeftAndMain_left.js index f816ceb1..c215f963 100755 --- a/javascript/LeftAndMain_left.js +++ b/javascript/LeftAndMain_left.js @@ -539,3 +539,60 @@ ReorganiseAction.prototype = { } } } + +var _CURRENT_CONTEXT_MENU = null; + +/** + * Create a new context menu + * @param event The event object + * @param owner The DOM element that this context-menu was requested from + * @param menuItems A map of title -> method; context-menu operations to get called + */ +function createContextMenu(event, owner, menuItems) { + if(_CURRENT_CONTEXT_MENU) { + document.body.removeChild(_CURRENT_CONTEXT_MENU); + _CURRENT_CONTEXT_MENU = null; + } + + var menu = document.createElement("ul"); + menu.className = 'contextMenu'; + menu.style.position = 'absolute'; + menu.style.left = event.clientX + 'px'; + menu.style.top = event.clientY + 'px'; + + var menuItemName, menuItemTag, menuATag; + for(menuItemName in menuItems) { + menuItemTag = document.createElement("li"); + + menuATag = document.createElement("a"); + menuATag.href = "#"; + menuATag.onclick = menuATag.oncontextmenu = contextmenu_onclick; + menuATag.innerHTML = menuItemName; + menuATag.handler = menuItems[menuItemName]; + menuATag.owner = owner; + + menuItemTag.appendChild(menuATag); + menu.appendChild(menuItemTag); + } + + document.body.appendChild(menu); + + document.body.onclick = contextmenu_close; + + _CURRENT_CONTEXT_MENU = menu; + + return menu; +} + +function contextmenu_close() { + if(_CURRENT_CONTEXT_MENU) { + document.body.removeChild(_CURRENT_CONTEXT_MENU); + _CURRENT_CONTEXT_MENU = null; + } +} + +function contextmenu_onclick() { + this.handler(this.owner); + contextmenu_close(); + return false; +} \ No newline at end of file