Вход Регистрация
Файл: public/js/3rd_party/ckeditor/plugins/link/dialogs/anchor.js
Строк: 147
<?php

/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

CKEDITOR.dialog.add'anchor', function( editor )
{
    
// Function called in onShow to load selected element.
    
var loadElements = function( element )
    {
        
this._.selectedElement element;

        var 
attributeValue element.data'cke-saved-name' );
        
this.setValueOf'info','txtName'attributeValue || '' );
    };

    function 
createFakeAnchoreditoranchor )
    {
        return 
editor.createFakeElementanchor'cke_anchor''anchor' );
    }

    return {
        
title editor.lang.anchor.title,
        
minWidth 300,
        
minHeight 60,
        
onOk : function()
        {
            var 
name this.getValueOf'info''txtName' );
            var 
attributes =
            {
                
name name,
                
'data-cke-saved-name' name
            
};

            if ( 
this._.selectedElement )
            {
                if ( 
this._.selectedElement.data'cke-realelement' ) )
                {
                    var 
newFake createFakeAnchoreditoreditor.document.createElement'a', { attributesattributes } ) );
                    
newFake.replacethis._.selectedElement );
                }
                else
                    
this._.selectedElement.setAttributesattributes );
            }
            else
            {
                var 
sel editor.getSelection(),
                        
range sel && sel.getRanges()[ ];

                
// Empty anchor
                
if ( range.collapsed )
                {
                    if ( 
CKEDITOR.plugins.link.synAnchorSelector )
                        
attributes'class' ] = 'cke_anchor_empty';

                    if ( 
CKEDITOR.plugins.link.emptyAnchorFix )
                    {
                        
attributes'contenteditable' ] = 'false';
                        
attributes'data-cke-editable' ] = 1;
                    }

                    var 
anchor editor.document.createElement'a', { attributesattributes } );

                    
// Transform the anchor into a fake element for browsers that need it.
                    
if ( CKEDITOR.plugins.link.fakeAnchor )
                        
anchor createFakeAnchoreditoranchor );

                    
range.insertNodeanchor );
                }
                else
                {
                    if ( 
CKEDITOR.env.ie && CKEDITOR.env.version )
                        
attributes['class'] = 'cke_anchor';

                    
// Apply style.
                    
var style = new CKEDITOR.style( { element 'a'attributes attributes } );
                    
style.type CKEDITOR.STYLE_INLINE;
                    
style.applyeditor.document );
                }
            }
        },

        
onHide : function()
        {
            
delete this._.selectedElement;
        },

        
onShow : function()
        {
            var 
selection editor.getSelection(),
                
fullySelected selection.getSelectedElement(),
                
partialSelected;

            
// Detect the anchor under selection.
            
if ( fullySelected )
            {
                if ( 
CKEDITOR.plugins.link.fakeAnchor )
                {
                    var 
realElement CKEDITOR.plugins.link.tryRestoreFakeAnchoreditorfullySelected );
                    
realElement && loadElements.callthisrealElement );
                    
this._.selectedElement fullySelected;
                }
                else if ( 
fullySelected.is'a' ) && fullySelected.hasAttribute'name' ) )
                    
loadElements.callthisfullySelected );
            }
            else
            {
                
partialSelected CKEDITOR.plugins.link.getSelectedLinkeditor );
                if ( 
partialSelected )
                {
                    
loadElements.callthispartialSelected );
                    
selection.selectElementpartialSelected );
                }
            }

            
this.getContentElement'info''txtName' ).focus();
        },
        
contents : [
            {
                
id 'info',
                
label editor.lang.anchor.title,
                
accessKey 'I',
                
elements :
                [
                    {
                        
type 'text',
                        
id 'txtName',
                        
label editor.lang.anchor.name,
                        
requiredtrue,
                        
validate : function()
                        {
                            if ( !
this.getValue() )
                            {
                                
alerteditor.lang.anchor.errorName );
                                return 
false;
                            }
                            return 
true;
                        }
                    }
                ]
            }
        ]
    };
} );
?>
Онлайн: 3
Реклама