Skip to content
Permalink
Browse files
[FIXED JENKINS-19835]
Merged pull request #962.
  • Loading branch information
kohsuke committed Oct 27, 2013
2 parents a84d1bc + a6b7f4b commit d3bce1e2de9fc0db250a1b7326e8da763d8b98a2
Showing 4 changed files with 62 additions and 2 deletions.
@@ -55,6 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=rfe>
Ask for confirmation if an user tries to leave an edited configuration page.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19835">issue 19835</a>)
<li class=rfe>
Test failure summary appearance is improved.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19884">issue 19884</a>)
@@ -63,11 +63,12 @@ THE SOFTWARE.
<j:if test="${h.hasPermission(it,it.CONFIGURE)}">
<f:bottomButtonBar>
<!--<input type="button" name="StructureTest" value="Test" onclick="buildFormTree(this.form)" />-->
<f:submit value="${%Save}" />
<f:submit value="${%Save}"/>
<f:apply />
</f:bottomButtonBar>
</j:if>
</f:form>
<st:adjunct includes="lib.form.confirm" />
</l:main-panel>
</l:layout>
</j:jelly>
@@ -35,5 +35,5 @@ THE SOFTWARE.
</s:documentation>
<st:adjunct includes="lib.form.apply.apply"/>
<input type="hidden" name="core:apply" value="" />
<input type="button" value="${%Apply}" class="apply-button applyButton" /><!-- applyButton is legacy -->
<input type="button" value="${%Apply}" class="apply-button applyButton" name="Apply"/><!-- applyButton is legacy -->
</j:jelly>
@@ -0,0 +1,56 @@
(function() {
var errorMessage = "You have modified configuration";
var needToConfirm = false;

function confirm() {
needToConfirm = true;
}

function confirmExit() {
if (needToConfirm) {
return errorMessage;
}
}

function initConfirm() {
var configForm = document.getElementsByName("config")[0];

var buttons = configForm.getElementsByTagName("button");
var name;
for ( var i = 0; i < buttons.length; i++) {
name = buttons[i].parentNode.parentNode.getAttribute('name');
if (name == "Submit" || name == "Apply") {
$(buttons[i]).on('click', function() {
needToConfirm = false;
});
} else {
$(buttons[i]).on('click', confirm);
}
}

var inputs = configForm.getElementsByTagName("input");
for ( var i = 0; i < inputs.length; i++) {
$(inputs[i]).on('change', confirm);
if (inputs[i].type == 'checkbox' || inputs[i].type == 'radio') {
$(inputs[i]).on('click', confirm);
} else {
$(inputs[i]).on('keydown', confirm);
}
}

inputs = configForm.getElementsByTagName("select");
for ( var i = 0; i < inputs.length; i++) {
$(inputs[i]).on('keydown', confirm);
$(inputs[i]).on('click', confirm);
}

inputs = configForm.getElementsByTagName("textarea");
for ( var i = 0; i < inputs.length; i++) {
$(inputs[i]).on('keydown', confirm);
}
}

window.onbeforeunload = confirmExit;
Event.on(window,'load', initConfirm);

})();

0 comments on commit d3bce1e

Please sign in to comment.