web/drupal/modules/fckeditor/plugins/linktonode/jscripts/utils.js
branchdrupal
changeset 74 0ff3ba646492
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/drupal/modules/fckeditor/plugins/linktonode/jscripts/utils.js	Fri Aug 21 16:26:26 2009 +0000
@@ -0,0 +1,134 @@
+if ( !FCKConfig.LinkDlgHideTarget )
+	window.parent.SetTabVisibility( 'Target', true ) ;
+
+// Overwrite linktocontent function
+//<!-- linktonode START -->
+function selectRow(row) {
+	if (!row) {
+		return;
+	}
+	$('#nodelist tbody tr').each(function() {
+		$(this).css({background: '#ffffff'});
+		selectedNode = null;
+	});
+	selectedNode = row;
+	$(row).css({background: '#dadfe9'});
+
+	GetE('txtUrlPath').value = selectedNode.cells[0].firstChild.nodeValue;
+	GetE('txtUrlInternal').value = 'internal:' + selectedNode.cells[4].firstChild.nodeValue;
+	SaveDrupalUrls();
+}
+//<!-- linktonode END -->
+
+// save node/path urls
+function SaveDrupalUrls()
+{
+	if ((!FCKConfig.DrupalLinkToContentSelect && FCKConfig.DrupalPathFilter) || GetE('cmbDrupalProtocol').value == 'internal') {
+		GetE('txtUrl').value = GetE('txtUrlInternal').value;
+	}
+	else {
+		GetE('txtUrl').value = GetE('txtUrlPath').value;
+	}
+}
+
+//#### The OK button was hit.
+function Ok()
+{
+	var sUri, sInnerHtml ;
+	var sUri = GetE('txtUrl').value;
+
+	oEditor.FCKUndo.SaveUndoStep() ;
+
+	// If no link is selected, create a new one (it may result in more than one link creation - #220).
+	var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri, true ) ;
+
+	// If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26)
+	var aHasSelection = ( aLinks.length > 0 ) ;
+	if ( !aHasSelection )
+	{
+		// Create a new (empty) anchor.
+		aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ;
+	}
+
+	// overwrite current selection
+	sInnerHtml = selectedNode.cells[1].firstChild.nodeValue;
+
+	for ( var i = 0 ; i < aLinks.length ; i++ )
+	{
+		oLink = aLinks[i] ;
+
+		/*
+		if ( aHasSelection )
+			sInnerHtml = oLink.innerHTML ;		// Save the innerHTML (IE changes it if it is like an URL).
+		*/
+
+		oLink.href = sUri ;
+		SetAttribute( oLink, '_fcksavedurl', sUri ) ;
+
+		var onclick;
+		// Accessible popups
+		if( GetE('cmbTarget').value == 'popup' )
+		{
+			onclick = BuildOnClickPopup() ;
+			// Encode the attribute
+			onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" )  ;
+			SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ;
+		}
+		else
+		{
+			// Check if the previous onclick was for a popup:
+			// In that case remove the onclick handler.
+			onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ;
+			if ( onclick )
+			{
+				// Decode the protected string
+				onclick = decodeURIComponent( onclick ) ;
+
+				if( oRegex.OnClickPopup.test( onclick ) )
+					SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ;
+			}
+		}
+
+		oLink.innerHTML = sInnerHtml ;		// Set (or restore) the innerHTML
+
+		// Target
+		if( GetE('cmbTarget').value != 'popup' )
+			SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ;
+		else
+			SetAttribute( oLink, 'target', null ) ;
+
+		// Let's set the "id" only for the first link to avoid duplication.
+		if ( i == 0 )
+			SetAttribute( oLink, 'id', GetE('txtAttId').value ) ;
+
+		// Advances Attributes
+		SetAttribute( oLink, 'name'		, GetE('txtAttName').value ) ;
+		SetAttribute( oLink, 'dir'		, GetE('cmbAttLangDir').value ) ;
+		SetAttribute( oLink, 'lang'		, GetE('txtAttLangCode').value ) ;
+		SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ;
+		SetAttribute( oLink, 'tabindex'	, ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ;
+		SetAttribute( oLink, 'title'	, GetE('txtAttTitle').value ) ;
+		SetAttribute( oLink, 'type'		, GetE('txtAttContentType').value ) ;
+		SetAttribute( oLink, 'charset'	, GetE('txtAttCharSet').value ) ;
+
+		if ( oEditor.FCKBrowserInfo.IsIE )
+		{
+			var sClass = GetE('txtAttClasses').value ;
+			// If it's also an anchor add an internal class
+			if ( GetE('txtAttName').value.length != 0 )
+				sClass += ' FCK__AnchorC' ;
+			SetAttribute( oLink, 'className', sClass ) ;
+
+			oLink.style.cssText = GetE('txtAttStyle').value ;
+		}
+		else
+		{
+			SetAttribute( oLink, 'class', GetE('txtAttClasses').value ) ;
+			SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ;
+		}
+	}
+	// Select the (first) link.
+	oEditor.FCKSelection.SelectNode( aLinks[0] );
+
+	return true ;
+}