// view for marking a page as reviewed or unreviewed

$( function() {
	mw.pageTriage.MarkView = mw.pageTriage.ToolView.extend( {
		id: 'mwe-pt-mark',
		icon: 'icon_mark_reviewed.png', // the default icon
		title: gM( 'pagetriage-mark-as-reviewed' ),
		template: mw.pageTriage.viewUtil.template( { 'view': 'toolbar', 'template': 'mark.html' } ),
		
		submit: function( action ) {
			var _this = this;
			apiRequest = {
				'action': 'pagetriageaction',
				'pageid': mw.config.get( 'wgArticleId' ),
				'reviewed': ( action === 'reviewed' ) ? '1' : '0',
				'token': mw.user.tokens.get('editToken'),
				'format': 'json'
			};
			return $.ajax( {
				type: 'post',
				url: mw.util.wikiScript( 'api' ),
				data: apiRequest,
				success: function( data ) {
					if ( data.error ) {
						// TODO: update for both review and unreview actions
						alert( mw.msg( 'pagetriage-mark-as-reviewed-error' ) );
					} else {
						// update the article model, since it's now changed.
						_this.model.fetch();
						_this.hide();
					}
				},
				dataType: 'json'
			} );
		},

		render: function() {
			var _this = this;

			// create the mark as reviewed flyout content here.
			this.$tel.html( this.template( this.model.toJSON() ) );
			
			// override the flyout title based on the current reviewed state of the page
			if ( this.model.get( 'patrol_status' ) > 0 ) {
				// page is reviewed
				$( '#mwe-pt-mark .mwe-pt-tool-title' ).html( mw.msg( 'pagetriage-mark-as-unreviewed' ) );
			} else {
				// page is unreviewed
				$( '#mwe-pt-mark .mwe-pt-tool-title' ).html( mw.msg( 'pagetriage-mark-as-reviewed' ) );
			}

			// initialize the buttons
			$( '#mwe-pt-mark-as-reviewed-button' )
				.button( { icons: { secondary:'ui-icon-triangle-1-e' } } )
				.click( function( e ) {
					_this.submit( 'reviewed' );
					e.stopPropagation();
				} );
			
			$( '#mwe-pt-mark-as-unreviewed-button' )
				.button( { icons: { secondary:'ui-icon-triangle-1-e' } } )
				.click( function( e ) {
					_this.submit( 'unreviewed' );
					e.stopPropagation();
				} );
			
			// bind down here so it doesn't happen before the first render
			this.model.unbind( 'change:patrol_status', function() { _this.render(); } );
			this.model.bind( 'change:patrol_status', function() { _this.render(); } );
		}

	} );

} );

@@ -338,18 +338,422 @@
 l' %7D ),%0A
+%0A
 %09%09
+initialize: function( options ) %7B%0A%09%09%09this.eventBus = options.eventBus;%0A%09%09%09this.model.on( 'change', this.setIcon, this );%0A%09%09%7D,%0A%0A%09%09// overwrite parent function%0A%09%09setIcon: function( dir ) %7B%0A%09%09%09if ( typeof( dir ) !== 'string' )  %7B%0A%09%09%09%09dir = 'normal';%0A%09%09%09%7D%0A%09%09%09if ( dir === 'normal' && this.model.get( 'patrol_status' ) %3E 0 ) %7B%0A%09%09%09%09dir = 'special';%0A%09%09%09%7D%0A%09%09%09this.$icon.attr('src', this.iconPath( dir ) );%0A%09%09%7D,%0A
 %0A%09%09submi

Make 'mark' icon stick to green when reviewed