Index: _source/plugins/jquery/plugin.js
===================================================================
--- _source/plugins/jquery/plugin.js	Fri Aug 07 12:14:55 CEST 2009
+++ _source/plugins/jquery/plugin.js	Fri Aug 07 12:14:55 CEST 2009
@@ -0,0 +1,247 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview jQuery plugin provides easy use of basic CKEditor functions
+ *   and access to internal API. It also integrates some aspects of CKEditor with
+ *   jQuery framework.
+ */
+
+(function()
+{
+	CKEDITOR.plugins.add( 'jquery',
+	{
+		load : function()
+		{
+			if ( !this.onLoad._called )
+			{
+				this.onLoad();
+				this.onLoad._called = 1;
+			}
+		},
+		onLoad : function()
+		{
+			if ( typeof jQuery == 'undefined' )
+				return console.log('no jQuery');
+			
+			// jQuery namespace methods.
+			jQuery.extend( jQuery,
+			{
+				ckeditorConfig: function( myConfig )
+				{
+					jQuery.extend( CKEDITOR.config, myConfig );
+				}
+			});
+			
+			// jQuery object methods.
+			jQuery.extend( jQuery.fn,
+			{
+				ckeditorGet: function()
+				{
+					var instance = this.eq( 0 ).data( 'ckeditorInstance' );
+					if ( !instance )
+						throw "CKEditor not yet initialized, use ckeditor() with callback.";
+					return instance;
+				},
+				/**
+				 *
+				 *
+				 * Mixed parameter order allowed.
+				 *
+				 * @param callback Function to be run on editor instance. Passed parameters: [ textarea ].
+				 * Callback is fiered in "this" scope being ckeditor instance and having source textarea as first param.
+				 *
+				 * @param config Configuration options for new instance(s) if not already created.
+				 * See URL
+				 *
+				 * @example
+				 * $( 'textarea' ).ckeditor( function( textarea ) {
+				 *   $( textarea ).val( this.getData() )
+				 * });
+				 */
+				ckeditor: function( callback, config )
+				{
+					if ( !jQuery.isFunction( callback ))
+					{
+						var tmp = config;
+						config = callback;
+						callback = tmp;
+					}
+					this.each( function()
+					{
+						var $element = jQuery( this ),
+							instance = $element.data( 'ckeditorInstance' ),
+							element = this;
+
+						// TODO filter elements ?
+
+						if ( instance )
+						{
+							if ( callback )
+								callback.apply( instance, [ this ] );
+						}
+						else
+						{
+							// CREATE NEW INSTANCE
+							// Register callback.
+							CKEDITOR.on( 'instanceReady', function( event )
+							{
+
+								var editor = event.editor;
+								setTimeout( function()
+								{
+									// Delay bit more if editor is still not ready.
+									if ( !editor.element )
+										return setTimeout( arguments.callee, 100 );
+
+									if ( editor.element.$ == element )
+									{
+										// Remove this listener.
+										event.removeListener( 'instanceReady', this.callee );
+
+										// Remove lock.
+										$element.data( '_ckeditorInstanceLock', null );
+
+										// Forward setData and getData events.
+										jQuery.each( [ 'setData', 'getData' ], function( i, name )
+										{
+
+											editor.on( name, function( event ) {
+
+												$element.trigger( name + '.ckeditor', [ editor, event.data.dataValue ] );
+											});
+										});
+
+										// Forward destroy event.
+										editor.on( 'destroy', function( event ) {
+											$element.trigger( 'destroy.ckeditor', [ editor ] );
+										});
+
+										// Integrate with form submit.
+										if ( editor.config.jquerySyncTextareaOnSubmit && $element.is( 'textarea' ) && $element.parents( 'form' ).length )
+										{
+											var onSubmit = function()
+											{
+
+												$element.ckeditor( function()
+												{
+
+	//												$textarea.val( this.getData(), true );
+													editor.updateElement();
+												});
+											};
+
+											// Bind to submit event.
+											$element.parents( 'form' ).submit( onSubmit );
+											
+											// Unbind when editor destroyed.
+											$element.bind( 'destroy.ckeditor', function() {
+													$element.parents( 'form' ).unbind( 'submit', onSubmit );
+												});
+										}
+										// Fire instanceReady event.
+										$element.trigger( 'instanceReady.ckeditor', [ editor ] );
+
+										// Run given code.
+										if ( callback )
+											callback.apply( editor, [ element ] );
+									}
+								});
+							}, null, null, 9999);
+							
+							// Trigger instance creation.
+							if ( !$element.data( '_ckeditorInstanceLock' ) )
+							{
+								$element
+									.data( '_ckeditorInstanceLock', true )
+									.data( 'ckeditorInstance', CKEDITOR.replace( element, config ) );
+
+							}
+						}
+					});
+					return this;
+				}
+			});
+
+			// New val() method for objects.
+			if ( CKEDITOR.config.jqueryOverrideVal )
+			{
+				jQuery.fn.val = CKEDITOR.tools.override( jQuery.fn.val, function( oldValMethod )
+				{
+					return function( newValue, forceNative )
+					{
+						var isSetter = typeof newValue != 'undefined',
+							result;
+
+						this.each( function()
+						{
+
+							var $this = jQuery( this ),
+								editor = $this.data( 'ckeditorInstance' );
+
+							if ( !forceNative && $this.is( 'textarea' ) && editor )
+							{
+								if ( isSetter )
+									editor.setData( newValue );
+								else
+								{
+									result = editor.getData();
+
+									// break;
+									return null;
+								}
+							}
+							else
+							{
+
+								if ( isSetter )
+									oldValMethod.call( $this, newValue );
+								else
+								{
+									result = oldValMethod.call( $this );
+
+									// break;
+									return null;
+								}
+
+							}
+						});
+						return isSetter ? this : result;
+					};
+				});
+			}
+		}
+	});
+})();
+
+/**
+ * Synchronizes textarea content on submit.
+ *
+ * Works with AJAX forms only if CKEditor is created before calling
+ * .ajaxForm() function on form element.
+ *
+ * @type Boolean
+ * @example
+ * $( 'form' )
+ *   .find( 'textarea' ).ckeditor().end()
+ *   .ajaxForm();
+ */
+CKEDITOR.config.jquerySyncTextareaOnSubmit = false;
+
+/**
+ * Allow CKEditor to override jQuery.fn.val(). This results in ability to use val()
+ * function on textareas as usual and having those calls synchronized with CKEditor
+ * Rich Text Editor component.
+ *
+ * This config option is global and executed during plugin load. Can't be customized accross
+ * editor instances.
+ *
+ * @type Boolean
+ * @example
+ * $( 'textarea' ).ckeditor();
+ * // ...
+ * $( 'textarea' ).val( 'New editor content' );
+ */
+CKEDITOR.config.jqueryOverrideVal = true;
 \ No newline at end of file

