Changeset 1066

Show
Ignore:
Timestamp:
2007-11-04 13:30:20 (2 years ago)
Author:
alfonsoml
Message:

Fix for #1500, the OnSelectionChange listeners did accumulate on each New Page call.

Location:
FCKeditor/trunk/editor/_source
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/_source/classes/fckevents.js

    r409 r1066  
    3535                this._RegisteredEvents[ eventName ] = [ functionPointer ] ; 
    3636        else 
    37                 aTargets.push( functionPointer ) ; 
     37        { 
     38                // Check that the event handler isn't already registered with the same listener 
     39                // It doesn't detect function pointers belonging to an object (at least in Gecko) 
     40                if ( aTargets.IndexOf( functionPointer ) == -1 ) 
     41                        aTargets.push( functionPointer ) ; 
     42        } 
    3843} 
    3944 
  • FCKeditor/trunk/editor/_source/internals/fck_gecko.js

    r925 r1066  
    197197        } 
    198198 
    199         this._FillEmptyBlock = function( emptyBlockNode ) 
    200         { 
    201                 if ( ! emptyBlockNode || emptyBlockNode.nodeType != 1 ) 
    202                         return ; 
    203                 var nodeTag = emptyBlockNode.tagName.toLowerCase() ; 
    204                 if ( nodeTag != 'p' && nodeTag != 'div' ) 
    205                         return ; 
    206                 if ( emptyBlockNode.firstChild ) 
    207                         return ; 
    208                 FCKTools.AppendBogusBr( emptyBlockNode ) ; 
    209         } 
    210  
    211         this._ExecCheckEmptyBlock = function() 
    212         { 
    213                 FCK._FillEmptyBlock( FCK.EditorDocument.body.firstChild ) ; 
    214                 var sel = FCK.EditorWindow.getSelection() ; 
    215                 if ( !sel || sel.rangeCount < 1 ) 
    216                         return ; 
    217                 var range = sel.getRangeAt( 0 ); 
    218                 FCK._FillEmptyBlock( range.startContainer ) ; 
    219         } 
    220  
    221199        this.ExecOnSelectionChangeTimer = function() 
    222200        { 
     
    286264                this.EditorDocument.addEventListener( 'click', this._ExecCheckCaret, false ) ; 
    287265        } 
    288         if ( FCKBrowserInfo.IsGecko ) 
    289                 this.AttachToOnSelectionChange( this._ExecCheckEmptyBlock ) ; 
    290266 
    291267        // Reset the context menu. 
     
    457433        return aCreatedLinks ; 
    458434} 
     435 
     436FCK._FillEmptyBlock = function( emptyBlockNode ) 
     437{ 
     438        if ( ! emptyBlockNode || emptyBlockNode.nodeType != 1 ) 
     439                return ; 
     440        var nodeTag = emptyBlockNode.tagName.toLowerCase() ; 
     441        if ( nodeTag != 'p' && nodeTag != 'div' ) 
     442                return ; 
     443        if ( emptyBlockNode.firstChild ) 
     444                return ; 
     445        FCKTools.AppendBogusBr( emptyBlockNode ) ; 
     446} 
     447 
     448FCK._ExecCheckEmptyBlock = function() 
     449{ 
     450        FCK._FillEmptyBlock( FCK.EditorDocument.body.firstChild ) ; 
     451        var sel = FCK.EditorWindow.getSelection() ; 
     452        if ( !sel || sel.rangeCount < 1 ) 
     453                return ; 
     454        var range = sel.getRangeAt( 0 ); 
     455        FCK._FillEmptyBlock( range.startContainer ) ; 
     456} 
  • FCKeditor/trunk/editor/_source/internals/fck.js

    r1062 r1066  
    105105                // Tab key handling for source mode. 
    106106                FCKTools.AddEventListener( document, "keydown", this._TabKeyHandler ) ; 
     107 
     108                // Add selection change listeners. They must be attached only once. 
     109                this.AttachToOnSelectionChange( _FCK_PaddingNodeListener ) ; 
     110                if ( FCKBrowserInfo.IsGecko ) 
     111                        this.AttachToOnSelectionChange( this._ExecCheckEmptyBlock ) ; 
     112 
    107113        }, 
    108114 
     
    811817 
    812818        FCK.InitializeBehaviors() ; 
    813         FCK.AttachToOnSelectionChange( _FCK_PaddingNodeListener ) ; 
    814819 
    815820        // Listen for mousedown and mouseup events for tracking drag and drops.