| [ 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.themes.add( 'default', (function() 7 { 8 function checkSharedSpace( editor, spaceName ) 9 { 10 var container, 11 element; 12 13 // Try to retrieve the target element from the sharedSpaces settings. 14 element = editor.config.sharedSpaces; 15 element = element && element[ spaceName ]; 16 element = element && CKEDITOR.document.getById( element ); 17 18 // If the element is available, we'll then create the container for 19 // the space. 20 if ( element ) 21 { 22 // Creates an HTML structure that reproduces the editor class hierarchy. 23 var html = 24 '<span class="cke_shared">' + 25 '<span class="' + editor.skinClass + ' cke_editor_' + editor.name + '">' + 26 '<span class="' + CKEDITOR.env.cssClass + '">' + 27 '<span class="cke_wrapper cke_' + editor.lang.dir + '">' + 28 '<span class="cke_editor">' + 29 '<div class="cke_' + spaceName + '">' + 30 '</div></span></span></span></span></span>'; 31 32 var mainContainer = element.append( CKEDITOR.dom.element.createFromHtml( html, element.getDocument() ) ); 33 34 // Only the first container starts visible. Others get hidden. 35 if ( element.getCustomData( 'cke_hasshared' ) ) 36 mainContainer.hide(); 37 else 38 element.setCustomData( 'cke_hasshared', 1 ); 39 40 // Get the deeper inner <div>. 41 container = mainContainer.getChild( [0,0,0,0] ); 42 43 // When the editor gets focus, we show the space container, hiding others. 44 editor.on( 'focus', function() 45 { 46 for ( var i = 0, sibling, children = element.getChildren() ; ( sibling = children.getItem( i ) ) ; i++ ) 47 { 48 if ( sibling.type == CKEDITOR.NODE_ELEMENT 49 && !sibling.equals( mainContainer ) 50 && sibling.hasClass( 'cke_shared' ) ) 51 { 52 sibling.hide(); 53 } 54 } 55 56 mainContainer.show(); 57 }); 58 59 editor.on( 'destroy', function() 60 { 61 mainContainer.remove(); 62 }); 63 } 64 65 return container; 66 } 67 68 return { 69 build : function( editor, themePath ) 70 { 71 var name = editor.name, 72 element = editor.element, 73 elementMode = editor.elementMode; 74 75 if ( !element || elementMode == CKEDITOR.ELEMENT_MODE_NONE ) 76 return; 77 78 if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) 79 element.hide(); 80 81 // Get the HTML for the predefined spaces. 82 var topHtml = editor.fire( 'themeSpace', { space : 'top', html : '' } ).html; 83 var contentsHtml = editor.fire( 'themeSpace', { space : 'contents', html : '' } ).html; 84 var bottomHtml = editor.fireOnce( 'themeSpace', { space : 'bottom', html : '' } ).html; 85 86 var height = contentsHtml && editor.config.height; 87 88 var tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0; 89 90 // The editor height is considered only if the contents space got filled. 91 if ( !contentsHtml ) 92 height = 'auto'; 93 else if ( !isNaN( height ) ) 94 height += 'px'; 95 96 var style = ''; 97 var width = editor.config.width; 98 99 if ( width ) 100 { 101 if ( !isNaN( width ) ) 102 width += 'px'; 103 104 style += "width: " + width + ";"; 105 } 106 107 var sharedTop = topHtml && checkSharedSpace( editor, 'top' ), 108 sharedBottoms = checkSharedSpace( editor, 'bottom' ); 109 110 sharedTop && ( sharedTop.setHtml( topHtml ) , topHtml = '' ); 111 sharedBottoms && ( sharedBottoms.setHtml( bottomHtml ), bottomHtml = '' ); 112 113 var container = CKEDITOR.dom.element.createFromHtml( [ 114 '<span' + 115 ' id="cke_', name, '"' + 116 ' onmousedown="return false;"' + 117 ' class="', editor.skinClass, ' cke_editor_', name, '"' + 118 ' dir="', editor.lang.dir, '"' + 119 ' title="', ( CKEDITOR.env.gecko ? ' ' : '' ), '"' + 120 ' lang="', editor.langCode, '"' + 121 ( CKEDITOR.env.webkit? ' tabindex="' + tabIndex + '"' : '' ) + 122 ' role="application"' + 123 ' aria-labelledby="cke_', name, '_arialbl"' + 124 ( style ? ' style="' + style + '"' : '' ) + 125 '>' + 126 '<span id="cke_', name, '_arialbl" class="cke_voice_label">' + editor.lang.editor + '</span>' + 127 '<span class="' , CKEDITOR.env.cssClass, '" role="presentation">' + 128 '<span class="cke_wrapper cke_', editor.lang.dir, '" role="presentation">' + 129 '<table class="cke_editor" border="0" cellspacing="0" cellpadding="0" role="presentation"><tbody>' + 130 '<tr', topHtml ? '' : ' style="display:none"', ' role="presentation"><td id="cke_top_' , name, '" class="cke_top" role="presentation">' , topHtml , '</td></tr>' + 131 '<tr', contentsHtml ? '' : ' style="display:none"', ' role="presentation"><td id="cke_contents_', name, '" class="cke_contents" style="height:', height, '" role="presentation">', contentsHtml, '</td></tr>' + 132 '<tr', bottomHtml ? '' : ' style="display:none"', ' role="presentation"><td id="cke_bottom_' , name, '" class="cke_bottom" role="presentation">' , bottomHtml , '</td></tr>' + 133 '</tbody></table>' + 134 //Hide the container when loading skins, later restored by skin css. 135 '<style>.', editor.skinClass, '{visibility:hidden;}</style>' + 136 '</span>' + 137 '</span>' + 138 '</span>' ].join( '' ) ); 139 140 container.getChild( [1, 0, 0, 0, 0] ).unselectable(); 141 container.getChild( [1, 0, 0, 0, 2] ).unselectable(); 142 143 if ( elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) 144 container.insertAfter( element ); 145 else 146 element.append( container ); 147 148 /** 149 * The DOM element that holds the main editor interface. 150 * @name CKEDITOR.editor.prototype.container 151 * @type CKEDITOR.dom.element 152 * @example 153 * var editor = CKEDITOR.instances.editor1; 154 * alert( <b>editor.container</b>.getName() ); "span" 155 */ 156 editor.container = container; 157 158 // Disable browser context menu for editor's chrome. 159 container.disableContextMenu(); 160 161 editor.fireOnce( 'themeLoaded' ); 162 editor.fireOnce( 'uiReady' ); 163 }, 164 165 buildDialog : function( editor ) 166 { 167 var baseIdNumber = CKEDITOR.tools.getNextNumber(); 168 169 var element = CKEDITOR.dom.element.createFromHtml( [ 170 '<div class="cke_editor_' + editor.name.replace('.', '\\.') + '_dialog cke_skin_', editor.skinName, 171 '" dir="', editor.lang.dir, '"' + 172 ' lang="', editor.langCode, '"' + 173 ' role="dialog"' + 174 ' aria-labelledby="%title#"' + 175 '>' + 176 '<table class="cke_dialog', ' ' + CKEDITOR.env.cssClass, 177 ' cke_', editor.lang.dir, '" style="position:absolute" role="presentation">' + 178 '<tr><td role="presentation">' + 179 '<div class="%body" role="presentation">' + 180 '<div id="%title#" class="%title" role="presentation"></div>' + 181 '<a id="%close_button#" class="%close_button" href="javascript:void(0)" title="' + editor.lang.common.close+'" role="button"><span class="cke_label">X</span></a>' + 182 '<div id="%tabs#" class="%tabs" role="tablist"></div>' + 183 '<table class="%contents" role="presentation"><tr>' + 184 '<td id="%contents#" class="%contents" role="presentation"></td>' + 185 '</tr></table>' + 186 '<div id="%footer#" class="%footer" role="presentation"></div>' + 187 '</div>' + 188 '<div id="%tl#" class="%tl"></div>' + 189 '<div id="%tc#" class="%tc"></div>' + 190 '<div id="%tr#" class="%tr"></div>' + 191 '<div id="%ml#" class="%ml"></div>' + 192 '<div id="%mr#" class="%mr"></div>' + 193 '<div id="%bl#" class="%bl"></div>' + 194 '<div id="%bc#" class="%bc"></div>' + 195 '<div id="%br#" class="%br"></div>' + 196 '</td></tr>' + 197 '</table>', 198 199 //Hide the container when loading skins, later restored by skin css. 200 ( CKEDITOR.env.ie ? '' : '<style>.cke_dialog{visibility:hidden;}</style>' ), 201 202 '</div>' 203 ].join( '' ) 204 .replace( /#/g, '_' + baseIdNumber ) 205 .replace( /%/g, 'cke_dialog_' ) ); 206 207 var body = element.getChild( [ 0, 0, 0, 0, 0 ] ), 208 title = body.getChild( 0 ), 209 close = body.getChild( 1 ); 210 211 // Make the Title and Close Button unselectable. 212 title.unselectable(); 213 close.unselectable(); 214 215 216 return { 217 element : element, 218 parts : 219 { 220 dialog : element.getChild( 0 ), 221 title : title, 222 close : close, 223 tabs : body.getChild( 2 ), 224 contents : body.getChild( [ 3, 0, 0, 0 ] ), 225 footer : body.getChild( 4 ) 226 } 227 }; 228 }, 229 230 destroy : function( editor ) 231 { 232 var container = editor.container; 233 container.clearCustomData(); 234 editor.element.clearCustomData(); 235 236 if ( container ) 237 container.remove(); 238 239 if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) 240 editor.element.show(); 241 242 delete editor.element; 243 } 244 }; 245 })() ); 246 247 /** 248 * Returns the DOM element that represents a theme space. The default theme defines 249 * three spaces, namely "top", "contents" and "bottom", representing the main 250 * blocks that compose the editor interface. 251 * @param {String} spaceName The space name. 252 * @returns {CKEDITOR.dom.element} The element that represents the space. 253 * @example 254 * // Hide the bottom space in the UI. 255 * var bottom = editor.getThemeSpace( 'bottom' ); 256 * bottom.setStyle( 'display', 'none' ); 257 */ 258 CKEDITOR.editor.prototype.getThemeSpace = function( spaceName ) 259 { 260 var spacePrefix = 'cke_' + spaceName; 261 var space = this._[ spacePrefix ] || 262 ( this._[ spacePrefix ] = CKEDITOR.document.getById( spacePrefix + '_' + this.name ) ); 263 return space; 264 }; 265 266 /** 267 * Resizes the editor interface. 268 * @param {Number|String} width The new width. It can be an pixels integer or a 269 * CSS size value. 270 * @param {Number|String} height The new height. It can be an pixels integer or 271 * a CSS size value. 272 * @param {Boolean} [isContentHeight] Indicates that the provided height is to 273 * be applied to the editor contents space, not to the entire editor 274 * interface. Defaults to false. 275 * @param {Boolean} [resizeInner] Indicates that the first inner interface 276 * element must receive the size, not the outer element. The default theme 277 * defines the interface inside a pair of span elements 278 * (<span><span>...</span></span>). By default the 279 * first span element receives the sizes. If this parameter is set to 280 * true, the second span is sized instead. 281 * @example 282 * editor.resize( 900, 300 ); 283 * @example 284 * editor.resize( '100%', 450, true ); 285 */ 286 CKEDITOR.editor.prototype.resize = function( width, height, isContentHeight, resizeInner ) 287 { 288 var numberRegex = /^\d+$/; 289 if ( numberRegex.test( width ) ) 290 width += 'px'; 291 292 var container = this.container, 293 contents = CKEDITOR.document.getById( 'cke_contents_' + this.name ), 294 outer = resizeInner ? container.getChild( 1 ) : container; 295 296 // Resize the width first. 297 // WEBKIT BUG: Webkit requires that we put the editor off from display when we 298 // resize it. If we don't, the browser crashes! 299 CKEDITOR.env.webkit && outer.setStyle( 'display', 'none' ); 300 outer.setStyle( 'width', width ); 301 if ( CKEDITOR.env.webkit ) 302 { 303 outer.$.offsetWidth; 304 outer.setStyle( 'display', '' ); 305 } 306 307 // Get the height delta between the outer table and the content area. 308 // If we're setting the content area's height, then we don't need the delta. 309 var delta = isContentHeight ? 0 : ( outer.$.offsetHeight || 0 ) - ( contents.$.clientHeight || 0 ); 310 contents.setStyle( 'height', Math.max( height - delta, 0 ) + 'px' ); 311 312 // Emit a resize event. 313 this.fire( 'resize' ); 314 }; 315 316 /** 317 * Gets the element that can be freely used to check the editor size. This method 318 * is mainly used by the resize plugin, which adds a UI handle that can be used 319 * to resize the editor. 320 * @returns {CKEDITOR.dom.element} The resizable element. 321 * @example 322 */ 323 CKEDITOR.editor.prototype.getResizable = function() 324 { 325 return this.container.getChild( 1 ); 326 }; 327 328 /** 329 * Makes it possible to place some of the editor UI blocks, like the toolbar 330 * and the elements path, into any element in the page. 331 * The elements used to hold the UI blocks can be shared among several editor 332 * instances. In that case, only the blocks of the active editor instance will 333 * display. 334 * @name CKEDITOR.config.sharedSpaces 335 * @type Object 336 * @default undefined 337 * @example 338 * // Place the toolbar inside the element with ID "someElementId" and the 339 * // elements path into the element with ID "anotherId". 340 * config.sharedSpaces = 341 * { 342 * top : 'someElementId', 343 * bottom : 'anotherId' 344 * }; 345 * @example 346 * // Place the toolbar inside the element with ID "someElementId". The 347 * // elements path will remain attached to the editor UI. 348 * config.sharedSpaces = 349 * { 350 * top : 'someElementId' 351 * }; 352 */ 353 354 /** 355 * Fired after the editor instance is resized through 356 * the {@link CKEDITOR.editor.prototype.resize} method. 357 * @name CKEDITOR#resize 358 * @event 359 */
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 |