JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2
[ckeditor.git] / _source / plugins / wysiwygarea / plugin.js
index 11fd76e..c256646 100644 (file)
@@ -241,16 +241,18 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        var fixForBody = ( editor.config.enterMode != CKEDITOR.ENTER_BR )\r
                                ? editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' : false;\r
 \r
+                       var frameLabel = editor.lang.editorTitle.replace( '%1', editor.name );\r
+\r
                        editor.on( 'editingBlockReady', function()\r
                                {\r
                                        var mainElement,\r
-                                               fieldset,\r
                                                iframe,\r
                                                isLoadingData,\r
                                                isPendingFocus,\r
                                                frameLoaded,\r
                                                fireMode;\r
 \r
+\r
                                        // Support for custom document.domain in IE.\r
                                        var isCustomDomain = CKEDITOR.env.isCustomDomain();\r
 \r
@@ -259,90 +261,59 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        {\r
                                                if ( iframe )\r
                                                        iframe.remove();\r
-                                               if ( fieldset )\r
-                                                       fieldset.remove();\r
 \r
                                                frameLoaded = 0;\r
 \r
+                                               var setDataFn = !CKEDITOR.env.gecko && CKEDITOR.tools.addFunction( function( doc )\r
+                                                       {\r
+                                                               CKEDITOR.tools.removeFunction( setDataFn );\r
+                                                               doc.write( data );\r
+                                                       });\r
+\r
+                                               var srcScript =\r
+                                                       'document.open();' +\r
+\r
+                                                       // The document domain must be set any time we\r
+                                                       // call document.open().\r
+                                                       ( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +\r
+\r
+                                                       // With FF, it's better to load the data on\r
+                                                       // iframe.load. (#3894,#4058)\r
+                                                       // But in FF, we still need the open()-close() call\r
+                                                       // to avoid HTTPS warnings.\r
+                                                       ( CKEDITOR.env.gecko ? '' : ( 'parent.CKEDITOR.tools.callFunction(' + setDataFn + ',document);' ) ) +\r
+\r
+                                                       'document.close();';\r
+\r
                                                iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +\r
                                                        ' style="width:100%;height:100%"' +\r
                                                        ' frameBorder="0"' +\r
-                                                       ( !CKEDITOR.env.webkit ?\r
-                                                               // Support for custom document.domain in IE.\r
-                                                               ' src="javascript:void((function(){' +\r
-                                                               'document.open();' +            // To avoid HTTPS warnings.\r
-                                                               ( isCustomDomain ?\r
-                                                                       'document.domain=\'' + document.domain + '\';' : '' ) +\r
-                                                               'document.close();' +\r
-                                                               '})())"' : '' ) +\r
-                                                       ' tabIndex="-1"' +\r
+                                                       ' src="javascript:void(function(){' + encodeURIComponent( srcScript ) + '}())"' +\r
+                                                       ' tabIndex="' + editor.tabIndex + '"' +\r
                                                        ' allowTransparency="true"' +\r
                                                        '></iframe>' );\r
 \r
-                                               // Register onLoad event for iframe element, which\r
-                                               // will fill it with content and set custom domain.\r
-                                               iframe.on( 'load', function( e )\r
-                                               {\r
-                                                       e.removeListener();\r
-                                                       var doc = iframe.getFrameDocument().$;\r
-\r
-                                                       // Custom domain handling is needed after each document.open().\r
-                                                       doc.open();\r
-                                                       if ( isCustomDomain )\r
-                                                               doc.domain = document.domain;\r
-                                                       doc.write( data );\r
-                                                       doc.close();\r
-\r
-                                               } );\r
+                                               // With FF, it's better to load the data on iframe.load. (#3894,#4058)\r
+                                               CKEDITOR.env.gecko && iframe.on( 'load', function( ev )\r
+                                                       {\r
+                                                               ev.removeListener();\r
 \r
-                                               var accTitle = editor.lang.editorTitle.replace( '%1', editor.name );\r
+                                                               var doc = iframe.getFrameDocument().$;\r
 \r
-                                               if ( CKEDITOR.env.gecko )\r
-                                               {\r
-                                                       // Accessibility attributes for Firefox.\r
-                                                       mainElement.setAttributes(\r
-                                                               {\r
-                                                                       role : 'region',\r
-                                                                       title : accTitle\r
-                                                               } );\r
-                                                       iframe.setAttributes(\r
-                                                               {\r
-                                                                       role : 'region',\r
-                                                                       title : ' '\r
-                                                               } );\r
-                                               }\r
-                                               else if ( CKEDITOR.env.webkit )\r
-                                               {\r
-                                                       iframe.setAttribute( 'title', accTitle );       // Safari 4\r
-                                                       iframe.setAttribute( 'name', accTitle );        // Safari 3\r
-                                               }\r
-                                               else if ( CKEDITOR.env.ie )\r
-                                               {\r
-                                                       // Accessibility label for IE.\r
-                                                       fieldset = CKEDITOR.dom.element.createFromHtml(\r
-                                                               '<fieldset style="height:100%' +\r
-                                                               ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? ';position:relative' : '' ) +\r
-                                                               '">' +\r
-                                                                       '<legend style="display:block;width:0;height:0;overflow:hidden;' +\r
-                                                                       ( CKEDITOR.env.ie && CKEDITOR.env.quirks ? 'position:absolute' : '' ) +\r
-                                                                       '">' +\r
-                                                                               CKEDITOR.tools.htmlEncode( accTitle ) +\r
-                                                                       '</legend>' +\r
-                                                               '</fieldset>'\r
-                                                               , CKEDITOR.document );\r
-                                                       iframe.appendTo( fieldset );\r
-                                                       fieldset.appendTo( mainElement );\r
-                                               }\r
+                                                               doc.open();\r
+                                                               doc.write( data );\r
+                                                               doc.close();\r
+                                                       });\r
 \r
-                                               if ( !CKEDITOR.env.ie )\r
-                                                       mainElement.append( iframe );\r
+                                               mainElement.append( iframe );\r
                                        };\r
 \r
                                        // The script that launches the bootstrap logic on 'domReady', so the document\r
                                        // is fully editable even before the editing iframe is fully loaded (#4455).\r
                                        var activationScript =\r
                                                '<script id="cke_actscrpt" type="text/javascript" cke_temp="1">' +\r
-                                                       'window.parent.CKEDITOR._["contentDomReady' + editor.name + '"]( window );' +\r
+                                                       ( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +\r
+                                                       'parent.CKEDITOR._["contentDomReady' + editor.name + '"]( window );' +\r
                                                '</script>';\r
 \r
                                        // Editing area bootstrap code.\r
@@ -350,9 +321,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        {\r
                                                if ( frameLoaded )\r
                                                        return;\r
-\r
                                                frameLoaded = 1;\r
 \r
+                                               editor.fire( 'ariaWidget', iframe );\r
+\r
                                                var domDocument = domWindow.document,\r
                                                        body = domDocument.body;\r
 \r
@@ -664,6 +636,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        data =\r
                                                                                config.docType +\r
                                                                                '<html dir="' + config.contentsLangDirection + '">' +\r
+                                                                               '<title>' + frameLabel + '</title>' +\r
                                                                                '<head>' +\r
                                                                                        baseTag +\r
                                                                                        headExtra +\r
@@ -759,6 +732,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        editor.on( 'selectionChange', onSelectionChangeFixBody, null, null, 1 );\r
                                });\r
 \r
+                       var titleBackup;\r
+                       // Setting voice label as window title, backup the original one\r
+                       // and restore it before running into use.\r
+                       editor.on( 'contentDom', function ()\r
+                               {\r
+                                       var title = editor.document.getElementsByTag( 'title' ).getItem( 0 );\r
+                                       title.setAttribute( '_cke_title', editor.document.$.title );\r
+                                       editor.document.$.title = frameLabel;\r
+                               });\r
+\r
+\r
                        // Create an invisible element to grab focus.\r
                        if ( CKEDITOR.env.ie )\r
                        {\r
@@ -766,7 +750,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                editor.on( 'uiReady', function()\r
                                {\r
                                        ieFocusGrabber = editor.container.append( CKEDITOR.dom.element.createFromHtml(\r
-                                       '<input tabindex="-1" style="position:absolute; left:-10000">' ) );\r
+                                               // Use 'span' instead of anything else to fly under the screen-reader radar. (#5049)\r
+                                               '<span tabindex="-1" style="position:absolute; left:-10000" role="presentation"></span>' ) );\r
 \r
                                        ieFocusGrabber.on( 'focus', function()\r
                                                {\r