Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to add new menu apart from 'Tools', 'Add' etc.?

Pankaj Jangid
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2011

I am creating a new plugin. And it requires a menu to be added to the page. I don't the plugin to be dependent on some other plugin.

How to create a new menu parallel to 'Add', 'Tools' etc. on a Page?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 11, 2011

Some Javascript like this...

<script>
AJS.toInit(function(){
AJS.$('#navigation .ajs-menu-bar').prepend('<li class="ajs-button normal"><a id="answersLink" href="https://answers.atlassian.com/" class="edit"><span>Answers</span></a></li>');
});
</script>

...would add a link to this website next to the Edit button/link.

Pankaj Jangid
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 14, 2011

This idea looks good. It should work. While I was trying I am stuck into another problem. Here I have asked that question - https://answers.atlassian.com/questions/3054/javascript-inclusion

Please respond if you have an answer.

Thanks & Regards.

Pankaj Jangid
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 17, 2011

This worked. Thanks.

Sven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 22, 2011

Thank you, that helped me a lot. But now I'm stuck in adding a whole drop-down-menu this way

(I want to show a list of spaces tagged with label xyz, thats a usermacro)

## @param 0:title=Label|type=string|required=true|desc=Label der Spaces

#set($labelmanager=$action.getLabelManager())
#set($label=$labelmanager.getLabel($param0) )
#set($spaces=$labelmanager.getSpacesWithLabel($label) )


## build HTML for menu

#set( $Q = '"' ) 
## now we can use ${Q}
#set ($myhtml = "&lt;li class=${Q}ajs-menu-item normal${Q}&gt;&lt;a id=${Q}space-menu-link${Q} class=${Q}action trigger ajs-menu-title${Q} href=${Q}#${Q}&gt;&lt;span&gt;&lt;span&gt;Spaceliste&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;div class=${Q}ajs-drop-down assistive${Q}&gt;")

#foreach( $space in $spaces)
#set ($myhtml = $myhtml + "&lt;ul&gt;&lt;li&gt;" + $action.getHelper().renderConfluenceMacro("[$space.getName()|$space.getKey():]") + "&lt;/li&gt;&lt;/ul&gt;")
#end
#set ($myhtml = $myhtml + "&lt;/ul&gt;&lt;/div&gt;&lt;/li&gt;")

&lt;script&gt;
// add menu item
AJS.toInit(function(){
  AJS.$('#navigation .ajs-menu-bar').prepend('$myhtml');
  // re-initialize drop down so that the new item is triggered, too, but how?
  //AJS.$("#ajs-menu-bar").dropDown("Standard");
});
&lt;/script&gt;

I had to deal with some "velocity quoting hell", but found a workaround (see above) ;-)

If I add "assistive" to the class, the menu is closed by default, but does not "open" on click.

(if I leave out "assistive", the menu is always open which is not very useful)

What is the missing brick?

Thanks in advance for hint, it seems that you are the confluence-master of DOM manipulation! ;-)

Pankaj Jangid
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2011

This will create a section within existing menus - Add, Tools etc. What I want is to create a new menu parallel to Add, Tools.

Suraiya Banu March 15, 2012

Hi Jangid, I am trying out for something similar like this. If you have acheived doing it, could you please guide me how to do it?

Thanks in advance

Pankaj Jangid
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 19, 2012

Hi Suraiya,

I did it as suggested by David (first answer). But to make it work in 4.0 and gel smoothly with existing menu, I had to write a lot of javascript code. But the basic concept remains the same.

Sven
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2012

Hi Jangid,

could you share your javascript code with us?

Thanks a lot in advance!

TAGS
AUG Leaders

Atlassian Community Events