Show
Ignore:
Timestamp:
2007-05-31 13:53:34 (20 months ago)
Author:
fredck
Message:

Fixed #220 : The creation of links or anchors in a selection that results on more than a single link created will not anymore leave temporary links in the source.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor/trunk/editor/dialog/fck_anchor.html

    r308 r341  
    111111 
    112112        // Create a new anchor preserving the current selection 
    113         oAnchor = oEditor.FCK.CreateLink( '#' ) ; 
    114         if ( !oAnchor ) 
     113        var aNewAnchors = oEditor.FCK.CreateLink( '#' ) ; 
     114 
     115        if ( aNewAnchors.length == 0 ) 
    115116        { 
    116117                // Nothing was selected, so now just create a normal A 
    117                 oAnchor = oEditor.FCK.InsertElement( 'a' ) ; 
     118                aNewAnchors.push( oEditor.FCK.InsertElement( 'a' ) ) ; 
    118119        } 
    119120        else 
    120121        { 
    121122                // Remove the fake href 
    122                 oAnchor.removeAttribute( 'href' ) ; 
    123         } 
    124         // Set the name 
    125         oAnchor.name = sNewName ; 
    126  
    127         // IE does require special processing to show the Anchor's image 
    128         // Opera doesn't allow to select empty anchors 
    129         if ( FCKBrowserInfo.IsIE || FCKBrowserInfo.IsOpera ) 
    130         { 
    131                 if ( oAnchor.innerHTML != '' ) 
     123                for ( var i = 0 ; i < aNewAnchors.length ; i++ ) 
     124                        aNewAnchors[i].removeAttribute( 'href' ) ; 
     125        } 
     126 
     127        // More than one anchors may have been created, so interact through all of them (see #220). 
     128        for ( var i = 0 ; i < aNewAnchors.length ; i++ ) 
     129        { 
     130                oAnchor = aNewAnchors[i] ; 
     131 
     132                // Set the name 
     133                oAnchor.name = sNewName ; 
     134 
     135                // IE does require special processing to show the Anchor's image 
     136                // Opera doesn't allow to select empty anchors 
     137                if ( FCKBrowserInfo.IsIE || FCKBrowserInfo.IsOpera ) 
    132138                { 
    133                         if ( FCKBrowserInfo.IsIE ) 
    134                                 oAnchor.className += ' FCK__AnchorC' ; 
     139                        if ( oAnchor.innerHTML != '' ) 
     140                        { 
     141                                if ( FCKBrowserInfo.IsIE ) 
     142                                        oAnchor.className += ' FCK__AnchorC' ; 
     143                        } 
     144                        else 
     145                        { 
     146                                // Create a fake image for both IE and Opera 
     147                                var oImg = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Anchor', oAnchor.cloneNode(true) ) ; 
     148                                oImg.setAttribute( '_fckanchor', 'true', 0 ) ; 
     149 
     150                                oAnchor.parentNode.insertBefore( oImg, oAnchor ) ; 
     151                                oAnchor.parentNode.removeChild( oAnchor ) ; 
     152                        } 
     153 
    135154                } 
    136                 else 
    137                 { 
    138                         // Create a fake image for both IE and Opera 
    139                         var oImg = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Anchor', oAnchor.cloneNode(true) ) ; 
    140                         oImg.setAttribute( '_fckanchor', 'true', 0 ) ; 
    141  
    142                         oAnchor.parentNode.insertBefore( oImg, oAnchor ) ; 
    143                         oAnchor.parentNode.removeChild( oAnchor ) ; 
    144                 } 
    145  
    146155        } 
    147156