Ticket #4555: 4555_3.patch
File 4555_3.patch, 13.3 KB (added by , 15 years ago) |
---|
-
_source/core/dom/domobject.js
115 115 delete nativeListeners[ eventName ]; 116 116 } 117 117 } 118 }, 119 120 /** @ignore */ 121 removeAllListeners : function() 122 { 123 // Call the original implementation. 124 CKEDITOR.event.prototype.removeAllListeners.apply( this ); 125 126 var nativeListeners = this.getCustomData( '_cke_nativeListeners' ); 127 for( eventName in nativeListeners) 128 { 129 var listener = nativeListeners[ eventName ]; 130 if ( this.$.removeEventListener ) 131 this.$.removeEventListener( eventName, listener, false ); 132 else if ( this.$.detachEvent ) 133 this.$.detachEvent( 'on' + eventName, listener ); 134 135 delete nativeListeners[ eventName ]; 136 } 118 137 } 119 138 }; 120 139 })(); … … 197 216 }; 198 217 199 218 /** 219 * @name CKEDITOR.dom.domObject.prototype.clearCustomData 220 */ 221 domObjectProto.clearCustomData = function() 222 { 223 // Clear all event listeners 224 this.removeAllListeners(); 225 226 var expandoNumber = this.$._cke_expando; 227 expandoNumber && delete customData[ expandoNumber ]; 228 }; 229 230 /** 200 231 * @name CKEDITOR.dom.domObject.prototype.getCustomData 201 232 */ 202 233 domObjectProto.getUniqueId = function() -
_source/core/editor.js
468 468 if ( !noUpdate ) 469 469 this.updateElement(); 470 470 471 if ( this.mode ) 472 { 473 var holderElement = this.getThemeSpace( 'contents' ), 474 currentMode = this._.modes[ editor.mode ]; 475 currentMode.unload( holderElement ); 476 } 477 471 478 this.theme.destroy( this ); 472 this.fire( 'destroy' ); 479 delete this.focusManager._.editor; 480 delete this.ui._.editor; 481 482 if (this.toolbox) 483 { 484 var toolbars = this.toolbox.toolbars; 485 for( var index = 0; index < toolbars.length ; index++ ) 486 { 487 var items = toolbars[ index ].items; 488 for ( j = 0; j<items.length ; j++) 489 { 490 var instance = items[ j ]; 491 if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn ); 492 if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null; 493 delete instance.editor; 494 delete instance.execute; 495 delete instance.toolbar; 496 delete instance.button; 497 } 498 toolbars[ index ] = null; 499 } 500 } 501 502 var commands = this._.commands; 503 for (var command in commands) 504 { 505 var o = commands[ command ]; 506 o.removeAllListeners(); 507 508 delete commands[ command ]; 509 } 510 511 delete this._.styleStateChangeCallbacks 512 513 if (this.contextMenu) 514 { 515 CKEDITOR.tools.removeFunction( this.contextMenu._.functionId ); 516 delete this.contextMenu.editor; 517 delete this._.menuItems; 518 } 519 if (this._.filebrowserFn) 520 { 521 CKEDITOR.tools.removeFunction( this._.filebrowserFn ); 522 } 523 524 this.fireOnce( 'destroy' ); 525 this.removeAllListeners(); 526 473 527 CKEDITOR.remove( this ); 474 528 CKEDITOR.fire( 'instanceDestroyed', null, this ); 475 529 }, -
_source/core/event.js
314 314 var index = event.getListenerIndex( listenerFunction ); 315 315 if ( index >= 0 ) 316 316 event.listeners.splice( index, 1 ); 317 318 // Clear the event if there are no more listeners 319 if (event.listeners.length==0) 320 delete getPrivate( this )[ eventName ] 317 321 } 318 322 }, 319 323 320 324 /** 325 * Removes any listener set on this object. 326 * To avoid memory leaks we must assure that there are no 327 * references left after the object is no longer needed. 328 */ 329 removeAllListeners : function() 330 { 331 var events = getPrivate( this ); 332 for(e in events) 333 { 334 delete events[ e ]; 335 } 336 }, 337 /** 321 338 * Checks if there is any listener registered to a given event. 322 339 * @param {String} eventName The event name. 323 340 * @example -
_source/plugins/button/plugin.js
69 69 */ 70 70 render : function( editor, output ) 71 71 { 72 var env = CKEDITOR.env; 72 var env = CKEDITOR.env, 73 id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber(), 74 classes = '', 75 command = this.command, // Get the command name. 76 clickFn, 77 index; 73 78 74 var id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber();75 79 this._.editor = editor; 76 80 77 81 var instance = … … 90 94 } 91 95 }; 92 96 93 varclickFn = CKEDITOR.tools.addFunction( instance.execute, instance );97 instance.clickFn = clickFn = CKEDITOR.tools.addFunction( instance.execute, instance ); 94 98 95 varindex = CKEDITOR.ui.button._.instances.push( instance ) - 1;99 instance.index = index = CKEDITOR.ui.button._.instances.push( instance ) - 1; 96 100 97 var classes = '';98 99 // Get the command name.100 var command = this.command;101 102 101 if ( this.modes ) 103 102 { 104 103 editor.on( 'mode', function() … … 134 133 output.push( 135 134 '<span class="cke_button">', 136 135 '<a id="', id, '"' + 137 ' class="', classes, '"', 136 ' class="', classes, '"', 138 137 env.gecko && env.version >= 10900 && !env.hc ? '' : '" href="javascript:void(\''+ ( this.title || '' ).replace( "'"+ '' )+ '\')"', 139 138 ' title="', this.title, '"' + 140 139 ' tabindex="-1"' + -
_source/plugins/filebrowser/plugin.js
378 378 init : function( editor, pluginPath ) 379 379 { 380 380 editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor ); 381 } 382 } ); 381 383 382 CKEDITOR.on( 'dialogDefinition', function( evt ) 384 CKEDITOR.on( 'dialogDefinition', function( evt ) 385 { 386 var definition = evt.data.definition, 387 element; 388 // Associate filebrowser to elements with 'filebrowser' attribute. 389 for ( var i in definition.contents ) 390 { 391 element = definition.contents[ i ] ; 392 attachFileBrowser( evt.editor, evt.data.name, definition, element.elements ); 393 if ( element.hidden && element.filebrowser ) 383 394 { 384 var definition = evt.data.definition, 385 element; 386 // Associate filebrowser to elements with 'filebrowser' attribute. 387 for ( var i in definition.contents ) 388 { 389 element = definition.contents[ i ] ; 390 attachFileBrowser( evt.editor, evt.data.name, definition, element.elements ); 391 if ( element.hidden && element.filebrowser ) 392 { 393 element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser ); 394 } 395 } 396 } ); 395 element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser ); 396 } 397 397 } 398 398 } ); 399 399 -
_source/plugins/resize/plugin.js
55 55 } 56 56 } ); 57 57 58 editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ) } ); 59 58 60 editor.on( 'themeSpace', function( event ) 59 61 { 60 62 if ( event.data.space == 'bottom' ) -
_source/plugins/richcombo/plugin.js
161 161 ev.preventDefault(); 162 162 }); 163 163 164 editor.on('destroy', function() { 165 CKEDITOR.tools.removeFunction( clickFn ); 166 CKEDITOR.tools.removeFunction( keyDownFn ); 167 }); 168 164 169 output.push( 165 170 '<span class="cke_rcombo">', 166 171 '<span id=', id ); … … 213 218 { 214 219 if ( this._.panel ) 215 220 return; 216 221 217 222 var panelDefinition = this._.panelDefinition, 218 223 panelBlockDefinition = this._.panelDefinition.block, 219 224 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(), -
_source/plugins/showborders/plugin.js
130 130 } ); 131 131 } 132 132 133 // Table dialog must be aware of it. 134 CKEDITOR.on( 'dialogDefinition', function( ev ) 133 var onDialogDefinition = function( ev ) 134 { 135 if ( ev.editor != editor ) 136 return; 137 138 var dialogName = ev.data.name; 139 140 if ( dialogName == 'table' || dialogName == 'tableProperties' ) 135 141 { 136 if ( ev.editor != editor ) 137 return; 142 var dialogDefinition = ev.data.definition, 143 infoTab = dialogDefinition.getContents( 'info' ), 144 borderField = infoTab.get( 'txtBorder' ), 145 originalCommit = borderField.commit; 138 146 139 var dialogName = ev.data.name; 140 141 if ( dialogName == 'table' || dialogName == 'tableProperties' ) 147 borderField.commit = CKEDITOR.tools.override( originalCommit, function( org ) 142 148 { 143 var dialogDefinition = ev.data.definition, 144 infoTab = dialogDefinition.getContents( 'info' ), 145 borderField = infoTab.get( 'txtBorder' ), 146 originalCommit = borderField.commit; 149 return function( data, selectedTable ) 150 { 151 org.apply( this, arguments ); 152 var value = parseInt( this.getValue(), 10 ); 153 selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName ); 154 }; 155 } ); 156 } 157 }; 147 158 148 borderField.commit = CKEDITOR.tools.override( originalCommit, function( org ) 149 { 150 return function( data, selectedTable ) 151 { 152 org.apply( this, arguments ); 153 var value = parseInt( this.getValue(), 10 ); 154 selectedTable[ ( !value || value <= 0 ) ? 'addClass' : 'removeClass' ]( showBorderClassName ); 155 }; 156 } ); 157 } 158 }); 159 // Table dialog must be aware of it. 160 CKEDITOR.on( 'dialogDefinition', onDialogDefinition); 161 editor.on( 'destroy', function() { CKEDITOR.removeListener( 'dialogDefinition', onDialogDefinition ) } ); 159 162 } 160 163 161 164 }); -
_source/plugins/sourcearea/plugin.js
138 138 139 139 unload : function( holderElement ) 140 140 { 141 textarea.clearCustomData(); 141 142 editor.textarea = textarea = null; 142 143 143 144 if ( onResize ) -
_source/plugins/toolbar/plugin.js
284 284 editor.execCommand( 'toolbarCollapse' ); 285 285 } ); 286 286 287 editor.on( 'destroy', function () { 288 CKEDITOR.tools.removeFunction( collapserFn ); 289 } ); 290 287 291 var collapserId = 'cke_' + CKEDITOR.tools.getNextNumber(); 288 292 289 293 editor.addCommand( 'toolbarCollapse', -
_source/plugins/wysiwygarea/plugin.js
263 263 iframe.remove(); 264 264 265 265 frameLoaded = 0; 266 266 267 267 var setDataFn = !CKEDITOR.env.gecko && CKEDITOR.tools.addFunction( function( doc ) 268 268 { 269 269 CKEDITOR.tools.removeFunction( setDataFn ); … … 690 690 691 691 unload : function( holderElement ) 692 692 { 693 editor.document.getDocumentElement().clearCustomData(); 694 editor.document.getBody().clearCustomData(); 695 696 editor.window.clearCustomData(); 697 editor.document.clearCustomData(); 698 693 699 editor.window = editor.document = iframe = mainElement = isPendingFocus = null; 694 700 695 701 editor.fire( 'contentDomUnload' ); … … 758 764 editor.focus(); 759 765 } ); 760 766 } ); 767 editor.on( 'destroy', function() 768 { 769 ieFocusGrabber.clearCustomData(); 770 ieFocusGrabber.remove() 771 ieFocusGrabber = null; 772 } ); 761 773 } 762 774 } 763 775 }); -
_source/themes/default/theme.js
229 229 destroy : function( editor ) 230 230 { 231 231 var container = editor.container; 232 container.clearCustomData(); 233 editor.element.clearCustomData(); 232 234 233 235 /* 234 236 * IE BUG: Removing the editor DOM elements while the selection is inside … … 254 256 255 257 if ( container ) 256 258 container.remove(); 259 delete editor.container; 257 260 258 261 if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) 259 {260 262 editor.element.show(); 261 delete editor.element; 262 }263 264 delete editor.element; 263 265 } 264 266 }; 265 267 })() );