From 5cc88fd55c94b5dc9a310ad5c5d87942d4154d3d Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Wed, 28 Jan 2015 16:20:19 +0000 Subject: Bug 1100382: backport upstream bug 1090727 to bmo/4.2 to support jquery in the global/header template, and update the header and footer to use jquery --- extensions/BMO/web/js/edituser_menu.js | 71 ++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 28 deletions(-) (limited to 'extensions/BMO/web/js') diff --git a/extensions/BMO/web/js/edituser_menu.js b/extensions/BMO/web/js/edituser_menu.js index 383418430..85d933220 100644 --- a/extensions/BMO/web/js/edituser_menu.js +++ b/extensions/BMO/web/js/edituser_menu.js @@ -1,33 +1,48 @@ -var usermenu_widget; +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ -YAHOO.util.Event.onDOMReady(function() { - usermenu_widget = new YAHOO.widget.Menu('usermenu_widget', { position : 'dynamic' }); - usermenu_widget.addItems([ - { text: 'Profile', url: '#', target: '_blank' }, - { text: 'Activity', url: '#', target: '_blank' }, - { text: 'Mail', url: '#', target: '_blank' }, - { text: 'Edit', url: '#', target: '_blank' } - ]); - usermenu_widget.render(document.body); -}); - -function show_usermenu(event, id, email, show_edit) { - if (!usermenu_widget) - return true; - if (event.ctrlKey || event.shiftKey || event.altKey || event.metaKey) - return true; - usermenu_widget.getItem(0).cfg.setProperty('url', - 'user_profile?login=' + encodeURIComponent(email)); - usermenu_widget.getItem(1).cfg.setProperty('url', - 'page.cgi?id=user_activity.html&action=run&from=-14d&who=' + encodeURIComponent(email)); - usermenu_widget.getItem(2).cfg.setProperty('url', 'mailto:' + encodeURIComponent(email)); +function show_usermenu(id, email, show_edit) { + var items = { + profile: { + name: "Profile", + callback: function () { + var href = "user_profile?login=" + encodeURIComponent(email); + window.open(href, "_blank"); + } + }, + activity: { + name: "Activity", + callback: function () { + var href = "page.cgi?id=user_activity.html&action=run&from=-14d&who=" + + encodeURIComponent(email); + window.open(href, "_blank"); + } + }, + mail: { + name: "Mail", + callback: function () { + var href = "mailto:" + encodeURIComponent(email); + window.open(href, "_blank"); + } + }, + }; if (show_edit) { - usermenu_widget.getItem(3).cfg.setProperty('url', 'editusers.cgi?action=edit&userid=' + id); - } else { - usermenu_widget.removeItem(3); + items.edit = { + name: "Edit", + callback: function () { + var href = "editusers.cgi?action=edit&userid=" + id; + window.open(href, "_blank"); + } + }; } - usermenu_widget.cfg.setProperty('xy', YAHOO.util.Event.getXY(event)); - usermenu_widget.show(); - return false; + $.contextMenu({ + selector: ".vcard_" + id, + trigger: "left", + items: items + }); } -- cgit v1.2.3-24-g4f1b