Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 7:03 PM

in-portal

Index: trunk/admin/editor/cmseditor/editor/dialog/fck_link/fck_link.js
===================================================================
--- trunk/admin/editor/cmseditor/editor/dialog/fck_link/fck_link.js (revision 1482)
+++ trunk/admin/editor/cmseditor/editor/dialog/fck_link/fck_link.js (revision 1483)
@@ -1,611 +1,617 @@
/*
* FCKeditor - The text editor for internet
* Copyright (C) 2003-2004 Frederico Caldeira Knabben
*
* Licensed under the terms of the GNU Lesser General Public License:
* http://www.opensource.org/licenses/lgpl-license.php
*
* For further information visit:
* http://www.fckeditor.net/
*
* File Name: fck_link.js
* Scripts related to the Link dialog window (see fck_link.html).
*
* Version: 2.0 RC3
* Modified: 2005-02-09 13:53:13
*
* File Authors:
* Frederico Caldeira Knabben (fredck@fckeditor.net)
*/
var oEditor = window.parent.InnerDialogLoaded() ;
var FCK = oEditor.FCK ;
var FCKLang = oEditor.FCKLang ;
var ServerPath = '';
var from = '';
var anchor_ = '';
//#### Dialog Tabs
// Set the dialog tabs.
//window.parent.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ;
//window.parent.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ;
// TODO : Enable File Upload (1/3).
//window.parent.AddTab( 'Upload', 'Upload', true ) ;
//window.parent.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ;
// Function called when a dialog tag is selected.
function OnDialogTabChange( tabCode )
{
// ShowE('divInfo' , ( tabCode == 'Info' ) ) ;
// ShowE('divTarget' , ( tabCode == 'Target' ) ) ;
// TODO : Enable File Upload (2/3).
// ShowE('divUpload' , ( tabCode == 'Upload' ) ) ;
// ShowE('divAttribs' , ( tabCode == 'Advanced' ) ) ;
}
//#### Regular Expressions library.
var oRegex = new Object() ;
oRegex.UriProtocol = new RegExp('') ;
oRegex.UriProtocol.compile( '^(((http|https|ftp|news):\/\/)|mailto:)', 'gi' ) ;
oRegex.UrlOnChangeProtocol = new RegExp('') ;
oRegex.UrlOnChangeProtocol.compile( '^(http|https|ftp|news)://(?=.)', 'gi' ) ;
oRegex.UrlOnChangeTestOther = new RegExp('') ;
oRegex.UrlOnChangeTestOther.compile( '^(javascript:|#|/)', 'gi' ) ;
oRegex.ReserveTarget = new RegExp('') ;
oRegex.ReserveTarget.compile( '^_(blank|self|top|parent)$', 'i' ) ;
oRegex.PopupUri = new RegExp('') ;
//oRegex.PopupUri.compile( "^javascript:void\\(\\s*window.open\\(\\s*'([^']+)'\\s*,\\s*(?:'([^']*)'|null)\\s*,\\s*'([^']*)'\\s*\\)\\s*\\)\\s*$" ) ;
oRegex.PopupUri.compile( "^javascript:openwincms\\(\\s*'([^']+)'\\s*,\\s*(?:'([^']*)'|null)\\s*,\\s*([^']*)\\s*,\\s*([^']*)\\s*\\)$" ) ;
oRegex.PopupFeatures = new RegExp('') ;
oRegex.PopupFeatures.compile( '(?:^|,)([^=]+)=(\\d+|yes|no)', 'gi' ) ;
//#### Parser Functions
var oParser = new Object() ;
oParser.ParseEMailUrl = function( emailUrl )
{
// Initializes the EMailInfo object.
var oEMailInfo = new Object() ;
oEMailInfo.Address = '' ;
oEMailInfo.Subject = '' ;
oEMailInfo.Body = '' ;
var oParts = emailUrl.match( /^([^\?]+)\??(.+)?/ ) ;
if ( oParts )
{
// Set the e-mail address.
oEMailInfo.Address = oParts[1] ;
// Look for the optional e-mail parameters.
if ( oParts[2] )
{
var oMatch = oParts[2].match( /(^|&)subject=([^&]+)/i ) ;
if ( oMatch ) oEMailInfo.Subject = unescape( oMatch[2] ) ;
oMatch = oParts[2].match( /(^|&)body=([^&]+)/i ) ;
if ( oMatch ) oEMailInfo.Body = unescape( oMatch[2] ) ;
}
}
return oEMailInfo ;
}
oParser.CreateEMailUri = function( address, subject, body )
{
var sBaseUri = 'mailto:' + address ;
var sParams = '' ;
if ( subject.length > 0 )
sParams = '?subject=' + escape( subject ) ;
if ( body.length > 0 )
{
sParams += ( sParams.length == 0 ? '?' : '&' ) ;
sParams += 'body=' + escape( body ) ;
}
return sBaseUri + sParams ;
}
//#### Initialization Code
// oLink: The actual selected link in the editor.
var oLink = FCK.Selection.MoveToAncestorNode( 'A' ) ;
if ( oLink ) {
FCK.Selection.MoveToNode( oLink ) ;
//show_props(oLink.attributes, 'LINK: ')
}
function OnDialogTabChange( tabCode )
{
if (tabCode == 'Info') {
updateDataArray();
}
}
function updateDataArray()
{
window.parent.parentData['linkTxtUrl'] = BuildUrlByType();
if (window.parent.parentData['linkTxtUrl'].length > 2) {
if (GetE('txtAlt')) {
window.parent.parentData['linkTxtAlt'] = GetE('txtAlt').value;
window.parent.parentData['linkTxtTitle'] = GetE('txtAlt').value;
}
window.parent.parentData['linkCmbTarget'] = GetE('cmbTarget').value;
window.parent.parentData['linkType'] = GetE('cmbLinkType').value;
window.location.href='dialog/fck_image.html?from';
}
}
window.onload = function()
{
// Translate the dialog box texts.
oEditor.FCKLanguageManager.TranslatePage(document) ;
// Fill the Anchor Names and Ids combos.
//LoadAnchorNamesAndIds();
//alert(window.location.search.substr(1));
// Load the selected link information (if any).
LoadSelection() ;
// Show the initial dialog content.
GetE('divInfo').style.display = '' ;
// Activate the "OK" button.
window.parent.SetOkButton( true ) ;
// if (window.location.search.substr(1) == 'create'){
// alert('OK');
// window.parent.Ok();
// }
}
var bHasAnchors ;
function LoadAnchorNamesAndIds()
{
//alert('LoadAnchorNamesAndIds');
if (GetE('cmbLinkType').value != 'internal') {
ShowE( 'divNoAnchor' , 0 ) ;
return;
}
var aAnchors = window.frames["frmInternal"].document.anchors ;
//var aAnchors = oEditor.FCK.EditorDocument.anchors ;
//var aIds = oEditor.FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ;
if (aAnchors) {
bHasAnchors = ( aAnchors.length > 0) ;
if (GetE('cmbAnchorName').options.length > 0) {
GetE('cmbAnchorName').options.length = 0;
}
oEditor.FCKTools.AddSelectOption( document, GetE('cmbAnchorName'), '', '' ) ;
for ( var i = 0 ; i < aAnchors.length ; i++ )
{
var sName = aAnchors[i].name ;
if ( sName && sName.length > 0 ) {
oEditor.FCKTools.AddSelectOption( document, GetE('cmbAnchorName'), sName, sName ) ;
}
}
ShowE( 'divSelAnchor' , bHasAnchors ) ;
ShowE( 'divNoAnchor' , !bHasAnchors ) ;
for ( var i = 0 ; i < GetE('cmbAnchorName').length ; i++ )
{
if (anchor_ == GetE('cmbAnchorName').options[i].value)
GetE('cmbAnchorName').options[i].selected=1;
}
}
}
function LoadSelection()
{
var sHRef = '';
var sType = '';
if (window.parent.parentData['linkTxtUrl'])
{
sHRef = window.parent.parentData['linkTxtUrl'];
if (window.parent.parentData['linkTxtAlt'])
GetE('txtAlt').value = window.parent.parentData['linkTxtAlt'];
sType = GetE('cmbLinkType').value = window.parent.parentData['linkType'];
var sTarget = window.parent.parentData['linkCmbTarget'];
//alert('href: ' + sHRef + '\n'+'txtAlt: '+ GetE('txtAlt').value+'\n'+'sType: ' + sType+'\n'+'sTarget: ' + sTarget);
} else if ( !oLink ) {
SetLinkType('external');
return ;
}
if (sHRef.length == 0)
{
// Get the actual Link href.
var sHRef = oLink.getAttribute('href',2) + '' ;
if (oLink.getAttribute('alt',2)) {
if(oLink.getAttribute('alt',2).length > 0)
GetE('txtAlt').value = oLink.getAttribute('alt',2) + '' ;
else
GetE('txtAlt').value = '';
}
// Look for a popup javascript link.
}
var oPopupMatch = oRegex.PopupUri.exec( sHRef ) ;
if( oPopupMatch )
{
GetE('cmbTarget').value = 'popup' ;
sHRef = oPopupMatch[1] ;
GetE('txtPopupWidth').value = oPopupMatch[3];
GetE('txtPopupHeight').value = oPopupMatch[4];
SetTarget('popup');
}
// Search for the protocol.
var sProtocol = oRegex.UriProtocol.exec( sHRef ) ;
if ( sProtocol )
{
sProtocol = sProtocol[0].toLowerCase() ;
GetE('cmbLinkProtocol').value = sProtocol ;
// Remove the protocol and get the remainig URL.
var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ;
if ( sProtocol == 'mailto:' ) // It is an e-mail link.
{
sType = 'email' ;
var oEMailInfo = oParser.ParseEMailUrl( sUrl ) ;
GetE('txtEMailAddress').value = oEMailInfo.Address ;
GetE('txtEMailSubject').value = oEMailInfo.Subject ;
GetE('txtEMailBody').value = oEMailInfo.Body ;
}
else // It is a normal link.
GetE('txtUrl').value = sUrl ;
}
else // It is another type of link.
{
GetE('cmbLinkProtocol').value = '' ;
GetE('txtUrl').value = sHRef ;
}
if (oLink) {
//if (!window.location.search)
if (sType.length == 0)
sType = GetAttribute( oLink, 'label', '' );
if (sType.length == 0)
sType = 'external';
}
if (sType == 'Doc' && sHRef.length > 2) {
GetE('fileUrl').value = sHRef ;
}
if (sType == 'internal' && sHRef.length > 2 && sHRef.indexOf('#') > 0) {
anchor_ = sHRef.slice(sHRef.lastIndexOf('#')+1);
sHRef = sHRef.slice(0,sHRef.lastIndexOf('#'));
GetE('txtUrl').value = sHRef ;
}
if ( !oPopupMatch )
{
// Get the target.
if (oLink)
var sTarget = oLink.target;
else if (window.parent.parentData['linkCmbTarget'])
var sTarget = window.parent.parentData['linkCmbTarget'];
if ( sTarget && sTarget.length > 0 )
{
if ( oRegex.ReserveTarget.test( sTarget ) )
{
sTarget = sTarget.toLowerCase() ;
GetE('cmbTarget').value = sTarget ;
}
else
GetE('cmbTarget').value = '' ;
}
}
GetE('cmbLinkType').value = sType ;
SetLinkType( sType );
}
//#### Link type selection.
function SetLinkType( linkType )
{
if (linkType == 'email') {
ShowE('divNoMail1',0);
ShowE('divNoMail2',0);
ShowE('divNoMail3',0);
} else {
ShowE('divNoMail1',1);
ShowE('divNoMail2',1);
ShowE('divNoMail3',1);
}
if (linkType != 'internal')
ShowE( 'divNoAnchor' , 0 ) ;
ShowE('divLinkTypeInternal' , (linkType == 'internal') ) ;
ShowE('divLinkTypeExternal' , (linkType == 'external') ) ;
ShowE('divLinkTypeEMail' , (linkType == 'email') ) ;
ShowE('divLinkTypeFile' , (linkType == 'Doc') ) ;
if(GetE('cmbTarget')) {
if (GetE('cmbTarget').value == 'popup' ) {
ShowE('divPopupSize',1);
} else
ShowE('divPopupSize',0);
} else
ShowE('divPopupSize',0);
if ( linkType == 'internal' ) {
LoadResources();
//LoadAnchorNamesAndIds();
}
if ( linkType == 'email')
window.parent.SetAutoSize( true ) ;
}
function LoadResources()
{
var oXML = new FCKXml() ;
var sConnUrl = 'filemanager/browser/default/connectors/php/connector.php?Command=GetCmsTree';
sConnUrl = window.location.href.replace( /dialog.*$/, '' ) + sConnUrl ;
oXML.LoadUrl(sConnUrl, GetCmsTreeCallBack ) ; // Asynchronous load.
}
function GetCmsTreeCallBack( fckXml )
{
//alert(show_props(fckXml, 'oNodes'));
var oNodes = fckXml.SelectNodes( 'Connector/CmsPages/CmsPage' ) ;
for ( var i = 0 ; i < oNodes.length ; i++ )
{
var sCmsPage = oNodes[i].attributes.getNamedItem('path').value ;
var sTitle = oNodes[i].attributes.getNamedItem('title').value ;
ServerPath = oNodes[i].attributes.getNamedItem('serverpath').value;
GetE('cmbImternalPagName').options[i] = new Option(sTitle, sCmsPage);
if (GetE('txtUrl')) {
tmpUrl = GetE('txtUrl').value;
if (tmpUrl.length == 0 && i == 0) {
- window.frames["frmInternal"].document.location.href = ServerPath + sCmsPage ;
+ window.frames["frmInternal"].document.location.href = ServerPath + sCmsPage+GetAdmin();
}
//alert(tmpUrl+' === '+sCmsPage);
if (tmpUrl.match(sCmsPage+'$')) {
GetE('cmbImternalPagName').options[i].selected=1;
- window.frames["frmInternal"].document.location.href = tmpUrl ;
+ window.frames["frmInternal"].document.location.href = tmpUrl+GetAdmin();
}
}
}
}
function ChangeInternalUrl(url)
{
- window.frames["frmInternal"].document.location.href = ServerPath + url;
+ window.frames["frmInternal"].document.location.href = ServerPath + url+GetAdmin();
//window.frames["frmInternal"].document.location.onload = LoadAnchorNamesAndIds();
//LoadAnchorNamesAndIds();
}
+function GetAdmin()
+{
+ if (oEditor.FCKConfig.Admin == 1)
+ return "&admin=1";
+}
+
function show_props(obj, objName) {
var result = "";
for (var i in obj) {
alert( objName + "." + i + " = " + obj[i] + " \n" );
}
}
//#### Target type selection.
function SetTarget( targetType )
{
switch ( targetType )
{
case "_blank" :
case "_self" :
case "_parent" :
case "_top" :
GetE('cmbTarget').value = targetType ;
break ;
case "" :
GetE('cmbTarget').value = '' ;
break ;
}
if ( targetType == 'popup' )
{
ShowE('divPopupSize',1);
window.parent.SetAutoSize( true ) ;
if (!GetE('txtPopupWidth').value)
GetE('txtPopupWidth').value = 800;
if (!GetE('txtPopupHeight').value)
GetE('txtPopupHeight').value = 600;
} else
ShowE('divPopupSize',0);
}
//#### Called while the user types the URL.
function OnUrlChange()
{
//alert("OnUrlChange "+ sUrl);
var sUrl = GetE('txtUrl').value ;
var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ;
if ( sProtocol )
{
sUrl = sUrl.substr( sProtocol[0].length ) ;
GetE('txtUrl').value = sUrl ;
GetE('cmbLinkProtocol').value = sProtocol[0].toLowerCase() ;
}
else if ( oRegex.UrlOnChangeTestOther.test( sUrl ) )
{
GetE('cmbLinkProtocol').value = '' ;
}
}
//#### Called while the user types the target name.
function OnTargetNameChange()
{
}
//#### Builds the javascript URI to open a popup to the specified URI.
function BuildPopupUri( uri )
{
var ret = "javascript:openwincms('"+uri+"','popup',"+GetE('txtPopupWidth').value+","+GetE('txtPopupHeight').value+")";
return ret; //void(window.open('" + uri + "'," + sWindowName + ",'" + sFeatures + "'))" ) ;
}
//#### The OK button was hit.
function BuildUrlByType()
{
switch ( GetE('cmbLinkType').value )
{
case 'internal' :
sUri = ServerPath+GetE('cmbImternalPagName').value;
//sUri = GetE('cmbLinkProtocol').value + sUri ;
var cmbAnchorName = GetE('cmbAnchorName').value
if (cmbAnchorName.length > 0)
sUri = sUri+'#'+cmbAnchorName
if( GetE('cmbTarget').value == 'popup' )
sUri = BuildPopupUri( sUri ) ;
break ;
case 'Doc' :
sUri = GetE('fileUrl').value ;
if ( sUri.length == 0 )
{
alert( FCKLang.DlnLnkMsgNoUrl ) ;
return false ;
}
//sUri = sUri ;
if( GetE('cmbTarget').value == 'popup' )
sUri = BuildPopupUri( sUri ) ;
break ;
case 'external' :
sUri = GetE('txtUrl').value ;
if ( sUri.length == 0 )
{
alert( FCKLang.DlnLnkMsgNoUrl ) ;
return false ;
}
sUri = GetE('cmbLinkProtocol').value + sUri ;
if( GetE('cmbTarget').value == 'popup' )
sUri = BuildPopupUri( sUri ) ;
break ;
case 'email' :
sUri = GetE('txtEMailAddress').value ;
if ( sUri.length == 0 )
{
alert( FCKLang.DlnLnkMsgNoEMail ) ;
return false ;
}
sUri = oParser.CreateEMailUri(
sUri,
GetE('txtEMailSubject').value,
GetE('txtEMailBody').value ) ;
break ;
}
return sUri;
}
function Ok()
{
var sUri = BuildUrlByType();
if (sUri == false)
return false;
if (window.location.search.substr(1) == 'from') {
updateDataArray();
window.location.href='dialog/fck_image.html?create';
return ;
}
if ( oLink )
oLink.href = sUri ;
else
{
oLink = oEditor.FCK.CreateLink( sUri ) ;
if ( ! oLink )
return true ;
}
if( GetE('cmbTarget').value != 'popup' )
SetAttribute( oLink, 'target', GetE('cmbTarget').value ) ;
else
SetAttribute( oLink, 'target', null ) ;
if (GetE('txtAlt')) {
SetAttribute( oLink, 'alt', GetE('txtAlt').value) ;
SetAttribute( oLink, 'title', GetE('txtAlt').value) ;
}
SetAttribute( oLink, 'label', GetE('cmbLinkType').value)
/*
if ( oEditor.FCKBrowserInfo.IsIE )
oLink.style.cssText = GetE('txtAttStyle').value ;
else
SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ;
*/
return true ;
}
function show_props(obj, objName) {
var result = "";
for (var i in obj) {
result = objName + "." + i + " = " + obj[i] + " \n";
alert(result);
}
//return result;
}
function BrowseServer(field)
{
// Set the browser window feature
urlField = field;
var iWidth = oEditor.FCKConfig.ImageBrowserWindowWidth ;
var iHeight = oEditor.FCKConfig.ImageBrowserWindowHeight ;
var iLeft = (screen.width - iWidth) / 2 ;
var iTop = (screen.height - iHeight) / 2 ;
var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
sOptions += ",width=" + iWidth ;
sOptions += ",height=" + iHeight ;
sOptions += ",left=" + iLeft ;
sOptions += ",top=" + iTop ;
// Open the browser window.
var oWindow = window.open( oEditor.FCKConfig.FilesBrowserURL, "FCKBrowseWindow", sOptions ) ;
}
function SetUrl( url, width, height, alt, fsize )
{
GetE(urlField).value = url ;
if ( alt )
GetE('txtAlt').value = alt;
}
\ No newline at end of file
Property changes on: trunk/admin/editor/cmseditor/editor/dialog/fck_link/fck_link.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property

Event Timeline