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",
'width' => "100%",
'auto_resize' => false,
'update_interval' => 5000, // Ensure update of this data every 5 seconds to the underlying textarea
'theme' => "advanced",
'theme_advanced_layout_manager' => "SimpleLayout",

View File

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