web/drupal/modules/fckeditor/plugins/linktomenu/jscripts/utils.js
branchdrupal
changeset 74 0ff3ba646492
equal deleted inserted replaced
73:fcf75e232c5b 74:0ff3ba646492
       
     1 if ( !FCKConfig.LinkDlgHideTarget )
       
     2 	window.parent.SetTabVisibility( 'Target', true ) ;
       
     3 
       
     4 // Overwrite linktocontent function
       
     5 //<!-- linktonode START -->
       
     6 function selectRow(row) {
       
     7 	if (!row) {
       
     8 		return;
       
     9 	}
       
    10 	$('#nodelist tbody tr').each(function() {
       
    11 		$(this).css({background: '#ffffff'});
       
    12 		selectedNode = null;
       
    13 	});
       
    14 	selectedNode = row;
       
    15 	$(row).css({background: '#dadfe9'});
       
    16 
       
    17 	GetE('txtUrl').value = selectedNode.cells[0].firstChild.nodeValue;
       
    18 }
       
    19 //<!-- linktonode END -->
       
    20 
       
    21 //#### The OK button was hit.
       
    22 function Ok()
       
    23 {
       
    24 	var sUri, sInnerHtml ;
       
    25 	var sUri = GetE('txtUrl').value;
       
    26 
       
    27 	oEditor.FCKUndo.SaveUndoStep() ;
       
    28 
       
    29 	// If no link is selected, create a new one (it may result in more than one link creation - #220).
       
    30 	var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri, true ) ;
       
    31 
       
    32 	// If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26)
       
    33 	var aHasSelection = ( aLinks.length > 0 ) ;
       
    34 	if ( !aHasSelection )
       
    35 	{
       
    36 		// Create a new (empty) anchor.
       
    37 		aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ;
       
    38 	}
       
    39 
       
    40 	// overwrite current selection
       
    41 	sInnerHtml = selectedNode.cells[1].firstChild.nodeValue;
       
    42 
       
    43 	for ( var i = 0 ; i < aLinks.length ; i++ )
       
    44 	{
       
    45 		oLink = aLinks[i] ;
       
    46 
       
    47 		/*
       
    48 		if ( aHasSelection )
       
    49 			sInnerHtml = oLink.innerHTML ;		// Save the innerHTML (IE changes it if it is like an URL).
       
    50 		*/
       
    51 
       
    52 		oLink.href = sUri ;
       
    53 		SetAttribute( oLink, '_fcksavedurl', sUri ) ;
       
    54 
       
    55 		var onclick;
       
    56 		// Accessible popups
       
    57 		if( GetE('cmbTarget').value == 'popup' )
       
    58 		{
       
    59 			onclick = BuildOnClickPopup() ;
       
    60 			// Encode the attribute
       
    61 			onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" )  ;
       
    62 			SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ;
       
    63 		}
       
    64 		else
       
    65 		{
       
    66 			// Check if the previous onclick was for a popup:
       
    67 			// In that case remove the onclick handler.
       
    68 			onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ;
       
    69 			if ( onclick )
       
    70 			{
       
    71 				// Decode the protected string
       
    72 				onclick = decodeURIComponent( onclick ) ;
       
    73 
       
    74 				if( oRegex.OnClickPopup.test( onclick ) )
       
    75 					SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ;
       
    76 			}
       
    77 		}
       
    78 
       
    79 		oLink.innerHTML = sInnerHtml ;		// Set (or restore) the innerHTML
       
    80 
       
    81 		// Target
       
    82 		if( GetE('cmbTarget').value != 'popup' )
       
    83 			SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ;
       
    84 		else
       
    85 			SetAttribute( oLink, 'target', null ) ;
       
    86 
       
    87 		// Let's set the "id" only for the first link to avoid duplication.
       
    88 		if ( i == 0 )
       
    89 			SetAttribute( oLink, 'id', GetE('txtAttId').value ) ;
       
    90 
       
    91 		// Advances Attributes
       
    92 		SetAttribute( oLink, 'name'		, GetE('txtAttName').value ) ;
       
    93 		SetAttribute( oLink, 'dir'		, GetE('cmbAttLangDir').value ) ;
       
    94 		SetAttribute( oLink, 'lang'		, GetE('txtAttLangCode').value ) ;
       
    95 		SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ;
       
    96 		SetAttribute( oLink, 'tabindex'	, ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ;
       
    97 		SetAttribute( oLink, 'title'	, GetE('txtAttTitle').value ) ;
       
    98 		SetAttribute( oLink, 'type'		, GetE('txtAttContentType').value ) ;
       
    99 		SetAttribute( oLink, 'charset'	, GetE('txtAttCharSet').value ) ;
       
   100 
       
   101 		if ( oEditor.FCKBrowserInfo.IsIE )
       
   102 		{
       
   103 			var sClass = GetE('txtAttClasses').value ;
       
   104 			// If it's also an anchor add an internal class
       
   105 			if ( GetE('txtAttName').value.length != 0 )
       
   106 				sClass += ' FCK__AnchorC' ;
       
   107 			SetAttribute( oLink, 'className', sClass ) ;
       
   108 
       
   109 			oLink.style.cssText = GetE('txtAttStyle').value ;
       
   110 		}
       
   111 		else
       
   112 		{
       
   113 			SetAttribute( oLink, 'class', GetE('txtAttClasses').value ) ;
       
   114 			SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ;
       
   115 		}
       
   116 	}
       
   117 	// Select the (first) link.
       
   118 	oEditor.FCKSelection.SelectNode( aLinks[0] );
       
   119 
       
   120 	return true ;
       
   121 }