| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 /* 2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * @fileOverview Spell Check As You Type (SCAYT). 8 * Button name : Scayt. 9 */ 10 11 (function() 12 { 13 var commandName = 'scaytcheck', 14 openPage = ''; 15 16 // Checks if a value exists in an array 17 function in_array(needle, haystack) 18 { 19 var found = false, key; 20 for (key in haystack) 21 { 22 if ((haystack[key] === needle) || ( haystack[key] == needle)) 23 { 24 found = true; 25 break; 26 } 27 } 28 return found; 29 } 30 31 var onEngineLoad = function() 32 { 33 var editor = this; 34 35 var createInstance = function() // Create new instance every time Document is created. 36 { 37 // Initialise Scayt instance. 38 var oParams = {}; 39 // Get the iframe. 40 oParams.srcNodeRef = editor.document.getWindow().$.frameElement; 41 // syntax : AppName.AppVersion@AppRevision 42 oParams.assocApp = 'CKEDITOR.' + CKEDITOR.version + '@' + CKEDITOR.revision; 43 oParams.customerid = editor.config.scayt_customerid || '1:WvF0D4-UtPqN1-43nkD4-NKvUm2-daQqk3-LmNiI-z7Ysb4-mwry24-T8YrS3-Q2tpq2'; 44 oParams.customDictionaryIds = editor.config.scayt_customDictionaryIds || ''; 45 oParams.userDictionaryName = editor.config.scayt_userDictionaryName || ''; 46 oParams.sLang = editor.config.scayt_sLang || 'en_US'; 47 48 // Introduce SCAYT onLoad callback. (#5632) 49 oParams.onLoad = function() 50 { 51 // Draw down word marker to avoid being covered by background-color style.(#5466) 52 if ( !( CKEDITOR.env.ie && CKEDITOR.env.version < 8 ) ) 53 this.addStyle( this.selectorCss(), 'padding-bottom: 2px !important;' ); 54 55 // Call scayt_control.focus when SCAYT loaded 56 // and only if editor has focus and scayt control creates at first time (#5720) 57 if ( editor.focusManager.hasFocus && !plugin.isControlRestored( editor ) ) 58 this.focus(); 59 60 }; 61 62 oParams.onBeforeChange = function() 63 { 64 if ( plugin.getScayt( editor ) && !editor.checkDirty() ) 65 setTimeout( function(){ editor.resetDirty(); } ); 66 }; 67 68 var scayt_custom_params = window.scayt_custom_params; 69 if ( typeof scayt_custom_params == 'object') 70 { 71 for ( var k in scayt_custom_params ) 72 { 73 oParams[ k ] = scayt_custom_params[ k ]; 74 } 75 } 76 // needs for restoring a specific scayt control settings 77 if ( plugin.getControlId(editor) ) 78 oParams.id = plugin.getControlId(editor); 79 80 var scayt_control = new window.scayt( oParams ); 81 82 scayt_control.afterMarkupRemove.push( function( node ) 83 { 84 ( new CKEDITOR.dom.element( node, scayt_control.document ) ).mergeSiblings(); 85 } ); 86 87 // Copy config. 88 var lastInstance = plugin.instances[ editor.name ]; 89 if ( lastInstance ) 90 { 91 scayt_control.sLang = lastInstance.sLang; 92 scayt_control.option( lastInstance.option() ); 93 scayt_control.paused = lastInstance.paused; 94 } 95 96 plugin.instances[ editor.name ] = scayt_control; 97 98 //window.scayt.uiTags 99 var menuGroup = 'scaytButton'; 100 var uiTabs = window.scayt.uiTags; 101 var fTabs = []; 102 103 for (var i = 0,l=4; i<l; i++) 104 fTabs.push( uiTabs[i] && plugin.uiTabs[i] ); 105 106 plugin.uiTabs = fTabs; 107 try { 108 scayt_control.setDisabled( plugin.isPaused( editor ) === false ); 109 } catch (e) {} 110 111 editor.fire( 'showScaytState' ); 112 }; 113 114 editor.on( 'contentDom', createInstance ); 115 editor.on( 'contentDomUnload', function() 116 { 117 // Remove scripts. 118 var scripts = CKEDITOR.document.getElementsByTag( 'script' ), 119 scaytIdRegex = /^dojoIoScript(\d+)$/i, 120 scaytSrcRegex = /^https?:\/\/svc\.spellchecker\.net\/spellcheck\/script\/ssrv\.cgi/i; 121 122 for ( var i=0; i < scripts.count(); i++ ) 123 { 124 var script = scripts.getItem( i ), 125 id = script.getId(), 126 src = script.getAttribute( 'src' ); 127 128 if ( id && src && id.match( scaytIdRegex ) && src.match( scaytSrcRegex )) 129 script.remove(); 130 } 131 }); 132 133 editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution. 134 { 135 if ( (ev.data.name == 'source' || ev.data.name == 'newpage') && editor.mode == 'wysiwyg' ) 136 { 137 var scayt_instance = plugin.getScayt( editor ); 138 if ( scayt_instance ) 139 { 140 plugin.setPaused( editor, !scayt_instance.disabled ); 141 // store a control id for restore a specific scayt control settings 142 plugin.setControlId( editor, scayt_instance.id ); 143 scayt_instance.destroy( true ); 144 delete plugin.instances[ editor.name ]; 145 } 146 } 147 // Catch on source mode switch off (#5720) 148 else if ( ev.data.name == 'source' && editor.mode == 'source' ) 149 plugin.markControlRestore( editor ); 150 }); 151 152 editor.on( 'afterCommandExec', function( ev ) 153 { 154 if ( !plugin.isScaytEnabled( editor ) ) 155 return; 156 157 if ( editor.mode == 'wysiwyg' && ( ev.data.name == 'undo' || ev.data.name == 'redo' ) ) 158 window.setTimeout( function() { plugin.getScayt( editor ).refresh(); }, 10 ); 159 }); 160 161 editor.on( 'destroy', function( ev ) 162 { 163 var editor = ev.editor, 164 scayt_instance = plugin.getScayt( editor ); 165 166 // SCAYT instance might already get destroyed by mode switch (#5744). 167 if ( !scayt_instance ) 168 return; 169 170 delete plugin.instances[ editor.name ]; 171 // store a control id for restore a specific scayt control settings 172 plugin.setControlId( editor, scayt_instance.id ); 173 scayt_instance.destroy( true ); 174 }); 175 176 // Listen to data manipulation to reflect scayt markup. 177 editor.on( 'afterSetData', function() 178 { 179 if ( plugin.isScaytEnabled( editor ) ) { 180 window.setTimeout( function() 181 { 182 var instance = plugin.getScayt( editor ); 183 instance && instance.refresh(); 184 }, 10 ); 185 } 186 }); 187 188 // Reload spell-checking for current word after insertion completed. 189 editor.on( 'insertElement', function() 190 { 191 var scayt_instance = plugin.getScayt( editor ); 192 if ( plugin.isScaytEnabled( editor ) ) 193 { 194 // Unlock the selection before reload, SCAYT will take 195 // care selection update. 196 if ( CKEDITOR.env.ie ) 197 editor.getSelection().unlock( true ); 198 199 // Return focus to the editor and refresh SCAYT markup (#5573). 200 window.setTimeout( function() 201 { 202 scayt_instance.focus(); 203 scayt_instance.refresh(); 204 }, 10 ); 205 } 206 }, this, null, 50 ); 207 208 editor.on( 'insertHtml', function() 209 { 210 var scayt_instance = plugin.getScayt( editor ); 211 if ( plugin.isScaytEnabled( editor ) ) 212 { 213 // Unlock the selection before reload, SCAYT will take 214 // care selection update. 215 if ( CKEDITOR.env.ie ) 216 editor.getSelection().unlock( true ); 217 218 // Return focus to the editor (#5573) 219 // Refresh SCAYT markup 220 window.setTimeout( function() 221 { 222 scayt_instance.focus(); 223 scayt_instance.refresh(); 224 }, 10 ); 225 } 226 }, this, null, 50 ); 227 228 editor.on( 'scaytDialog', function( ev ) // Communication with dialog. 229 { 230 ev.data.djConfig = window.djConfig; 231 ev.data.scayt_control = plugin.getScayt( editor ); 232 ev.data.tab = openPage; 233 ev.data.scayt = window.scayt; 234 }); 235 236 var dataProcessor = editor.dataProcessor, 237 htmlFilter = dataProcessor && dataProcessor.htmlFilter; 238 239 if ( htmlFilter ) 240 { 241 htmlFilter.addRules( 242 { 243 elements : 244 { 245 span : function( element ) 246 { 247 if ( element.attributes.scayt_word && element.attributes.scaytid ) 248 { 249 delete element.name; // Write children, but don't write this node. 250 return element; 251 } 252 } 253 } 254 } 255 ); 256 } 257 258 // Override Image.equals method avoid CK snapshot module to add SCAYT markup to snapshots. (#5546) 259 var undoImagePrototype = CKEDITOR.plugins.undo.Image.prototype; 260 undoImagePrototype.equals = CKEDITOR.tools.override( undoImagePrototype.equals, function( org ) 261 { 262 return function( otherImage ) 263 { 264 var thisContents = this.contents, 265 otherContents = otherImage.contents; 266 var scayt_instance = plugin.getScayt( this.editor ); 267 // Making the comparison based on content without SCAYT word markers. 268 if ( scayt_instance && plugin.isScaytReady( this.editor ) ) 269 { 270 // scayt::reset might return value undefined. (#5742) 271 this.contents = scayt_instance.reset( thisContents ) || ''; 272 otherImage.contents = scayt_instance.reset( otherContents ) || ''; 273 } 274 275 var retval = org.apply( this, arguments ); 276 277 this.contents = thisContents; 278 otherImage.contents = otherContents; 279 return retval; 280 }; 281 }); 282 283 if ( editor.document ) 284 createInstance(); 285 }; 286 287 CKEDITOR.plugins.scayt = 288 { 289 engineLoaded : false, 290 instances : {}, 291 // Data storage for SCAYT control, based on editor instances 292 controlInfo : {}, 293 setControlInfo : function( editor, o ) 294 { 295 if ( editor && editor.name && typeof ( this.controlInfo[ editor.name ] ) != 'object' ) 296 this.controlInfo[ editor.name ] = {}; 297 298 for ( var infoOpt in o ) 299 this.controlInfo[ editor.name ][ infoOpt ] = o[ infoOpt ]; 300 }, 301 isControlRestored : function ( editor ) 302 { 303 if ( editor && 304 editor.name && 305 this.controlInfo[ editor.name ] ) 306 { 307 return this.controlInfo[ editor.name ].restored ; 308 } 309 return false; 310 }, 311 markControlRestore : function ( editor ) 312 { 313 this.setControlInfo( editor,{ restored:true } ); 314 }, 315 setControlId: function (editor, id) 316 { 317 this.setControlInfo( editor,{ id:id } ); 318 }, 319 getControlId: function (editor) 320 { 321 if ( editor && 322 editor.name && 323 this.controlInfo[ editor.name ] && 324 this.controlInfo[ editor.name ].id ) 325 { 326 return this.controlInfo[ editor.name ].id; 327 } 328 return null; 329 }, 330 setPaused: function ( editor , bool ) 331 { 332 this.setControlInfo( editor,{ paused:bool } ); 333 }, 334 isPaused: function (editor) 335 { 336 if ( editor && 337 editor.name && 338 this.controlInfo[editor.name] ) 339 { 340 return this.controlInfo[editor.name].paused ; 341 } 342 return undefined; 343 }, 344 getScayt : function( editor ) 345 { 346 return this.instances[ editor.name ]; 347 }, 348 isScaytReady : function( editor ) 349 { 350 return this.engineLoaded === true && 351 'undefined' !== typeof window.scayt && this.getScayt( editor ); 352 }, 353 isScaytEnabled : function( editor ) 354 { 355 var scayt_instance = this.getScayt( editor ); 356 return ( scayt_instance ) ? scayt_instance.disabled === false : false; 357 }, 358 loadEngine : function( editor ) 359 { 360 // SCAYT doesn't work with Firefox2, Opera. 361 if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 || CKEDITOR.env.opera ) 362 return editor.fire( 'showScaytState' ); 363 364 if ( this.engineLoaded === true ) 365 return onEngineLoad.apply( editor ); // Add new instance. 366 else if ( this.engineLoaded == -1 ) // We are waiting. 367 return CKEDITOR.on( 'scaytReady', function(){ onEngineLoad.apply( editor ); } ); // Use function(){} to avoid rejection as duplicate. 368 369 CKEDITOR.on( 'scaytReady', onEngineLoad, editor ); 370 CKEDITOR.on( 'scaytReady', function() 371 { 372 this.engineLoaded = true; 373 }, 374 this, 375 null, 376 0 377 ); // First to run. 378 379 this.engineLoaded = -1; // Loading in progress. 380 381 // compose scayt url 382 var protocol = document.location.protocol; 383 // Default to 'http' for unknown. 384 protocol = protocol.search( /https?:/) != -1? protocol : 'http:'; 385 var baseUrl = 'svc.spellchecker.net/scayt25/loader__base.js'; 386 387 var scaytUrl = editor.config.scayt_srcUrl || ( protocol + '//' + baseUrl ); 388 var scaytConfigBaseUrl = plugin.parseUrl( scaytUrl ).path + '/'; 389 390 if( window.scayt == undefined ) 391 { 392 CKEDITOR._djScaytConfig = 393 { 394 baseUrl: scaytConfigBaseUrl, 395 addOnLoad: 396 [ 397 function() 398 { 399 CKEDITOR.fireOnce( 'scaytReady' ); 400 } 401 ], 402 isDebug: false 403 }; 404 // Append javascript code. 405 CKEDITOR.document.getHead().append( 406 CKEDITOR.document.createElement( 'script', 407 { 408 attributes : 409 { 410 type : 'text/javascript', 411 async : 'true', 412 src : scaytUrl 413 } 414 }) 415 ); 416 } 417 else 418 CKEDITOR.fireOnce( 'scaytReady' ); 419 420 return null; 421 }, 422 parseUrl : function ( data ) 423 { 424 var match; 425 if ( data.match && ( match = data.match(/(.*)[\/\\](.*?\.\w+)$/) ) ) 426 return { path: match[1], file: match[2] }; 427 else 428 return data; 429 } 430 }; 431 432 var plugin = CKEDITOR.plugins.scayt; 433 434 // Context menu constructing. 435 var addButtonCommand = function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder ) 436 { 437 editor.addCommand( commandName, command ); 438 439 // If the "menu" plugin is loaded, register the menu item. 440 editor.addMenuItem( commandName, 441 { 442 label : buttonLabel, 443 command : commandName, 444 group : menugroup, 445 order : menuOrder 446 }); 447 }; 448 449 var commandDefinition = 450 { 451 preserveState : true, 452 editorFocus : false, 453 454 exec: function( editor ) 455 { 456 if ( plugin.isScaytReady( editor ) ) 457 { 458 var isEnabled = plugin.isScaytEnabled( editor ); 459 460 this.setState( isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_ON ); 461 462 var scayt_control = plugin.getScayt( editor ); 463 // the place where the status of editor focus should be restored 464 // after there will be ability to store its state before SCAYT button click 465 // if (storedFocusState is focused ) 466 // scayt_control.focus(); 467 // 468 // now focus is set certainly 469 scayt_control.focus( ); 470 scayt_control.setDisabled( isEnabled ); 471 } 472 else if ( !editor.config.scayt_autoStartup && plugin.engineLoaded >= 0 ) // Load first time 473 { 474 this.setState( CKEDITOR.TRISTATE_DISABLED ); 475 plugin.loadEngine( editor ); 476 } 477 } 478 }; 479 480 // Add scayt plugin. 481 CKEDITOR.plugins.add( 'scayt', 482 { 483 requires : [ 'menubutton' ], 484 485 beforeInit : function( editor ) 486 { 487 var items_order = editor.config.scayt_contextMenuItemsOrder 488 || 'suggest|moresuggest|control', 489 items_order_str = ""; 490 491 items_order = items_order.split( '|' ); 492 493 if ( items_order && items_order.length ) 494 { 495 for ( var pos in items_order ) 496 items_order_str += 'scayt_' + items_order[ pos ] + ( items_order.length != parseInt( pos, 10 ) + 1 ? ',' : '' ); 497 } 498 499 // Register scayt rbc menu group. 500 if ( editor.config.scayt_contextMenuOntop ) 501 // Put it on top of all context menu items 502 editor.config.menu_groups = items_order_str + ',' + editor.config.menu_groups; 503 else 504 // Put it down 505 editor.config.menu_groups = editor.config.menu_groups + ',' +items_order_str; 506 }, 507 508 init : function( editor ) 509 { 510 var moreSuggestions = {}; 511 var mainSuggestions = {}; 512 513 // Scayt command. 514 var command = editor.addCommand( commandName, commandDefinition ); 515 516 // Add Options dialog. 517 CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) ); 518 // read ui tags 519 var confuiTabs = editor.config.scayt_uiTabs || '1,1,1'; 520 var uiTabs =[]; 521 // string to array convert 522 confuiTabs = confuiTabs.split( ',' ); 523 // check array length ! always must be 3 filled with 1 or 0 524 for (var i=0,l=3; i<l; i++) 525 { 526 var flag = parseInt(confuiTabs[i] || '1' ,10); 527 uiTabs.push( flag ); 528 } 529 530 var menuGroup = 'scaytButton'; 531 editor.addMenuGroup( menuGroup ); 532 // combine menu items to render 533 var uiMuneItems = {}; 534 535 // always added 536 uiMuneItems.scaytToggle = 537 { 538 label : editor.lang.scayt.enable, 539 command : commandName, 540 group : menuGroup 541 }; 542 543 if (uiTabs[0] == 1) 544 uiMuneItems.scaytOptions = 545 { 546 label : editor.lang.scayt.options, 547 group : menuGroup, 548 onClick : function() 549 { 550 openPage = 'options'; 551 editor.openDialog( commandName ); 552 } 553 }; 554 555 if (uiTabs[1] == 1) 556 uiMuneItems.scaytLangs = 557 { 558 label : editor.lang.scayt.langs, 559 group : menuGroup, 560 onClick : function() 561 { 562 openPage = 'langs'; 563 editor.openDialog( commandName ); 564 } 565 }; 566 if (uiTabs[2] == 1) 567 uiMuneItems.scaytDict = 568 { 569 label : editor.lang.scayt.dictionariesTab, 570 group : menuGroup, 571 onClick : function() 572 { 573 openPage = 'dictionaries'; 574 editor.openDialog( commandName ); 575 } 576 }; 577 // always added 578 uiMuneItems.scaytAbout = 579 { 580 label : editor.lang.scayt.about, 581 group : menuGroup, 582 onClick : function() 583 { 584 openPage = 'about'; 585 editor.openDialog( commandName ); 586 } 587 } 588 ; 589 590 uiTabs[3] = 1; // about us tab is always on 591 plugin.uiTabs = uiTabs; 592 593 editor.addMenuItems( uiMuneItems ); 594 595 editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON, 596 { 597 label : editor.lang.scayt.title, 598 title : CKEDITOR.env.opera ? editor.lang.scayt.opera_title : editor.lang.scayt.title, 599 className : 'cke_button_scayt', 600 onRender: function() 601 { 602 command.on( 'state', function() 603 { 604 this.setState( command.state ); 605 }, 606 this); 607 }, 608 onMenu : function() 609 { 610 var isEnabled = plugin.isScaytEnabled( editor ); 611 612 editor.getMenuItem( 'scaytToggle' ).label = editor.lang.scayt[ isEnabled ? 'disable' : 'enable' ]; 613 614 return { 615 scaytToggle : CKEDITOR.TRISTATE_OFF, 616 scaytOptions : isEnabled && plugin.uiTabs[0] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 617 scaytLangs : isEnabled && plugin.uiTabs[1] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 618 scaytDict : isEnabled && plugin.uiTabs[2] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED, 619 scaytAbout : isEnabled && plugin.uiTabs[3] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED 620 }; 621 } 622 }); 623 624 // If the "contextmenu" plugin is loaded, register the listeners. 625 if ( editor.contextMenu && editor.addMenuItems ) 626 { 627 editor.contextMenu.addListener( function( element, selection ) 628 { 629 if ( !plugin.isScaytEnabled( editor ) 630 || selection.getCommonAncestor().isReadOnly() ) 631 return null; 632 633 var scayt_control = plugin.getScayt( editor ), 634 node = scayt_control.getScaytNode(); 635 636 if ( !node ) 637 return null; 638 639 var word = scayt_control.getWord( node ); 640 641 if ( !word ) 642 return null; 643 644 var sLang = scayt_control.getLang(), 645 _r = {}, 646 items_suggestion = window.scayt.getSuggestion( word, sLang ); 647 if ( !items_suggestion || !items_suggestion.length ) 648 return null; 649 // Remove unused commands and menuitems 650 for ( i in moreSuggestions ) 651 { 652 delete editor._.menuItems[ i ]; 653 delete editor._.commands[ i ]; 654 } 655 for ( i in mainSuggestions ) 656 { 657 delete editor._.menuItems[ i ]; 658 delete editor._.commands[ i ]; 659 } 660 moreSuggestions = {}; // Reset items. 661 mainSuggestions = {}; 662 663 var moreSuggestionsUnable = editor.config.scayt_moreSuggestions || 'on'; 664 var moreSuggestionsUnableAdded = false; 665 666 var maxSuggestions = editor.config.scayt_maxSuggestions; 667 ( typeof maxSuggestions != 'number' ) && ( maxSuggestions = 5 ); 668 !maxSuggestions && ( maxSuggestions = items_suggestion.length ); 669 670 var contextCommands = editor.config.scayt_contextCommands || 'all'; 671 contextCommands = contextCommands.split( '|' ); 672 673 for ( var i = 0, l = items_suggestion.length; i < l; i += 1 ) 674 { 675 var commandName = 'scayt_suggestion_' + items_suggestion[i].replace( ' ', '_' ); 676 var exec = ( function( el, s ) 677 { 678 return { 679 exec: function() 680 { 681 scayt_control.replace(el, s); 682 } 683 }; 684 })( node, items_suggestion[i] ); 685 686 if ( i < maxSuggestions ) 687 { 688 addButtonCommand( editor, 'button_' + commandName, items_suggestion[i], 689 commandName, exec, 'scayt_suggest', i + 1 ); 690 _r[ commandName ] = CKEDITOR.TRISTATE_OFF; 691 mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF; 692 } 693 else if ( moreSuggestionsUnable == 'on' ) 694 { 695 addButtonCommand( editor, 'button_' + commandName, items_suggestion[i], 696 commandName, exec, 'scayt_moresuggest', i + 1 ); 697 moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF; 698 moreSuggestionsUnableAdded = true; 699 } 700 } 701 702 if ( moreSuggestionsUnableAdded ) 703 { 704 // Register the More suggestions group; 705 editor.addMenuItem( 'scayt_moresuggest', 706 { 707 label : editor.lang.scayt.moreSuggestions, 708 group : 'scayt_moresuggest', 709 order : 10, 710 getItems : function() 711 { 712 return moreSuggestions; 713 } 714 }); 715 mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF; 716 } 717 718 if ( in_array( 'all', contextCommands ) || in_array( 'ignore', contextCommands) ) 719 { 720 var ignore_command = { 721 exec: function(){ 722 scayt_control.ignore( node ); 723 } 724 }; 725 addButtonCommand( editor, 'ignore', editor.lang.scayt.ignore, 'scayt_ignore', ignore_command, 'scayt_control', 1 ); 726 mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF; 727 } 728 729 if ( in_array( 'all', contextCommands ) || in_array( 'ignoreall', contextCommands ) ) 730 { 731 var ignore_all_command = { 732 exec: function(){ 733 scayt_control.ignoreAll( node ); 734 } 735 }; 736 addButtonCommand(editor, 'ignore_all', editor.lang.scayt.ignoreAll, 'scayt_ignore_all', ignore_all_command, 'scayt_control', 2); 737 mainSuggestions['scayt_ignore_all'] = CKEDITOR.TRISTATE_OFF; 738 } 739 740 if ( in_array( 'all', contextCommands ) || in_array( 'add', contextCommands ) ) 741 { 742 var addword_command = { 743 exec: function(){ 744 window.scayt.addWordToUserDictionary( node ); 745 } 746 }; 747 addButtonCommand(editor, 'add_word', editor.lang.scayt.addWord, 'scayt_add_word', addword_command, 'scayt_control', 3); 748 mainSuggestions['scayt_add_word'] = CKEDITOR.TRISTATE_OFF; 749 } 750 751 if ( scayt_control.fireOnContextMenu ) 752 scayt_control.fireOnContextMenu( editor ); 753 754 return mainSuggestions; 755 }); 756 } 757 758 var showInitialState = function() 759 { 760 editor.removeListener( 'showScaytState', showInitialState ); 761 762 if ( !CKEDITOR.env.opera ) 763 command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF ); 764 else 765 command.setState( CKEDITOR.TRISTATE_DISABLED ); 766 }; 767 768 editor.on( 'showScaytState', showInitialState ); 769 770 if ( CKEDITOR.env.opera ) 771 { 772 editor.on( 'instanceReady', function() 773 { 774 showInitialState(); 775 }); 776 } 777 778 // Start plugin 779 if ( editor.config.scayt_autoStartup ) 780 { 781 editor.on( 'instanceReady', function() 782 { 783 plugin.loadEngine( editor ); 784 }); 785 } 786 }, 787 788 afterInit : function( editor ) 789 { 790 // Prevent word marker line from displaying in elements path and been removed when cleaning format. (#3570) (#4125) 791 var elementsPathFilters, 792 scaytFilter = function( element ) 793 { 794 if ( element.hasAttribute( 'scaytid' ) ) 795 return false; 796 }; 797 798 if ( editor._.elementsPath && ( elementsPathFilters = editor._.elementsPath.filters ) ) 799 elementsPathFilters.push( scaytFilter ); 800 801 editor.addRemoveFormatFilter && editor.addRemoveFormatFilter( scaytFilter ); 802 803 } 804 }); 805 })(); 806 807 /** 808 * If enabled (true), turns on SCAYT automatically after loading the editor. 809 * @name CKEDITOR.config.scayt_autoStartup 810 * @type Boolean 811 * @default false 812 * @example 813 * config.scayt_autoStartup = true; 814 */ 815 816 /** 817 * Defines the number of SCAYT suggestions to show in the main context menu. 818 * The possible values are: 819 * <ul> 820 * <li>0 (zero): All suggestions are displayed in the main context menu.</li> 821 * <li>Positive number: The maximum number of suggestions to shown in context 822 * menu. Other entries will be shown in "More Suggestions" sub-menu.</li> 823 * <li>Negative number: No suggestions are shown in the main context menu. All 824 * entries will be listed in the "Suggestions" sub-menu.</li> 825 * </ul> 826 * @name CKEDITOR.config.scayt_maxSuggestions 827 * @type Number 828 * @default 5 829 * @example 830 * // Display only three suggestions in the main context menu. 831 * config.scayt_maxSuggestions = 3; 832 * @example 833 * // Do not show the suggestions directly. 834 * config.scayt_maxSuggestions = -1; 835 */ 836 837 /** 838 * Sets the customer ID for SCAYT. Required for migration from free version 839 * with banner to paid version. 840 * @name CKEDITOR.config.scayt_customerid 841 * @type String 842 * @default '' 843 * @example 844 * // Load SCAYT using my customer ID. 845 * config.scayt_customerid = 'your-encrypted-customer-id'; 846 */ 847 848 /** 849 * Enables/disables the "More Suggestions" sub-menu in the context menu. 850 * The possible values are "on" or "off". 851 * @name CKEDITOR.config.scayt_moreSuggestions 852 * @type String 853 * @default 'on' 854 * @example 855 * // Disables the "More Suggestions" sub-menu. 856 * config.scayt_moreSuggestions = 'off'; 857 */ 858 859 /** 860 * Customizes the display of SCAYT context menu commands ("Add Word", "Ignore" 861 * and "Ignore All"). It must be a string with one or more of the following 862 * words separated by a pipe ("|"): 863 * <ul> 864 * <li>"off": disables all options.</li> 865 * <li>"all": enables all options.</li> 866 * <li>"ignore": enables the "Ignore" option.</li> 867 * <li>"ignoreall": enables the "Ignore All" option.</li> 868 * <li>"add": enables the "Add Word" option.</li> 869 * </ul> 870 * @name CKEDITOR.config.scayt_contextCommands 871 * @type String 872 * @default 'all' 873 * @example 874 * // Show only "Add Word" and "Ignore All" in the context menu. 875 * config.scayt_contextCommands = 'add|ignoreall'; 876 */ 877 878 /** 879 * Sets the default spellchecking language for SCAYT. 880 * @name CKEDITOR.config.scayt_sLang 881 * @type String 882 * @default 'en_US' 883 * @example 884 * // Sets SCAYT to German. 885 * config.scayt_sLang = 'de_DE'; 886 */ 887 888 /** 889 * Sets the visibility of the SCAYT tabs in the settings dialog and toolbar 890 * button. The value must contain a "1" (enabled) or "0" (disabled) number for 891 * each of the following entries, in this precise order, separated by a 892 * comma (","): "Options", "Languages" and "Dictionary". 893 * @name CKEDITOR.config.scayt_uiTabs 894 * @type String 895 * @default '1,1,1' 896 * @example 897 * // Hide the "Languages" tab. 898 * config.scayt_uiTabs = '1,0,1'; 899 */ 900 901 902 /** 903 * Set the URL to SCAYT core. Required to switch to licensed version of SCAYT application. 904 * Further details at http://wiki.spellchecker.net/doku.php?id=3rd:wysiwyg:fckeditor:wscckf3l . 905 * @name CKEDITOR.config.scayt_srcUrl 906 * @type String 907 * @default '' 908 * @example 909 * config.scayt_srcUrl = "http://my-host/spellcheck/lf/scayt/scayt.js"; 910 */ 911 912 /** 913 * Links SCAYT to custom dictionaries. It's a string containing dictionary ids 914 * separared by commas (","). Available only for licensed version. 915 * Further details at http://wiki.spellchecker.net/doku.php?id=custom_dictionary_support . 916 * @name CKEDITOR.config.scayt_customDictionaryIds 917 * @type String 918 * @default '' 919 * @example 920 * config.scayt_customDictionaryIds = '3021,3456,3478"'; 921 */ 922 923 /** 924 * Makes it possible to activate a custom dictionary on SCAYT. The user 925 * dictionary name must be used. Available only for licensed version. 926 * @name CKEDITOR.config.scayt_userDictionaryName 927 * @type String 928 * @default '' 929 * @example 930 * config.scayt_userDictionaryName = 'MyDictionary'; 931 */ 932 933 /** 934 * Makes it possible to place the SCAYT context menu items above others. 935 * @name CKEDITOR.config.scayt_contextMenuOntop 936 * @type Boolean 937 * @default false 938 * @example 939 * config.scayt_contextMenuOntop = true; 940 */ 941 942 /** 943 * Define order of placing of SCAYT context menu items by groups. 944 * It must be a string with one or more of the following 945 * words separated by a pipe ("|"): 946 * <ul> 947 * <li>'suggest' - main suggestion word list,</li> 948 * <li>'moresuggest' - more suggestions word list,</li> 949 * <li>'control' - SCAYT commands, such as 'Ignore' and 'Add Word'</li> 950 * </ul> 951 * 952 * @name CKEDITOR.config.scayt_contextMenuItemsOrder 953 * @type String 954 * @default 'suggest|moresuggest|control' 955 * @example 956 * config.scayt_contextMenuItemsOrder = 'moresuggest|control|suggest'; 957 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |