w/extensions/FlaggedRevs/frontend/modules/ext.flaggedRevs.review.js
/*
	 * Updates for radios/checkboxes on patch by Daniel Arnold (bug 13744).
	 * Visually update the revision rating form on change.
	 * - Disable submit in case of invalid input.
	 * - Update colors when <select> changes.
	 * - Also remove comment box clutter in case of invalid input.
	 * NOTE: all buttons should exist (perhaps hidden though)
	 */
Updates for radios/checkboxes on patch by Daniel Arnold (bug 13744).
Visually update the revision rating form on change.
- Disable submit in case of invalid input.
- Update colors when  changes.
- Also remove comment box clutter in case of invalid input.
NOTE: all buttons should exist (perhaps hidden though)
Updates for radios / checkboxes on patch by Daniel Arnold ( bug 13744 ) . Visually update the revision rating form on change . - Disable submit in case of invalid input . - Update colors when changes . - Also remove comment box clutter in case of invalid input . NOTE : all buttons should exist ( perhaps hidden though )
function updateReviewForm( form ) {
		var somezero, tag, tagLevelSelects, tagLevelSelect, selectedlevel, i, l;
		if ( form.prop( 'disabled' ) ) {
			return;
		}
		somezero = false;
		for ( tag in wgFlaggedRevsParams.tags ) {
			tagLevelSelects = form.find( '[name="wp' + tag + '"]' );
			if ( !tagLevelSelects.length ) {
				continue; 
			}
			tagLevelSelect = tagLevelSelects.eq( 0 ); 
			selectedlevel = 0; 
			if ( tagLevelSelect.prop( 'nodeName' ) === 'SELECT' ) {
				selectedlevel = tagLevelSelect.prop( 'selectedIndex' );
			} else if ( tagLevelSelect.prop( 'type' ) === 'checkbox' ) {
				selectedlevel = tagLevelSelect.prop( 'checked' ) ? 1 : 0;
			} else if ( tagLevelSelect.prop( 'type' ) === 'radio' ) {
				for ( i = 0, l = tagLevelSelects.length; i < l; i++ ) {
					if ( tagLevelSelects.eq( i ).prop( 'checked' ) ) {
						selectedlevel = i;
						break;
					}
				}
			} else {
				return; 
			}
			if ( selectedlevel <= 0 ) {
				somezero = true;
			}
		}
		$( '#mw-fr-submit-accept' )
			.prop( 'disabled', somezero )
			.val( mw.msg( 'revreview-submit-review' ) ); 
		updateReviewFormColors( form );
	}
function updateReviewForm ( form ) { var somezero , tag , tagLevelSelects , tagLevelSelect , selectedlevel , i , l ; if ( form . prop ( 'disabled' ) ) { return ; } somezero = false ; for ( tag in wgFlaggedRevsParams . tags ) { tagLevelSelects = form . find ( '[name="wp' + tag + '"]' ) ; if ( ! tagLevelSelects . length ) { continue ; } tagLevelSelect = tagLevelSelects . eq ( 0 ) ; selectedlevel = 0 ; if ( tagLevelSelect . prop ( 'nodeName' ) === 'SELECT' ) { selectedlevel = tagLevelSelect . prop ( 'selectedIndex' ) ; } else if ( tagLevelSelect . prop ( 'type' ) === 'checkbox' ) { selectedlevel = tagLevelSelect . prop ( 'checked' ) ? 1 : 0 ; } else if ( tagLevelSelect . prop ( 'type' ) === 'radio' ) { for ( i = 0 , l = tagLevelSelects . length ; i < l ; i ++ ) { if ( tagLevelSelects . eq ( i ) . prop ( 'checked' ) ) { selectedlevel = i ; break ; } } } else { return ; } if ( selectedlevel <= 0 ) { somezero = true ; } } $ ( '#mw-fr-submit-accept' ) . prop ( 'disabled' , somezero ) . val ( mw . msg ( 'revreview-submit-review' ) ) ; updateReviewFormColors ( form ) ; }
Updates for radios/checkboxes on patch by Daniel Arnold (bug 13744).
Updates for radios / checkboxes on patch by Daniel Arnold ( bug 13744 ) .
// Determine if this is a "quality" or "incomplete" review // Get the element or elements for selecting the tag level. // We might get back a select, a checkbox, or *several* radios. // none found; binary flagging? // convenient for select and checkbox // default // Go through each radio option and find the selected one... // error: should not happen // (a) If only a few levels are zero ("incomplete") then disable submission. // (b) Re-enable submission for already accepted revs when ratings change. // reset to "Accept" // Update colors of <select>