Manipulating CSS in Jira's activity stream via announcement banner

Hello,

we are trying to introduce voting feature for just one project. In this case, I need to find a way to hide every vote functionality by default, but activate for the mentioned project.

I'm running into problems by hiding the vote button in activity stream. I don't want to manipulate Jira's source code to get this work (explained here: http://blog.networkedcollaboration.com/2012/03/19/editing-jira-activity-stream-css).

When I use this code in the announcement banner, I can hide the button by adding an css to the header of every iframe:

AJS.$(document).ready(function() {	
	AJS.$("input#testbutton").click(function () {
		AJS.$("iframe").each(function (index) {
			var frm = this.contentWindow.document;
			var otherhead = frm.getElementsByTagName("head")[0];
			var link = frm.createElement("link");
			link.setAttribute("rel", "stylesheet");
			link.setAttribute("type", "text/css");
			link.setAttribute("href", "vote.css");
			otherhead.appendChild(link);
		});
	});
});

As you can see, this code gets triggered by a click on a button, placed in the announcement banner, too. So after finishing load of page and iframes, I can hide the vote button by firing this click event of the testbutton.

What does not work is executing this code on every iframe's load event:

AJS.$(document).ready(function() {
	AJS.$("iframe").load(function() {
		var frm = this.contentWindow.document;
		var otherhead = frm.getElementsByTagName("head")[0];
		var link = frm.createElement("link");
		link.setAttribute("rel", "stylesheet");
		link.setAttribute("type", "text/css");
		link.setAttribute("href", "vote.css");
		otherhead.appendChild(link);
	});
});

I tested the load event in a single html file, that includes two iframes. There it works quite good! Placing this in Jira's announcement banner nothing happens. I tried to use the load event to raise an alert message, this does not show up, either. So my conclusion is, that the load event is not fired.

Anyone with a suggestion here? :)

Thank you in advance!

1 answer

1 accepted

This widget could not be displayed.

I finished up with the following solution/workaround:

  1. create function that hides the vote button (see above)
  2. call this function after a timeout of x seconds, where x is 0.1, 0.5, 1, 5 seconds

this is not a good one , but a solution, that works.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

578 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you