| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 /* 2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 CKEDITOR.dialog.add( 'paste', function( editor ) 7 { 8 var lang = editor.lang.clipboard; 9 var isCustomDomain = CKEDITOR.env.isCustomDomain(); 10 11 function onPasteFrameLoad( win ) 12 { 13 var doc = new CKEDITOR.dom.document( win.document ), 14 docElement = doc.$; 15 16 doc.getById( "cke_actscrpt" ).remove(); 17 18 CKEDITOR.env.ie ? 19 docElement.body.contentEditable = "true" : 20 docElement.designMode = "on"; 21 22 // IE before version 8 will leave cursor blinking inside the document after 23 // editor blurred unless we clean up the selection. (#4716) 24 if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 ) 25 { 26 doc.getWindow().on( 'blur', function() 27 { 28 docElement.selection.empty(); 29 } ); 30 } 31 32 doc.on( "keydown", function( e ) 33 { 34 var domEvent = e.data, 35 key = domEvent.getKeystroke(), 36 processed; 37 38 switch( key ) 39 { 40 case 27 : 41 this.hide(); 42 processed = 1; 43 break; 44 45 case 9 : 46 case CKEDITOR.SHIFT + 9 : 47 this.changeFocus( true ); 48 processed = 1; 49 } 50 51 processed && domEvent.preventDefault(); 52 }, this ); 53 54 editor.fire( 'ariaWidget', new CKEDITOR.dom.element( win.frameElement ) ); 55 } 56 57 return { 58 title : lang.title, 59 60 minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350, 61 minHeight : CKEDITOR.env.quirks ? 250 : 245, 62 onShow : function() 63 { 64 // FIREFOX BUG: Force the browser to render the dialog to make the to-be- 65 // inserted iframe editable. (#3366) 66 this.parts.dialog.$.offsetHeight; 67 68 var htmlToLoad = 69 '<html dir="' + editor.config.contentsLangDirection + '"' + 70 ' lang="' + ( editor.config.contentsLanguage || editor.langCode ) + '">' + 71 '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' + 72 '<script id="cke_actscrpt" type="text/javascript">' + 73 'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, this ) + ', this );' + 74 '</script></body>' + 75 '</html>'; 76 77 var iframe = CKEDITOR.dom.element.createFromHtml( 78 '<iframe' + 79 ' class="cke_pasteframe"' + 80 ' frameborder="0" ' + 81 ' allowTransparency="true"' + 82 // Support for custom document.domain in IE. 83 ( isCustomDomain ? 84 ' src="javascript:void((function(){' + 85 'document.open();' + 86 'document.domain=\'' + document.domain + '\';' + 87 'document.close();' + 88 '})())"' : '' ) + 89 ' role="region"' + 90 ' aria-label="' + lang.pasteArea + '"' + 91 ' aria-describedby="' + this.getContentElement( 'general', 'pasteMsg' ).domId + '"' + 92 ' aria-multiple="true"' + 93 '></iframe>' ); 94 95 iframe.on( 'load', function( e ) 96 { 97 e.removeListener(); 98 var doc = iframe.getFrameDocument().$; 99 // Custom domain handling is needed after each document.open(). 100 doc.open(); 101 if ( isCustomDomain ) 102 doc.domain = document.domain; 103 doc.write( htmlToLoad ); 104 doc.close(); 105 }, this ); 106 107 iframe.setCustomData( 'dialog', this ); 108 109 var field = this.getContentElement( 'general', 'editing_area' ), 110 container = field.getElement(); 111 container.setHtml( '' ); 112 container.append( iframe ); 113 114 // IE need a redirect on focus to make 115 // the cursor blinking inside iframe. (#5461) 116 if ( CKEDITOR.env.ie ) 117 { 118 var focusGrabber = CKEDITOR.dom.element.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' ); 119 focusGrabber.on( 'focus', function() 120 { 121 iframe.$.contentWindow.focus(); 122 }); 123 container.append( focusGrabber ); 124 125 // Override focus handler on field. 126 field.focus = function() 127 { 128 focusGrabber.focus(); 129 this.fire( 'focus' ); 130 }; 131 } 132 133 field.getInputElement = function(){ return iframe; }; 134 135 // Force container to scale in IE. 136 if ( CKEDITOR.env.ie ) 137 { 138 container.setStyle( 'display', 'block' ); 139 container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' ); 140 } 141 }, 142 143 onHide : function() 144 { 145 if ( CKEDITOR.env.ie ) 146 this.getParentEditor().document.getBody().$.contentEditable = 'true'; 147 }, 148 149 onLoad : function() 150 { 151 if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' ) 152 this.parts.contents.setStyle( 'overflow', 'hidden' ); 153 }, 154 155 onOk : function() 156 { 157 var container = this.getContentElement( 'general', 'editing_area' ).getElement(), 158 iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ), 159 editor = this.getParentEditor(), 160 html = iframe.$.contentWindow.document.body.innerHTML; 161 162 setTimeout( function(){ 163 editor.fire( 'paste', { 'html' : html } ); 164 }, 0 ); 165 166 }, 167 168 contents : [ 169 { 170 id : 'general', 171 label : editor.lang.common.generalTab, 172 elements : [ 173 { 174 type : 'html', 175 id : 'securityMsg', 176 html : '<div style="white-space:normal;width:340px;">' + lang.securityMsg + '</div>' 177 }, 178 { 179 type : 'html', 180 id : 'pasteMsg', 181 html : '<div style="white-space:normal;width:340px;">'+lang.pasteMsg +'</div>' 182 }, 183 { 184 type : 'html', 185 id : 'editing_area', 186 style : 'width: 100%; height: 100%;', 187 html : '', 188 focus : function() 189 { 190 var win = this.getInputElement().$.contentWindow; 191 192 // #3291 : JAWS needs the 500ms delay to detect that the editor iframe 193 // iframe is no longer editable. So that it will put the focus into the 194 // Paste from Word dialog's editable area instead. 195 setTimeout( function() 196 { 197 win.focus(); 198 }, 500 ); 199 } 200 } 201 ] 202 } 203 ] 204 }; 205 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |