HTML composition, take 2

Monotone-Parent: dbd490c81ea6cac4c12b2e17661e2fef43219e68
Monotone-Revision: 0801dc9f1e4fdc49ea44fc0450fb025c2639ed26

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-06-25T19:18:02
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
C Robert
2009-06-25 19:18:02 +00:00
parent 6ea89d62cd
commit b943372f17
1386 changed files with 231527 additions and 82366 deletions
@@ -0,0 +1,468 @@
/*
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.dialog.add( 'scaytcheck', function( editor )
{
var firstLoad = true,
captions,
doc = CKEDITOR.document,
fckLang = 'en';
var dic_buttons = [
// [0] contains buttons for creating
"dic_create,dic_restore",
// [1] contains buton for manipulation
"dic_rename,dic_delete"
];
var init_with_captions = function()
{
var dialog = this,
lang_list = dialog.data.scayt.getLangList(),
buttons = [ 'dic_create','dic_delete','dic_rename','dic_restore' ],
labels = [ 'mixedCase','mixedWithDigits','allCaps','ignoreDomainNames' ],
i;
// Add buttons titles
for ( i in buttons )
{
var button = buttons[ i ];
doc.getById( button ).setHtml( '<span class="cke_dialog_ui_button">' + captions[ 'button_' + button] +'</span>' );
}
doc.getById( 'dic_info' ).setHtml( captions[ 'dic_info' ] );
// Fill options and dictionary labels.
for ( i in labels )
{
var label = 'label_' + labels[ i ],
labelElement = doc.getById( label );
if ( 'undefined' != typeof labelElement
&& 'undefined' != typeof captions[ label ]
&& 'undefined' != typeof dialog.options[labels[ i ]] )
{
labelElement.setHtml( captions[ label ] );
var labelParent = labelElement.getParent();
labelParent.$.style.display = "block";
}
}
var about = '<p>' + captions[ 'about_throwt_image' ] + '</p>'+
'<p>' + captions[ 'version' ] + dialog.data.scayt.version.toString() + '</p>' +
'<p>' + captions[ 'about_throwt_copy' ] + '</p>';
doc.getById( 'scayt_about' ).setHtml( about );
// Create languages tab.
var createOption = function( option, list )
{
var label = doc.createElement( 'label' );
label.setAttribute( 'for', 'cke_option' + option );
label.setHtml( list[ option ] );
if ( dialog.sLang == option ) // Current.
dialog.chosed_lang = option;
var div = doc.createElement( 'div' );
var radio = CKEDITOR.dom.element.createFromHtml( '<input id="cke_option' +
option + '" type="radio" ' +
( dialog.sLang == option ? 'checked="checked"' : '' ) +
' value="' + option + '" name="scayt_lang" />' );
radio.on( 'click', function()
{
this.$.checked = true;
dialog.chosed_lang = option;
});
div.append( radio );
div.append( label );
return {
lang : list[ option ],
code : option,
radio : div
};
};
var langList = [];
for ( i in lang_list.rtl )
langList[ langList.length ] = createOption( i, lang_list.ltr );
for ( i in lang_list.ltr )
langList[ langList.length ] = createOption( i, lang_list.ltr );
langList.sort( function( lang1, lang2 )
{
return ( lang2.lang > lang1.lang ) ? -1 : 1 ;
});
var fieldL = doc.getById( 'scayt_lcol' ),
fieldR = doc.getById( 'scayt_rcol' );
for ( i=0; i < langList.length; i++ )
{
var field = ( i < langList.length / 2 ) ? fieldL : fieldR;
field.append( langList[ i ].radio );
}
// user dictionary handlers
var dic = {};
dic.dic_create = function( el, dic_name , dic_buttons )
{
// comma separated button's ids include repeats if exists
var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
var err_massage = captions["err_dic_create"];
var suc_massage = captions["succ_dic_create"];
//console.info("--plugin ");
scayt.createUserDictionary(dic_name,
function(arg)
{
//console.info( "dic_create callback called with args" , arg );
hide_dic_buttons ( all_buttons );
display_dic_buttons ( dic_buttons[1] );
suc_massage = suc_massage.replace("%s" , arg.dname );
dic_success_message (suc_massage);
},
function(arg)
{
//console.info( "dic_create errorback called with args" , arg )
err_massage = err_massage.replace("%s" ,arg.dname );
dic_error_message ( err_massage + "( "+ (arg.message || "") +")");
});
};
dic.dic_rename = function( el, dic_name , dic_buttons )
{
//
// try to rename dictionary
// @TODO: rename dict
//console.info ( captions["err_dic_rename"] )
var err_massage = captions["err_dic_rename"] || "";
var suc_massage = captions["succ_dic_rename"] || "";
scayt.renameUserDictionary(dic_name,
function(arg)
{
//console.info( "dic_rename callback called with args" , arg );
suc_massage = suc_massage.replace("%s" , arg.dname );
set_dic_name( dic_name );
dic_success_message ( suc_massage );
},
function(arg)
{
//console.info( "dic_rename errorback called with args" , arg )
err_massage = err_massage.replace("%s" , arg.dname );
set_dic_name( dic_name );
dic_error_message( err_massage + "( " + ( arg.message || "" ) + " )" );
});
};
dic.dic_delete = function ( el, dic_name , dic_buttons )
{
var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
var err_massage = captions["err_dic_delete"];
var suc_massage = captions["succ_dic_delete"];
// try to delete dictionary
// @TODO: delete dict
scayt.deleteUserDictionary(
function(arg)
{
//console.info( "dic_delete callback " , dic_name ,arg );
suc_massage = suc_massage.replace("%s" , arg.dname );
hide_dic_buttons ( all_buttons );
display_dic_buttons ( dic_buttons[0] );
set_dic_name( "" ); // empty input field
dic_success_message( suc_massage );
},
function(arg)
{
//console.info( " dic_delete errorback called with args" , arg )
err_massage = err_massage.replace("%s" , arg.dname );
dic_error_message(err_massage);
});
};
dic.dic_restore = dialog.dic_restore || function ( el, dic_name , dic_buttons )
{
// try to restore existing dictionary
var all_buttons = dic_buttons[0] + ',' + dic_buttons[1];
var err_massage = captions["err_dic_restore"];
var suc_massage = captions["succ_dic_restore"];
scayt.restoreUserDictionary(dic_name,
function(arg)
{
//console.info( "dic_restore callback called with args" , arg );
suc_massage = suc_massage.replace("%s" , arg.dname );
hide_dic_buttons ( all_buttons );
display_dic_buttons(dic_buttons[1]);
dic_success_message( suc_massage );
},
function(arg)
{
//console.info( " dic_restore errorback called with args" , arg )
err_massage = err_massage.replace("%s" , arg.dname );
dic_error_message( err_massage );
});
};
// ** bind event listeners
var arr_buttons = ( dic_buttons[0] + ',' + dic_buttons[1] ).split( ',' ),
l;
for ( i = 0, l = arr_buttons.length ; i < l ; i += 1 )
{
var dic_button = doc.getById(arr_buttons[i]);
dic_button.on( 'click', function ()
{
var dic_name = doc.getById('dic_name').getValue();
if ( !dic_name )
{
dic_error_message(" Dictionary name should not be empty. ");
return false;
}
//apply handler
dic[ this.getId() ].apply( null, [ this, dic_name, dic_buttons ] );
return true;
});
}
};
var reload = function()
{
var dialog = this;
// Animate options.
for ( var i in dialog.options )
{
var checkbox = doc.getById( i );
if ( checkbox )
{
checkbox.removeAttribute( 'checked' );
if ( dialog.options[ i ] == 1 )
checkbox.setAttribute( 'checked', 'checked' );
// Bind events. Do it only once.
if ( firstLoad )
{
checkbox.on( 'click', function()
{
dialog.options[ this.getId() ] = this.$.checked ? 1 : 0 ;
} );
}
}
}
// * user dictionary
scayt.getNameUserDictionary(
function( o )
{
var dic_name = o.dname;
if ( dic_name )
{
doc.getById( 'dic_name' ).setValue(dic_name);
display_dic_buttons( dic_buttons[1] );
}
else
display_dic_buttons( dic_buttons[0] );
},
function ()
{
doc.getById( 'dic_name' ).setValue("");
});
dic_success_message("");
};
function dic_error_message ( m )
{
doc.getById('dic_message').setHtml('<span style="color:red;">' + m + '</span>' );
}
function dic_success_message ( m )
{
doc.getById('dic_message').setHtml('<span style="color:blue;">' + m + '</span>') ;
}
function display_dic_buttons ( sIds )
{
sIds = new String( sIds );
var aIds = sIds.split(',');
for ( var i=0, l = aIds.length; i < l ; i+=1)
{
doc.getById( aIds[i] ).$.style.display = "inline";
}
}
function hide_dic_buttons ( sIds )
{
sIds = new String( sIds );
var aIds = sIds.split(',');
for ( var i = 0, l = aIds.length; i < l ; i += 1 )
{
doc.getById( aIds[i] ).$.style.display = "none";
}
}
function set_dic_name ( dic_name )
{
doc.getById('dic_name').$.value= dic_name;
}
return {
title : editor.lang.scayt.title,
minWidth : 340,
minHeight : 200,
onShow : function()
{
var dialog = this;
dialog.data = editor.fire( 'scaytDialog', {} );
dialog.options = dialog.data.scayt_control.option();
dialog.sLang = dialog.data.scayt_control.sLang;
if ( !dialog.data || !dialog.data.scayt || !dialog.data.scayt_control )
{
alert( 'Error loading application service' );
dialog.hide();
return;
}
var stop = 0;
if ( firstLoad )
{
dialog.data.scayt.getCaption( 'en', function( caps )
{
if ( stop++ > 0 ) // Once only
return;
captions = caps;
init_with_captions.apply( dialog );
reload.apply( dialog );
firstLoad = false;
});
}
else
reload.apply( dialog );
dialog.selectPage( dialog.data.tab );
},
onOk : function()
{
var scayt_control = this.data.scayt_control,
o = scayt_control.option(),
c = 0;
// Set up options if any was set.
for ( var oN in this.options )
{
if (o[oN] != this.options[ oN ] && c === 0 )
{
scayt_control.option( this.options );
c++;
}
}
// Setup languge if it was changed.
var csLang = this.chosed_lang;
if ( csLang && this.data.sLang != csLang )
{
scayt_control.setLang( csLang );
c++;
}
if ( c > 0 )
scayt_control.refresh();
},
contents : [
{
id : 'options',
label : editor.lang.scayt.optionsTab,
elements : [
{
type : 'html',
id : 'options',
html : '<div class="inner_options">' +
' <div class="messagebox"></div>' +
' <div style="display:none;">' +
' <input type="checkbox" value="0" id="allCaps" />' +
' <label for="allCaps" id="label_allCaps"></label>' +
' </div>' +
' <div style="display:none;">' +
' <input type="checkbox" value="0" id="ignoreDomainNames" />' +
' <label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>' +
' </div>' +
' <div style="display:none;">' +
' <input type="checkbox" value="0" id="mixedCase" />' +
' <label for="mixedCase" id="label_mixedCase"></label>' +
' </div>' +
' <div style="display:none;">' +
' <input type="checkbox" value="0" id="mixedWithDigits" />' +
' <label for="mixedWithDigits" id="label_mixedWithDigits"></label>' +
' </div>' +
'</div>'
}
]
},
{
id : 'langs',
label : editor.lang.scayt.languagesTab,
elements : [
{
type : 'html',
id : 'langs',
html : '<div class="inner_langs">' +
' <div class="messagebox"></div> ' +
' <div style="float:left;width:47%;margin-left:5px;" id="scayt_lcol" ></div>' +
' <div style="float:left;width:47%;margin-left:15px;" id="scayt_rcol"></div>' +
'</div>'
}
]
},
{
id : 'dictionaries',
label : editor.lang.scayt.dictionariesTab,
elements : [
{
type : 'html',
style: '',
id : 'dic',
html : '<div class="inner_dictionary" style="text-align:left; white-space:normal;">' +
' <div style="margin:5px auto; width:80%;white-space:normal; overflow:hidden;" id="dic_message"> </div>' +
' <div style="margin:5px auto; width:80%;white-space:normal;"> ' +
' <span class="cke_dialog_ui_labeled_label" >Dictionary name</span><br>'+
' <span class="cke_dialog_ui_labeled_content" >'+
' <div class="cke_dialog_ui_input_text">'+
' <input id="dic_name" type="text" class="cke_dialog_ui_input_text"/>'+
' </div></span></div>'+
' <div style="margin:5px auto; width:80%;white-space:normal;">'+
' <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_create">'+
' </a>' +
' <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_delete">'+
' </a>' +
' <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_rename">'+
' </a>' +
' <a style="display:none;" class="cke_dialog_ui_button" href="javascript:void(0)" id="dic_restore">'+
' </a>' +
' </div>' +
' <div style="margin:5px auto; width:95%;white-space:normal;" id="dic_info"></div>' +
'</div>'
}
]
},
{
id : 'about',
label : editor.lang.scayt.aboutTab,
elements : [
{
type : 'html',
id : 'about',
style : 'margin: 10px 40px;',
html : '<div id="scayt_about"></div>'
}
]
}
]
};
});
@@ -0,0 +1,71 @@
a
{
text-decoration:none;
padding: 2px 4px 4px 6px;
display : block;
border-width: 1px;
border-style: solid;
margin : 0px;
}
a.cke_scayt_toogle:hover,
a.cke_scayt_toogle:focus,
a.cke_scayt_toogle:active
{
border-color: #316ac5;
background-color: #dff1ff;
color : #000;
cursor: pointer;
margin : 0px;
}
a.cke_scayt_toogle {
color : #316ac5;
border-color: #fff;
}
.scayt_enabled a.cke_scayt_item {
color : #316ac5;
border-color: #fff;
margin : 0px;
}
.scayt_disabled a.cke_scayt_item {
color : gray;
border-color : #fff;
}
.scayt_enabled a.cke_scayt_item:hover,
.scayt_enabled a.cke_scayt_item:focus,
.scayt_enabled a.cke_scayt_item:active
{
border-color: #316ac5;
background-color: #dff1ff;
color : #000;
cursor: pointer;
}
.scayt_disabled a.cke_scayt_item:hover,
.scayt_disabled a.cke_scayt_item:focus,
.scayt_disabled a.cke_scayt_item:active
{
border-color: gray;
background-color: #dff1ff;
color : gray;
cursor: no-drop;
}
.cke_scayt_set_on, .cke_scayt_set_off
{
display: none;
}
.scayt_enabled .cke_scayt_set_on
{
display: none;
}
.scayt_disabled .cke_scayt_set_on
{
display: inline;
}
.scayt_disabled .cke_scayt_set_off
{
display: none;
}
.scayt_enabled .cke_scayt_set_off
{
display: inline;
}
@@ -0,0 +1,485 @@
/*
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Spell Check As You Type (SCAYT).
* Button name : Scayt.
*/
(function()
{
var commandName = 'scaytcheck',
sc_on_cssclass = 'scayt_enabled',
sc_off_cssclass = 'scayt_disabled',
openPage = '';
var onEngineLoad = function()
{
var editor = this;
dojo.requireLocalization( 'scayt', 'caption', '', 'ROOT' );
var createInstance = function() // Create new instance every time Document is created.
{
// Initialise Scayt instance.
var oParams = CKEDITOR.config.scaytParams || {};
oParams.srcNodeRef = editor.document.getWindow().$.frameElement; // Get the iframe.
// syntax : AppName.AppVersion@AppRevision
oParams.assocApp = "CKEDITOR." + CKEDITOR.version + "@" + CKEDITOR.revision;
var scayt_control = new scayt( oParams );
// Copy config.
var lastInstance = plugin.instances[ editor.name ];
if ( lastInstance )
{
scayt_control.sLang = lastInstance.sLang;
scayt_control.option( lastInstance.option() );
scayt_control.paused = lastInstance.paused;
}
plugin.instances[ editor.name ] = scayt_control;
try {
scayt_control.setDisabled( scayt_control.paused === false ); // I really don't know why it causes JS error in IE
} catch (e) {}
editor.fire( 'showScaytState' );
};
editor.on( 'contentDom', createInstance );
editor.on( 'contentDomUnload', function()
{
// Remove scripts.
var scripts = CKEDITOR.document.getElementsByTag( 'script' ),
scaytIdRegex = /^dojoIoScript(\d+)$/i,
scaytSrcRegex = /^https?:\/\/svc\.spellchecker\.net\/spellcheck\/script\/ssrv\.cgi/i;
for ( var i=0; i < scripts.count(); i++ )
{
var script = scripts.getItem( i ),
id = script.getId(),
src = script.getAttribute( 'src' );
if ( id && src && id.match( scaytIdRegex ) && src.match( scaytSrcRegex ))
script.remove();
}
});
editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution.
{
if ( ev.data.name == 'source' && editor.mode == 'wysiwyg' )
{
var scayt = plugin.getScayt( editor );
if ( scayt )
{
scayt.paused = !scayt.disabled;
scayt.setDisabled( true );
}
}
});
// Listen to data manipulation to reflect scayt markup.
editor.on( 'afterSetData', function()
{
if ( plugin.isScaytEnabled( editor ) )
plugin.getScayt( editor ).refresh();
});
editor.on( 'scaytDialog', function( ev ) // Communication with dialog.
{
ev.data.djConfig = djConfig;
ev.data.scayt_control = plugin.getScayt( editor );
ev.data.tab = openPage;
ev.data.scayt = scayt;
});
var dataProcessor = editor.dataProcessor,
htmlFilter = dataProcessor && dataProcessor.htmlFilter;
if ( htmlFilter )
{
htmlFilter.addRules(
{
elements :
{
span : function( element )
{
if ( element.attributes.scayt_word && element.attributes.scaytid )
{
delete element.name; // Write children, but don't write this node.
return element;
}
}
}
}
);
}
if ( editor.document )
createInstance();
};
CKEDITOR.plugins.scayt =
{
engineLoaded : false,
instances : {},
getScayt : function( editor )
{
var instance = this.instances[ editor.name ];
return instance;
},
isScaytReady : function( editor )
{
return this.engineLoaded === true &&
'undefined' !== typeof scayt && this.getScayt( editor );
},
isScaytEnabled : function( editor )
{
var scayt = this.getScayt( editor );
return ( scayt ) ? scayt.disabled === false : false;
},
loadEngine : function( editor )
{
if ( this.engineLoaded === true )
return onEngineLoad.apply( editor ); // Add new instance.
else if ( this.engineLoaded == -1 ) // We are waiting.
return CKEDITOR.on( 'scaytReady', function(){ onEngineLoad.apply( editor );} ); // Use function(){} to avoid rejection as duplicate.
CKEDITOR.on( 'scaytReady', onEngineLoad, editor );
CKEDITOR.on( 'scaytReady', function()
{
this.engineLoaded = true;
},
this,
null,
0 ); // First to run.
this.engineLoaded = -1; // Loading in progress.
// assign diojo configurable vars
var parseUrl = function(data)
{
var m = data.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/);
return { path: m[1], file: m[2] };
};
// compose scayt url
var protocol = document.location.protocol;
var baseUrl = "svc.spellchecker.net/spellcheck/lf/scayt/scayt.js";
var scaytUrl = editor.config.scaytParams.srcScayt ||
(protocol + "//" + baseUrl);
var scaytConfigBaseUrl = parseUrl(scaytUrl).path + "/";
djScaytConfig =
{
baseUrl: scaytConfigBaseUrl,
addOnLoad:
[
function()
{
CKEDITOR.fireOnce( "scaytReady" );
}
],
isDebug: false
};
// Append javascript code.
CKEDITOR.document.getHead().append(
CKEDITOR.document.createElement( 'script',
{
attributes :
{
type : 'text/javascript',
src : scaytUrl
}
})
);
return null;
}
};
var plugin = CKEDITOR.plugins.scayt;
// Context menu constructing.
var addButtonCommand = function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
{
editor.addCommand( commandName, command );
// If the "menu" plugin is loaded, register the menu item.
editor.addMenuItem( commandName,
{
label : buttonLabel,
command : commandName,
group : menugroup,
order : menuOrder
});
};
var commandDefinition =
{
preserveState : true,
exec: function( editor )
{
if ( plugin.isScaytReady( editor ) )
{
var isEnabled = plugin.isScaytEnabled( editor );
this.setState( isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_ON );
var scayt_control = plugin.getScayt( editor );
scayt_control.setDisabled( isEnabled );
}
else if ( !editor.config.scayt_autoStartup && plugin.engineLoaded >= 0 ) // Load first time
{
this.setState( CKEDITOR.TRISTATE_DISABLED );
editor.on( 'showScaytState', function()
{
this.removeListener();
this.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
},
this);
plugin.loadEngine( editor );
}
}
};
// Add scayt plugin.
CKEDITOR.plugins.add( 'scayt',
{
requires : [ 'menubutton' ],
beforeInit : function( editor )
{
// Register own rbc menu group.
editor.config.menu_groups = 'scayt_suggest,scayt_moresuggest,scayt_control,' + editor.config.menu_groups;
},
init : function( editor )
{
var moreSuggestions = {};
var mainSuggestions = {};
// Scayt command.
var command = editor.addCommand( commandName, commandDefinition );
// Add Options dialog.
CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
var menuGroup = 'scaytButton';
editor.addMenuGroup( menuGroup );
editor.addMenuItems(
{
scaytToggle :
{
label : editor.lang.scayt.enable,
command : commandName,
group : menuGroup
},
scaytOptions :
{
label : editor.lang.scayt.options,
group : menuGroup,
onClick : function()
{
openPage = 'options';
editor.openDialog( commandName );
}
},
scaytLangs :
{
label : editor.lang.scayt.langs,
group : menuGroup,
onClick : function()
{
openPage = 'langs';
editor.openDialog( commandName );
}
},
scaytAbout :
{
label : editor.lang.scayt.about,
group : menuGroup,
onClick : function()
{
openPage = 'about';
editor.openDialog( commandName );
}
}
});
// Disabling it on IE for now, as it's blocking the browser (#3802).
if ( !CKEDITOR.env.ie )
{
editor.ui.add( 'Scayt', CKEDITOR.UI_MENUBUTTON,
{
label : editor.lang.scayt.title,
title : editor.lang.scayt.title,
className : 'cke_button_scayt',
onRender: function()
{
command.on( 'state', function()
{
this.setState( command.state );
},
this);
},
onMenu : function()
{
var isEnabled = plugin.isScaytEnabled( editor );
editor.getMenuItem( 'scaytToggle' ).label = editor.lang.scayt[ isEnabled ? 'disable' : 'enable' ];
return {
scaytToggle : CKEDITOR.TRISTATE_OFF,
scaytOptions : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
scaytLangs : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
scaytAbout : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
};
}
});
}
// If the "contextmenu" plugin is loaded, register the listeners.
if ( editor.contextMenu && editor.addMenuItems )
{
editor.contextMenu.addListener( function( element, selection )
{
var scayt_control = plugin.getScayt( editor );
if ( !plugin.isScaytEnabled( editor ) || !element || !element.$ )
return null;
var word = scayt_control.getWord( element.$ );
if ( !word )
return null;
var sLang = scayt_control.getLang(),
_r = {},
items_suggestion = scayt.getSuggestion( word, sLang );
if (!items_suggestion || !items_suggestion.length )
return null;
// Remove unused commands and menuitems
for ( i in moreSuggestions )
{
delete editor._.menuItems[ i ];
delete editor._.commands[ i ];
}
for ( i in mainSuggestions )
{
delete editor._.menuItems[ i ];
delete editor._.commands[ i ];
}
moreSuggestions = {}; // Reset items.
mainSuggestions = {};
var moreSuggestionsUnable = false;
for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )
{
var commandName = 'scayt_suggestion_' + items_suggestion[i].replace( ' ', '_' );
var exec = ( function( el, s )
{
return {
exec: function( editor )
{
scayt_control.replace(el, s);
}
};
})( element.$, items_suggestion[i] );
if ( i < editor.config.scayt_maxSuggestions )
{
addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
commandName, exec, 'scayt_suggest', i + 1 );
_r[ commandName ] = CKEDITOR.TRISTATE_OFF;
mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
}
else
{
addButtonCommand( editor, 'button_' + commandName, items_suggestion[i],
commandName, exec, 'scayt_moresuggest', i + 1 );
moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
moreSuggestionsUnable = true;
}
}
if ( moreSuggestionsUnable )
// Rgister the More suggestions group;
editor.addMenuItem( 'scayt_moresuggest',
{
label : editor.lang.scayt.moreSuggestions,
group : 'scayt_moresuggest',
order : 10,
getItems : function()
{
return moreSuggestions;
}
});
var ignore_command =
{
exec: function()
{
scayt_control.ignore( element.$ );
}
};
var ignore_all_command =
{
exec: function()
{
scayt_control.ignoreAll( element.$ );
}
};
var addword_command =
{
exec: function()
{
scayt.addWordToUserDictionary( element.$ );
}
};
addButtonCommand( editor, 'ignore', editor.lang.scayt.ignore,
'scayt_ignore', ignore_command, 'scayt_control', 1);
addButtonCommand( editor, 'ignore_all', editor.lang.scayt.ignoreAll,
'scayt_ignore_all', ignore_all_command, 'scayt_control', 2);
addButtonCommand( editor, 'add_word', editor.lang.scayt.addWord,
'scayt_add_word', addword_command, 'scayt_control', 3);
mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;
mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF;
mainSuggestions[ 'scayt_ignore_all' ] = CKEDITOR.TRISTATE_OFF;
mainSuggestions[ 'scayt_add_word' ] = CKEDITOR.TRISTATE_OFF;
// ** ahow ads entry point
// ** hide ads listener register
// try{
//scayt_control.showBanner( editor )
// }catch(err){}
return mainSuggestions;
});
}
// Start plugin
if ( editor.config.scayt_autoStartup )
{
var showInitialState = function()
{
editor.removeListener( 'showScaytState', showInitialState );
command.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
};
editor.on( 'showScaytState', showInitialState );
plugin.loadEngine( editor );
}
}
});
})();
CKEDITOR.config.scaytParams = CKEDITOR.config.scaytParams || {};
CKEDITOR.config.scayt_maxSuggestions = 5;
CKEDITOR.config.scayt_autoStartup = false;