JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.3
[ckeditor.git] / _source / adapters / jquery.js
index 314c8ed..d958426 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -32,15 +32,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 (function()\r
 {\r
        /**\r
-        * Allow CKEditor to override jQuery.fn.val(). This results in ability to use val()\r
-        * function on textareas as usual and having those calls synchronized with CKEditor\r
-        * Rich Text Editor component.\r
-        *\r
-        * This config option is global and executed during plugin load.\r
-        * Can't be customized across editor instances.\r
-        *\r
+        * Allows CKEditor to override jQuery.fn.val(), making it possible to use the val()\r
+        * function on textareas, as usual, having it synchronized with CKEditor.<br>\r
+        * <br>\r
+        * This configuration option is global and executed during the jQuery Adapter loading.\r
+        * It can't be customized across editor instances.\r
         * @type Boolean\r
         * @example\r
+        * &lt;script&gt;\r
+        * CKEDITOR.config.jqueryOverrideVal = true;\r
+        * &lt;/script&gt;\r
+        * &lt;!-- Important: The JQuery adapter is loaded *after* setting jqueryOverrideVal --&gt;\r
+        * &lt;script src="/ckeditor/adapters/jquery.js"&gt;&lt;/script&gt;\r
+        * @example\r
+        * // ... then later in the code ...\r
+        *\r
         * $( 'textarea' ).ckeditor();\r
         * // ...\r
         * $( 'textarea' ).val( 'New content' );\r
@@ -97,6 +103,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                 */\r
                ckeditor: function( callback, config )\r
                {\r
+                       if ( !CKEDITOR.env.isCompatible )\r
+                               return this;\r
+\r
                        if ( !jQuery.isFunction( callback ))\r
                        {\r
                                var tmp = config;\r
@@ -183,10 +192,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                // Bind to submit event.\r
                                                                $element.parents( 'form' ).submit( onSubmit );\r
 \r
+                                                               // Bind to form-pre-serialize from jQuery Forms plugin.\r
+                                                               $element.parents( 'form' ).bind( 'form-pre-serialize', onSubmit );\r
+\r
                                                                // Unbind when editor destroyed.\r
                                                                $element.bind( 'destroy.ckeditor', function()\r
                                                                {\r
                                                                        $element.parents( 'form' ).unbind( 'submit', onSubmit );\r
+                                                                       $element.parents( 'form' ).unbind( 'form-pre-serialize', onSubmit );\r
                                                                });\r
                                                        }\r
 \r