This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement client-side verification of Change note
- Loading branch information
Showing
1 changed file
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
<tal:script replace="structure string:<script" /> type="text/javascript"<tal:script replace="structure string:>" /> | ||
var notes = <tal:notes replace="view/json_notes" />; | ||
jQuery(function($){ | ||
$("#cmfeditions_version_comment").autocomplete(notes); | ||
var notes = <tal:notes replace="view/json_notes" />; | ||
var commentfield = $("#cmfeditions_version_comment"); | ||
|
||
/* Mark as required */ | ||
var span = document.createElement("span"); | ||
$(span).css("color", "red").attr("title", "Required").addClass( | ||
"required").append(document.createTextNode(" " + "\u25a0")); | ||
commentfield.parent().find("label").append(span); | ||
|
||
/* Set up autocomplete */ | ||
commentfield.autocomplete(notes); | ||
|
||
/* Clear any error formatting on change note once it is filled in */ | ||
commentfield.change(function(){ | ||
commentfield.parent().toggleClass('error', false); | ||
}); | ||
|
||
/* Check that the change note field has been entered */ | ||
var form = commentfield.closest("form"); | ||
form.submit(function(){ | ||
if(commentfield.val().length == 0){ | ||
commentfield.parent().toggleClass("error", true); | ||
/* Remove this class from the submit button, otherwise we | ||
* might be prompted to confirm a resubmit */ | ||
$(":submit", form).toggleClass("submitting", false); | ||
return false; | ||
} | ||
return true; | ||
}); | ||
}); | ||
<tal:script replace="structure string:</script>" /> |