public/ckeditor/4.4dev/plugins/indent/plugin.js
function setupGenericListeners( editor, command ) {
		var selection, bookmarks;

		// Set the command state according to content-specific
		// command states.
		command.on( 'refresh', function( evt ) {
			// If no state comes with event data, disable command.
			var states = [ TRISTATE_DISABLED ];

			for ( var s in evt.data.states )
				states.push( evt.data.states[ s ] );

			this.setState( CKEDITOR.tools.search( states, TRISTATE_OFF ) ?
					TRISTATE_OFF
				:
					TRISTATE_DISABLED );
		}, command, null, 100 );

		// Initialization. Save bookmarks and mark event as not handled
		// by any plugin (command) yet.
		command.on( 'exec', function( evt ) {
			selection = editor.getSelection();
			bookmarks = selection.createBookmarks( 1 );

			// Mark execution as not handled yet.
			if ( !evt.data )
				evt.data = {};

			evt.data.done = false;
		}, command, null, 0 );

		// Housekeeping. Make sure selectionChange will be called.
		// Also re-select previously saved bookmarks.
		command.on( 'exec', function( evt ) {
			editor.forceNextSelectionCheck();
			selection.selectBookmarks( bookmarks );
		}, command, null, 100 );
	}
function setupGenericListeners( editor, command ) {
		var selection, bookmarks;

		// Set the command state according to content-specific
		// command states.
		command.on( 'refresh', function( evt ) {
			// If no state comes with event data, disable command.
			var states = [ TRISTATE_DISABLED ];

			for ( var s in evt.data.states )
				states.push( evt.data.states[ s ] );

			this.setState( CKEDITOR.tools.search( states, TRISTATE_OFF ) ?
					TRISTATE_OFF
				:
					TRISTATE_DISABLED );
		}, command, null, 100 );

		// Initialization. Save bookmarks and mark event as not handled
		// by any plugin (command) yet.
		command.on( 'exec', function( evt ) {
			selection = editor.getSelection();
			bookmarks = selection.createBookmarks( 1 );

			// Mark execution as not handled yet.
			if ( !evt.data )
				evt.data = {};

			evt.data.done = false;
		}, command, null, 0 );

		// Housekeeping. Make sure selectionChange will be called.
		// Also re-select previously saved bookmarks.
		command.on( 'exec', function( evt ) {
			editor.forceNextSelectionCheck();
			selection.selectBookmarks( bookmarks );
		}, command, null, 100 );
	}
function setupGenericListeners ( editor , command ) { var selection , bookmarks ; // Set the command state according to content-specific
 // command states.
 command . on ( 'refresh' , function ( evt ) { // If no state comes with event data, disable command.
 var states = [ TRISTATE_DISABLED ] ; for ( var s in evt . data . states ) states . push ( evt . data . states [ s ] ) ; this . setState ( CKEDITOR . tools . search ( states , TRISTATE_OFF ) ? TRISTATE_OFF : TRISTATE_DISABLED ) ; } , command , null , 100 ) ; // Initialization. Save bookmarks and mark event as not handled
 // by any plugin (command) yet.
 command . on ( 'exec' , function ( evt ) { selection = editor . getSelection ( ) ; bookmarks = selection . createBookmarks ( 1 ) ; // Mark execution as not handled yet.
 if ( ! evt . data ) evt . data = { } ; evt . data . done = false ; } , command , null , 0 ) ; // Housekeeping. Make sure selectionChange will be called.
 // Also re-select previously saved bookmarks.
 command . on ( 'exec' , function ( evt ) { editor . forceNextSelectionCheck ( ) ; selection . selectBookmarks ( bookmarks ) ; } , command , null , 100 ) ; }
Attaches event listeners for this generic command. Since the indentation
system is event-oriented, generic commands communicate with
content-specific commands using the `exec` and `refresh` events.

Listener priorities are crucial. Different indentation phases
are executed with different priorities.

For the `exec` event:

* 0: Selection and bookmarks are saved by the generic command.
* 1-99: Content-specific commands try to indent the code by executing
their own jobs ({@link CKEDITOR.plugins.indent.specificDefinition#jobs}).
* 100: Bookmarks are re-selected by the generic command.

The visual interpretation looks as follows:

+------------------+
| Exec event fired |
+------ + ---------+
|
0 -<----------+ Selection and bookmarks saved.
|
|
25 -<---+ Exec 1st job of plugin#1 (return false, continuing...).
|
|
50 -<---+ Exec 1st job of plugin#2 (return false, continuing...).
|
|
75 -<---+ Exec 2nd job of plugin#1 (only if plugin#2 failed).
|
|
100 -<-----------+ Re-select bookmarks, clean-up.
|
+-------- v ----------+
| Exec event finished |
+---------------------+

For the `refresh` event:

* <100: Content-specific commands refresh their job states according
to the given path. Jobs save their states in the `evt.data.states` object
passed along with the event. This can be either {@link CKEDITOR#TRISTATE_DISABLED}
or {@link CKEDITOR#TRISTATE_OFF}.
* 100: Command state is determined according to what states
have been returned by content-specific jobs (`evt.data.states`).
UI elements are updated at this stage.

**Note**: If there is at least one job with the {@link CKEDITOR#TRISTATE_OFF} state,
then the generic command state is also {@link CKEDITOR#TRISTATE_OFF}. Otherwise,
the command state is {@link CKEDITOR#TRISTATE_DISABLED}.

@param {CKEDITOR.command} command The command to be set up.
@private
Attaches event listeners for this generic command . Since the indentation system is event - oriented generic commands communicate with content - specific commands using the exec and refresh events .