I call an external .vm file from my plugin. The .vm file contains Java Script which opens a new browser and sets the focus to the new browser page.
My Atlassian-plugin.xml, which is the file you build the plugin with and which contains the <link> tags, looks like this:
{code}
<web-item key="rally_link" name="Rally Hosted Web Site" section="links_link/links_section" weight="10">
<label>Rally - Hosted Scrum Tool</label>
<link >/templates/rally.vm</link>
</web-item>
{code}
My .vm files contents look like this:
{code}
<!-- Open a new browser window from a plugin -->
<html>
<head>
<script type="text/javascript">
function load()
{
newwindow = window.open("https://rally1.rallydev.com/slm/login.op", "newwindow")
<!-- have JIRA window go back a page -->
history.go( -1 );
<!-- Set focus to the new page -->
newwindow.focus();
<!-- Move the new page to the forground -->
newwindow.resizeTo(875, 320);
newwindow.moveTo(0,0);
return false;
}
</script>
</head>
<body
onload="load()">
</body>
</html>
{code}
*.vm files are located here on the server:
/webapps/ROOT/WEB-INF/classes/templates
Hope this helps
This was more of an informational blog of how I got this to work and not really a question. The code works as displayed. My vm file is located here on my JIRA server: /tomcat/apache-tomcat-6.0.29/webapps/ROOT/WEB-INF/classes/templates
You should be able to do it straight from the web-item....
<web-item key="rally_link" name="Rally Hosted Web Site" section="links_link/links_section" weight="10"> <label>Rally - Hosted Scrum Tool</label> <link linkId="rally_linkid">javascript:window.open('https://rally1.rallydev.com/slm/login.op', 'newwindow').focus();</link> </web-item>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does this still work in JIRA 6? When I try to put the javascript directly in web-item (using the example from above), when I click the button it just goes to a blank page with the following URL: http://localhost:2990/jirajavascript:window.open('https://rally1.rallydev.com/slm/login.op',%20'newwindow').focus();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How can I make this work ? I want to change name each time this button is clicked
<ac:macro ac:name="web-item">
<ac:parameter ac:name="key">selector-for-button</ac:parameter>
<ac:parameter ac:name="section">system.content.button</ac:parameter>
<ac:parameter ac:name="item">pagefavourite</ac:parameter>
<ac:parameter ac:name="force">true</ac:parameter>
<ac:macro ac:name="link">
<ac:parameter ac:name="linkId">selector-for-button</ac:parameter>
</ac:macro>
<ac:rich-text-body>s</ac:rich-text-body>
</ac:macro>
and in Javascript section, I have -
AJS.toInit(function() {
$('.selector-for-button').click(function() {
alert('Hello!');
});
})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your template file must reside with the plugin I think.
Have you tried moving the file ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.