Ticket #8255: patch_ckeditor_link_dialog.patch

File patch_ckeditor_link_dialog.patch, 4.2 KB (added by Martin, 13 years ago)

Patch

  • link.js

    old new  
    1 /*
     1/*
    22Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
    33For licensing, see LICENSE.html or http://ckeditor.com/license
    44*/
     
    4444        var linkTypeChanged = function()
    4545        {
    4646                var dialog = this.getDialog(),
    47                         partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ],
     47                        partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions', 'urlListOptions' ],
    4848                        typeValue = this.getValue(),
    4949                        uploadTab = dialog.definition.getContents( 'upload' ),
    5050                        uploadInitiallyHidden = uploadTab && uploadTab.hidden;
     
    8686                emailBodyRegex = /body=([^;?:@&=$,\/]*)/,
    8787                anchorRegex = /^#(.*)$/,
    8888                urlRegex = /^((?:http|https|ftp|news):\/\/)?(.*)$/,
     89                urlListRegex = /^\/.+/,
    8990                selectableTargets = /^(_(?:self|top|parent|blank))$/,
    9091                encodedEmailLinkRegex = /^javascript:void\(location\.href='mailto:'\+String\.fromCharCode\(([^)]+)\)(?:\+'(.*)')?\)$/,
    9192                functionCallProtectedEmailLinkRegex = /^javascript:([^(]+)\(([^)]+)\)$/;
     
    101102                        emailMatch,
    102103                        anchorMatch,
    103104                        urlMatch,
     105                        urlListMatch,
    104106                        retval = {};
    105107
    106108                if ( ( javascriptMatch = href.match( javascriptProtocolRegex ) ) )
     
    146148
    147149                if ( !retval.type )
    148150                {
    149                         if ( ( anchorMatch = href.match( anchorRegex ) ) )
     151                   
     152                       if (  href && ( urlListMatch = href.match( urlListRegex ) ) )
     153                       {
     154                               var blnFound = false;
     155                               var strAddress = urlListMatch[0];
     156                               for(i=0;i<editor.config.urlList.length;i++){
     157                                       if(editor.config.urlList[i][1] == strAddress) blnFound = true;
     158                               }
     159                               if(blnFound){
     160                                       retval.type = 'urlList';
     161                               }
     162                               else {
     163                                       retval.type = 'url';
     164                               }
     165                               retval.url = {};
     166                               retval.url.protocol = "";
     167                               retval.url.url = strAddress;
     168                       }                   
     169                       else if ( ( anchorMatch = href.match( anchorRegex ) ) )
    150170                        {
    151171                                retval.type = 'anchor';
    152172                                retval.anchor = {};
     
    412432                                                [
    413433                                                        [ linkLang.toUrl, 'url' ],
    414434                                                        [ linkLang.toAnchor, 'anchor' ],
    415                                                         [ linkLang.toEmail, 'email' ]
     435                                                        [ linkLang.toEmail, 'email' ],
     436                                                        [ 'Url list', 'urlList']
    416437                                                ],
    417438                                                onChange : linkTypeChanged,
    418439                                                setup : function( data )
     
    752773                                                        if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )
    753774                                                                this.getElement().hide();
    754775                                                }
     776                                        },
     777                                        {
     778                                                type :  'vbox',
     779                                                id : 'urlListOptions',
     780                                                padding : 1,
     781                                                children :
     782                                                [
     783                                                        {
     784                                                                id : 'urlListAddress',
     785                                                                type : 'select',
     786                                                                label : 'Page',
     787                                                                'default' : '/',
     788                                                                style : 'width : 100%;',
     789                                                                items : editor.config.urlList,
     790                                                                setup : function( data ) {
     791                                                                        if ( data.url ) this.setValue( data.url.url );
     792                                                                },
     793                                                                commit : function( data ) {
     794                                                                       
     795                                                                        if ( !data.urlList )
     796                                                                                data.urlList = {};
     797                                                                                                                                                               
     798                                                                        data.urlList.url = this.getValue();
     799                                                                       
     800                                                                }
     801                                                        }                                                       
     802                                                ],
     803                                                setup : function( data )
     804                                                {
     805                                                        if ( !this.getDialog().getContentElement( 'info', 'linkType' ) ) this.getElement().hide();
     806                                                }
    755807                                        }
     808                                       
    756809                                ]
    757810                        },
    758811                        {
     
    12061259                                                id = ( data.anchor && data.anchor.id );
    12071260                                        attributes[ 'data-cke-saved-href' ] = '#' + ( name || id || '' );
    12081261                                        break;
     1262                               case 'urlList':
     1263                                       var urlList = ( data.urlList && data.urlList.url ) || '';
     1264                                       attributes[ 'data-cke-saved-href' ] = urlList;
     1265                                       break;
    12091266                                case 'email':
    12101267
    12111268                                        var linkHref,
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy