Merge pull request #3322 from tractorcow/pulls/3.1/tinymce-config

API Let update interval of tinymce be changed or disabled
This commit is contained in:
Mateusz U 2014-07-28 14:17:42 +12:00
commit f7a9005a8e
2 changed files with 17 additions and 14 deletions

View File

@ -73,6 +73,7 @@ class HtmlEditorConfig {
'editor_selector' => "htmleditor", 'editor_selector' => "htmleditor",
'width' => "100%", 'width' => "100%",
'auto_resize' => false, 'auto_resize' => false,
'update_interval' => 5000, // Ensure update of this data every 5 seconds to the underlying textarea
'theme' => "advanced", 'theme' => "advanced",
'theme_advanced_layout_manager' => "SimpleLayout", 'theme_advanced_layout_manager' => "SimpleLayout",

View File

@ -89,20 +89,22 @@ ss.editorWrappers.tinyMCE = (function() {
// after an (undetected) inline change. This "blur" causes onChange // after an (undetected) inline change. This "blur" causes onChange
// to trigger, which will change the button markup to show "alternative" styles, // to trigger, which will change the button markup to show "alternative" styles,
// effectively cancelling the original click event. // effectively cancelling the original click event.
var interval; if(ed.settings.update_interval) {
jQuery(ed.getBody()).on('focus', function() { var interval;
interval = setInterval(function() { jQuery(ed.getBody()).on('focus', function() {
// Update underlying element as necessary interval = setInterval(function() {
var element = jQuery(ed.getElement()); // Update underlying element as necessary
if(ed.isDirty()) { var element = jQuery(ed.getElement());
// Set content without triggering editor content cleanup if(ed.isDirty()) {
element.val(ed.getContent({format : 'raw', no_events : 1})); // Set content without triggering editor content cleanup
} element.val(ed.getContent({format : 'raw', no_events : 1}));
}, 5000); }
}); }, ed.settings.update_interval);
jQuery(ed.getBody()).on('blur', function() { });
clearInterval(interval); jQuery(ed.getBody()).on('blur', function() {
}); clearInterval(interval);
});
}
}); });
this.instance.onChange.add(function(ed, l) { this.instance.onChange.add(function(ed, l) {
// Update underlying textarea on every change, so external handlers // Update underlying textarea on every change, so external handlers