Ticket #2852: 2852_9.patch

File 2852_9.patch, 48.3 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/fakeobjects/plugin.js

     
    55
    66CKEDITOR.plugins.add( 'fakeobjects' );
    77
    8 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className )
     8CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType )
    99{
    10         return this.document.createElement( 'img',
    11                 {
    12                         attributes :
    13                                 {
    14                                         'class' : className,
    15                                         src : CKEDITOR.getUrl( 'images/spacer.gif' ),
    16                                         _cke_realelement : encodeURIComponent( realElement.getOuterHtml() )
    17                                 }
    18                 });
     10        var attributes =
     11        {
     12                'class' : className,
     13                src : CKEDITOR.getUrl( 'images/spacer.gif' ),
     14                _cke_realelement : encodeURIComponent( realElement.getOuterHtml() )
     15        };
     16        if ( realElementType )
     17                attributes._cke_real_element_type = realElementType;
     18
     19        return this.document.createElement( 'img', { attributes : attributes } );
    1920};
     21
     22CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement )
     23{
     24        var html = decodeURIComponent( fakeElement.getAttribute( '_cke_realelement' ) ),
     25                realElement = CKEDITOR.dom.element.createFromHtml( html, this.document );
     26
     27        if ( fakeElement.$.style.width )
     28                realElement.setStyle( 'width', fakeElement.$.style.width );
     29        if ( fakeElement.$.style.height )
     30                realElement.setStyle( 'height', fakeElement.$.style.height );
     31
     32        return realElement;
     33};
  • _source/plugins/pagebreak/plugin.js

     
    4949                                        div = divs.getItem( i );
    5050                                        if ( div.getStyle( 'page-break-after' ) == 'always' && !/[^\s\u00A0]/.test( div.getText() ) )
    5151                                        {
    52                                                 editor.createFakeElement( div, 'cke_pagebreak' ).replace( div );
     52                                                editor.createFakeElement( div, 'cke_pagebreak', 'div' ).replace( div );
    5353                                        }
    5454                                }
    5555                        });
     
    6565                var breakObject = CKEDITOR.dom.element.createFromHtml( '<div style="page-break-after: always;"><span style="display: none;">&nbsp;</span></div>' );
    6666               
    6767                // Creates the fake image used for this element.
    68                 breakObject = editor.createFakeElement( breakObject, 'cke_pagebreak' );
     68                breakObject = editor.createFakeElement( breakObject, 'cke_pagebreak', 'div' );
    6969               
    7070                var ranges = editor.getSelection().getRanges();
    7171               
  • _source/plugins/dialogui/plugin.js

     
    883883                                accessKeyUp : function()
    884884                                {
    885885                                        this.select();
     886                                },
     887
     888                                /**
     889                                 * Sets the value of this text input object.
     890                                 * @param {Object} value The new value.
     891                                 * @returns {CKEDITOR.ui.dialog.textInput} The current UI element.
     892                                 * @example
     893                                 * uiElement.setValue( 'Blamo' );
     894                                 */
     895                                setValue : function( value )
     896                                {
     897                                        value = value || '';
     898                                        return CKEDITOR.ui.dialog.uiElement.prototype.setValue.call( this, value );
    886899                                }
    887900                        }, commonPrototype, true );
    888901
  • _source/plugins/link/dialogs/anchor.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.dialog.add( 'anchor', function( editor )
     7{
     8        // Function called in onShow to load selected element.
     9        var loadElements = function( editor, selection, ranges, element )
     10        {
     11                this.saveSelection();
     12                this.editMode = true;
     13                this.editObj = element;
     14
     15                var attributeValue = this.editObj.getAttribute( 'name' );
     16                if ( attributeValue == null )
     17                        this.setValueOf( 'info','txtName', "" );
     18                else
     19                        this.setValueOf( 'info','txtName', attributeValue );
     20        };
     21
     22        return {
     23                title : editor.lang.anchor.title,
     24                minWidth : 350,
     25                minHeight : 150,
     26                onOk : function()
     27                {
     28                        // Always create a new anchor, because of IE BUG.
     29                        var name = this.getValueOf( 'info', 'txtName' ),
     30                                element = CKEDITOR.env.ie ?
     31                                editor.document.createElement( '<a name="' + CKEDITOR.tools.htmlEncode( name ) + '">' ) :
     32                                editor.document.createElement( 'a' );
     33
     34                        // Move contents and attributes of old anchor to new anchor.
     35                        if ( this.editMode )
     36                        {
     37                                this.editObj.copyAttributes( element, { name : 1 } );
     38                                this.editObj.moveChildren( element );
     39                        }
     40
     41                        // Set name.
     42                        element.setAttribute( 'name', name );
     43
     44                        // Insert a new anchor.
     45                        var fakeElement = editor.createFakeElement( element, 'cke_anchor', 'anchor' );
     46                        if ( !this.editMode )
     47                        {
     48                                // It doesn't work with IE.
     49                                this.restoreSelection();
     50                                this.clearSavedSelection();
     51
     52                                editor.insertElement( fakeElement );
     53                        }
     54                        else
     55                                fakeElement.replace( this.fakeObj );
     56                        return true;
     57                },
     58                onShow : function()
     59                {
     60                        this.editObj = false;
     61                        this.fakeObj = false;
     62                        this.editMode = false;
     63
     64                        // IE BUG: Selection must be in the editor for getSelection() to work.
     65                        this.restoreSelection();
     66
     67                        var editor = this.getParentEditor(),
     68                                selection = editor.getSelection(),
     69                                ranges = selection.getRanges();
     70
     71                        if ( ranges.length == 1 )
     72                        {
     73                                ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT );
     74                                rangeRoot = ranges[0].getCommonAncestor( true );
     75                                var element = rangeRoot.getAscendant( 'img', true );
     76                                if ( element && element.getAttribute( '_cke_real_element_type' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' )
     77                                {
     78                                        this.fakeObj = element;
     79                                        element = editor.restoreRealElement( this.fakeObj );
     80                                        loadElements.apply( this, [ editor, selection, ranges, element ] );
     81                                        selection.selectElement( this.fakeObj );
     82                                        this.saveSelection();
     83                                }
     84                        }
     85                        this.getContentElement( 'info', 'txtName' ).focus();
     86                },
     87                contents : [
     88                        {
     89                                id : 'info',
     90                                label : editor.lang.anchor.title,
     91                                accessKey : 'I',
     92                                elements :
     93                                [
     94                                        {
     95                                                type : 'text',
     96                                                id : 'txtName',
     97                                                label : editor.lang.anchor.name,
     98                                                validate : function()
     99                                                {
     100                                                        if ( this.getValue() == '' )
     101                                                        {
     102                                                                alert( editor.lang.anchor.errorName );
     103                                                                return false;
     104                                                        }
     105                                                        return true;
     106                                                }
     107                                        },
     108                                ]
     109                        }
     110                ]
     111        };
     112} );
  • _source/plugins/link/dialogs/link.js

    Property changes on: _source/plugins/link/dialogs/anchor.js
    ___________________________________________________________________
    Added: svn:executable
       + *
    
     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.dialog.add( 'link', function( editor )
     7{
     8        // Handles the event when the "Target" selection box is changed.
     9        var targetChanged = function()
     10        {
     11                var dialog = this.getDialog(),
     12                        popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ),
     13                        targetName = dialog.getContentElement( 'target', 'linkTargetName' ),
     14                        value = this.getValue();
     15
     16                if ( !popupFeatures || !targetName )
     17                        return;
     18
     19                popupFeatures = popupFeatures.getElement();
     20
     21                if ( value == 'popup' )
     22                {
     23                        popupFeatures.show();
     24                        targetName.setLabel( editor.lang.link.targetPopupName );
     25                }
     26                else
     27                {
     28                        popupFeatures.hide();
     29                        targetName.setLabel( editor.lang.link.targetFrameName );
     30                        this.getDialog().setValueOf( 'target', 'linkTargetName', value.charAt( 0 ) == '_' ? value : '' );
     31                }
     32        };
     33
     34        // Handles the event when the "Type" selection box is changed.
     35        var linkTypeChanged = function()
     36        {
     37                var dialog = this.getDialog(),
     38                        partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ],
     39                        typeValue = this.getValue();
     40                if ( typeValue == 'url' )
     41                {
     42                        if ( editor.config.linkShowTargetTab )
     43                                dialog.showPage( 'target' );
     44                        if ( editor.config.linkUploadTab )
     45                                dialog.showPage( 'upload' );
     46                }
     47                else
     48                {
     49                        dialog.hidePage( 'target' );
     50                        dialog.hidePage( 'upload' );
     51                }
     52
     53                for ( var i = 0 ; i < partIds.length ; i++ )
     54                {
     55                        var element = dialog.getContentElement( 'info', partIds[i] );
     56                        if ( !element )
     57                                continue;
     58
     59                        element = element.getElement().getParent().getParent();
     60                        if ( partIds[i] == typeValue + 'Options' )
     61                                element.show();
     62                        else
     63                                element.hide();
     64                }
     65        };
     66
     67        // Loads the parameters in a selected link to the link dialog fields.
     68        var emailRegex = /^mailto:([^?]+)(?:\?(.+))?$/,
     69                emailSubjectRegex = /subject=([^;?:@&=$,\/]*)/,
     70                emailBodyRegex = /body=([^;?:@&=$,\/]*)/,
     71                anchorRegex = /^#(.*)$/,
     72                urlRegex = /^((?:http|https|ftp|news):\/\/)?(.*)$/,
     73                selectableTargets = /^(_(?:self|top|parent|blank))$/;
     74
     75        var popupRegex =
     76                /\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*/;
     77        var popupFeaturesRegex = /(?:^|,)([^=]+)=(\d+|yes|no)/gi;
     78
     79        var parseLink = function( editor, element )
     80        {
     81                var href = element ? ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) : '',
     82                        emailMatch = '',
     83                        anchorMatch = '',
     84                        urlMatch = false,
     85                        retval = {};
     86
     87                if ( href != null )
     88                {
     89                        emailMatch = href.match( emailRegex );
     90                        anchorMatch = href.match( anchorRegex );
     91                        urlMatch = href.match( urlRegex );
     92                }
     93               
     94                // Load the link type and URL.
     95                if ( emailMatch )
     96                {
     97                        var subjectMatch = href.match( emailSubjectRegex ),
     98                                bodyMatch = href.match( emailBodyRegex );
     99                        retval.type = 'email';
     100                        retval.email = {};
     101                        retval.email.address = emailMatch[1];
     102                        subjectMatch && ( retval.email.subject = decodeURIComponent( subjectMatch[1] ) );
     103                        bodyMatch && ( retval.email.body = decodeURIComponent( bodyMatch[1] ) );
     104                }
     105                else if ( anchorMatch )
     106                {
     107                        retval.type = 'anchor';
     108                        retval.anchor = {};
     109                        retval.anchor.name = retval.anchor.id = anchorMatch[1];
     110                }
     111                else if ( href && urlMatch )            // urlRegex matches empty strings, so need to check for href as well.
     112                {
     113                        retval.type = 'url';
     114                        retval.url = {};
     115                        retval.url.protocol = urlMatch[1];
     116                        retval.url.url = urlMatch[2];
     117                }
     118                else
     119                        retval.type = 'url';
     120
     121                // Load target and popup settings.
     122                if ( element )
     123                {
     124                        var target = element.getAttribute( 'target' );
     125                        retval.target = {};
     126                        retval.adv = {};
     127
     128                        // IE BUG: target attribute is an empty string instead of null in IE if it's not set.
     129                        if ( !target )
     130                        {
     131                                var onclick = element.getAttribute( '_cke_saved_onclick' ) || element.getAttribute( 'onclick' ),
     132                                        onclickMatch = onclick && onclick.match( popupRegex );
     133                                if ( onclickMatch )
     134                                {
     135                                        retval.target.type = 'popup';
     136                                        retval.target.name = onclickMatch[1];
     137
     138                                        var featureMatch;
     139                                        while ( ( featureMatch = popupFeaturesRegex.exec( onclickMatch[2] ) ) )
     140                                        {
     141                                                if ( featureMatch[2] == 'yes' || featureMatch[2] == '1' )
     142                                                        retval.target[ featureMatch[1] ] = true;
     143                                                else if ( isFinite( featureMatch[2] ) )
     144                                                        retval.target[ featureMatch[1] ] = featureMatch[2];
     145                                        }
     146                                }
     147                        }
     148                        else
     149                        {
     150                                var targetMatch = target.match( selectableTargets );
     151                                if ( targetMatch )
     152                                        retval.target.type = retval.target.name = target;
     153                                else
     154                                {
     155                                        retval.target.type = 'frame';
     156                                        retval.target.name = target;
     157                                }
     158                        }
     159
     160                        var me = this;
     161                        var advAttr = function( inputName, attrName )
     162                        {
     163                                var value = element.getAttribute( attrName );
     164                                if ( value != null )
     165                                        retval.adv[ inputName ] = value || '';
     166                        };
     167                        advAttr( 'advId', 'id' );
     168                        advAttr( 'advLangDir', 'dir' );
     169                        advAttr( 'advAccessKey', 'accessKey' );
     170                        advAttr( 'advName', 'name' );
     171                        advAttr( 'advLangCode', 'lang' );
     172                        advAttr( 'advTabIndex', 'tabindex' );
     173                        advAttr( 'advTitle', 'title' );
     174                        advAttr( 'advContentType', 'type' );
     175                        advAttr( 'advCSSClasses', 'class' );
     176                        advAttr( 'advCharset', 'charset' );
     177                        advAttr( 'advStyles', 'style' );
     178                }
     179
     180                // Find out whether we have any anchors in the editor.
     181                // Get all IMG elements in CK document.
     182                var elements = editor.document.$.getElementsByTagName( 'img' ),
     183                        realAnchors = editor.document.$.anchors,
     184                        anchors = retval.anchors = [];
     185                for( var i = 0; i < elements.length ; i++ )
     186                {
     187                        var item = elements.item( i );
     188                        if ( item.getAttribute( '_cke_realelement' ) && item.getAttribute( '_cke_real_element_type' ) == 'anchor' )
     189                        {
     190                                var domElement = new CKEDITOR.dom.element( item );
     191                                domElement = editor.restoreRealElement( domElement );
     192                                anchors.push( domElement );
     193                        }
     194                }
     195                for ( var i = 0 ; i < realAnchors.length ; i++ )
     196                        anchors.push( realAnchors[i] );
     197                for ( var i = 0, item, length = anchors.length ; i < length && ( item = anchors.shift() ) ; i++ )
     198                        anchors.push( { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) } );
     199
     200                // Record down the selected element in the dialog.
     201                this._.selectedElement = element;
     202
     203                return retval;
     204        };
     205
     206        var setupParams = function( page, data )
     207        {
     208                if ( data[page] )
     209                        this.setValue( data[page][this.id] || '' );
     210        };
     211
     212        var setupPopupParams = function( data )
     213        {
     214                return setupParams.call( this, 'target', data );
     215        };
     216
     217        var setupAdvParams = function( data )
     218        {
     219                return setupParams.call( this, 'adv', data );
     220        };
     221
     222        var commitParams = function( page, data )
     223        {
     224                if ( !data[page] )
     225                        data[page] = {};
     226
     227                data[page][this.id] = this.getValue() || '';
     228        };
     229
     230        var commitPopupParams = function( data )
     231        {
     232                return commitParams.call( this, 'target', data );
     233        };
     234
     235        var commitAdvParams = function( data )
     236        {
     237                return commitParams.call( this, 'adv', data );
     238        };
     239
     240        return {
     241                title : editor.lang.link.title,
     242                minWidth : 400,
     243                minHeight : 320,
     244                contents : [
     245                        {
     246                                id : 'info',
     247                                label : editor.lang.link.info,
     248                                title : editor.lang.link.info,
     249                                elements :
     250                                [
     251                                        {
     252                                                id : 'linkType',
     253                                                type : 'select',
     254                                                label : editor.lang.link.type,
     255                                                'default' : 'url',
     256                                                items :
     257                                                [
     258                                                        [ editor.lang.common.url, 'url' ],
     259                                                        [ editor.lang.link.toAnchor, 'anchor' ],
     260                                                        [ editor.lang.link.toEmail, 'email' ]
     261                                                ],
     262                                                onChange : linkTypeChanged,
     263                                                setup : function( data )
     264                                                {
     265                                                        if ( data.type )
     266                                                                this.setValue( data.type );
     267                                                },
     268                                                commit : function( data )
     269                                                {
     270                                                        data.type = this.getValue();
     271                                                }
     272                                        },
     273                                        {
     274                                                type : 'vbox',
     275                                                id : 'urlOptions',
     276                                                children :
     277                                                [
     278                                                        {
     279                                                                type : 'hbox',
     280                                                                widths : [ '25%', '75%' ],
     281                                                                children :
     282                                                                [
     283                                                                        {
     284                                                                                id : 'protocol',
     285                                                                                type : 'select',
     286                                                                                label : editor.lang.common.protocol,
     287                                                                                'default' : 'http://',
     288                                                                                style : 'width : 100%;',
     289                                                                                items :
     290                                                                                [
     291                                                                                        [ 'http://' ],
     292                                                                                        [ 'https//' ],
     293                                                                                        [ 'ftp://' ],
     294                                                                                        [ 'news://' ],
     295                                                                                        [ '<other>', '' ]
     296                                                                                ],
     297                                                                                setup : function( data )
     298                                                                                {
     299                                                                                        if ( data.url )
     300                                                                                                this.setValue( data.url.protocol );
     301                                                                                },
     302                                                                                commit : function( data )
     303                                                                                {
     304                                                                                        if ( !data.url )
     305                                                                                                data.url = {};
     306
     307                                                                                        data.url.protocol = this.getValue();
     308                                                                                }
     309                                                                        },
     310                                                                        {
     311                                                                                type : 'text',
     312                                                                                id : 'url',
     313                                                                                label : editor.lang.common.url,
     314                                                                                validate : function()
     315                                                                                {
     316                                                                                        var dialog = this.getDialog();
     317
     318                                                                                        if ( dialog.getContentElement( 'info', 'linkType' ) &&
     319                                                                                                        dialog.getValueOf( 'info', 'linkType' ) != 'url' )
     320                                                                                                return true;
     321
     322                                                                                        if ( this.getDialog().fakeObj != false )        // Edit Anchor.
     323                                                                                                return true;
     324
     325                                                                                        var func = CKEDITOR.dialog.validate.notEmpty( editor.lang.link.noUrl );
     326                                                                                        return func.apply( this );
     327                                                                                },
     328                                                                                setup : function( data )
     329                                                                                {
     330                                                                                        if ( data.url )
     331                                                                                                this.setValue( data.url.url );
     332
     333                                                                                        var linkType = this.getDialog().getContentElement( 'info', 'linkType' );
     334                                                                                        if ( linkType && linkType.getValue() == 'url' )
     335                                                                                                this.select();
     336                                                                                },
     337                                                                                commit : function( data )
     338                                                                                {
     339                                                                                        if ( !data.url )
     340                                                                                                data.url = {};
     341
     342                                                                                        data.url.url = this.getValue();
     343                                                                                }
     344                                                                        }
     345                                                                ],
     346                                                                setup : function( data )
     347                                                                {
     348                                                                        if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )
     349                                                                                this.getElement().show();
     350                                                                }
     351                                                        },
     352                                                        {
     353                                                                type : 'button',
     354                                                                id : 'browse',
     355                                                                label : editor.lang.common.browseServer
     356                                                        }
     357                                                ]
     358                                        },
     359                                        {
     360                                                type : 'vbox',
     361                                                id : 'anchorOptions',
     362                                                width : 260,
     363                                                align : 'center',
     364                                                padding : 0,
     365                                                children :
     366                                                [
     367                                                        {
     368                                                                type : 'html',
     369                                                                id : 'selectAnchorText',
     370                                                                html : CKEDITOR.tools.htmlEncode( editor.lang.link.selectAnchor ),
     371                                                                setup : function( data )
     372                                                                {
     373                                                                        if ( data.anchors.length > 0 )
     374                                                                                this.getElement().show();
     375                                                                        else
     376                                                                                this.getElement().hide();
     377                                                                }
     378                                                        },
     379                                                        {
     380                                                                type : 'html',
     381                                                                id : 'noAnchors',
     382                                                                style : 'text-align: center;',
     383                                                                html : '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.link.noAnchors ) + '</div>',
     384                                                                setup : function( data )
     385                                                                {
     386                                                                        if ( data.anchors.length < 1 )
     387                                                                                this.getElement().show();
     388                                                                        else
     389                                                                                this.getElement().hide();
     390                                                                }
     391                                                        },
     392                                                        {
     393                                                                type : 'hbox',
     394                                                                id : 'selectAnchor',
     395                                                                children :
     396                                                                [
     397                                                                        {
     398                                                                                type : 'select',
     399                                                                                id : 'anchorName',
     400                                                                                'default' : '',
     401                                                                                label : editor.lang.link.anchorName,
     402                                                                                style : 'width: 100%;',
     403                                                                                items :
     404                                                                                [
     405                                                                                        [ '' ]
     406                                                                                ],
     407                                                                                setup : function( data )
     408                                                                                {
     409                                                                                        this.clear();
     410                                                                                        this.add( '' );
     411                                                                                        for ( var i = 0 ; i < data.anchors.length ; i++ )
     412                                                                                        {
     413                                                                                                if ( data.anchors[i].name )
     414                                                                                                        this.add( data.anchors[i].name );
     415                                                                                        }
     416
     417                                                                                        if ( data.anchor )
     418                                                                                                this.setValue( data.anchor.name );
     419
     420                                                                                        var linkType = this.getDialog().getContentElement( 'info', 'linkType' );
     421                                                                                        if ( linkType && linkType.getValue() == 'email' )
     422                                                                                                this.focus();
     423                                                                                },
     424                                                                                commit : function( data )
     425                                                                                {
     426                                                                                        if ( !data.anchor )
     427                                                                                                data.anchor = {};
     428
     429                                                                                        data.anchor.name = this.getValue();
     430                                                                                }
     431                                                                        },
     432                                                                        {
     433                                                                                type : 'select',
     434                                                                                id : 'anchorId',
     435                                                                                'default' : '',
     436                                                                                label : editor.lang.link.anchorId,
     437                                                                                style : 'width: 100%;',
     438                                                                                items :
     439                                                                                [
     440                                                                                        [ '' ]
     441                                                                                ],
     442                                                                                setup : function( data )
     443                                                                                {
     444                                                                                        this.clear();
     445                                                                                        this.add( '' );
     446                                                                                        for ( var i = 0 ; i < data.anchors.length ; i++ )
     447                                                                                        {
     448                                                                                                if ( data.anchors[i].id )
     449                                                                                                        this.add( data.anchors[i].id );
     450                                                                                        }
     451
     452                                                                                        if ( data.anchor )
     453                                                                                                this.setValue( data.anchor.id );
     454                                                                                },
     455                                                                                commit : function( data )
     456                                                                                {
     457                                                                                        if ( !data.anchor )
     458                                                                                                data.anchor = {};
     459
     460                                                                                        data.anchor.id = this.getValue();
     461                                                                                }
     462                                                                        }
     463                                                                ],
     464                                                                setup : function( data )
     465                                                                {
     466                                                                        if ( data.anchors.length > 0 )
     467                                                                                this.getElement().show();
     468                                                                        else
     469                                                                                this.getElement().hide();
     470                                                                }
     471                                                        }
     472                                                ],
     473                                                setup : function( data )
     474                                                {
     475                                                        if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )
     476                                                                this.getElement().hide();
     477                                                }
     478                                        },
     479                                        {
     480                                                type :  'vbox',
     481                                                id : 'emailOptions',
     482                                                padding : 1,
     483                                                children :
     484                                                [
     485                                                        {
     486                                                                type : 'text',
     487                                                                id : 'emailAddress',
     488                                                                label : editor.lang.link.emailAddress,
     489                                                                validate : function()
     490                                                                {
     491                                                                        var dialog = this.getDialog();
     492
     493                                                                        if ( !dialog.getContentElement( 'info', 'linkType' ) ||
     494                                                                                        dialog.getValueOf( 'info', 'linkType' ) != 'email' )
     495                                                                                return true;
     496
     497                                                                        var func = CKEDITOR.dialog.validate.notEmpty( editor.lang.link.noEmail );
     498                                                                        return func.apply( this );
     499                                                                },
     500                                                                setup : function( data )
     501                                                                {
     502                                                                        if ( data.email )
     503                                                                                this.setValue( data.email.address );
     504
     505                                                                        var linkType = this.getDialog().getContentElement( 'info', 'linkType' );
     506                                                                        if ( linkType && linkType.getValue() == 'email' )
     507                                                                                this.select();
     508                                                                },
     509                                                                commit : function( data )
     510                                                                {
     511                                                                        if ( !data.email )
     512                                                                                data.email = {};
     513
     514                                                                        data.email.address = this.getValue();
     515                                                                }
     516                                                        },
     517                                                        {
     518                                                                type : 'text',
     519                                                                id : 'emailSubject',
     520                                                                label : editor.lang.link.emailSubject,
     521                                                                setup : function( data )
     522                                                                {
     523                                                                        if ( data.email )
     524                                                                                this.setValue( data.email.subject );
     525                                                                },
     526                                                                commit : function( data )
     527                                                                {
     528                                                                        if ( !data.email )
     529                                                                                data.email = {};
     530
     531                                                                        data.email.subject = this.getValue();
     532                                                                }
     533                                                        },
     534                                                        {
     535                                                                type : 'textarea',
     536                                                                id : 'emailBody',
     537                                                                label : editor.lang.link.emailBody,
     538                                                                rows : 3,
     539                                                                'default' : '',
     540                                                                setup : function( data )
     541                                                                {
     542                                                                        if ( data.email )
     543                                                                                this.setValue( data.email.body );
     544                                                                },
     545                                                                commit : function( data )
     546                                                                {
     547                                                                        if ( !data.email )
     548                                                                                data.email = {};
     549
     550                                                                        data.email.body = this.getValue();
     551                                                                }
     552                                                        }
     553                                                ],
     554                                                setup : function( data )
     555                                                {
     556                                                        if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )
     557                                                                this.getElement().hide();
     558                                                }
     559                                        }
     560                                ]
     561                        },
     562                        {
     563                                id : 'target',
     564                                label : editor.lang.link.target,
     565                                title : editor.lang.link.target,
     566                                elements :
     567                                [
     568                                        {
     569                                                type : 'hbox',
     570                                                widths : [ '50%', '50%' ],
     571                                                children :
     572                                                [
     573                                                        {
     574                                                                type : 'select',
     575                                                                id : 'linkTargetType',
     576                                                                label : editor.lang.link.target,
     577                                                                'default' : 'notSet',
     578                                                                style : 'width : 100%;',
     579                                                                'items' :
     580                                                                [
     581                                                                        [ editor.lang.link.targetNotSet, 'notSet' ],
     582                                                                        [ editor.lang.link.targetFrame, 'frame' ],
     583                                                                        [ editor.lang.link.targetPopup, 'popup' ],
     584                                                                        [ editor.lang.link.targetNew, '_blank' ],
     585                                                                        [ editor.lang.link.targetTop, '_top' ],
     586                                                                        [ editor.lang.link.targetSelf, '_self' ],
     587                                                                        [ editor.lang.link.targetParent, '_parent' ]
     588                                                                ],
     589                                                                onChange : targetChanged,
     590                                                                setup : function( data )
     591                                                                {
     592                                                                        if ( data.target )
     593                                                                                this.setValue( data.target.type );
     594                                                                },
     595                                                                commit : function( data )
     596                                                                {
     597                                                                        if ( !data.target )
     598                                                                                data.target = {};
     599
     600                                                                        data.target.type = this.getValue();
     601                                                                }
     602                                                        },
     603                                                        {
     604                                                                type : 'text',
     605                                                                id : 'linkTargetName',
     606                                                                label : editor.lang.link.targetFrameName,
     607                                                                'default' : '',
     608                                                                setup : function( data )
     609                                                                {
     610                                                                        if ( data.target )
     611                                                                                this.setValue( data.target.name );
     612                                                                },
     613                                                                commit : function( data )
     614                                                                {
     615                                                                        if ( !data.target )
     616                                                                                data.target = {};
     617
     618                                                                        data.target.name = this.getValue();
     619                                                                }
     620                                                        }
     621                                                ]
     622                                        },
     623                                        {
     624                                                type : 'vbox',
     625                                                width : 260,
     626                                                align : 'center',
     627                                                padding : 2,
     628                                                id : 'popupFeatures',
     629                                                children :
     630                                                [
     631                                                        {
     632                                                                type : 'html',
     633                                                                html : CKEDITOR.tools.htmlEncode( editor.lang.link.popupFeatures )
     634                                                        },
     635                                                        {
     636                                                                type : 'hbox',
     637                                                                children :
     638                                                                [
     639                                                                        {
     640                                                                                type : 'checkbox',
     641                                                                                id : 'resizable',
     642                                                                                label : editor.lang.link.popupResizable,
     643                                                                                setup : setupPopupParams,
     644                                                                                commit : commitPopupParams
     645                                                                        },
     646                                                                        {
     647                                                                                type : 'checkbox',
     648                                                                                id : 'status',
     649                                                                                label : editor.lang.link.popupStatusBar,
     650                                                                                setup : setupPopupParams,
     651                                                                                commit : commitPopupParams
     652
     653                                                                        }
     654                                                                ]
     655                                                        },
     656                                                        {
     657                                                                type : 'hbox',
     658                                                                children :
     659                                                                [
     660                                                                        {
     661                                                                                type : 'checkbox',
     662                                                                                id : 'location',
     663                                                                                label : editor.lang.link.popupLocationBar,
     664                                                                                setup : setupPopupParams,
     665                                                                                commit : commitPopupParams
     666
     667                                                                        },
     668                                                                        {
     669                                                                                type : 'checkbox',
     670                                                                                id : 'toolbar',
     671                                                                                label : editor.lang.link.popupToolbar,
     672                                                                                setup : setupPopupParams,
     673                                                                                commit : commitPopupParams
     674
     675                                                                        }
     676                                                                ]
     677                                                        },
     678                                                        {
     679                                                                type : 'hbox',
     680                                                                children :
     681                                                                [
     682                                                                        {
     683                                                                                type : 'checkbox',
     684                                                                                id : 'menubar',
     685                                                                                label : editor.lang.link.popupMenuBar,
     686                                                                                setup : setupPopupParams,
     687                                                                                commit : commitPopupParams
     688
     689                                                                        },
     690                                                                        {
     691                                                                                type : 'checkbox',
     692                                                                                id : 'fullscreen',
     693                                                                                label : editor.lang.link.popupFullScreen,
     694                                                                                setup : setupPopupParams,
     695                                                                                commit : commitPopupParams
     696
     697                                                                        }
     698                                                                ]
     699                                                        },
     700                                                        {
     701                                                                type : 'hbox',
     702                                                                children :
     703                                                                [
     704                                                                        {
     705                                                                                type : 'checkbox',
     706                                                                                id : 'scrollbars',
     707                                                                                label : editor.lang.link.popupScrollBars,
     708                                                                                setup : setupPopupParams,
     709                                                                                commit : commitPopupParams
     710
     711                                                                        },
     712                                                                        {
     713                                                                                type : 'checkbox',
     714                                                                                id : 'dependent',
     715                                                                                label : editor.lang.link.popupDependent,
     716                                                                                setup : setupPopupParams,
     717                                                                                commit : commitPopupParams
     718
     719                                                                        }
     720                                                                ]
     721                                                        },
     722                                                        {
     723                                                                type : 'hbox',
     724                                                                children :
     725                                                                [
     726                                                                        {
     727                                                                                type :  'text',
     728                                                                                widths : [ '30%', '70%' ],
     729                                                                                labelLayout : 'horizontal',
     730                                                                                label : editor.lang.link.popupWidth,
     731                                                                                id : 'width',
     732                                                                                setup : setupPopupParams,
     733                                                                                commit : commitPopupParams
     734
     735                                                                        },
     736                                                                        {
     737                                                                                type :  'text',
     738                                                                                labelLayout : 'horizontal',
     739                                                                                widths : [ '55%', '45%' ],
     740                                                                                label : editor.lang.link.popupLeft,
     741                                                                                id : 'left',
     742                                                                                setup : setupPopupParams,
     743                                                                                commit : commitPopupParams
     744
     745                                                                        }
     746                                                                ]
     747                                                        },
     748                                                        {
     749                                                                type : 'hbox',
     750                                                                children :
     751                                                                [
     752                                                                        {
     753                                                                                type :  'text',
     754                                                                                labelLayout : 'horizontal',
     755                                                                                widths : [ '30%', '70%' ],
     756                                                                                label : editor.lang.link.popupHeight,
     757                                                                                id : 'height',
     758                                                                                setup : setupPopupParams,
     759                                                                                commit : commitPopupParams
     760
     761                                                                        },
     762                                                                        {
     763                                                                                type :  'text',
     764                                                                                labelLayout : 'horizontal',
     765                                                                                label : editor.lang.link.popupTop,
     766                                                                                widths : [ '55%', '45%' ],
     767                                                                                id : 'top',
     768                                                                                setup : setupPopupParams,
     769                                                                                commit : commitPopupParams
     770
     771                                                                        }
     772                                                                ]
     773                                                        }
     774                                                ]
     775                                        }
     776                                ]
     777                        },
     778                        {
     779                                id : 'upload',
     780                                label : editor.lang.link.upload,
     781                                title : editor.lang.link.upload,
     782                                elements :
     783                                [
     784                                        {
     785                                                type : 'file',
     786                                                id : 'upload',
     787                                                label : editor.lang.common.upload,
     788                                                action : editor.config.linkUploadAction,
     789                                                size : 38
     790                                        },
     791                                        {
     792                                                type : 'fileButton',
     793                                                id : 'uploadButton',
     794                                                label : editor.lang.common.uploadSubmit,
     795                                                'for' : [ 'upload', 'upload' ]
     796                                        }
     797                                ]
     798                        },
     799                        {
     800                                id : 'advanced',
     801                                label : editor.lang.link.advanced,
     802                                title : editor.lang.link.advanced,
     803                                elements :
     804                                [
     805                                        {
     806                                                type : 'vbox',
     807                                                padding : 1,
     808                                                children :
     809                                                [
     810                                                        {
     811                                                                type : 'hbox',
     812                                                                widths : [ '45%', '35%', '20%' ],
     813                                                                children :
     814                                                                [
     815                                                                        {
     816                                                                                type : 'text',
     817                                                                                id : 'advId',
     818                                                                                label : editor.lang.link.id,
     819                                                                                setup : setupAdvParams,
     820                                                                                commit : commitAdvParams
     821                                                                        },
     822                                                                        {
     823                                                                                type : 'select',
     824                                                                                id : 'advLangDir',
     825                                                                                label : editor.lang.link.langDir,
     826                                                                                'default' : '',
     827                                                                                style : 'width: 100%;',
     828                                                                                items :
     829                                                                                [
     830                                                                                        [ editor.lang.link.langDirNotSet, '' ],
     831                                                                                        [ editor.lang.link.langDirLTR, 'ltr' ],
     832                                                                                        [ editor.lang.link.langDirRTL, 'rtl' ]
     833                                                                                ],
     834                                                                                setup : setupAdvParams,
     835                                                                                commit : commitAdvParams
     836                                                                        },
     837                                                                        {
     838                                                                                type : 'text',
     839                                                                                id : 'advAccessKey',
     840                                                                                label : editor.lang.link.acccessKey,
     841                                                                                maxLength : 1,
     842                                                                                setup : setupAdvParams,
     843                                                                                commit : commitAdvParams
     844
     845                                                                        }
     846                                                                ]
     847                                                        },
     848                                                        {
     849                                                                type : 'hbox',
     850                                                                widths : [ '45%', '35%', '20%' ],
     851                                                                children :
     852                                                                [
     853                                                                        {
     854                                                                                type : 'text',
     855                                                                                label : editor.lang.link.name,
     856                                                                                id : 'advName',
     857                                                                                setup : setupAdvParams,
     858                                                                                commit : commitAdvParams
     859
     860                                                                        },
     861                                                                        {
     862                                                                                type : 'text',
     863                                                                                label : editor.lang.link.langCode,
     864                                                                                id : 'advLangCode',
     865                                                                                'default' : '',
     866                                                                                setup : setupAdvParams,
     867                                                                                commit : commitAdvParams
     868
     869                                                                        },
     870                                                                        {
     871                                                                                type : 'text',
     872                                                                                label : editor.lang.link.tabIndex,
     873                                                                                id : 'advTabIndex',
     874                                                                                maxLength : 5,
     875                                                                                setup : setupAdvParams,
     876                                                                                commit : commitAdvParams
     877
     878                                                                        }
     879                                                                ]
     880                                                        }
     881                                                ]
     882                                        },
     883                                        {
     884                                                type : 'vbox',
     885                                                padding : 1,
     886                                                children :
     887                                                [
     888                                                        {
     889                                                                type : 'hbox',
     890                                                                widths : [ '45%', '55%' ],
     891                                                                children :
     892                                                                [
     893                                                                        {
     894                                                                                type : 'text',
     895                                                                                label : editor.lang.link.advisoryTitle,
     896                                                                                'default' : '',
     897                                                                                id : 'advTitle',
     898                                                                                setup : setupAdvParams,
     899                                                                                commit : commitAdvParams
     900
     901                                                                        },
     902                                                                        {
     903                                                                                type : 'text',
     904                                                                                label : editor.lang.link.advisoryContentType,
     905                                                                                'default' : '',
     906                                                                                id : 'advContentType',
     907                                                                                setup : setupAdvParams,
     908                                                                                commit : commitAdvParams
     909
     910                                                                        }
     911                                                                ]
     912                                                        },
     913                                                        {
     914                                                                type : 'hbox',
     915                                                                widths : [ '45%', '55%' ],
     916                                                                children :
     917                                                                [
     918                                                                        {
     919                                                                                type : 'text',
     920                                                                                label : editor.lang.link.cssClasses,
     921                                                                                'default' : '',
     922                                                                                id : 'advCSSClasses',
     923                                                                                setup : setupAdvParams,
     924                                                                                commit : commitAdvParams
     925
     926                                                                        },
     927                                                                        {
     928                                                                                type : 'text',
     929                                                                                label : editor.lang.link.charset,
     930                                                                                'default' : '',
     931                                                                                id : 'advCharset',
     932                                                                                setup : setupAdvParams,
     933                                                                                commit : commitAdvParams
     934
     935                                                                        }
     936                                                                ]
     937                                                        },
     938                                                        {
     939                                                                type : 'hbox',
     940                                                                children :
     941                                                                [
     942                                                                        {
     943                                                                                type : 'text',
     944                                                                                label : editor.lang.link.styles,
     945                                                                                'default' : '',
     946                                                                                id : 'advStyles',
     947                                                                                setup : setupAdvParams,
     948                                                                                commit : commitAdvParams
     949
     950                                                                        }
     951                                                                ]
     952                                                        }
     953                                                ]
     954                                        }
     955                                ]
     956                        }
     957                ],
     958                onShow : function()
     959                {
     960                        this.fakeObj = false;
     961                        // IE BUG: Selection must be in the editor for getSelection() to work.
     962                        this.restoreSelection();
     963                        var editor = this.getParentEditor(),
     964                                selection = editor.getSelection(),
     965                                ranges = selection.getRanges(),
     966                                element = null,
     967                                me = this;
     968
     969                        // Fill in all the relevant fields if there's already one link selected.
     970                        if ( ranges.length == 1 )
     971                        {
     972                                ranges[0].enlarge( CKEDITOR.ENLARGE_ELEMENT );
     973
     974                                var rangeRoot = ranges[0].getCommonAncestor( true );
     975                                element = rangeRoot.getAscendant( 'a', true );
     976                                if ( element && element.getAttribute( 'href' ) )
     977                                {
     978                                        selection.selectElement( element );
     979                                        this.saveSelection();
     980                                }
     981                                else
     982                                {
     983                                        element = rangeRoot.getAscendant( 'img', true );
     984                                        if ( element && element.getAttribute( '_cke_real_element_type' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' )
     985                                        {
     986                                                this.fakeObj = element;
     987                                                element = editor.restoreRealElement( this.fakeObj );
     988                                                selection.selectElement( this.fakeObj );
     989                                                this.saveSelection();
     990                                        }
     991                                }
     992                        }
     993
     994                        this.setupContent( parseLink.apply( this, [ editor, element ] ) );
     995                },
     996                onOk : function()
     997                {
     998                        var attributes = { href : 'javascript:void(0)/*' + CKEDITOR.tools.getNextNumber() + '*/' },
     999                                removeAttributes = [],
     1000                                data = { href : attributes.href },
     1001                                me = this, editor = this.getParentEditor();
     1002
     1003                        this.commitContent( data );
     1004
     1005                        // Compose the URL.
     1006                        switch ( data.type || 'url' )
     1007                        {
     1008                                case 'url':
     1009                                        var protocol = ( data.url && data.url.protocol ) || 'http://',
     1010                                                url = ( data.url && data.url.url ) || '';
     1011                                        attributes._cke_saved_href = protocol + url;
     1012                                        break;
     1013                                case 'anchor':
     1014                                        var name = ( data.anchor && data.anchor.name ),
     1015                                                id = ( data.anchor && data.anchor.id );
     1016                                        attributes._cke_saved_href = '#' + ( name || id || '' );
     1017                                        break;
     1018                                case 'email':
     1019                                        var address = ( data.email && data.email.address ),
     1020                                                subject = ( data.email && encodeURIComponent( data.email.subject || '' ) ),
     1021                                                body = ( data.email && encodeURIComponent( data.email.body || '' ) ),
     1022                                                linkList = [ 'mailto:', address ];
     1023                                        if ( subject || body )
     1024                                        {
     1025                                                var argList = [];
     1026                                                linkList.push( '?' );
     1027                                                subject && argList.push( 'subject=' + subject );
     1028                                                body && argList.push( 'body=' + body );
     1029                                                linkList.push( argList.join( '&' ) );
     1030                                        }
     1031                                        attributes._cke_saved_href = linkList.join( '' );
     1032                                        break;
     1033                                default:
     1034                        }
     1035
     1036                        // Popups and target.
     1037                        if ( data.target )
     1038                        {
     1039                                if ( data.target.type == 'popup' )
     1040                                {
     1041                                        var onclickList = [ 'window.open(this.href, \'',
     1042                                                        data.target.name || '', '\', \'' ];
     1043                                        var featureList = [ 'resizable', 'status', 'location', 'toolbar', 'menubar', 'fullscreen',
     1044                                                        'scrollbars', 'dependent' ];
     1045                                        var featureLength = featureList.length;
     1046                                        var addFeature = function( featureName )
     1047                                        {
     1048                                                if ( data.target[ featureName ] )
     1049                                                        featureList.push( featureName + '=' + data.target[ featureName ] );
     1050                                        };
     1051
     1052                                        for ( var i = 0 ; i < featureLength ; i++ )
     1053                                                featureList[i] = featureList[i] + ( data.target[ featureList[i] ] ? '=yes' : '=no' ) ;
     1054                                        addFeature( 'width' );
     1055                                        addFeature( 'left' );
     1056                                        addFeature( 'height' );
     1057                                        addFeature( 'top' );
     1058
     1059                                        onclickList.push( featureList.join( ',' ), '\'); return false;' );
     1060                                        attributes._cke_saved_onclick = onclickList.join( '' );
     1061                                }
     1062                                else
     1063                                {
     1064                                        if ( data.target.type != 'notSet' && data.target.name )
     1065                                                attributes.target = data.target.name;
     1066                                        removeAttributes.push( '_cke_saved_onclick', 'onclick' );
     1067                                }
     1068                        }
     1069
     1070                        // Advanced attributes.
     1071                        if ( data.adv )
     1072                        {
     1073                                var advAttr = function( inputName, attrName )
     1074                                {
     1075                                        var value = data.adv[ inputName ];
     1076                                        if ( value )
     1077                                                attributes[attrName] = value;
     1078                                        else
     1079                                                removeAttributes.push( attrName );
     1080                                };
     1081
     1082                                if ( this._.selectedElement )
     1083                                        advAttr( 'advId', 'id' );
     1084                                advAttr( 'advLangDir', 'dir' );
     1085                                advAttr( 'advAccessKey', 'accessKey' );
     1086                                advAttr( 'advName', 'name' );
     1087                                advAttr( 'advLangCode', 'lang' );
     1088                                advAttr( 'advTabIndex', 'tabindex' );
     1089                                advAttr( 'advTitle', 'title' );
     1090                                advAttr( 'advContentType', 'type' );
     1091                                advAttr( 'advCSSClasses', 'class' );
     1092                                advAttr( 'advCharset', 'charset' );
     1093                                advAttr( 'advStyles', 'style' );
     1094                        }
     1095
     1096                        if ( !this._.selectedElement )
     1097                        {
     1098                                // IE BUG: Selection must be in the editor for getSelection() to work.
     1099                                this.restoreSelection();
     1100                                this.clearSavedSelection();
     1101
     1102                                // Create element if current selection is collapsed.
     1103                                var selection = editor.getSelection(),
     1104                                        ranges = selection.getRanges();
     1105                                if ( ranges.length == 1 && ranges[0].collapsed )
     1106                                {
     1107                                        var text = new CKEDITOR.dom.text( attributes._cke_saved_href, editor.document );
     1108                                        ranges[0].insertNode( text );
     1109                                        ranges[0].selectNodeContents( text );
     1110                                        selection.selectRanges( ranges );
     1111                                }
     1112
     1113                                // Apply style.
     1114                                var style = new CKEDITOR.style( { element : 'a', attributes : attributes } );
     1115                                style.type = CKEDITOR.STYLE_INLINE;             // need to override... dunno why.
     1116                                style.apply( editor.document );
     1117
     1118                                // Id. Apply only to the first link.
     1119                                if ( data.adv && data.adv.advId != '' )
     1120                                {
     1121                                        var links = this.getParentEditor().document.$.getElementsByTagName( 'a' );
     1122                                        for ( var i = 0 ; i < links.length ; i++ )
     1123                                        {
     1124                                                if ( links[i].href == attributes.href )
     1125                                                {
     1126                                                        links[i].id = data.adv.advId;
     1127                                                        break;
     1128                                                }
     1129                                        }
     1130                                }
     1131                        }
     1132                        else
     1133                        {
     1134                                // We're only editing an existing link, so just overwrite the attributes.
     1135                                var element = this._.selectedElement;
     1136
     1137                                // IE BUG: Setting the name attribute to an existing link doesn't work.
     1138                                // Must re-create the link from weired syntax to workaround.
     1139                                if ( CKEDITOR.env.ie && attributes.name != element.getAttribute( 'name' ) )
     1140                                {
     1141                                        var newElement = new CKEDITOR.dom.element( '<a name="' + CKEDITOR.tools.htmlEncode( attributes.name ) + '">',
     1142                                                        editor.document );
     1143
     1144                                        this.restoreSelection();
     1145                                        var selection = editor.getSelection();
     1146
     1147                                        element.moveChildren( newElement );
     1148                                        element.copyAttributes( newElement, { name : 1 } );
     1149                                        newElement.replace( element );
     1150                                        element = newElement;
     1151
     1152                                        this.clearSavedSelection();
     1153                                        selection.selectElement( element );
     1154                                }
     1155
     1156                                element.setAttributes( attributes );
     1157                                element.removeAttributes( removeAttributes );
     1158
     1159                                // Make the element display as an anchor if a name has been set.
     1160                                if ( element.getAttribute( 'name' ) )
     1161                                        element.addClass( 'cke_anchor' );
     1162                                else
     1163                                        element.removeClass( 'cke_anchor' );
     1164
     1165                                if ( this.fakeObj )
     1166                                        editor.createFakeElement( element, 'cke_anchor', 'anchor' ).replace( this.fakeObj );
     1167
     1168                                delete this._.selectedElement;
     1169                        }
     1170                },
     1171                onLoad : function()
     1172                {
     1173                        if ( editor.config.linkUploadTab == false )
     1174                                this.hidePage( 'upload' );              //Hide Upload tab.
     1175
     1176                        if ( editor.config.linkShowAdvancedTab == false )
     1177                                this.hidePage( 'advanced' );            //Hide Advanded tab.
     1178
     1179                        if ( editor.config.linkBrowseServer == false )
     1180                                this.getContentElement( 'info', 'browse' ).getElement().hide();
     1181
     1182                        if ( editor.config.linkShowTargetTab == false )
     1183                                this.hidePage( 'target' );              //Hide Target tab.
     1184
     1185                }
     1186        };
     1187} );
  • _source/plugins/link/plugin.js

    Property changes on: _source/plugins/link/dialogs/link.js
    ___________________________________________________________________
    Added: svn:executable
       + *
    
    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    
    Property changes on: _source/plugins/link/images/anchor.gif
    ___________________________________________________________________
    Added: svn:mime-type
       + application/octet-stream
    
     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.plugins.add( 'link',
     7{
     8        init : function( editor, pluginPath )
     9        {
     10                // Add the link and unlink buttons.
     11                editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link' ) );
     12                editor.addCommand( 'anchor', new CKEDITOR.dialogCommand( 'anchor' ) );
     13                editor.addCommand( 'unlink', new CKEDITOR.unlinkCommand() );
     14                editor.ui.addButton( 'Link',
     15                        {
     16                                label : editor.lang.link.toolbar,
     17                                command : 'link'
     18                        } );
     19                editor.ui.addButton( 'Unlink',
     20                        {
     21                                label : editor.lang.unlink,
     22                                command : 'unlink'
     23                        } );
     24                editor.ui.addButton( 'Anchor',
     25                        {
     26                                label : editor.lang.anchor.toolbar,
     27                                command : 'anchor'
     28                        } );
     29                CKEDITOR.dialog.add( 'link', this.path + 'dialogs/link.js' );
     30                CKEDITOR.dialog.add( 'anchor', this.path + 'dialogs/anchor.js' );
     31
     32                // Add the CSS styles for anchor placeholders.
     33                editor.addCss(
     34                        'img.cke_anchor' +
     35                        '{' +
     36                                'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ');' +
     37                                'background-position: center center;' +
     38                                'background-repeat: no-repeat;' +
     39                                'border: 1px solid #a9a9a9;' +
     40                                'width: 18px;' +
     41                                'height: 18px;' +
     42                        '}\n' +
     43                        'a.cke_anchor' +
     44                        '{' +
     45                                'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/anchor.gif' ) + ');' +
     46                                'background-position: 0 center;' +
     47                                'background-repeat: no-repeat;' +
     48                                'border: 1px solid #a9a9a9;' +
     49                                'padding-left: 18px;' +
     50                        '}'
     51                        );
     52
     53                // Register selection change handler for the unlink button.
     54                 editor.on( 'selectionChange', function( evt )
     55                        {
     56                                /*
     57                                 * Despite our initial hope, document.queryCommandEnabled() does not work
     58                                 * for this in Firefox. So we must detect the state by element paths.
     59                                 */
     60                                var command = editor.getCommand( 'unlink' ),
     61                                        element = evt.data.path.lastElement.getAscendant( 'a', true );
     62                                if ( element && element.getName() == 'a' && element.getAttribute( 'href' ) )
     63                                        command.state = CKEDITOR.TRISTATE_OFF;
     64                                else
     65                                        command.state = CKEDITOR.TRISTATE_DISABLED;
     66                                command.fire( 'state' );
     67                        } );
     68
     69                // Register a contentDom handler for displaying placeholders after mode change.
     70                editor.on( 'contentDom', function()
     71                        {
     72                                var rawAnchors = editor.document.$.anchors;
     73                                for ( var i = rawAnchors.length - 1, anchor ; i >= 0 ; i-- )
     74                                {
     75                                        anchor = new CKEDITOR.dom.element( rawAnchors[ i ] );
     76
     77                                        // IE BUG: When an <a> tag doesn't have href, IE would return empty string
     78                                        // instead of null on getAttribute.
     79                                        if ( !anchor.getAttribute( 'href' ) )
     80                                                editor.createFakeElement( anchor, 'cke_anchor', 'anchor' ).replace( anchor );
     81                                        else
     82                                                anchor.addClass( 'cke_anchor' );
     83                                }
     84                        } );
     85        },
     86
     87        requires : [ 'fakeobjects' ]
     88} );
     89
     90CKEDITOR.unlinkCommand = function(){};
     91CKEDITOR.unlinkCommand.prototype =
     92{
     93        /** @ignore */
     94        exec : function( editor )
     95        {
     96                /*
     97                 * execCommand( 'unlink', ... ) in Firefox leaves behind <span> tags at where
     98                 * the <a> was, so again we have to remove the link ourselves. (See #430)
     99                 *
     100                 * TODO: Use the style system when it's complete. Let's use execCommand()
     101                 * as a stopgap solution for now.
     102                 */
     103                var selection = editor.getSelection(),
     104                        bookmarks = selection.createBookmarks(),
     105                        ranges = selection.getRanges(),
     106                        rangeRoot,
     107                        element;
     108
     109                for ( var i = 0 ; i < ranges.length ; i++ )
     110                {
     111                        rangeRoot = ranges[i].getCommonAncestor( true );
     112                        element = rangeRoot.getAscendant( 'a', true );
     113                        if ( !element )
     114                                continue;
     115                        ranges[i].selectNodeContents( element );
     116                }
     117
     118                selection.selectRanges( ranges );
     119                editor.document.$.execCommand( 'unlink', false, null );
     120                selection.selectBookmarks( bookmarks );
     121        }
     122};
     123
     124CKEDITOR.tools.extend( CKEDITOR.config,
     125{
     126        linkUploadTab : true,
     127        linkBrowseServer : true,
     128        linkUploadAction : 'nowhere.php',
     129        linkShowAdvancedTab : true,
     130        linkShowTargetTab : true
     131} );
  • _source/plugins/toolbar/plugin.js

    Property changes on: _source/plugins/link/plugin.js
    ___________________________________________________________________
    Added: svn:executable
       + *
    
     
    211211                'Bold', 'Italic', 'Underline', 'Strike', '-',
    212212                'Subscript', 'Superscript', '-',
    213213                'SelectAll', 'RemoveFormat', '-',
    214                 'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak'
     214                'Link', 'Unlink', 'Anchor', 'Smiley', 'HorizontalRule', 'SpecialChar', 'PageBreak'
    215215        ]
    216216];
  • _source/core/config.js

     
    146146         * @example
    147147         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    148148         */
    149         plugins : 'basicstyles,button,elementspath,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,removeformat,smiley,sourcearea,specialchar,tab,toolbar,wysiwygarea',
     149        plugins : 'basicstyles,button,elementspath,horizontalrule,htmldataprocessor,keystrokes,newpage,pagebreak,removeformat,smiley,link,sourcearea,specialchar,tab,toolbar,wysiwygarea',
    150150
    151151        /**
    152152         * The theme to be used to build the UI.
  • _source/core/htmlparser/element.js

     
    6666                return a < b ? -1 : a > b ? 1 : 0;
    6767        };
    6868
     69        var ckeAttrRegex = /^_cke/,
     70                ckeClassRegex = /(^|\s+)cke_[^\s]*/g;
     71
    6972        CKEDITOR.htmlParser.element.prototype =
    7073        {
    7174                /**
     
    130133                        for ( var a in attributes )
    131134                        {
    132135                                // Ignore all attributes starting with "_cke".
    133                                 if ( !/^_cke/.test( a ) )
    134                                         attribsArray.push( [ a, this.attributes[ a ] ] );
     136                                if ( ckeAttrRegex.test( a ) )
     137                                        continue;
     138
     139                                // Ignore all cke_* CSS classes.
     140                                if ( a.toLowerCase() == 'class' )
     141                                {
     142                                        this.attributes[ a ] = CKEDITOR.tools.ltrim( this.attributes[ a ].replace( ckeClassRegex, '' ) );
     143                                        if ( this.attributes[ a ] == '' )
     144                                                continue;
     145                                }
     146
     147                                attribsArray.push( [ a, this.attributes[ a ] ] );
    135148                        }
    136149
    137150                        // Sort the attributes by name.
  • _source/core/dom/element.js

     
    685685                        }
    686686                },
    687687
     688                copyAttributes : function( target, skip )
     689                {
     690                        skip || ( skip = {} );
     691                        var attributes = this.$.attributes ;
     692
     693                        for ( var n = 0 ; n < attributes.length ; n++ )
     694                        {
     695                                var attr = attributes[n] ;
     696
     697                                if ( attr.specified )
     698                                {
     699                                        var attrName = attr.nodeName ;
     700                                        if ( attrName in skip )
     701                                                continue ;
     702
     703                                        var attrValue = this.getAttribute( attrName );
     704                                        if ( !attrValue )
     705                                                attrValue = attr.nodeValue ;
     706
     707                                        target.setAttribute( attrName, attrValue );
     708                                }
     709                        }
     710
     711                        if ( this.$.style.cssText !== '' )
     712                                target.$.style.cssText = this.$.style.cssText ;
     713                },
     714
    688715                /**
    689716                 * Shows this element (display it).
    690717                 * @example
  • _samples/api_dialog.html

     
    5656
    5757                        // Remove the "Link Type" combo and the "Browser
    5858                        // Server" button from the "info" tab.
    59                         infoTab.remove( 'protocol' );
     59                        infoTab.remove( 'linkType' );
    6060                        infoTab.remove( 'browse' );
    6161
    6262                        // Set the default value for the URL field.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy