| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 /* 2 Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 CKEDITOR.dialog.add( 'linktonode', function( editor ) 7 { 8 //<!-- linktonode START --> 9 CKEDITOR.scriptLoader.load( Drupal.settings.basePath + "misc/jquery.js"); 10 CKEDITOR.scriptLoader.load( Drupal.settings.ckeditor.module_path + "/plugins/linktonode/jscripts/functions.js", function() { 11 //window.focus(); 12 loadCategories(null); 13 }); 14 //<!-- linktonode END --> 15 16 // Handles the event when the "Target" selection box is changed. 17 var targetChanged = function() 18 { 19 var dialog = this.getDialog(), 20 popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ), 21 targetName = dialog.getContentElement( 'target', 'linkTargetName' ), 22 value = this.getValue(); 23 24 if ( !popupFeatures || !targetName ) 25 return; 26 27 popupFeatures = popupFeatures.getElement(); 28 29 if ( value == 'popup' ) 30 { 31 popupFeatures.show(); 32 targetName.setLabel( editor.lang.link.targetPopupName ); 33 } 34 else 35 { 36 popupFeatures.hide(); 37 targetName.setLabel( editor.lang.link.targetFrameName ); 38 this.getDialog().setValueOf( 'target', 'linkTargetName', value.charAt( 0 ) == '_' ? value : '' ); 39 } 40 }; 41 42 // Loads the parameters in a selected link to the link dialog fields. 43 var emailRegex = /^mailto:([^?]+)(?:\?(.+))?$/, 44 emailSubjectRegex = /subject=([^;?:@&=$,\/]*)/, 45 emailBodyRegex = /body=([^;?:@&=$,\/]*)/, 46 anchorRegex = /^#(.*)$/, 47 urlRegex = /^((?:http|https|ftp|news):\/\/)?(.*)$/, 48 selectableTargets = /^(_(?:self|top|parent|blank))$/; 49 50 var popupRegex = 51 /\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*/; 52 var popupFeaturesRegex = /(?:^|,)([^=]+)=(\d+|yes|no)/gi; 53 54 var parseLink = function( editor, element ) 55 { 56 var href = element ? ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) : '', 57 emailMatch = '', 58 anchorMatch = '', 59 urlMatch = false, 60 retval = {}; 61 62 if ( href ) 63 { 64 emailMatch = href.match( emailRegex ); 65 anchorMatch = href.match( anchorRegex ); 66 urlMatch = href.match( urlRegex ); 67 } 68 69 // Load the link type and URL. 70 if ( emailMatch ) 71 { 72 var subjectMatch = href.match( emailSubjectRegex ), 73 bodyMatch = href.match( emailBodyRegex ); 74 retval.type = 'email'; 75 retval.email = {}; 76 retval.email.address = emailMatch[1]; 77 subjectMatch && ( retval.email.subject = decodeURIComponent( subjectMatch[1] ) ); 78 bodyMatch && ( retval.email.body = decodeURIComponent( bodyMatch[1] ) ); 79 } 80 else if ( anchorMatch ) 81 { 82 retval.type = 'anchor'; 83 retval.anchor = {}; 84 retval.anchor.name = retval.anchor.id = anchorMatch[1]; 85 } 86 else if ( href && urlMatch ) // urlRegex matches empty strings, so need to check for href as well. 87 { 88 retval.type = 'url'; 89 retval.url = {}; 90 retval.url.protocol = urlMatch[1]; 91 retval.url.url = urlMatch[2]; 92 } 93 else 94 retval.type = 'url'; 95 96 // Load target and popup settings. 97 if ( element ) 98 { 99 var target = element.getAttribute( 'target' ); 100 retval.target = {}; 101 retval.adv = {}; 102 103 // IE BUG: target attribute is an empty string instead of null in IE if it's not set. 104 if ( !target ) 105 { 106 var onclick = element.getAttribute( '_cke_pa_onclick' ) || element.getAttribute( 'onclick' ), 107 onclickMatch = onclick && onclick.match( popupRegex ); 108 if ( onclickMatch ) 109 { 110 retval.target.type = 'popup'; 111 retval.target.name = onclickMatch[1]; 112 113 var featureMatch; 114 while ( ( featureMatch = popupFeaturesRegex.exec( onclickMatch[2] ) ) ) 115 { 116 if ( featureMatch[2] == 'yes' || featureMatch[2] == '1' ) 117 retval.target[ featureMatch[1] ] = true; 118 else if ( isFinite( featureMatch[2] ) ) 119 retval.target[ featureMatch[1] ] = featureMatch[2]; 120 } 121 } 122 } 123 else 124 { 125 var targetMatch = target.match( selectableTargets ); 126 if ( targetMatch ) 127 retval.target.type = retval.target.name = target; 128 else 129 { 130 retval.target.type = 'frame'; 131 retval.target.name = target; 132 } 133 } 134 135 var me = this; 136 var advAttr = function( inputName, attrName ) 137 { 138 var value = element.getAttribute( attrName ); 139 if ( value !== null ) 140 retval.adv[ inputName ] = value || ''; 141 }; 142 advAttr( 'advId', 'id' ); 143 advAttr( 'advLangDir', 'dir' ); 144 advAttr( 'advAccessKey', 'accessKey' ); 145 advAttr( 'advName', 'name' ); 146 advAttr( 'advLangCode', 'lang' ); 147 advAttr( 'advTabIndex', 'tabindex' ); 148 advAttr( 'advTitle', 'title' ); 149 advAttr( 'advContentType', 'type' ); 150 advAttr( 'advCSSClasses', 'class' ); 151 advAttr( 'advCharset', 'charset' ); 152 advAttr( 'advStyles', 'style' ); 153 } 154 155 // Find out whether we have any anchors in the editor. 156 // Get all IMG elements in CK document. 157 var elements = editor.document.getElementsByTag( 'img' ), 158 realAnchors = new CKEDITOR.dom.nodeList( editor.document.$.anchors ), 159 anchors = retval.anchors = []; 160 161 for( var i = 0; i < elements.count() ; i++ ) 162 { 163 var item = elements.getItem( i ); 164 if ( item.getAttribute( '_cke_realelement' ) && item.getAttribute( '_cke_real_element_type' ) == 'anchor' ) 165 { 166 anchors.push( editor.restoreRealElement( item ) ); 167 } 168 } 169 170 for ( i = 0 ; i < realAnchors.count() ; i++ ) 171 anchors.push( realAnchors.getItem( i ) ); 172 173 for ( i = 0 ; i < anchors.length ; i++ ) 174 { 175 item = anchors[ i ]; 176 anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) }; 177 } 178 179 // Record down the selected element in the dialog. 180 this._.selectedElement = element; 181 182 return retval; 183 }; 184 185 var setupParams = function( page, data ) 186 { 187 if ( data[page] ) 188 this.setValue( data[page][this.id] || '' ); 189 }; 190 191 var setupPopupParams = function( data ) 192 { 193 return setupParams.call( this, 'target', data ); 194 }; 195 196 var setupAdvParams = function( data ) 197 { 198 return setupParams.call( this, 'adv', data ); 199 }; 200 201 var commitParams = function( page, data ) 202 { 203 if ( !data[page] ) 204 data[page] = {}; 205 206 data[page][this.id] = this.getValue() || ''; 207 }; 208 209 var commitPopupParams = function( data ) 210 { 211 return commitParams.call( this, 'target', data ); 212 }; 213 214 var commitAdvParams = function( data ) 215 { 216 return commitParams.call( this, 'adv', data ); 217 }; 218 219 return { 220 title : 'Link to node', 221 minWidth : 350, 222 minHeight : 230, 223 contents : [ 224 { 225 id : 'info', 226 label : editor.lang.link.info, 227 title : editor.lang.link.info, 228 elements : 229 [ 230 { 231 type : 'vbox', 232 id : 'urlOptions', 233 children : 234 [ 235 { 236 type : 'hbox', 237 widths : [ '25%', '75%' ], 238 children : 239 [ 240 { 241 id : 'linkType', 242 type : 'select', 243 label : editor.lang.link.type, 244 hidden : !Drupal.settings.ckeditor.linktocontent_node_select_type, 245 'default' : 'url', 246 items : 247 [ 248 [ 'path', 'path' ], 249 [ 'internal', 'internal' ], 250 ], 251 onChange : function() { 252 var url = this.getDialog().getContentElement( 'info', 'url' ); 253 if ( ( !Drupal.settings.ckeditor.linktocontent_node_select_type && Drupal.settings.ckeditor.linktocontent_node_path_filter ) 254 || this.getValue() == 'internal' ) { 255 url.setValue($('#txtUrlInternal').val()); 256 } 257 else { 258 url.setValue($('#txtUrlPath').val()); 259 } 260 }, 261 setup : function( data ) 262 { 263 if ( data.type ) 264 this.setValue( data.type ); 265 }, 266 commit : function( data ) 267 { 268 data.type = this.getValue(); 269 } 270 }, 271 { 272 type : 'text', 273 id : 'url', 274 label : editor.lang.common.url, 275 onLoad : function () 276 { 277 this.allowOnChange = true; 278 }, 279 validate : function() 280 { 281 var dialog = this.getDialog(); 282 var func = CKEDITOR.dialog.validate.notEmpty( editor.lang.link.noUrl ); 283 return func.apply( this ); 284 }, 285 setup : function( data ) 286 { 287 this.allowOnChange = false; 288 if ( data.url ) 289 this.setValue( data.url.url ); 290 this.allowOnChange = true; 291 292 var linkType = this.getDialog().getContentElement( 'info', 'linkType' ); 293 if ( linkType && linkType.getValue() == 'url' ) 294 this.select(); 295 296 }, 297 commit : function( data ) 298 { 299 if ( !data.url ) 300 data.url = {}; 301 302 data.url.url = this.getValue(); 303 this.allowOnChange = false; 304 } 305 } 306 ], 307 setup : function( data ) 308 { 309 if ( !this.getDialog().getContentElement( 'info', 'linkType' ) ) 310 this.getElement().show(); 311 } 312 } 313 ] 314 }, 315 { 316 type : 'html', 317 html : 318 '<link rel="stylesheet" href="' + Drupal.settings.ckeditor.module_path + '/plugins/linktonode/css/linktocontent.css" type="text/css" />' + 319 '<div class="panel_wrap" id="list">' + 320 '<div class="nodes">' + 321 '<div id="nodelist" class="scrollable accessible">' + 322 '<table cellspacing="0" summary="nodelist" style="width:100%">' + 323 '<thead>' + 324 '<tr>' + 325 '<th style="font-weight:bold">Node title</th>' + 326 '<th style="font-weight:bold">Created</th>' + 327 '<th style="font-weight:bold">Author</th>' + 328 '</tr>' + 329 '</thead>' + 330 '<tbody>' + 331 '</tbody>' + 332 '</table>' + 333 '</div>' + 334 '</div>' + 335 '</div>' + 336 '<input id="txtUrlPath" type="hidden" />' + 337 '<input id="txtUrlInternal" type="hidden" />' + 338 '<input id="txtUrlText" type="hidden" />' + 339 '<div id="statusImg"><img alt="loading" src="' + Drupal.settings.ckeditor.module_path + '/plugins/linktonode/images/loading.gif" />loading...</div>' 340 } 341 ] 342 }, 343 { 344 id : 'target', 345 label : editor.lang.link.target, 346 title : editor.lang.link.target, 347 elements : 348 [ 349 { 350 type : 'hbox', 351 widths : [ '50%', '50%' ], 352 children : 353 [ 354 { 355 type : 'select', 356 id : 'linkTargetType', 357 label : editor.lang.link.target, 358 'default' : 'notSet', 359 style : 'width : 100%;', 360 'items' : 361 [ 362 [ editor.lang.link.targetNotSet, 'notSet' ], 363 [ editor.lang.link.targetFrame, 'frame' ], 364 [ editor.lang.link.targetPopup, 'popup' ], 365 [ editor.lang.link.targetNew, '_blank' ], 366 [ editor.lang.link.targetTop, '_top' ], 367 [ editor.lang.link.targetSelf, '_self' ], 368 [ editor.lang.link.targetParent, '_parent' ] 369 ], 370 onChange : targetChanged, 371 setup : function( data ) 372 { 373 if ( data.target ) 374 this.setValue( data.target.type ); 375 }, 376 commit : function( data ) 377 { 378 if ( !data.target ) 379 data.target = {}; 380 381 data.target.type = this.getValue(); 382 } 383 }, 384 { 385 type : 'text', 386 id : 'linkTargetName', 387 label : editor.lang.link.targetFrameName, 388 'default' : '', 389 setup : function( data ) 390 { 391 if ( data.target ) 392 this.setValue( data.target.name ); 393 }, 394 commit : function( data ) 395 { 396 if ( !data.target ) 397 data.target = {}; 398 399 data.target.name = this.getValue(); 400 } 401 } 402 ] 403 }, 404 { 405 type : 'vbox', 406 width : 260, 407 align : 'center', 408 padding : 2, 409 id : 'popupFeatures', 410 children : 411 [ 412 { 413 type : 'html', 414 html : CKEDITOR.tools.htmlEncode( editor.lang.link.popupFeatures ) 415 }, 416 { 417 type : 'hbox', 418 children : 419 [ 420 { 421 type : 'checkbox', 422 id : 'resizable', 423 label : editor.lang.link.popupResizable, 424 setup : setupPopupParams, 425 commit : commitPopupParams 426 }, 427 { 428 type : 'checkbox', 429 id : 'status', 430 label : editor.lang.link.popupStatusBar, 431 setup : setupPopupParams, 432 commit : commitPopupParams 433 434 } 435 ] 436 }, 437 { 438 type : 'hbox', 439 children : 440 [ 441 { 442 type : 'checkbox', 443 id : 'location', 444 label : editor.lang.link.popupLocationBar, 445 setup : setupPopupParams, 446 commit : commitPopupParams 447 448 }, 449 { 450 type : 'checkbox', 451 id : 'toolbar', 452 label : editor.lang.link.popupToolbar, 453 setup : setupPopupParams, 454 commit : commitPopupParams 455 456 } 457 ] 458 }, 459 { 460 type : 'hbox', 461 children : 462 [ 463 { 464 type : 'checkbox', 465 id : 'menubar', 466 label : editor.lang.link.popupMenuBar, 467 setup : setupPopupParams, 468 commit : commitPopupParams 469 470 }, 471 { 472 type : 'checkbox', 473 id : 'fullscreen', 474 label : editor.lang.link.popupFullScreen, 475 setup : setupPopupParams, 476 commit : commitPopupParams 477 478 } 479 ] 480 }, 481 { 482 type : 'hbox', 483 children : 484 [ 485 { 486 type : 'checkbox', 487 id : 'scrollbars', 488 label : editor.lang.link.popupScrollBars, 489 setup : setupPopupParams, 490 commit : commitPopupParams 491 492 }, 493 { 494 type : 'checkbox', 495 id : 'dependent', 496 label : editor.lang.link.popupDependent, 497 setup : setupPopupParams, 498 commit : commitPopupParams 499 500 } 501 ] 502 }, 503 { 504 type : 'hbox', 505 children : 506 [ 507 { 508 type : 'text', 509 widths : [ '30%', '70%' ], 510 labelLayout : 'horizontal', 511 label : editor.lang.link.popupWidth, 512 id : 'width', 513 setup : setupPopupParams, 514 commit : commitPopupParams 515 516 }, 517 { 518 type : 'text', 519 labelLayout : 'horizontal', 520 widths : [ '55%', '45%' ], 521 label : editor.lang.link.popupLeft, 522 id : 'left', 523 setup : setupPopupParams, 524 commit : commitPopupParams 525 526 } 527 ] 528 }, 529 { 530 type : 'hbox', 531 children : 532 [ 533 { 534 type : 'text', 535 labelLayout : 'horizontal', 536 widths : [ '30%', '70%' ], 537 label : editor.lang.link.popupHeight, 538 id : 'height', 539 setup : setupPopupParams, 540 commit : commitPopupParams 541 542 }, 543 { 544 type : 'text', 545 labelLayout : 'horizontal', 546 label : editor.lang.link.popupTop, 547 widths : [ '55%', '45%' ], 548 id : 'top', 549 setup : setupPopupParams, 550 commit : commitPopupParams 551 552 } 553 ] 554 } 555 ] 556 } 557 ] 558 }, 559 { 560 id : 'advanced', 561 label : editor.lang.link.advanced, 562 title : editor.lang.link.advanced, 563 elements : 564 [ 565 { 566 type : 'vbox', 567 padding : 1, 568 children : 569 [ 570 { 571 type : 'hbox', 572 widths : [ '45%', '35%', '20%' ], 573 children : 574 [ 575 { 576 type : 'text', 577 id : 'advId', 578 label : editor.lang.link.id, 579 setup : setupAdvParams, 580 commit : commitAdvParams 581 }, 582 { 583 type : 'select', 584 id : 'advLangDir', 585 label : editor.lang.link.langDir, 586 'default' : '', 587 style : 'width:110px', 588 items : 589 [ 590 [ editor.lang.link.langDirNotSet, '' ], 591 [ editor.lang.link.langDirLTR, 'ltr' ], 592 [ editor.lang.link.langDirRTL, 'rtl' ] 593 ], 594 setup : setupAdvParams, 595 commit : commitAdvParams 596 }, 597 { 598 type : 'text', 599 id : 'advAccessKey', 600 width : '80px', 601 label : editor.lang.link.acccessKey, 602 maxLength : 1, 603 setup : setupAdvParams, 604 commit : commitAdvParams 605 606 } 607 ] 608 }, 609 { 610 type : 'hbox', 611 widths : [ '45%', '35%', '20%' ], 612 children : 613 [ 614 { 615 type : 'text', 616 label : editor.lang.link.name, 617 id : 'advName', 618 setup : setupAdvParams, 619 commit : commitAdvParams 620 621 }, 622 { 623 type : 'text', 624 label : editor.lang.link.langCode, 625 id : 'advLangCode', 626 width : '110px', 627 'default' : '', 628 setup : setupAdvParams, 629 commit : commitAdvParams 630 631 }, 632 { 633 type : 'text', 634 label : editor.lang.link.tabIndex, 635 id : 'advTabIndex', 636 width : '80px', 637 maxLength : 5, 638 setup : setupAdvParams, 639 commit : commitAdvParams 640 641 } 642 ] 643 } 644 ] 645 }, 646 { 647 type : 'vbox', 648 padding : 1, 649 children : 650 [ 651 { 652 type : 'hbox', 653 widths : [ '45%', '55%' ], 654 children : 655 [ 656 { 657 type : 'text', 658 label : editor.lang.link.advisoryTitle, 659 'default' : '', 660 id : 'advTitle', 661 setup : setupAdvParams, 662 commit : commitAdvParams 663 664 }, 665 { 666 type : 'text', 667 label : editor.lang.link.advisoryContentType, 668 'default' : '', 669 id : 'advContentType', 670 setup : setupAdvParams, 671 commit : commitAdvParams 672 673 } 674 ] 675 }, 676 { 677 type : 'hbox', 678 widths : [ '45%', '55%' ], 679 children : 680 [ 681 { 682 type : 'text', 683 label : editor.lang.link.cssClasses, 684 'default' : '', 685 id : 'advCSSClasses', 686 setup : setupAdvParams, 687 commit : commitAdvParams 688 689 }, 690 { 691 type : 'text', 692 label : editor.lang.link.charset, 693 'default' : '', 694 id : 'advCharset', 695 setup : setupAdvParams, 696 commit : commitAdvParams 697 698 } 699 ] 700 }, 701 { 702 type : 'hbox', 703 children : 704 [ 705 { 706 type : 'text', 707 label : editor.lang.link.styles, 708 'default' : '', 709 id : 'advStyles', 710 setup : setupAdvParams, 711 commit : commitAdvParams 712 713 } 714 ] 715 } 716 ] 717 } 718 ] 719 } 720 ], 721 onShow : function() 722 { 723 this.fakeObj = false; 724 725 var editor = this.getParentEditor(), 726 selection = editor.getSelection(), 727 ranges = selection.getRanges(), 728 element = null, 729 me = this; 730 // Fill in all the relevant fields if there's already one link selected. 731 if ( ranges.length == 1 ) 732 { 733 734 var rangeRoot = ranges[0].getCommonAncestor( true ); 735 element = rangeRoot.getAscendant( 'a', true ); 736 if ( element && element.getAttribute( 'href' ) ) 737 { 738 selection.selectElement( element ); 739 } 740 else if ( ( element = rangeRoot.getAscendant( 'img', true ) ) && 741 element.getAttribute( '_cke_real_element_type' ) && 742 element.getAttribute( '_cke_real_element_type' ) == 'anchor' ) 743 { 744 this.fakeObj = element; 745 element = editor.restoreRealElement( this.fakeObj ); 746 selection.selectElement( this.fakeObj ); 747 } 748 else 749 element = null; 750 } 751 752 this.setupContent( parseLink.apply( this, [ editor, element ] ) ); 753 }, 754 onOk : function() 755 { 756 var attributes = { href : 'javascript:void(0)/*' + CKEDITOR.tools.getNextNumber() + '*/' }, 757 removeAttributes = [], 758 data = { href : attributes.href }, 759 me = this, editor = this.getParentEditor(); 760 this.commitContent( data ); 761 //<!-- linktonode START --> 762 attributes._cke_saved_href = this.getContentElement( 'info', 'url' ).getValue(); 763 //<!-- linktonode END --> 764 765 // Popups and target. 766 if ( data.target ) 767 { 768 if ( data.target.type == 'popup' ) 769 { 770 var onclickList = [ 'window.open(this.href, \'', 771 data.target.name || '', '\', \'' ]; 772 var featureList = [ 'resizable', 'status', 'location', 'toolbar', 'menubar', 'fullscreen', 773 'scrollbars', 'dependent' ]; 774 var featureLength = featureList.length; 775 var addFeature = function( featureName ) 776 { 777 if ( data.target[ featureName ] ) 778 featureList.push( featureName + '=' + data.target[ featureName ] ); 779 }; 780 781 for ( var i = 0 ; i < featureLength ; i++ ) 782 featureList[i] = featureList[i] + ( data.target[ featureList[i] ] ? '=yes' : '=no' ) ; 783 addFeature( 'width' ); 784 addFeature( 'left' ); 785 addFeature( 'height' ); 786 addFeature( 'top' ); 787 788 onclickList.push( featureList.join( ',' ), '\'); return false;' ); 789 attributes[ CKEDITOR.env.ie || CKEDITOR.env.webkit ? '_cke_pa_onclick' : 'onclick' ] = onclickList.join( '' ); 790 } 791 else 792 { 793 if ( data.target.type != 'notSet' && data.target.name ) 794 attributes.target = data.target.name; 795 removeAttributes.push( '_cke_pa_onclick', 'onclick' ); 796 } 797 } 798 799 // Advanced attributes. 800 if ( data.adv ) 801 { 802 var advAttr = function( inputName, attrName ) 803 { 804 var value = data.adv[ inputName ]; 805 if ( value ) 806 attributes[attrName] = value; 807 else 808 removeAttributes.push( attrName ); 809 }; 810 811 if ( this._.selectedElement ) 812 advAttr( 'advId', 'id' ); 813 advAttr( 'advLangDir', 'dir' ); 814 advAttr( 'advAccessKey', 'accessKey' ); 815 advAttr( 'advName', 'name' ); 816 advAttr( 'advLangCode', 'lang' ); 817 advAttr( 'advTabIndex', 'tabindex' ); 818 advAttr( 'advTitle', 'title' ); 819 advAttr( 'advContentType', 'type' ); 820 advAttr( 'advCSSClasses', 'class' ); 821 advAttr( 'advCharset', 'charset' ); 822 advAttr( 'advStyles', 'style' ); 823 } 824 825 if ( !this._.selectedElement ) 826 { 827 // Create element if current selection is collapsed. 828 var selection = editor.getSelection(), 829 ranges = selection.getRanges(); 830 if ( ranges.length == 1 && ranges[0].collapsed ) 831 { 832 // <!-- linktonode START --> 833 var text = new CKEDITOR.dom.text( $('#txtUrlText').val() || attributes._cke_saved_href, editor.document ); 834 // <!-- linktonode END --> 835 ranges[0].insertNode( text ); 836 ranges[0].selectNodeContents( text ); 837 selection.selectRanges( ranges ); 838 } 839 840 // Apply style. 841 var style = new CKEDITOR.style( { element : 'a', attributes : attributes } ); 842 style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why. 843 style.apply( editor.document ); 844 845 // Id. Apply only to the first link. 846 if ( data.adv && data.adv.advId ) 847 { 848 var links = this.getParentEditor().document.$.getElementsByTagName( 'a' ); 849 for ( i = 0 ; i < links.length ; i++ ) 850 { 851 if ( links[i].href == attributes.href ) 852 { 853 links[i].id = data.adv.advId; 854 break; 855 } 856 } 857 } 858 } 859 else 860 { 861 // We're only editing an existing link, so just overwrite the attributes. 862 var element = this._.selectedElement; 863 864 // IE BUG: Setting the name attribute to an existing link doesn't work. 865 // Must re-create the link from weired syntax to workaround. 866 if ( CKEDITOR.env.ie && attributes.name != element.getAttribute( 'name' ) ) 867 { 868 var newElement = new CKEDITOR.dom.element( '<a name="' + CKEDITOR.tools.htmlEncode( attributes.name ) + '">', 869 editor.document ); 870 871 selection = editor.getSelection(); 872 873 element.moveChildren( newElement ); 874 element.copyAttributes( newElement, { name : 1 } ); 875 newElement.replace( element ); 876 element = newElement; 877 878 selection.selectElement( element ); 879 } 880 881 element.setAttributes( attributes ); 882 element.removeAttributes( removeAttributes ); 883 884 // Make the element display as an anchor if a name has been set. 885 if ( element.getAttribute( 'name' ) ) 886 element.addClass( 'cke_anchor' ); 887 else 888 element.removeClass( 'cke_anchor' ); 889 890 if ( this.fakeObj ) 891 editor.createFakeElement( element, 'cke_anchor', 'anchor' ).replace( this.fakeObj ); 892 893 delete this._.selectedElement; 894 } 895 }, 896 onLoad : function() 897 { 898 CKEDITOR._._linkToNodeDialog = this; 899 900 if ( !editor.config.linkShowAdvancedTab ) 901 this.hidePage( 'advanced' ); //Hide Advanded tab. 902 903 if ( !editor.config.linkShowTargetTab ) 904 this.hidePage( 'target' ); //Hide Target tab. 905 906 } 907 }; 908 } );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |