admin管理员组文章数量:1291119
Normally when you click other place in the page other than the edit area, the toolbar will hide, now i need to hide the toolbar also on user mand(such as user press a shortcut).
I tried to call jQuery hide
method on ckeditor toolbar div, but once hidden, it will never bee visible even when user focus on the edit area.
Any ideas on how to achieve this? Many thanks.
Normally when you click other place in the page other than the edit area, the toolbar will hide, now i need to hide the toolbar also on user mand(such as user press a shortcut).
I tried to call jQuery hide
method on ckeditor toolbar div, but once hidden, it will never bee visible even when user focus on the edit area.
Any ideas on how to achieve this? Many thanks.
Share Improve this question asked Apr 8, 2013 at 11:31 MikeMike 3,57511 gold badges47 silver badges70 bronze badges2 Answers
Reset to default 4did you try to do jQuery Show when the focus es back in to the edit area?
you can also attach to the focus and blur events to show and hide toolbar:
// Call showToolBarDiv() when editor get the focus
editor.on('focus', function (event)
{
showToolBarDiv( event );
});
// Call hideToolBarDiv() when editor loses the focus
editor.on('blur', function (event)
{
hideToolBarDiv( event );
});
//Whenever CKEditor get focus. We will show the toolbar DIV.
function showToolBarDiv( event )
{
// Select the correct toolbar DIV and show it.
//'event.editor.name' returns the name of the DIV receiving focus.
$('#'+event.editor.name+'TBdiv').show();
}
//Whenever CKEditor loses focus, We will hide the corresponding toolbar DIV.
function hideToolBarDiv( event )
{
// Select the correct toolbar DIV and hide it.
//'event.editor.name' returns the name of the DIV receiving focus.
$('#'+event.editor.name+'TBdiv').hide();
}
where you create instance of ckedito use below code. editor.id use for three part of ckeditor, toolbar,edit area, footer for example if editor.id have 'cke_12' value for toolbar div id is 'cke_12_top'. note this is for iframe mode.
CKEDITOR.replace(divId, {toolbar: [
{ name: 'clipboard', items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']},
{name: 'editing', items: ['Format', 'Font', 'FontSize', 'TextColor', 'BGColor' , 'Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat'] }
]});
//use for loop because i have multi ckeditor in page.
for (instance in CKEDITOR.instances) {
var editor = CKEDITOR.instances[instance];
if (editor) {
// Call showToolBarDiv() when editor get the focus
editor.on('focus', function (event) {
showToolBarDiv(event);
});
// Call hideToolBarDiv() when editor loses the focus
editor.on('blur', function (event) {
hideToolBarDiv(event);
});
//Whenever CKEditor get focus. We will show the toolbar span.
function showToolBarDiv(event) {
//'event.editor.id' returns the id of the spans used in ckeditr.
$('#'+event.editor.id+'_top').show();
}
function hideToolBarDiv(event) {
//'event.editor.id' returns the id of the spans used in ckeditr.
$('#'+event.editor.id+'_top').hide()
}
}
}
本文标签: javascriptCKEditor 4 Inline How to hide toolbar on demandStack Overflow
版权声明:本文标题:javascript - CKEditor 4 Inline: How to hide toolbar on demand? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741508465a2382461.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论