Imported CKEDITOR 3.0

Monotone-Parent: 5f9c08dd6b5b34d815ddb2108abbf4055e846934
Monotone-Revision: b2cf7eda0ef8f15fb6e78f8c38a7406a47bcdd2f

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-08-26T14:03:12
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
C Robert
2009-08-26 14:03:12 +00:00
parent 4d1a003124
commit 0ce87017d6
329 changed files with 5266 additions and 3451 deletions
@@ -8,374 +8,17 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
var firstLoad = true,
captions,
doc = CKEDITOR.document,
fckLang = 'en';
tags = [],
i,
contents = [],
userDicActive = false;
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 : [
var tags_contents = [
{
id : 'options',
label : editor.lang.scayt.optionsTab,
@@ -463,6 +106,389 @@ CKEDITOR.dialog.add( 'scaytcheck', function( editor )
}
]
}
]
];
var dialogDefiniton = {
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 i in this.options )
{
if (o[i] != this.options[ i ] && 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 : contents
};
var scayt_control = CKEDITOR.plugins.scayt.getScayt( editor );
if ( scayt_control )
{
tags = scayt_control.uiTags;
}
for ( i in tags ) {
if ( tags[ i ] == 1 )
contents[ contents.length ] = tags_contents[ i ];
}
if ( tags[2] == 1 )
userDicActive = true;
function onDicButtonClick()
{
var dic_name = doc.getById('dic_name').getValue();
if ( !dic_name )
{
dic_error_message(" Dictionary name should not be empty. ");
return false;
}
//apply handler
window.dic[ this.getId() ].apply( null, [ this, dic_name, dic_buttons ] );
return true;
}
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
if (userDicActive)
{
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 ");
window.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 )
{
//
// 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"] || "";
window.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
window.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"];
window.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]);
if ( dic_button )
dic_button.on( 'click', onDicButtonClick, this );
}
};
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
if ( userDicActive ){
window.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 = 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 = 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 dialogDefiniton;
});
@@ -11,23 +11,34 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
(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 || {};
var oParams = {};
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 );
oParams.customerid = editor.config.scayt_customerid || "1:11111111111111111111111111111111111111";
oParams.customDictionaryName = editor.config.scayt_customDictionaryName;
oParams.userDictionaryName = editor.config.scayt_userDictionaryName;
oParams.defLang = editor.scayt_defLang;
if ( CKEDITOR._scaytParams )
{
for ( var k in CKEDITOR._scaytParams )
{
oParams[ k ] = CKEDITOR._scaytParams[ k ];
}
}
var scayt_control = new window.scayt( oParams );
// Copy config.
var lastInstance = plugin.instances[ editor.name ];
@@ -67,13 +78,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
editor.on( 'beforeCommandExec', function( ev ) // Disable SCAYT before Source command execution.
{
if ( ev.data.name == 'source' && editor.mode == 'wysiwyg' )
if ( (ev.data.name == 'source' || ev.data.name == 'newpage') && editor.mode == 'wysiwyg' )
{
var scayt = plugin.getScayt( editor );
if ( scayt )
var scayt_instanse = plugin.getScayt( editor );
if ( scayt_instanse )
{
scayt.paused = !scayt.disabled;
scayt.setDisabled( true );
scayt_instanse.paused = !scayt_instanse.disabled;
scayt_instanse.destroy();
delete plugin.instances[ editor.name ];
}
}
});
@@ -85,12 +97,31 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
plugin.getScayt( editor ).refresh();
});
// Reload spell-checking for current word after insertion completed.
editor.on( 'insertElement', function()
{
var scayt_instance = plugin.getScayt( editor );
if ( plugin.isScaytEnabled( editor ) )
{
// Unlock the selection before reload, SCAYT will take
// care selection update.
if ( CKEDITOR.env.ie )
editor.getSelection().unlock( true );
// Swallow any SCAYT engine errors.
try{
scayt_instance.refresh();
}catch( er )
{}
}
}, this, null, 50 );
editor.on( 'scaytDialog', function( ev ) // Communication with dialog.
{
ev.data.djConfig = djConfig;
ev.data.djConfig = window.djConfig;
ev.data.scayt_control = plugin.getScayt( editor );
ev.data.tab = openPage;
ev.data.scayt = scayt;
ev.data.scayt = window.scayt;
});
var dataProcessor = editor.dataProcessor,
@@ -124,18 +155,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
instances : {},
getScayt : function( editor )
{
var instance = this.instances[ editor.name ];
return instance;
return this.instances[ editor.name ];
},
isScaytReady : function( editor )
{
return this.engineLoaded === true &&
'undefined' !== typeof scayt && this.getScayt( editor );
'undefined' !== typeof window.scayt && this.getScayt( editor );
},
isScaytEnabled : function( editor )
{
var scayt = this.getScayt( editor );
return ( scayt ) ? scayt.disabled === false : false;
var scayt_instanse = this.getScayt( editor );
return ( scayt_instanse ) ? scayt_instanse.disabled === false : false;
},
loadEngine : function( editor )
{
@@ -154,21 +184,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
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 + "/";
// Default to 'http' for unknown.
protocol = protocol.search( /https?:/) != -1? protocol : 'http:';
var baseUrl = "svc.spellchecker.net/spellcheck/lf/scayt/scayt1.js";
djScaytConfig =
var scaytUrl = editor.config.scayt_srcUrl || ( protocol + "//" + baseUrl );
var scaytConfigBaseUrl = plugin.parseUrl( scaytUrl ).path + "/";
CKEDITOR._djScaytConfig =
{
baseUrl: scaytConfigBaseUrl,
addOnLoad:
@@ -193,6 +219,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
);
return null;
},
parseUrl : function ( data )
{
var match;
if ( data.match && ( match = data.match(/(.*)[\/\\](.*?\.\w+)$/) ) )
return { path: match[1], file: match[2] };
else
return data;
}
};
@@ -311,9 +345,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
});
// 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,
@@ -321,17 +352,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
className : 'cke_button_scayt',
onRender: function()
{
command.on( 'state', function()
{
this.setState( command.state );
},
this);
},
onMenu : function()
{
var isEnabled = plugin.isScaytEnabled( editor );
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' ];
editor.getMenuItem( 'scaytToggle' ).label = editor.lang.scayt[ isEnabled ? 'disable' : 'enable' ];
return {
scaytToggle : CKEDITOR.TRISTATE_OFF,
@@ -341,25 +372,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
};
}
});
}
// If the "contextmenu" plugin is loaded, register the listeners.
if ( editor.contextMenu && editor.addMenuItems )
{
editor.contextMenu.addListener( function( element, selection )
editor.contextMenu.addListener( function( element )
{
var scayt_control = plugin.getScayt( editor );
if ( !plugin.isScaytEnabled( editor ) || !element || !element.$ )
if ( !( plugin.isScaytEnabled( editor ) && element ) )
return null;
var word = scayt_control.getWord( element.$ );
var scayt_control = plugin.getScayt( editor ),
word = scayt_control.getWord( element.$ );
if ( !word )
return null;
var sLang = scayt_control.getLang(),
_r = {},
items_suggestion = scayt.getSuggestion( word, sLang );
items_suggestion = window.scayt.getSuggestion( word, sLang );
if (!items_suggestion || !items_suggestion.length )
return null;
// Remove unused commands and menuitems
@@ -384,7 +414,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var exec = ( function( el, s )
{
return {
exec: function( editor )
exec: function()
{
scayt_control.replace(el, s);
}
@@ -438,7 +468,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
exec: function()
{
scayt.addWordToUserDictionary( element.$ );
window.scayt.addWordToUserDictionary( element.$ );
}
};
@@ -454,11 +484,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
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){}
if ( scayt_control.fireOnContextMenu )
scayt_control.fireOnContextMenu( editor );
return mainSuggestions;
});
@@ -480,6 +507,5 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
});
})();
CKEDITOR.config.scaytParams = CKEDITOR.config.scaytParams || {};
CKEDITOR.config.scayt_maxSuggestions = 5;
CKEDITOR.config.scayt_maxSuggestions = 5;
CKEDITOR.config.scayt_autoStartup = false;