Add an alert box to all attachment dialog

Olivier Bourquin March 8, 2012

Hello,

We're looking for a simple way of adding an alert box whenever adding an attachment (for juridical reasons).

Once i've was given from the support a trick to fill in the description field with some text by adding the following javascript to the field's label in the field configuration:

{noformat}

<script type="text/javascript">

AJS.$(document).ready(function() {

if (AJS.$(#description) 0 .value == ) {AJS.$(#description) 0 .value = some text; }});

</script>

{noformat}

Now i've been trying to do the same for the attachment field, to no avail. So i thought maybe you could help me.

What i want is that any time you add a file to attach it to an issue, a javascript alert box should popup.

In a simple html file i would do like this:

{noformat}

<input type="file" onchange="alert('When" uploading="" attachment,="" blablabla');=""/>

{noformat}

Unfortunately i could not find where the attachment field is generated or where i should put my simple javascript code.

Do you have an idea? It would help us a lot

2 answers

1 vote
MatthewC
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 8, 2012

If you'd rather just put a message in the attachment popup instead so that the warning is given without being so annoying, the template file would be

atlassian-jira\secure\views\issue\attachFile.jsp

but any change here would need to be re-applied any time you did an upgrade

1 vote
JamieA
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 8, 2012

You don't say if it's jira4 or jira5... what should work for both is:

AJS.$("#attachment_box").live("change", function () {alert("blah")})

(within the document ready handler).

To ensure this javascript gets on every page you need a plugin with a webresource context of jira.general. Or you can just put it in the announcement banner (bit ugly though).

I think you should also do something to limit it to only showing the alert on the first attachment added, or once per month etc, to reduce annoyance.


Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events