diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-28 10:55:59 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-28 10:55:59 +0000 |
commit | bb4acc02d06d507424057ea41eebe54fdb224b85 (patch) | |
tree | 51601cb26b1e8f0122c7529a203485cbb2bed882 /public/javascripts/context_menu.js | |
parent | d9e6359a839d7097283c237e4982e8ef5df2849e (diff) | |
download | redmine-bb4acc02d06d507424057ea41eebe54fdb224b85.tar.gz redmine-bb4acc02d06d507424057ea41eebe54fdb224b85.zip |
Added AJAX based context menu on the project issue list that provide shortcuts for editing, re-assigning, changing the status or the priority, moving or deleting an issue.
The context menu shows up when right-clicking an issue (Opera users have to use Ctrl + left-click instead since right-click can't be reassigned for this browser).
Works with Firefox 2, IE 7 (not perfect), Opera 9 and Safari 2. IE 6 doesn't display submenus.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@872 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public/javascripts/context_menu.js')
-rw-r--r-- | public/javascripts/context_menu.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.js new file mode 100644 index 000000000..a6e39c512 --- /dev/null +++ b/public/javascripts/context_menu.js @@ -0,0 +1,44 @@ +ContextMenu = Class.create(); +ContextMenu.prototype = { + initialize: function (options) { + this.options = Object.extend({selector: '.hascontextmenu'}, options || { }); + + Event.observe(document, 'click', function(e){ + var t = Event.findElement(e, 'a'); + if ((t != document) && (Element.hasClassName(t, 'disabled') || Element.hasClassName(t, 'submenu'))) { + Event.stop(e); + } else { + $('context-menu').hide(); + if (this.selection) { + this.selection.removeClassName('context-menu-selection'); + } + } + + }.bind(this)); + + $$(this.options.selector).invoke('observe', (window.opera ? 'click' : 'contextmenu'), function(e){ + if (window.opera && !e.ctrlKey) { + return; + } + this.show(e); + }.bind(this)); + + }, + show: function(e) { + Event.stop(e); + Element.hide('context-menu'); + if (this.selection) { + this.selection.removeClassName('context-menu-selection'); + } + $('context-menu').style['left'] = (Event.pointerX(e) + 'px'); + $('context-menu').style['top'] = (Event.pointerY(e) + 'px'); + Element.update('context-menu', ''); + + var tr = Event.findElement(e, 'tr'); + tr.addClassName('context-menu-selection'); + this.selection = tr; + var id = tr.id.substring(6, tr.id.length); + /* TODO: do not hard code path */ + new Ajax.Updater('context-menu', '../../issues/context_menu/' + id, {asynchronous:true, evalScripts:true, onComplete:function(request){Effect.Appear('context-menu', {duration: 0.20})}}) + } +} |