Is it possible to make the change comment mandatory for every change to a confluence page? I tested a solution with a jquery macro but it doesn't work correct.
Any idea.Thank you.
Okay, i will test and find out, why it doesn't work under Firefox.
The solutiion is a good base for further developement.
Thank you.
Has nobody a good idea for this problem or maybe a link to a good workaround?
as of now this is not feasible in confluence and already submitted request to implement this @ https://jira.atlassian.com/browse/CONF-6373
Have you tried something like this? Add it to the custom html in Confluence Admin. I would stick it in the box that says "At end of the BODY".
AJS.toInit(function() { var buttonID = 'rte-button-publish'; var textID = 'versionComment'; if(AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) { //Disable save button AJS.$('#' + buttonID).prop('disabled', true); //If the text box changes and there is content re-enable the save button AJS.$("#" + textID).keyup(function() { if(AJS.$(this).val() !== '') { AJS.$('#' + buttonID).prop('disabled', false); } else { AJS.$('#' + buttonID).prop('disabled', true); } }); } });
Yes, i tested a solution with jquery, but it doesn't work. Your script doesn't disable the save button, it ist always enabled.
What Confluence version are you on and what browser/verion are you using? This works just fine on my environments (Confluence 5.1.3 and 5.2.4).
Okay, we are using Firefox. Now i have tested it with Chrome and IE and it works. But but why not with Firefox? Firefox is our preferred browser. I put debug messages to the script so i could see that the script was called but it was not able to disable the save button.
I have tested it on my system with IE9,10,11, current Chrome, and current Firefox and all of them are working. I'm not sure why it isn't working on your system, but the code should work.
I tried this using IE and Firefox and the save button is NOT disabled. DO I need to restart confluence on the server?
Does anyone know if there is a newer or improved solution for this? So far in my searching this answer is the one that seems most promising.
Davin Studer, I would like to enable mandatory change comments for a subset of pages within a space I own, but I don't have admin privlidges for the server - is this possible with your solution described above?
We are using version 5.8 server.
Thanks!
You would need to be a system admin. Also the JavaScript I provided would affect every page system wide.
Ok, that's what I thought but I appreciate the confirmation and the quick response.
I need something like this that requires body text in confluence. I tried pasting this into the At the end of the BODY section with no changes in behaviour on Chrome on Mac or Safari on Mac. We are running 6.3.3. Do we need to restart confluence after adding Custom HTML? I wouldn't think so.
Did you put it inside script tags? If not you need to do that for it to work.
<script type="text/javascript">AJS.toInit(function() { var buttonID = 'rte-button-publish'; var textID = 'versionComment'; if(AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) { //Disable save button AJS.$('#' + buttonID).prop('disabled', true); //If the text box changes and there is content re-enable the save button AJS.$("#" + textID).keyup(function() { if(AJS.$(this).val() !== '') { AJS.$('#' + buttonID).prop('disabled', false); } else { AJS.$('#' + buttonID).prop('disabled', true); } }); }});</script>
Oh, wait ... Also since they have changed how the editor work you now have to bind to it when it is initialized. It used to be that the page would reload for editing, but not anymore. Here is an updated version for newer versions of Confluence.
<script type="text/javascript"> AJS.toInit(function(){ AJS.bind('init.rte-control', function(){ var buttonID = 'rte-button-publish'; var textID = 'versionComment'; if(AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) { //Disable save button AJS.$('#' + buttonID).prop('disabled', true); //If the text box changes and there is content re-enable the save button AJS.$("#" + textID).keyup(function() { if(AJS.$(this).val() !== '') { AJS.$('#' + buttonID).prop('disabled', false); } else { AJS.$('#' + buttonID).prop('disabled', true); } }); } }); }); </script>
I tried the solution above (server 6.0.4), but the binding didn't work and also preview bypassed the control.
Below is my JS solution which always binds, including when previewing:
<script type="text/javascript">function commentRequired() { var buttonID = 'rte-button-publish'; var textID = 'versionComment'; // Find the button & text box, only work if they exist if (AJS.$('#' + buttonID).length > 0 && AJS.$("#" + textID).length > 0) { // Set status at start if necessary if (AJS.$('#' + textID).val().length < 10) { AJS.$('#' + buttonID).prop('disabled', true); AJS.$("#" + textID).css('border-color','#f00') AJS.$("#" + textID).css('background-color','#fff4f4') } //If the textbox changes update the status of button and textbox AJS.$("#" + textID).keyup(function() { if(AJS.$(this).val().length > 9) { AJS.$('#' + buttonID).prop('disabled', false); AJS.$("#" + textID).css('border-color','') AJS.$("#" + textID).css('background-color','') } else { AJS.$('#' + buttonID).prop('disabled', true); AJS.$("#" + textID).css('border-color','#f00') AJS.$("#" + textID).css('background-color','#fff4f4') } }); }}AJS.bind('init.rte', function(a, e) { $(e.editor.getWin().parent.document).bind("mode-changed", function() { commentRequired(); }); $(e.editor.getWin().parent.document).bind("iframeAppended", function() { commentRequired(); }); });</script>
What I also did was used a Script Runner Script Fragment of type Web Panel to put this into the alt.editor.savebar area only for spaces matching certain criteria.
Now that the new editor experience does not even allow for a comment, is there a way to use this code to "extend" the "contracted" UI? In effect, this could require a comment even though a comment isn't allowed. It could do this in many ways. A pop-up sounds easiest, but I'm betting there are about 17 other ways to do it.
It looks like you're new here. Sign in or register to get started.