Commits

Mike Cannon-Brookes  committed b4fbb70

Fixed #2 - admin sections now grouped.

  • Participants
  • Parent commits 959015c

Comments (0)

Files changed (1)

File src/main/resources/js/jira-admin-prototype.js

 window.onload = function() {
 	
-	var adminSections = [];
+	var adminSections = {};
 
 	jQuery('.section > a', jQuery('#adminMenu')).each(function() {
 	    var section = jQuery(this);
 				sectionLinks.push({'id': link.attr('id'), 'href': link.attr('href'), 'text': link.text()});
 			}
 		
-	        adminSections.push({'id': section.attr('id'), 'name': section.text(), 'links': sectionLinks});
+	        adminSections[section.attr('id')] = {'id': section.attr('id'), 'name': section.text(), 'links': sectionLinks};
 	    }
 	});
 
 	// console.dir(adminSections);
 
 	// now that we've made the admin links model, let's rewrite it.
-
+	var sectionGroups = { 
+		'Projects': ['admin.project'],
+		'Issues': ['admin.issuesettings', 'admin.issuefields'],
+		'Apps' : ['admin.greenhopper-admin'],
+		'Advanced': ['admin.schemes'],
+		'Users and Groups': ['admin.usersgroups'],
+		'Settings': ['admin.globalsettings', 'admin.options'],
+		'System': ['admin.exportimport', 'admin.system']
+	}
+		
+	// now let's output the HTML
 	var html = '';
 
-	for (var i = 0; i < adminSections.length; i++) {
-		var section = adminSections[i];
+	jQuery.each(sectionGroups, function(name, contents) { 
+		var secName = name.replace(' ', '_');
+		
+		html += '<li class="aui-dd-parent nonlazy speakeasy" style="">' +
+		'<a title="' + name + '" id="' + secName + '_link" href="#" class="lnk">' + name + '</a> ' +
+		'<span class="drop-wrap"><a href="#" rel="' + secName + '_link" id="' + secName + '_link_drop" class="drop aui-dd-link"><span>Access more options</span></a></span>';
 	
-		var niceName = section.id.replace('.', '-');
-		html += '<li class="aui-dd-parent nonlazy speakeasy" style="">' +
-		'<a title="' + section.name + '" id="' + niceName + '_link" href="#" class="lnk">' + section.name + '</a> ' +
-		'<span class="drop-wrap"><a href="#" rel="' + niceName + '_link" id="' + niceName + '_link_drop" class="drop aui-dd-link"><span>Access more options</span></a></span>';
+		html += '<div class="aui-dropdown standard aui-dropdown-right hidden" style="top: 25px; right: auto; left: -1px;"><div>';
+		
+		jQuery.each(contents, function(index, sectionId) {
+			var section = adminSections[sectionId];	
+			var niceName = section.name.replace('.', '_');
+			
+			html += '<h5>' + section.name + '</h5>';
+			
+			html += '<ul id="' + niceName + '_main" class="first">';
 	
-		html += '<div class="aui-dropdown standard aui-dropdown-right hidden" style="top: 25px; right: auto; left: -1px;"><div><ul id="' + niceName + '_main" class="first">';
-	
-		for (var j = 0; j < section.links.length; j++) {
-			var link = section.links[j];
+			jQuery.each(section.links, function(index, link) {
+				html += '<li class="dropdown-item" id="' + niceName + '_' + link.id + '_link"><a class="item-link" href="' + link.href + '" id="' + niceName + '_' + link.id + '_link_lnk">' + link.text + '</a></li>';				
+			});
+
+			html += '</ul>';
+		});
 		
-			html += '<li class="dropdown-item" id="' + niceName + '_' + link.id + '_link"><a class="item-link" href="' + link.href + '" id="' + niceName + '_' + link.id + '_link_lnk">' + link.text + '</a></li>';
-		}
-	
-		html+= '</ul></div></div></li>';
-	}
+		html+= '</div></div></li>';
+	});
 
 	jQuery("#main-nav").append(html);
-	jQuery("#main-nav .lazy").hide();
-	jQuery(".adminMenuWrap").hide();
+	jQuery("#main-nav .lazy").hide(); // hide the old menu items
+	jQuery("#main-nav .nonlazy > #greenhopper_menu").parent().hide(); // hide greenhopper (the only nonlazy original item)
+	jQuery(".adminMenuWrap").hide(); // hide the admin left column
 
 	jQuery("#logo").after("<div style='border: 1px solid #eee; background-color: white; float: left; display: inline; margin-top: 5px; padding: 2px 5px; font-weight: bold; font-size: 90%; color: black;'>You are currently administering JIRA - <a href='" + contextPath + "'>view your Dashboard &nbsp;<img align='absmiddle' src='" + contextPath + "/images/icons/icon_blockcollapsed.png'></a></div>");