source: branches/1.2/workflow/js/fckeditor/editor/dialog/fck_anchor.html @ 1349

Revision 1349, 5.9 KB checked in by niltonneto, 15 years ago (diff)

Ticket #561 - Inclusão do módulo Workflow faltante nessa versão.

  • Property svn:executable set to *
Line 
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-2007 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
32var oEditor     = window.parent.InnerDialogLoaded() ;
33var FCK         = oEditor.FCK ;
34var FCKBrowserInfo = oEditor.FCKBrowserInfo ;
35var FCKTools = oEditor.FCKTools ;
36var FCKRegexLib = oEditor.FCKRegexLib ;
37
38// Gets the document DOM
39var oDOM = oEditor.FCK.EditorDocument ;
40
41var oFakeImage = FCK.Selection.GetSelectedElement() ;
42var oAnchor ;
43
44if ( oFakeImage )
45{
46        if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckanchor') )
47                oAnchor = FCK.GetRealElement( oFakeImage ) ;
48        else
49                oFakeImage = null ;
50}
51
52//Search for a real anchor
53if ( !oFakeImage )
54{
55        oAnchor = FCK.Selection.MoveToAncestorNode( 'A' ) ;
56        if ( oAnchor )
57                FCK.Selection.SelectNode( oAnchor ) ;
58}
59
60window.onload = function()
61{
62        // First of all, translate the dialog box texts
63        oEditor.FCKLanguageManager.TranslatePage(document) ;
64
65        if ( oAnchor )
66                GetE('txtName').value = oAnchor.name ;
67        else
68                oAnchor = null ;
69
70        window.parent.SetOkButton( true ) ;
71}
72
73function Ok()
74{
75        var sNewName = GetE('txtName').value ;
76
77        // Remove any illegal character in a name attribute:
78        // A name should start with a letter, but the validator passes anyway.
79        sNewName = sNewName.replace( /[^\w-_\.:]/g, '_' ) ;
80
81        if ( sNewName.length == 0 )
82        {
83                // Remove the anchor if the user leaves the name blank
84                if ( oAnchor )
85                {
86                        RemoveAnchor() ;
87                        return true ;
88                }
89
90                alert( oEditor.FCKLang.DlgAnchorErrorName ) ;
91                return false ;
92        }
93
94        oEditor.FCKUndo.SaveUndoStep() ;
95
96        if ( oAnchor )  // Modifying an existent anchor.
97        {
98                ReadjustLinksToAnchor( oAnchor.name, sNewName );
99
100                // Buggy explorer, bad bad browser. http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/
101                // Instead of just replacing the .name for the existing anchor (in order to preserve the content), we must remove the .name
102                // and assign .name, although it won't appear until it's specially processed in fckxhtml.js
103
104                // We remove the previous name
105                oAnchor.removeAttribute( 'name' ) ;
106                // Now we set it, but later we must process it specially
107                oAnchor.name = sNewName ;
108
109                return true ;
110        }
111
112        // Create a new anchor preserving the current selection
113        oAnchor = oEditor.FCK.CreateLink( '#' ) ;
114        if ( !oAnchor )
115        {
116                // Nothing was selected, so now just create a normal A
117                oAnchor = oEditor.FCK.CreateElement( 'a' ) ;
118        }
119        else
120        {
121                // 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 != '' )
132                {
133                        if ( FCKBrowserInfo.IsIE )
134                                oAnchor.className += ' FCK__AnchorC' ;
135                }
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
146        }
147
148        return true ;
149}
150
151// Removes the current anchor from the document
152function RemoveAnchor()
153{
154        // If it's also a link, then just remove the name and exit
155        if ( oAnchor.href.length != 0 )
156        {
157                oAnchor.removeAttribute( 'name' ) ;
158                // Remove temporary class for IE
159                if ( FCKBrowserInfo.IsIE )
160                        oAnchor.className = oAnchor.className.replace( FCKRegexLib.FCK_Class, '' ) ;
161                return ;
162        }
163
164        // We need to remove the anchor
165        // If we got a fake image, then just remove it and we're done
166        if ( oFakeImage )
167        {
168                oFakeImage.parentNode.removeChild( oFakeImage ) ;
169                return ;
170        }
171        // Empty anchor, so just remove it
172        if ( oAnchor.innerHTML.length == 0 )
173        {
174                oAnchor.parentNode.removeChild( oAnchor ) ;
175                return ;
176        }
177        // Anchor with content, leave the content
178        FCKTools.RemoveOuterTags( oAnchor ) ;
179}
180
181// Checks all the links in the current page pointing to the current name and changes them to the new name
182function ReadjustLinksToAnchor( sCurrent, sNew )
183{
184        var oDoc = FCK.EditorDocument ;
185
186        var aLinks = oDoc.getElementsByTagName( 'A' ) ;
187
188        var sReference = '#' + sCurrent ;
189        // The url of the document, so we check absolute and partial references.
190        var sFullReference = oDoc.location.href.replace( /(#.*$)/, '') ;
191        sFullReference += sReference ;
192
193        var oLink ;
194        var i = aLinks.length - 1 ;
195        while ( i >= 0 && ( oLink = aLinks[i--] ) )
196        {
197                var sHRef = oLink.getAttribute( '_fcksavedurl' ) ;
198                if ( sHRef == null )
199                        sHRef = oLink.getAttribute( 'href' , 2 ) || '' ;
200
201                if ( sHRef == sReference || sHRef == sFullReference )
202                {
203                        oLink.href = '#' + sNew ;
204                        SetAttribute( oLink, '_fcksavedurl', '#' + sNew ) ;
205                }
206        }
207}
208
209                </script>
210        </head>
211        <body style="OVERFLOW: hidden" scroll="no">
212                <table height="100%" width="100%">
213                        <tr>
214                                <td align="center">
215                                        <table border="0" cellpadding="0" cellspacing="0" width="80%">
216                                                <tr>
217                                                        <td>
218                                                                <span fckLang="DlgAnchorName">Anchor Name</span><BR>
219                                                                <input id="txtName" style="WIDTH: 100%" type="text">
220                                                        </td>
221                                                </tr>
222                                        </table>
223                                </td>
224                        </tr>
225                </table>
226        </body>
227</html>
Note: See TracBrowser for help on using the repository browser.