Skip to content

Instantly share code, notes, and snippets.

@dougn
Last active December 18, 2015 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dougn/5746654 to your computer and use it in GitHub Desktop.
Save dougn/5746654 to your computer and use it in GitHub Desktop.
FogBugz Customization to split the Filters Menu into My Filters and Shared Filters
name: Menus: Shared Filters and My Filters
description: Menu: Split 'Filters' Menu into 'Shared Filters' and 'My Filters' Menues
author: Doug Napoleone
version: 1.0.0.0
js:
/*
Based on this plugin by Jon Ericson:
http://fogbugz.stackexchange.com/questions/6471/how-to-create-a-custom-menu-in-the-menu-bar
*/
/*
====================================================================================================
CUSTOMIZE THESE VARIABLES
customMenuTitle
Title of the custom menu you wish to be displayed
====================================================================================================
*/
var customMenuTitle = 'My Filters';
(function($) {
if (typeof(window.GetPersonID) != "undefined" && window.GetPersonID()) { // If user is currently logged on.
var urlToFogBugz = GetURLPrefix() + "/",
customMenuId = 'idCustomMenu_' + customMenuTitle.replace(' ', '_');
var myFilters = $($('div.popupHeadline:contains("My Filters")')[0]).nextAll('a');
var myhrs = $('#filterPopup').find('hr');
$(myhrs[myhrs.length-1]).hide();
if ($('#filterPopup').find('a[href="default.asp?pg=pgList&pre=preSaveInboxFilter"]')) {
$(myhrs[0]).hide();
}
$('#Menu_Filter').prepend("Shared ");
var menues = $('#mainnav span.popupMenu');
function CreateMenuLink(text, url) {
return $('<a>').attr({ 'onclick': 'return doPopupClick();', 'href': url }).text(text);
}
function CreateMenuBugLink(text, urlParams) {
return CreateMenuLink(text, urlToFogBugz + 'default.asp?command=new&pg=pgEditBug' + urlParams);
}
// Create your custom links that you want to appear in the menu
// fogbugz will automatically prefill the drop downs with the query string parameters
// Put links in the order that you want them to appear in the menu
// Put in horizontal rules in desired positions
var myCases = $('#filterPopup table tbody tr td div a[href^="default.asp?pg=pgList&pre=preSaveFilterEZ&ixPersonAssignedTo="]');
var helpDiv = $('<div>')
.append('<a href="default.asp?pg=pgManageFilters" onclick="return doPopupClick()">Manage saved filters...</a>')
.append('<hr />')
.append(myCases)
.append('<hr />')
.append($('div.popupHeadline:contains("My Filters")')[0]);
for (var i = 0; i < myFilters.length-1; i++) {
helpDiv.append(myFilters[i]);
}
helpDiv.append('<hr />')
.append('<a href="default.asp?pg=pgFilter" onclick="return doPopupClick();">Customize...</a>');
// shouldn't need to customize anything below this comment...
var customMenu = $('<span>')
.attr('id', customMenuId)
.css({
'display': 'none',
'position': 'absolute',
'left': '0px',
'top': '0px'
})
.addClass('popupMenu')
.addClass(customMenuId);
customMenu
.append('<table>')
.children('table')
.append('<tbody></tbody>')
.children('tbody')
.append('<tr></tr>')
.children('tr')
.append('<td></td>')
.children('td')
.append(helpDiv);
var helpMenu = $('<a>')
.attr({
'id': 'Menu_' + customMenuId,
'title': customMenuTitle,
'href': urlToFogBugz
})
.addClass('navlink')
.addClass('menu')
.html(customMenuTitle +
'<img src="images/clear.gif" border="0" class="down-arrow-blue" />');
$($('#Menu_Filter'))
.before(helpMenu, customMenu);
$(function() {
theMgr.add(customMenuId);
$('#Menu_' + customMenuId).click(function(e) {
e.preventDefault();
return theMgr.showPopup(customMenuId, this, 0, this.offsetHeight + 2, null, true) || KeyManager.browseMenus('mainnav') || KeyManager.oMenuBrowser.setElCurrent(this) || KeyManager.browsePopup(customMenuId);
});
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment