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

Edit & Edit Preview custom CSS - Confluence 5.3

Joey McDaniel February 5, 2014

Hi Answers!

When going into Edit / Edit Preview mode on Confluence 5.3 I would like additional CSS to apply to my custom header.

The problem I'm having is that the page doesn't referesh when a user enters Edit mode. So if I use targeting like this:

#if ($mode == "edit" || $mode == "edit-preview")
<style>
#header {
display: none !important;
}
</style>
#end

It doesn't work unless the user refreshes the page.

I've also tried adding some simple javascript to autorefresh on load, but again the page isn't doing a load so the script doesn't run.

<script>
	window.onload = function() {
	if(!window.location.hash) {
		window.location = window.location + '#loaded';
		window.location.reload();
	}
	}
	</script>

So, my question is:

How can I run custom javascript or CSS apply only when the user is in Edit mode?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Davin Studer
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.
February 6, 2014

How about this?

body.edit #header {
display: none !important;
}

Joey McDaniel February 6, 2014

Davin, thank you so much! Works great.

Rosario De Domenico
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, 2016

Hi,

I have a similar issue therefore I would like to understand your suggestion better.

I am adding some CSS to my ul element in my space style-sheet, but this makes editing inconvenient, so I want to revert (or apply a different CSS) when in edit mode.

I have changed the HTML source of a page when in view and when in edit mode and I do not see any "edit" class for the body element; how does your suggestion work?

Thanks and regards,

Rosario

 

P.S. I user confluence 5.8.18 and the default theme

Davin Studer
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 9, 2016

I'm using both a 5.5.6 and a 5.8.6 system and when I enter edit mode they add an edit class to the body element.

Rosario De Domenico
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 9, 2016

Well, this is my body tag when I edit a page:

<body onload="placeFocus()" id="com-atlassian-confluence" class="theme-default  aui-layout aui-theme-default">

Davin Studer
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 9, 2016

Hmm. Well, since I don't have a system >= 5.8.18 then I can't quite say. Seems odd that they would remove that from 5.8.6 to 5.8.18. Maybe they put a clue somewhere else. What's on the html element in edit mode?

Rosario De Domenico
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 9, 2016

it is identical.

0 votes
Sam Lee May 15, 2014

I'm trying to do something similar. Where in the Custom HTML section should it go and what should the entire code look like.

This is my "At end of the HEAD"

<div id="header">
<a href="/">Home</a>
<a href="http://someurl">People</a>
<a href="https://someurl">Internal Websites</a>
</div>
<script type="text/javascript">
AJS.bind('init.rte', function() {
AJS.$('#notifyWatchers').attr('checked', false);
});
</script>

I want to hide that header in edit mode.

TAGS
AUG Leaders

Atlassian Community Events