FCKeditor 2.6.6
[freeside.git] / httemplate / elements / fckeditor / editor / dialog / fck_link / fck_link.js
index 6d96499..449e13f 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2007 Frederico Caldeira Knabben\r
+ * Copyright (C) 2003-2010 Frederico Caldeira Knabben\r
  *\r
  * == BEGIN LICENSE ==\r
  *\r
  * Scripts related to the Link dialog window (see fck_link.html).\r
  */\r
 \r
-var oEditor            = window.parent.InnerDialogLoaded() ;\r
+var dialog     = window.parent ;\r
+var oEditor = dialog.InnerDialogLoaded() ;\r
+\r
 var FCK                        = oEditor.FCK ;\r
 var FCKLang            = oEditor.FCKLang ;\r
 var FCKConfig  = oEditor.FCKConfig ;\r
 var FCKRegexLib        = oEditor.FCKRegexLib ;\r
+var FCKTools   = oEditor.FCKTools ;\r
 \r
 //#### Dialog Tabs\r
 \r
 // Set the dialog tabs.\r
-window.parent.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;\r
+dialog.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;\r
 \r
 if ( !FCKConfig.LinkDlgHideTarget )\r
-       window.parent.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;\r
+       dialog.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;\r
 \r
 if ( FCKConfig.LinkUpload )\r
-       window.parent.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ;\r
+       dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ;\r
 \r
 if ( !FCKConfig.LinkDlgHideAdvanced )\r
-       window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;\r
+       dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;\r
 \r
 // Function called when a dialog tag is selected.\r
 function OnDialogTabChange( tabCode )\r
@@ -49,7 +52,7 @@ function OnDialogTabChange( tabCode )
        ShowE('divUpload'       , ( tabCode == 'Upload' ) ) ;\r
        ShowE('divAttribs'      , ( tabCode == 'Advanced' ) ) ;\r
 \r
-       window.parent.SetAutoSize( true ) ;\r
+       dialog.SetAutoSize( true ) ;\r
 }\r
 \r
 //#### Regular Expressions library.\r
@@ -74,36 +77,187 @@ oRegex.PopupFeatures = /(?:^|,)([^=]+)=(\d+|yes|no)/gi ;
 \r
 var oParser = new Object() ;\r
 \r
-oParser.ParseEMailUrl = function( emailUrl )\r
+// This method simply returns the two inputs in numerical order. You can even\r
+// provide strings, as the method would parseInt() the values.\r
+oParser.SortNumerical = function(a, b)\r
+{\r
+       return parseInt( a, 10 ) - parseInt( b, 10 ) ;\r
+}\r
+\r
+oParser.ParseEMailParams = function(sParams)\r
+{\r
+       // Initialize the oEMailParams object.\r
+       var oEMailParams = new Object() ;\r
+       oEMailParams.Subject = '' ;\r
+       oEMailParams.Body = '' ;\r
+\r
+       var aMatch = sParams.match( /(^|^\?|&)subject=([^&]+)/i ) ;\r
+       if ( aMatch ) oEMailParams.Subject = decodeURIComponent( aMatch[2] ) ;\r
+\r
+       aMatch = sParams.match( /(^|^\?|&)body=([^&]+)/i ) ;\r
+       if ( aMatch ) oEMailParams.Body = decodeURIComponent( aMatch[2] ) ;\r
+\r
+       return oEMailParams ;\r
+}\r
+\r
+// This method returns either an object containing the email info, or FALSE\r
+// if the parameter is not an email link.\r
+oParser.ParseEMailUri = function( sUrl )\r
 {\r
        // Initializes the EMailInfo object.\r
        var oEMailInfo = new Object() ;\r
-       oEMailInfo.Address      = '' ;\r
-       oEMailInfo.Subject      = '' ;\r
-       oEMailInfo.Body         = '' ;\r
+       oEMailInfo.Address = '' ;\r
+       oEMailInfo.Subject = '' ;\r
+       oEMailInfo.Body = '' ;\r
 \r
-       var oParts = emailUrl.match( /^([^\?]+)\??(.+)?/ ) ;\r
-       if ( oParts )\r
+       var aLinkInfo = sUrl.match( /^(\w+):(.*)$/ ) ;\r
+       if ( aLinkInfo && aLinkInfo[1] == 'mailto' )\r
        {\r
-               // Set the e-mail address.\r
-               oEMailInfo.Address = oParts[1] ;\r
-\r
-               // Look for the optional e-mail parameters.\r
-               if ( oParts[2] )\r
+               // This seems to be an unprotected email link.\r
+               var aParts = aLinkInfo[2].match( /^([^\?]+)\??(.+)?/ ) ;\r
+               if ( aParts )\r
                {\r
-                       var oMatch = oParts[2].match( /(^|&)subject=([^&]+)/i ) ;\r
-                       if ( oMatch ) oEMailInfo.Subject = decodeURIComponent( oMatch[2] ) ;\r
+                       // Set the e-mail address.\r
+                       oEMailInfo.Address = aParts[1] ;\r
 \r
-                       oMatch = oParts[2].match( /(^|&)body=([^&]+)/i ) ;\r
-                       if ( oMatch ) oEMailInfo.Body = decodeURIComponent( oMatch[2] ) ;\r
+                       // Look for the optional e-mail parameters.\r
+                       if ( aParts[2] )\r
+                       {\r
+                               var oEMailParams = oParser.ParseEMailParams( aParts[2] ) ;\r
+                               oEMailInfo.Subject = oEMailParams.Subject ;\r
+                               oEMailInfo.Body = oEMailParams.Body ;\r
+                       }\r
                }\r
+               return oEMailInfo ;\r
        }\r
+       else if ( aLinkInfo && aLinkInfo[1] == 'javascript' )\r
+       {\r
+               // This may be a protected email.\r
+\r
+               // Try to match the url against the EMailProtectionFunction.\r
+               var func = FCKConfig.EMailProtectionFunction ;\r
+               if ( func != null )\r
+               {\r
+                       try\r
+                       {\r
+                               // Escape special chars.\r
+                               func = func.replace( /([\/^$*+.?()\[\]])/g, '\\$1' ) ;\r
+\r
+                               // Define the possible keys.\r
+                               var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY') ;\r
+\r
+                               // Get the order of the keys (hold them in the array <pos>) and\r
+                               // the function replaced by regular expression patterns.\r
+                               var sFunc = func ;\r
+                               var pos = new Array() ;\r
+                               for ( var i = 0 ; i < keys.length ; i ++ )\r
+                               {\r
+                                       var rexp = new RegExp( keys[i] ) ;\r
+                                       var p = func.search( rexp ) ;\r
+                                       if ( p >= 0 )\r
+                                       {\r
+                                               sFunc = sFunc.replace( rexp, '\'([^\']*)\'' ) ;\r
+                                               pos[pos.length] = p + ':' + keys[i] ;\r
+                                       }\r
+                               }\r
+\r
+                               // Sort the available keys.\r
+                               pos.sort( oParser.SortNumerical ) ;\r
+\r
+                               // Replace the excaped single quotes in the url, such they do\r
+                               // not affect the regexp afterwards.\r
+                               aLinkInfo[2] = aLinkInfo[2].replace( /\\'/g, '###SINGLE_QUOTE###' ) ;\r
+\r
+                               // Create the regexp and execute it.\r
+                               var rFunc = new RegExp( '^' + sFunc + '$' ) ;\r
+                               var aMatch = rFunc.exec( aLinkInfo[2] ) ;\r
+                               if ( aMatch )\r
+                               {\r
+                                       var aInfo = new Array();\r
+                                       for ( var i = 1 ; i < aMatch.length ; i ++ )\r
+                                       {\r
+                                               var k = pos[i-1].match(/^\d+:(.+)$/) ;\r
+                                               aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\'') ;\r
+                                       }\r
+\r
+                                       // Fill the EMailInfo object that will be returned\r
+                                       oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN'] ;\r
+                                       oEMailInfo.Subject = decodeURIComponent( aInfo['SUBJECT'] ) ;\r
+                                       oEMailInfo.Body = decodeURIComponent( aInfo['BODY'] ) ;\r
+\r
+                                       return oEMailInfo ;\r
+                               }\r
+                       }\r
+                       catch (e)\r
+                       {\r
+                       }\r
+               }\r
 \r
-       return oEMailInfo ;\r
+               // Try to match the email against the encode protection.\r
+               var aMatch = aLinkInfo[2].match( /^(?:void\()?location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'\)?$/ ) ;\r
+               if ( aMatch )\r
+               {\r
+                       // The link is encoded\r
+                       oEMailInfo.Address = eval( aMatch[1] ) ;\r
+                       if ( aMatch[2] )\r
+                       {\r
+                               var oEMailParams = oParser.ParseEMailParams( aMatch[2] ) ;\r
+                               oEMailInfo.Subject = oEMailParams.Subject ;\r
+                               oEMailInfo.Body = oEMailParams.Body ;\r
+                       }\r
+                       return oEMailInfo ;\r
+               }\r
+       }\r
+       return false;\r
 }\r
 \r
 oParser.CreateEMailUri = function( address, subject, body )\r
 {\r
+       // Switch for the EMailProtection setting.\r
+       switch ( FCKConfig.EMailProtection )\r
+       {\r
+               case 'function' :\r
+                       var func = FCKConfig.EMailProtectionFunction ;\r
+                       if ( func == null )\r
+                       {\r
+                               if ( FCKConfig.Debug )\r
+                               {\r
+                                       alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"') ;\r
+                               }\r
+                               return '';\r
+                       }\r
+\r
+                       // Split the email address into name and domain parts.\r
+                       var aAddressParts = address.split( '@', 2 ) ;\r
+                       if ( aAddressParts[1] == undefined )\r
+                       {\r
+                               aAddressParts[1] = '' ;\r
+                       }\r
+\r
+                       // Replace the keys by their values (embedded in single quotes).\r
+                       func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'") ;\r
+                       func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'") ;\r
+                       func = func.replace(/SUBJECT/g, "'" + encodeURIComponent( subject ).replace(/'/g, '\\\'') + "'") ;\r
+                       func = func.replace(/BODY/g, "'" + encodeURIComponent( body ).replace(/'/g, '\\\'') + "'") ;\r
+\r
+                       return 'javascript:' + func ;\r
+\r
+               case 'encode' :\r
+                       var aParams = [] ;\r
+                       var aAddressCode = [] ;\r
+\r
+                       if ( subject.length > 0 )\r
+                               aParams.push( 'subject='+ encodeURIComponent( subject ) ) ;\r
+                       if ( body.length > 0 )\r
+                               aParams.push( 'body=' + encodeURIComponent( body ) ) ;\r
+                       for ( var i = 0 ; i < address.length ; i++ )\r
+                               aAddressCode.push( address.charCodeAt( i ) ) ;\r
+\r
+                       return 'javascript:void(location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join( ',' ) + ')+\'?' + aParams.join( '&' ) + '\')' ;\r
+       }\r
+\r
+       // EMailProtection 'none'\r
+\r
        var sBaseUri = 'mailto:' + address ;\r
 \r
        var sParams = '' ;\r
@@ -123,7 +277,7 @@ oParser.CreateEMailUri = function( address, subject, body )
 //#### Initialization Code\r
 \r
 // oLink: The actual selected link in the editor.\r
-var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;\r
+var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ;\r
 if ( oLink )\r
        FCK.Selection.SelectNode( oLink ) ;\r
 \r
@@ -155,7 +309,23 @@ window.onload = function()
        SetDefaultTarget() ;\r
 \r
        // Activate the "OK" button.\r
-       window.parent.SetOkButton( true ) ;\r
+       dialog.SetOkButton( true ) ;\r
+\r
+       // Select the first field.\r
+       switch( GetE('cmbLinkType').value )\r
+       {\r
+               case 'url' :\r
+                       SelectField( 'txtUrl' ) ;\r
+                       break ;\r
+               case 'email' :\r
+                       SelectField( 'txtEMailAddress' ) ;\r
+                       break ;\r
+               case 'anchor' :\r
+                       if ( GetE('divSelAnchor').style.display != 'none' )\r
+                               SelectField( 'cmbAnchorName' ) ;\r
+                       else\r
+                               SelectField( 'cmbLinkType' ) ;\r
+       }\r
 }\r
 \r
 var bHasAnchors ;\r
@@ -181,7 +351,7 @@ function LoadAnchorNamesAndIds()
                        aAnchors[ aAnchors.length ] = oLinks[i] ;\r
        }\r
 \r
-       var aIds = oEditor.FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ;\r
+       var aIds = FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ;\r
 \r
        bHasAnchors = ( aAnchors.length > 0 || aIds.length > 0 ) ;\r
 \r
@@ -189,12 +359,12 @@ function LoadAnchorNamesAndIds()
        {\r
                var sName = aAnchors[i].name ;\r
                if ( sName && sName.length > 0 )\r
-                       oEditor.FCKTools.AddSelectOption( GetE('cmbAnchorName'), sName, sName ) ;\r
+                       FCKTools.AddSelectOption( GetE('cmbAnchorName'), sName, sName ) ;\r
        }\r
 \r
        for ( i = 0 ; i < aIds.length ; i++ )\r
        {\r
-               oEditor.FCKTools.AddSelectOption( GetE('cmbAnchorId'), aIds[i], aIds[i] ) ;\r
+               FCKTools.AddSelectOption( GetE('cmbAnchorId'), aIds[i], aIds[i] ) ;\r
        }\r
 \r
        ShowE( 'divSelAnchor'   , bHasAnchors ) ;\r
@@ -222,43 +392,48 @@ function LoadSelection()
                SetTarget( 'popup' ) ;\r
        }\r
 \r
-       // Accesible popups, the popup data is in the onclick attribute\r
-       if ( !oPopupMatch ) {\r
+       // Accessible popups, the popup data is in the onclick attribute\r
+       if ( !oPopupMatch )\r
+       {\r
                var onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ;\r
-               oPopupMatch = oRegex.OnClickPopup.exec( onclick ) ;\r
-               if( oPopupMatch )\r
+               if ( onclick )\r
                {\r
-                       GetE( 'cmbTarget' ).value = 'popup' ;\r
-                       FillPopupFields( oPopupMatch[1], oPopupMatch[2] ) ;\r
-                       SetTarget( 'popup' ) ;\r
+                       // Decode the protected string\r
+                       onclick = decodeURIComponent( onclick ) ;\r
+\r
+                       oPopupMatch = oRegex.OnClickPopup.exec( onclick ) ;\r
+                       if( oPopupMatch )\r
+                       {\r
+                               GetE( 'cmbTarget' ).value = 'popup' ;\r
+                               FillPopupFields( oPopupMatch[1], oPopupMatch[2] ) ;\r
+                               SetTarget( 'popup' ) ;\r
+                       }\r
                }\r
        }\r
 \r
        // Search for the protocol.\r
        var sProtocol = oRegex.UriProtocol.exec( sHRef ) ;\r
 \r
-       if ( sProtocol )\r
+       // Search for a protected email link.\r
+       var oEMailInfo = oParser.ParseEMailUri( sHRef );\r
+\r
+       if ( oEMailInfo )\r
+       {\r
+               sType = 'email' ;\r
+\r
+               GetE('txtEMailAddress').value = oEMailInfo.Address ;\r
+               GetE('txtEMailSubject').value = oEMailInfo.Subject ;\r
+               GetE('txtEMailBody').value    = oEMailInfo.Body ;\r
+       }\r
+       else if ( sProtocol )\r
        {\r
                sProtocol = sProtocol[0].toLowerCase() ;\r
                GetE('cmbLinkProtocol').value = sProtocol ;\r
 \r
-               // Remove the protocol and get the remainig URL.\r
+               // Remove the protocol and get the remaining URL.\r
                var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ;\r
-\r
-               if ( sProtocol == 'mailto:' )   // It is an e-mail link.\r
-               {\r
-                       sType = 'email' ;\r
-\r
-                       var oEMailInfo = oParser.ParseEMailUrl( sUrl ) ;\r
-                       GetE('txtEMailAddress').value   = oEMailInfo.Address ;\r
-                       GetE('txtEMailSubject').value   = oEMailInfo.Subject ;\r
-                       GetE('txtEMailBody').value              = oEMailInfo.Body ;\r
-               }\r
-               else                            // It is a normal link.\r
-               {\r
-                       sType = 'url' ;\r
-                       GetE('txtUrl').value = sUrl ;\r
-               }\r
+               sType = 'url' ;\r
+               GetE('txtUrl').value = sUrl ;\r
        }\r
        else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 )        // It is an anchor link.\r
        {\r
@@ -330,16 +505,16 @@ function SetLinkType( linkType )
        ShowE('divLinkTypeEMail'        , (linkType == 'email') ) ;\r
 \r
        if ( !FCKConfig.LinkDlgHideTarget )\r
-               window.parent.SetTabVisibility( 'Target'        , (linkType == 'url') ) ;\r
+               dialog.SetTabVisibility( 'Target'       , (linkType == 'url') ) ;\r
 \r
        if ( FCKConfig.LinkUpload )\r
-               window.parent.SetTabVisibility( 'Upload'        , (linkType == 'url') ) ;\r
+               dialog.SetTabVisibility( 'Upload'       , (linkType == 'url') ) ;\r
 \r
        if ( !FCKConfig.LinkDlgHideAdvanced )\r
-               window.parent.SetTabVisibility( 'Advanced'      , (linkType != 'anchor' || bHasAnchors) ) ;\r
+               dialog.SetTabVisibility( 'Advanced'     , (linkType != 'anchor' || bHasAnchors) ) ;\r
 \r
        if ( linkType == 'email' )\r
-               window.parent.SetAutoSize( true ) ;\r
+               dialog.SetAutoSize( true ) ;\r
 }\r
 \r
 //#### Target type selection.\r
@@ -347,7 +522,7 @@ function SetTarget( targetType )
 {\r
        GetE('tdTargetFrame').style.display     = ( targetType == 'popup' ? 'none' : '' ) ;\r
        GetE('tdPopupName').style.display       =\r
-               GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ;\r
+       GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ;\r
 \r
        switch ( targetType )\r
        {\r
@@ -363,7 +538,7 @@ function SetTarget( targetType )
        }\r
 \r
        if ( targetType == 'popup' )\r
-               window.parent.SetAutoSize( true ) ;\r
+               dialog.SetAutoSize( true ) ;\r
 }\r
 \r
 //#### Called while the user types the URL.\r
@@ -397,7 +572,7 @@ function OnTargetNameChange()
                GetE('cmbTarget').value = 'frame' ;\r
 }\r
 \r
-// Accesible popups\r
+// Accessible popups\r
 function BuildOnClickPopup()\r
 {\r
        var sWindowName = "'" + GetE('txtPopupName').value.replace(/\W/gi, "") + "'" ;\r
@@ -457,6 +632,7 @@ function FillPopupFields( windowName, features )
 function Ok()\r
 {\r
        var sUri, sInnerHtml ;\r
+       oEditor.FCKUndo.SaveUndoStep() ;\r
 \r
        switch ( GetE('cmbLinkType').value )\r
        {\r
@@ -503,7 +679,7 @@ function Ok()
        }\r
 \r
        // If no link is selected, create a new one (it may result in more than one link creation - #220).\r
-       var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri ) ;\r
+       var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri, true ) ;\r
 \r
        // If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26)\r
        var aHasSelection = ( aLinks.length > 0 ) ;\r
@@ -534,11 +710,9 @@ function Ok()
                }\r
 \r
                // Create a new (empty) anchor.\r
-               aLinks = [ oEditor.FCK.CreateElement( 'a' ) ] ;\r
+               aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ;\r
        }\r
 \r
-       oEditor.FCKUndo.SaveUndoStep() ;\r
-\r
        for ( var i = 0 ; i < aLinks.length ; i++ )\r
        {\r
                oLink = aLinks[i] ;\r
@@ -549,18 +723,28 @@ function Ok()
                oLink.href = sUri ;\r
                SetAttribute( oLink, '_fcksavedurl', sUri ) ;\r
 \r
-               // Accesible popups\r
+               var onclick;\r
+               // Accessible popups\r
                if( GetE('cmbTarget').value == 'popup' )\r
                {\r
-                       SetAttribute( oLink, 'onclick_fckprotectedatt', " onclick=\"" + BuildOnClickPopup() + "\"") ;\r
+                       onclick = BuildOnClickPopup() ;\r
+                       // Encode the attribute\r
+                       onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" )  ;\r
+                       SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ;\r
                }\r
                else\r
                {\r
                        // Check if the previous onclick was for a popup:\r
                        // In that case remove the onclick handler.\r
-                       var onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ;\r
-                       if( oRegex.OnClickPopup.test( onclick ) )\r
-                               SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ;\r
+                       onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ;\r
+                       if ( onclick )\r
+                       {\r
+                               // Decode the protected string\r
+                               onclick = decodeURIComponent( onclick ) ;\r
+\r
+                               if( oRegex.OnClickPopup.test( onclick ) )\r
+                                       SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ;\r
+                       }\r
                }\r
 \r
                oLink.innerHTML = sInnerHtml ;          // Set (or restore) the innerHTML\r
@@ -615,13 +799,17 @@ function BrowseServer()
 \r
 function SetUrl( url )\r
 {\r
-       document.getElementById('txtUrl').value = url ;\r
+       GetE('txtUrl').value = url ;\r
        OnUrlChange() ;\r
-       window.parent.SetSelectedTab( 'Info' ) ;\r
+       dialog.SetSelectedTab( 'Info' ) ;\r
 }\r
 \r
 function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )\r
 {\r
+       // Remove animation\r
+       window.parent.Throbber.Hide() ;\r
+       GetE( 'divUpload' ).style.display  = '' ;\r
+\r
        switch ( errorNumber )\r
        {\r
                case 0 :        // No errors\r
@@ -642,6 +830,9 @@ function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
                case 203 :\r
                        alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;\r
                        return ;\r
+               case 500 :\r
+                       alert( 'The connector is disabled' ) ;\r
+                       break ;\r
                default :\r
                        alert( 'Error on file upload. Error number: ' + errorNumber ) ;\r
                        return ;\r
@@ -671,13 +862,17 @@ function CheckUpload()
                return false ;\r
        }\r
 \r
+       // Show animation\r
+       window.parent.Throbber.Show( 100 ) ;\r
+       GetE( 'divUpload' ).style.display  = 'none' ;\r
+\r
        return true ;\r
 }\r
 \r
 function SetDefaultTarget()\r
 {\r
-       var target = FCKConfig.DefaultLinkTarget + '' ;\r
-       \r
+       var target = FCKConfig.DefaultLinkTarget || '' ;\r
+\r
        if ( oLink || target.length == 0 )\r
                return ;\r
 \r
@@ -693,6 +888,6 @@ function SetDefaultTarget()
                        GetE('cmbTarget').value = 'frame' ;\r
                        break ;\r
        }\r
-       \r
+\r
        GetE('txtTargetFrame').value = target ;\r
 }\r