Difference between revisions 234899 and 261916 on testwiki

/* Uploaded from https://github.com/WPAFC/afch-rewrite, commit: 970e1b3cd6a6f455ff884c868cb8f567125b0b6a33571bbd95044dad114a43e9c994da21a2d44a86 (master) */
//<nowiki>
( function ( AFCH, $, mw ) {
	var $afchLaunchLink, $afch, $afchWrapper,
		afchPage, afchSubmission, afchViews, afchViewer;

	// Die if reviewing a nonexistent page or a userjs/css page
	if ( mw.config.get( 'wgArticleId' ) === 0 ||
(contracted; show full)						$extra.find( 'a' ).css( 'display', 'block' );
						extrasRevealed = true;
					} );
				}
			} );

			// Add feedback and preferences links
			
// FIXME: Feedback temporarily disabled due to https://github.com/WPAFC/afch-rewrite/issues/71
			// AFCH.initFeedback( $afch.find( 'span.feedback-wrapper' ), '[your topic here]', 'give feedback' );
			AFCH.preferences.initLink( $afch.find( 'span.preferences-wrapper' ), 'preferences' );

			// Set up click handlers
			$afch.find( '#afchAccept' ).click( function () { spinnerAndRun( showAcceptOptions ); } );
			$afch.find( '#afchDecline' ).click( function () { spinnerAndRun( showDeclineOptions ); } );
(contracted; show full)						// (returning true keeps the item, false removes it)
						return ref.indexOf( '/>', ref.length - 2 ) === -1;
					} ),

					refEndRe = /<\/\s*ref\s*\>/ig,
					refEndMatches = text.match( refEndRe )|| [],

					reflistRe = /({{(ref
list|listaref(erence)?(\s|-)?list|listaref|refs|footnote|reference|referencias)(?:{{[^{}]*}}|[^}{])*}})|(<\s*references\s*\/?>)/ig,
					hasReflist = reflistRe.test( text ),

					// This isn't as good as a tokenizer, and believes that <ref> foo </b> is
					// completely correct... but it's a good intermediate level solution.
					malformedRefs = text.match( /<\s*ref\s*[^\/]*>?<\s*[^\/]*\s*ref\s*>/ig ) || [];

				// Uneven (/unclosed) <ref> and </ref> tags
(contracted; show full)				$.each( declineList.splice( 0, 5 ), function ( _, rationale ) {
					var $relevant = $reasons.find( 'option[value="' + rationale + '"]' );
					$relevant.clone( true ).appendTo( $commonSection );
				} );
			}

			// Set up jquery.chosen for the decline reason
		
        		$afch.find( '#declineReason' ).chosen( {
				placeholder_text_single: 'Select a decline reason...',
				no_results_text: 'Whoops, no reasons matched your search. Type "custom" to add a custom rationale instead.',
				search_contains: true,
				inherit_select_classes: true
			} );

			// And now add the handlers for when a specific decline reason is selected
		        		$afch.find( '#declineReason' ).change( function ( event, params ) {
				var reason = $afch.find( '#declineReason' ).val(),
					candidateDupeName = ( afchSubmission.shortTitle !== 'sandbox' ) ? afchSubmission.shortTitle : '',
					declineHandlers = {
						cv: function () {
							var $textfieldWrapper, $addAnotherLink, $clone;

							updateTextfield( 'Original URL', 'https://example.com/cake' );
(contracted; show full)					}
					// ... and just outright hide it
					$afch.find( '#csdWrapper' ).toggleClass( 'hidden', !this.checked );
				} );

				// If a reason has been specified, show the textarea, notify
				// option, and the submit form button

				$afch.find( '#textareaWrapper' ).toggleClass( 'hidden', !reason );
				$afch.find( '#declineTextareaPreviewTrigger' ).click( function () {
				$( '#declineTextareaPreview' ).text( $( "#declineTextarea" ).text() );
				} );
				$afch.find( '#declineTextarea' ).add( '#notifyWrapper' ).add( '#afchSubmitForm' )
					.toggleClass( 'hidden', !reason );
			} );
		} );

		addFormSubmitHandler( handleDecline );
	}

	function showCommentOptions () {
(contracted; show full)		afchPage.edit( {
			contents: text.get(),
			summary: 'Postponing [[WP:G13|G13]] speedy deletion'
		} );
	}

}( AFCH, jQuery, mediaWiki ) );
//</nowiki>