add "submit" button+style and handler for individual action screens

This commit is contained in:
theopolisme 2014-02-15 18:54:56 -06:00
parent 9164a4ffe4
commit 64bec40b08
2 changed files with 37 additions and 7 deletions

View File

@ -38,6 +38,15 @@
vertical-align: top; vertical-align: top;
} }
#afchSubmit {
text-align: center;
width: 30%;
padding: 5px;
margin-top: 10px;
margin-left: auto;
margin-right: 0px;
}
.header { .header {
height: 60px; height: 60px;
line-height: 1.2em; line-height: 1.2em;

View File

@ -366,6 +366,24 @@
} ); } );
} }
/**
* Adds handler for when the accept/decline/etc form is submitted
* that calls a given function and passes an object to the function
* containing data from all .afch-input elements in the dom
*
* @param {Function} fn function to call with data
*/
function addFormSubmitHandler ( fn ) {
$( '#afchSubmit' ).click( function () {
var data = {};
$( '.afch-input' ).each( function ( _, element ) {
data[element.id] = $( element ).val();
} );
fn( data );
} );
}
// These functions show the options before doing something // These functions show the options before doing something
// to a submission. // to a submission.
@ -373,27 +391,30 @@
$afchWrapper.html( afchViews.renderView( 'accept', { $afchWrapper.html( afchViews.renderView( 'accept', {
newTitle: afchSubmission.shortTitle newTitle: afchSubmission.shortTitle
} ) ); } ) );
addFormSubmitHandler( handleAccept );
return;
} }
function showDeclineOptions () { function showDeclineOptions () {
return; $afchWrapper.html( afchViews.renderView( 'decline', {} ) );
addFormSubmitHandler( handleDecline );
} }
function showCommentOptions () { function showCommentOptions () {
return; $afchWrapper.html( afchViews.renderView( 'comment', {} ) );
addFormSubmitHandler( handleComment );
} }
function showSubmitOptions () { function showSubmitOptions () {
return; $afchWrapper.html( afchViews.renderView( 'submit', {} ) );
addFormSubmitHandler( handleSubmit );
} }
function showG13Options () { function showG13Options () {
return; $afchWrapper.html( afchViews.renderView( 'g13', {} ) );
addFormSubmitHandler( handleG13 );
} }
// The functions actually perform a given action using data passed // These functions actually perform a given action using data passed
// in the `data` parameter. // in the `data` parameter.
/** /**