diff --git a/src/less/submissions.less b/src/less/submissions.less index 92971cd..2ed4847 100644 --- a/src/less/submissions.less +++ b/src/less/submissions.less @@ -264,7 +264,7 @@ } /* - Since we're hacking this dynamic suggestion feature into + Since we are hacking this dynamic suggestion feature into jquery.chosen, we have to manually set the width of the input. (see "Offer dynamic category suggestions" in submissions.js) */ @@ -283,11 +283,11 @@ padding-top: 5px; } - #declineTextareaPreviewTrigger { + #previewTrigger { font-size: 80%; } - #declineTextareaPreview { + #previewContainer { border: thin dotted gray; width: 50%; margin: 0.5em auto; @@ -295,9 +295,16 @@ padding: 0 0.5em; } - #declineTextareaPreview:empty { + #previewContainer:empty { display: none; } + + #declineRejectWrapper{ + font-size: 120%; + padding: 0; + border: 0; + margin: 0 0 .5em 0; + } } /* COMMENT */ diff --git a/src/modules/core.js b/src/modules/core.js index 8d28c35..f833c32 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -1315,6 +1315,10 @@ * converting checkboxes to bools, providing textual values of select * elements, ignoring placeholder elements, and more. * + * For a radio button group, pass in the container element, which must + * be a fieldset with the appropriate "name" attribute. Its id will + * be used as the key in the data object. + * * @param {jQuery} $selector elements to get values from * @return {object} object of values, with the ids as keys */ @@ -1327,6 +1331,8 @@ if ( element.type === 'checkbox' ) { value = element.checked; + } else if ( element.type === 'fieldset' ) { + value = $element.find( ':checked' ).val(); } else { value = $element.val(); diff --git a/src/modules/submissions.js b/src/modules/submissions.js index 35eca20..29ab8be 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -1621,6 +1621,18 @@ max_selected_options: 2 } ); + // Set up jquery.chosen for the reject reason + $afch.find( '#rejectReason' ).chosen( { + placeholder_text_single: 'Select a reject reason...', + search_contains: true, + inherit_select_classes: true, + max_selected_options: 2 + } ); + + // rejectReason starts off hidden by default, which makes the _chosen div + // display at 0px wide for some reason. We must manually fix this. + $afch.find( '#rejectReason_chosen' ).css( 'width', '350px' ); + // And now add the handlers for when a specific decline reason is selected $afch.find( '#declineReason' ).change( function () { var reason = $afch.find( '#declineReason' ).val(), @@ -1706,15 +1718,15 @@ $afch.find( '#declineTextarea' ).val( prevDeclineComment ); // If the user wants a preview, show it - if ( $( '#declineTextareaPreviewTrigger' ).text() == '(hide preview)' ) { - $( '#declineTextareaPreview' ) + if ( $( '#previewTrigger' ).text() == '(hide preview)' ) { + $( '#previewContainer' ) .empty() .append( $.createSpinner( { size: 'large', type: 'block' } ).css( 'padding', '20px' ) ); AFCH.getReason( reason ).done( function ( html ) { - $( '#declineTextareaPreview' ).html( html ); + $( '#previewContainer' ).html( html ); } ); } @@ -1725,10 +1737,10 @@ } ); // End change handler for the reason select box // Attach the preview event listener - $afch.find( '#declineTextareaPreviewTrigger' ).click( function () { + $afch.find( '#previewTrigger' ).click( function () { var reason = $afch.find( '#declineReason' ).val(); if ( this.textContent == '(preview)' && reason ) { - $( '#declineTextareaPreview' ) + $( '#previewContainer' ) .empty() .append( $.createSpinner( { size: 'large', @@ -1736,17 +1748,26 @@ } ).css( 'padding', '20px' ) ); var reasonDeferreds = reason.map( AFCH.getReason ); $.when.apply( $, reasonDeferreds ).then( function ( a, b ) { - $( '#declineTextareaPreview' ) + $( '#previewContainer' ) .html( Array.prototype.slice.call( arguments ) .join( '