+\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.data( 'cke-title', editor.document.$.title );\r
+ editor.document.$.title = frameLabel;\r
+ });\r
+\r
+ // IE8 stricts mode doesn't have 'contentEditable' in effect\r
+ // on element unless it has layout. (#5562)\r
+ if ( CKEDITOR.env.ie8Compat )\r
+ {\r
+ editor.addCss( 'html.CSS1Compat [contenteditable=false]{ min-height:0 !important;}' );\r
+\r
+ var selectors = [];\r
+ for ( var tag in CKEDITOR.dtd.$removeEmpty )\r
+ selectors.push( 'html.CSS1Compat ' + tag + '[contenteditable=false]' );\r
+ editor.addCss( selectors.join( ',' ) + '{ display:inline-block;}' );\r
+ }\r
+ // Set the HTML style to 100% to have the text cursor in affect (#6341)\r
+ else if ( CKEDITOR.env.gecko )\r
+ editor.addCss( 'html { height: 100% !important; }' );\r
+\r
+ // Switch on design mode for a short while and close it after then.\r
+ function blinkCursor( retry )\r
+ {\r
+ CKEDITOR.tools.tryThese(\r
+ function()\r
+ {\r
+ editor.document.$.designMode = 'on';\r
+ setTimeout( function()\r
+ {\r
+ editor.document.$.designMode = 'off';\r
+ if ( CKEDITOR.currentInstance == editor )\r
+ editor.document.getBody().focus();\r
+ }, 50 );\r
+ },\r
+ function()\r
+ {\r
+ // The above call is known to fail when parent DOM\r
+ // tree layout changes may break design mode. (#5782)\r
+ // Refresh the 'contentEditable' is a cue to this.\r
+ editor.document.$.designMode = 'off';\r
+ var body = editor.document.getBody();\r
+ body.setAttribute( 'contentEditable', false );\r
+ body.setAttribute( 'contentEditable', true );\r
+ // Try it again once..\r
+ !retry && blinkCursor( 1 );\r
+ });\r
+ }\r
+\r
+ // Create an invisible element to grab focus.\r
+ if ( CKEDITOR.env.gecko || CKEDITOR.env.ie || CKEDITOR.env.opera )\r
+ {\r
+ var focusGrabber;\r
+ editor.on( 'uiReady', function()\r
+ {\r
+ focusGrabber = editor.container.append( CKEDITOR.dom.element.createFromHtml(\r
+ // Use 'span' instead of anything else to fly under the screen-reader radar. (#5049)\r
+ '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' ) );\r
+\r
+ focusGrabber.on( 'focus', function()\r
+ {\r
+ editor.focus();\r
+ } );\r
+\r
+ editor.focusGrabber = focusGrabber;\r
+ } );\r
+ editor.on( 'destroy', function()\r
+ {\r
+ CKEDITOR.tools.removeFunction( contentDomReadyHandler );\r
+ focusGrabber.clearCustomData();\r
+ delete editor.focusGrabber;\r
+ } );\r
+ }\r
+\r
+ // Disable form elements editing mode provided by some browers. (#5746)\r
+ editor.on( 'insertElement', function ( evt )\r
+ {\r
+ var element = evt.data;\r
+ if ( element.type == CKEDITOR.NODE_ELEMENT\r
+ && ( element.is( 'input' ) || element.is( 'textarea' ) ) )\r
+ {\r
+ // We should flag that the element was locked by our code so\r
+ // it'll be editable by the editor functions (#6046).\r
+ if ( !element.isReadOnly() )\r
+ element.data( 'cke-editable', element.hasAttribute( 'contenteditable' ) ? 'true' : '1' );\r
+ element.setAttribute( 'contentEditable', false );\r
+ }\r
+ });\r
+\r