JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.2
[ckeditor.git] / _source / plugins / sourcearea / plugin.js
index ca2d307..234bbf0 100644 (file)
@@ -14,7 +14,8 @@ CKEDITOR.plugins.add( 'sourcearea',
 \r
        init : function( editor )\r
        {\r
-               var sourcearea = CKEDITOR.plugins.sourcearea;\r
+               var sourcearea = CKEDITOR.plugins.sourcearea,\r
+                       win = CKEDITOR.document.getWindow();\r
 \r
                editor.on( 'editingBlockReady', function()\r
                        {\r
@@ -33,7 +34,9 @@ CKEDITOR.plugins.add( 'sourcearea',
                                                        textarea.setAttributes(\r
                                                                {\r
                                                                        dir : 'ltr',\r
-                                                                       tabIndex : -1\r
+                                                                       tabIndex : CKEDITOR.env.webkit ? -1 : editor.tabIndex,\r
+                                                                       'role' : 'textbox',\r
+                                                                       'aria-label' : editor.lang.editorTitle.replace( '%1', editor.name )\r
                                                                });\r
                                                        textarea.addClass( 'cke_source' );\r
                                                        textarea.addClass( 'cke_enable_context_menu' );\r
@@ -48,36 +51,33 @@ CKEDITOR.plugins.add( 'sourcearea',
                                                                'text-align' : 'left'\r
                                                        };\r
 \r
-                                                       // The textarea height/width='100%' doesn't\r
-                                                       // constraint to the 'td' in IE strick mode\r
+                                                       // Having to make <textarea> fixed sized to conque the following bugs:\r
+                                                       // 1. The textarea height/width='100%' doesn't constraint to the 'td' in IE6/7.\r
+                                                       // 2. Unexpected vertical-scrolling behavior happens whenever focus is moving out of editor\r
+                                                       // if text content within it has overflowed. (#4762)\r
                                                        if ( CKEDITOR.env.ie )\r
                                                        {\r
-                                                               if ( !CKEDITOR.env.ie8Compat )\r
+                                                               onResize = function()\r
                                                                {\r
-                                                                       onResize = function()\r
-                                                                               {\r
-                                                                                       // Holder rectange size is stretched by textarea,\r
-                                                                                       // so hide it just for a moment.\r
-                                                                                       textarea.hide();\r
-                                                                                       textarea.setStyle( 'height', holderElement.$.clientHeight + 'px' );\r
-                                                                                       // When we have proper holder size, show textarea again.\r
-                                                                                       textarea.show();\r
-                                                                               };\r
-                                                                       editor.on( 'resize', onResize );\r
-                                                                       editor.on( 'afterCommandExec', function( event )\r
-                                                                       {\r
-                                                                               if ( event.data.name == 'toolbarCollapse' )\r
-                                                                                       onResize();\r
-                                                                       });\r
-                                                                       styles.height = holderElement.$.clientHeight + 'px';\r
-                                                               }\r
+                                                                       // Holder rectange size is stretched by textarea,\r
+                                                                       // so hide it just for a moment.\r
+                                                                       textarea.hide();\r
+                                                                       textarea.setStyle( 'height', holderElement.$.clientHeight + 'px' );\r
+                                                                       textarea.setStyle( 'width', holderElement.$.clientWidth + 'px' );\r
+                                                                       // When we have proper holder size, show textarea again.\r
+                                                                       textarea.show();\r
+                                                               };\r
+\r
+                                                               editor.on( 'resize', onResize );\r
+                                                               win.on( 'resize', onResize );\r
+                                                               setTimeout( onResize, 0 );\r
                                                        }\r
-                                                       else\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
-                                                               // By some yet unknown reason, we must stop the\r
-                                                               // mousedown propagation for the textarea,\r
-                                                               // otherwise it's not possible to place the caret\r
-                                                               // inside of it (non IE).\r
                                                                textarea.on( 'mousedown', function( evt )\r
                                                                        {\r
                                                                                evt.data.stopPropagation();\r
@@ -90,6 +90,8 @@ CKEDITOR.plugins.add( 'sourcearea',
                                                        holderElement.append( textarea );\r
                                                        textarea.setStyles( styles );\r
 \r
+                                                       editor.fire( 'ariaWidget', textarea );\r
+\r
                                                        textarea.on( 'blur', function()\r
                                                                {\r
                                                                        editor.focusManager.blur();\r
@@ -136,10 +138,14 @@ CKEDITOR.plugins.add( 'sourcearea',
 \r
                                                unload : function( holderElement )\r
                                                {\r
+                                                       textarea.clearCustomData();\r
                                                        editor.textarea = textarea = null;\r
 \r
                                                        if ( onResize )\r
+                                                       {\r
                                                                editor.removeListener( 'resize', onResize );\r
+                                                               win.removeListener( 'resize', onResize );\r
+                                                       }\r
 \r
                                                        if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 )\r
                                                                holderElement.removeStyle( 'position' );\r
@@ -185,6 +191,7 @@ CKEDITOR.plugins.sourcearea =
                source :\r
                {\r
                        modes : { wysiwyg:1, source:1 },\r
+                       editorFocus : false,\r
 \r
                        exec : function( editor )\r
                        {\r