Skip to content

Instantly share code, notes, and snippets.

@Tabrisrp
Created April 14, 2015 14:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Tabrisrp/8fd06872d1b9f0971296 to your computer and use it in GitHub Desktop.
Save Tabrisrp/8fd06872d1b9f0971296 to your computer and use it in GitHub Desktop.
WordPress customizer custom tinymce control javascript
( function( $ ) {
wp.customizerCtrlEditor = {
init: function() {
$(window).load(function(){
$('textarea.wp-editor-area').each(function(){
var tArea = $(this),
id = tArea.attr('id'),
editor = tinyMCE.get(id),
setChange,
content;
if(editor){
editor.onChange.add(function (ed, e) {
ed.save();
content = editor.getContent();
clearTimeout(setChange);
setChange = setTimeout(function(){
tArea.val(content).trigger('change');
},500);
});
}
tArea.css({
visibility: 'visible'
}).on('keyup', function(){
content = tArea.val();
clearTimeout(setChange);
setChange = setTimeout(function(){
content.trigger('change');
},500);
});
});
});
}
};
wp.customizerCtrlEditor.init();
} )( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment