Reputation: 180
I have a tinyMCE textarea, in div named text_editor. So i have in my jQuery:
$('#text_editor').hover(function(){
mouse_is_inside=true;
}, function(){
mouse_is_inside=false;
});
$('body').mouseup(function(){
if(! mouse_is_inside){
$('#text_editor').hide();
}
});
with this when the user click outside the div text editor, this will hide, but if the user select a font family or a font size, the text editor hide, so i add this in my jQuery:
$(document).on('click', '.mceMenuItem, .mceColorSplitMenu, .mceBottom, .mceMoreColors', function(e){
e.stopPropagation();
$('#text_editor').show();
});
this resolve the problem overhead. but if the users click in the colorpicker-more colors, a new window open, and text_editor hide, and i don't want that.
Upvotes: 3
Views: 1216
Reputation: 206171
var $editor = $('#text_editor');
$('textarea').click(function(e){
e.stopPropagation();
$editor.fadeTo(400,1);
});
$('body').on('click', function ( e ) {
if( !($(e.target).is('#text_editor')) && $editor.is(':visible') ){
$editor.hide();
}
});
Upvotes: 1