From 8f5abd2cc18863fecdbf8bc7d17ea66438129a3d Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 6 Aug 2013 19:07:46 +0000 Subject: [PATCH] in main menu, bind to history events --- static/js/mainMenu.js | 18 ++++++++++++++---- static/js/utils.js | 3 --- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index 07f2e9acf..0a72ea2b7 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -401,12 +401,14 @@ pandora.ui.mainMenu = function() { pandora.reloadList(); }); } else if (data.id == 'undo') { + fromMenu = true; pandora.undoHistory(); } else if (data.id == 'redo') { + fromMenu = true; pandora.redoHistory(); } else if (data.id == 'clearhistory') { + fromMenu = true; pandora.history.clear(); - that.replaceMenu('itemMenu', getItemMenu()); } else if (data.id == 'showsidebar') { pandora.UI.set({showSidebar: !ui.showSidebar}); } else if (data.id == 'showinfo') { @@ -741,11 +743,19 @@ pandora.ui.mainMenu = function() { }); pandora.clipboard.bindEvent(function(data, event) { - if (Ox.contains(['add', 'copy', 'paste'], event) && !fromMenu) { - that.highlightMenu('itemMenu'); - } if (Ox.contains(['add', 'copy', 'clear'], event)) { that.replaceMenu('itemMenu', getItemMenu()); + if (Ox.contains(['add', 'copy'], event) && !fromMenu) { + that.highlightMenu('itemMenu'); + } + } + fromMenu = false; + }); + + pandora.history.bindEvent(function(data, event) { + that.replaceMenu('itemMenu', getItemMenu()); + if (Ox.contains(['add', 'undo', 'redo'], event) && !fromMenu) { + that.highlightMenu('itemMenu'); } fromMenu = false; }); diff --git a/static/js/utils.js b/static/js/utils.js index 0b916b1bd..492b1494e 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -320,7 +320,6 @@ pandora.createLinks = function($element) { targets: targets, text: text }); - pandora.$ui.mainMenu.replaceItemMenu(); callback(result); } }; @@ -328,7 +327,6 @@ pandora.createLinks = function($element) { pandora.redoHistory = function(callback) { var object = pandora.history.redo(); if (object) { - pandora.$ui.mainMenu.replaceItemMenu(); if (object.action == 'copy' || object.action == 'paste') { addItems(object.items[0], object.targets[0], done); } else if (object.action == 'cut' || object.action == 'delete') { @@ -347,7 +345,6 @@ pandora.createLinks = function($element) { pandora.undoHistory = function(callback) { var object = pandora.history.undo(); if (object) { - pandora.$ui.mainMenu.replaceItemMenu(); if (object.action == 'copy' || object.action == 'paste') { removeItems(object.items[0], object.targets[0], done); } else if (object.action == 'cut' || object.action == 'delete') {