JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.2
[ckeditor.git] / _source / plugins / sourcearea / plugin.js
index 234bbf0..354c3b2 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -41,6 +41,8 @@ CKEDITOR.plugins.add( 'sourcearea',
                                                        textarea.addClass( 'cke_source' );\r
                                                        textarea.addClass( 'cke_enable_context_menu' );\r
 \r
+                                                       editor.readOnly && textarea.setAttribute( 'readOnly', 'readonly' );\r
+\r
                                                        var styles =\r
                                                        {\r
                                                                // IE7 has overflow the <textarea> from wrapping table cell.\r
@@ -72,17 +74,6 @@ CKEDITOR.plugins.add( 'sourcearea',
                                                                win.on( 'resize', onResize );\r
                                                                setTimeout( onResize, 0 );\r
                                                        }\r
-                                                       // As we prevent click to put focus on editor container,\r
-                                                       // while 'mousedown' inside <textarea> is also captured,\r
-                                                       // but we must stop the even propagation, otherwise\r
-                                                       // it's not possible to place the caret inside of it (non IE and IE9).\r
-                                                       if ( document.addEventListener )\r
-                                                       {\r
-                                                               textarea.on( 'mousedown', function( evt )\r
-                                                                       {\r
-                                                                               evt.data.stopPropagation();\r
-                                                                       } );\r
-                                                       }\r
 \r
                                                        // Reset the holder element and append the\r
                                                        // <textarea> to it.\r
@@ -115,7 +106,7 @@ CKEDITOR.plugins.add( 'sourcearea',
                                                        setTimeout( function()\r
                                                        {\r
                                                                editor.mode = 'source';\r
-                                                               editor.fire( 'mode' );\r
+                                                               editor.fire( 'mode', { previousMode : editor._.previousMode } );\r
                                                        },\r
                                                        ( CKEDITOR.env.gecko || CKEDITOR.env.webkit ) ? 100 : 0 );\r
                                                },\r
@@ -158,6 +149,17 @@ CKEDITOR.plugins.add( 'sourcearea',
                                        });\r
                        });\r
 \r
+               editor.on( 'readOnly', function()\r
+                       {\r
+                               if ( editor.mode == 'source' )\r
+                               {\r
+                                       if ( editor.readOnly )\r
+                                               editor.textarea.setAttribute( 'readOnly', 'readonly' );\r
+                                       else\r
+                                               editor.textarea.removeAttribute( 'readOnly' );\r
+                               }\r
+                       });\r
+\r
                editor.addCommand( 'source', sourcearea.commands.source );\r
 \r
                if ( editor.ui.addButton )\r
@@ -192,7 +194,7 @@ CKEDITOR.plugins.sourcearea =
                {\r
                        modes : { wysiwyg:1, source:1 },\r
                        editorFocus : false,\r
-\r
+                       readOnly : 1,\r
                        exec : function( editor )\r
                        {\r
                                if ( editor.mode == 'wysiwyg' )\r