[1575] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
|
---|
| 2 | <!--
|
---|
| 3 | * FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
---|
| 4 | * Copyright (C) 2003-2009 Frederico Caldeira Knabben
|
---|
| 5 | *
|
---|
| 6 | * == BEGIN LICENSE ==
|
---|
| 7 | *
|
---|
| 8 | * Licensed under the terms of any of the following licenses at your
|
---|
| 9 | * choice:
|
---|
| 10 | *
|
---|
| 11 | * - GNU General Public License Version 2 or later (the "GPL")
|
---|
| 12 | * http://www.gnu.org/licenses/gpl.html
|
---|
| 13 | *
|
---|
| 14 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
---|
| 15 | * http://www.gnu.org/licenses/lgpl.html
|
---|
| 16 | *
|
---|
| 17 | * - Mozilla Public License Version 1.1 or later (the "MPL")
|
---|
| 18 | * http://www.mozilla.org/MPL/MPL-1.1.html
|
---|
| 19 | *
|
---|
| 20 | * == END LICENSE ==
|
---|
| 21 | *
|
---|
| 22 | * Anchor dialog window.
|
---|
| 23 | -->
|
---|
| 24 | <html>
|
---|
| 25 | <head>
|
---|
| 26 | <title>Anchor Properties</title>
|
---|
| 27 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
---|
| 28 | <meta content="noindex, nofollow" name="robots">
|
---|
| 29 | <script src="common/fck_dialog_common.js" type="text/javascript"></script>
|
---|
| 30 | <script type="text/javascript">
|
---|
| 31 |
|
---|
| 32 | var dialog = window.parent ;
|
---|
| 33 | var oEditor = dialog.InnerDialogLoaded() ;
|
---|
| 34 |
|
---|
| 35 | var FCK = oEditor.FCK ;
|
---|
| 36 | var FCKBrowserInfo = oEditor.FCKBrowserInfo ;
|
---|
| 37 | var FCKTools = oEditor.FCKTools ;
|
---|
| 38 | var FCKRegexLib = oEditor.FCKRegexLib ;
|
---|
| 39 |
|
---|
| 40 | var oDOM = FCK.EditorDocument ;
|
---|
| 41 |
|
---|
| 42 | var oFakeImage = dialog.Selection.GetSelectedElement() ;
|
---|
| 43 |
|
---|
| 44 | var oAnchor ;
|
---|
| 45 |
|
---|
| 46 | if ( oFakeImage )
|
---|
| 47 | {
|
---|
| 48 | if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckanchor') )
|
---|
| 49 | oAnchor = FCK.GetRealElement( oFakeImage ) ;
|
---|
| 50 | else
|
---|
| 51 | oFakeImage = null ;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | //Search for a real anchor
|
---|
| 55 | if ( !oFakeImage )
|
---|
| 56 | {
|
---|
| 57 | oAnchor = FCK.Selection.MoveToAncestorNode( 'A' ) ;
|
---|
| 58 | if ( oAnchor )
|
---|
| 59 | FCK.Selection.SelectNode( oAnchor ) ;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | window.onload = function()
|
---|
| 63 | {
|
---|
| 64 | // First of all, translate the dialog box texts
|
---|
| 65 | oEditor.FCKLanguageManager.TranslatePage(document) ;
|
---|
| 66 |
|
---|
| 67 | if ( oAnchor )
|
---|
| 68 | GetE('txtName').value = oAnchor.name ;
|
---|
| 69 | else
|
---|
| 70 | oAnchor = null ;
|
---|
| 71 |
|
---|
| 72 | window.parent.SetOkButton( true ) ;
|
---|
| 73 | window.parent.SetAutoSize( true ) ;
|
---|
| 74 |
|
---|
| 75 | SelectField( 'txtName' ) ;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | function Ok()
|
---|
| 79 | {
|
---|
| 80 | var sNewName = GetE('txtName').value ;
|
---|
| 81 |
|
---|
| 82 | // Remove any illegal character in a name attribute:
|
---|
| 83 | // A name should start with a letter, but the validator passes anyway.
|
---|
| 84 | sNewName = sNewName.replace( /[^\w-_\.:]/g, '_' ) ;
|
---|
| 85 |
|
---|
| 86 | if ( sNewName.length == 0 )
|
---|
| 87 | {
|
---|
| 88 | // Remove the anchor if the user leaves the name blank
|
---|
| 89 | if ( oAnchor )
|
---|
| 90 | {
|
---|
| 91 | // Removes the current anchor from the document using the new command
|
---|
| 92 | FCK.Commands.GetCommand( 'AnchorDelete' ).Execute() ;
|
---|
| 93 | return true ;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | alert( oEditor.FCKLang.DlgAnchorErrorName ) ;
|
---|
| 97 | return false ;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | oEditor.FCKUndo.SaveUndoStep() ;
|
---|
| 101 |
|
---|
| 102 | if ( oAnchor ) // Modifying an existent anchor.
|
---|
| 103 | {
|
---|
| 104 | ReadjustLinksToAnchor( oAnchor.name, sNewName );
|
---|
| 105 |
|
---|
| 106 | // Buggy explorer, bad bad browser. http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/
|
---|
| 107 | // Instead of just replacing the .name for the existing anchor (in order to preserve the content), we must remove the .name
|
---|
| 108 | // and assign .name, although it won't appear until it's specially processed in fckxhtml.js
|
---|
| 109 |
|
---|
| 110 | // We remove the previous name
|
---|
| 111 | oAnchor.removeAttribute( 'name' ) ;
|
---|
| 112 | // Now we set it, but later we must process it specially
|
---|
| 113 | oAnchor.name = sNewName ;
|
---|
| 114 |
|
---|
| 115 | return true ;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | // Create a new anchor preserving the current selection
|
---|
| 119 | var aNewAnchors = oEditor.FCK.CreateLink( '#' ) ;
|
---|
| 120 |
|
---|
| 121 | if ( aNewAnchors.length == 0 )
|
---|
| 122 | aNewAnchors.push( oEditor.FCK.InsertElement( 'a' ) ) ;
|
---|
| 123 | else
|
---|
| 124 | {
|
---|
| 125 | // Remove the fake href
|
---|
| 126 | for ( var i = 0 ; i < aNewAnchors.length ; i++ )
|
---|
| 127 | aNewAnchors[i].removeAttribute( 'href' ) ;
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | // More than one anchors may have been created, so interact through all of them (see #220).
|
---|
| 131 | for ( var i = 0 ; i < aNewAnchors.length ; i++ )
|
---|
| 132 | {
|
---|
| 133 | oAnchor = aNewAnchors[i] ;
|
---|
| 134 |
|
---|
| 135 | // Set the name
|
---|
| 136 | if ( FCKBrowserInfo.IsIE )
|
---|
| 137 | {
|
---|
| 138 | // Setting anchor names directly in IE will trash the HTML code stored
|
---|
| 139 | // in FCKTempBin after undos. See #2263.
|
---|
| 140 | var replaceAnchor = oEditor.FCK.EditorDocument.createElement( '<a name="' +
|
---|
| 141 | FCKTools.HTMLEncode( sNewName ).replace( '"', '"' ) + '">' ) ;
|
---|
| 142 | oEditor.FCKDomTools.MoveChildren( oAnchor, replaceAnchor ) ;
|
---|
| 143 | oAnchor.parentNode.replaceChild( replaceAnchor, oAnchor ) ;
|
---|
| 144 | oAnchor = replaceAnchor ;
|
---|
| 145 | }
|
---|
| 146 | else
|
---|
| 147 | oAnchor.name = sNewName ;
|
---|
| 148 |
|
---|
| 149 | // IE does require special processing to show the Anchor's image
|
---|
| 150 | // Opera doesn't allow to select empty anchors
|
---|
| 151 | if ( FCKBrowserInfo.IsIE || FCKBrowserInfo.IsOpera )
|
---|
| 152 | {
|
---|
| 153 | if ( oAnchor.innerHTML != '' )
|
---|
| 154 | {
|
---|
| 155 | if ( FCKBrowserInfo.IsIE )
|
---|
| 156 | oAnchor.className += ' FCK__AnchorC' ;
|
---|
| 157 | }
|
---|
| 158 | else
|
---|
| 159 | {
|
---|
| 160 | // Create a fake image for both IE and Opera
|
---|
| 161 | var oImg = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Anchor', oAnchor.cloneNode(true) ) ;
|
---|
| 162 | oImg.setAttribute( '_fckanchor', 'true', 0 ) ;
|
---|
| 163 |
|
---|
| 164 | oAnchor.parentNode.insertBefore( oImg, oAnchor ) ;
|
---|
| 165 | oAnchor.parentNode.removeChild( oAnchor ) ;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | return true ;
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | // Checks all the links in the current page pointing to the current name and changes them to the new name
|
---|
| 175 | function ReadjustLinksToAnchor( sCurrent, sNew )
|
---|
| 176 | {
|
---|
| 177 | var oDoc = FCK.EditorDocument ;
|
---|
| 178 |
|
---|
| 179 | var aLinks = oDoc.getElementsByTagName( 'A' ) ;
|
---|
| 180 |
|
---|
| 181 | var sReference = '#' + sCurrent ;
|
---|
| 182 | // The url of the document, so we check absolute and partial references.
|
---|
| 183 | var sFullReference = oDoc.location.href.replace( /(#.*$)/, '') ;
|
---|
| 184 | sFullReference += sReference ;
|
---|
| 185 |
|
---|
| 186 | var oLink ;
|
---|
| 187 | var i = aLinks.length - 1 ;
|
---|
| 188 | while ( i >= 0 && ( oLink = aLinks[i--] ) )
|
---|
| 189 | {
|
---|
| 190 | var sHRef = oLink.getAttribute( '_fcksavedurl' ) ;
|
---|
| 191 | if ( sHRef == null )
|
---|
| 192 | sHRef = oLink.getAttribute( 'href' , 2 ) || '' ;
|
---|
| 193 |
|
---|
| 194 | if ( sHRef == sReference || sHRef == sFullReference )
|
---|
| 195 | {
|
---|
| 196 | oLink.href = '#' + sNew ;
|
---|
| 197 | SetAttribute( oLink, '_fcksavedurl', '#' + sNew ) ;
|
---|
| 198 | }
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | </script>
|
---|
| 203 | </head>
|
---|
| 204 | <body style="overflow: hidden">
|
---|
| 205 | <table height="100%" width="100%">
|
---|
| 206 | <tr>
|
---|
| 207 | <td align="center">
|
---|
| 208 | <table border="0" cellpadding="0" cellspacing="0" width="80%">
|
---|
| 209 | <tr>
|
---|
| 210 | <td>
|
---|
| 211 | <span fckLang="DlgAnchorName">Anchor Name</span><BR>
|
---|
| 212 | <input id="txtName" style="WIDTH: 100%" type="text">
|
---|
| 213 | </td>
|
---|
| 214 | </tr>
|
---|
| 215 | </table>
|
---|
| 216 | </td>
|
---|
| 217 | </tr>
|
---|
| 218 | </table>
|
---|
| 219 | </body>
|
---|
| 220 | </html>
|
---|