Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
implement client-side verification of Change note
Browse files Browse the repository at this point in the history
  • Loading branch information
izak committed Nov 3, 2011
1 parent 87bb87a commit 74dfc75
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/slc/quickchangenote/browser/javascript.pt
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>" />

0 comments on commit 74dfc75

Please sign in to comment.