/ Published in: JavaScript
This override function for the default Drupal.toggleFieldset function adds code that looks for instances of TinyMCE inside the fieldset and triggers the autoresize on them when the fieldset is opened. Otherwise TinyMCE renders with a weird height.
Expand |
Embed | Plain Text
/** * OVERWRITES Drupal.toggleFieldset in /misc/collapse.js * * Modified to trigger autoresize on tinyMCE textareas inside collapsed fieldsets */ Drupal.toggleFieldset = function(fieldset) { if ($(fieldset).is('.collapsed')) { // Action div containers are processed separately because of a IE bug // that alters the default submit button behavior. var content = $('> div:not(.action)', fieldset); $(fieldset).removeClass('collapsed'); content.hide(); content.slideDown( { duration: 'fast', easing: 'linear', complete: function() { Drupal.collapseScrollIntoView(this.parentNode); this.parentNode.animating = false; $('div.action', fieldset).show(); // >>>> var editors = $(fieldset).find('.mceEditor'); $.each(editors, function() { var instance = tinyMCE.get($(this).attr('id').replace('_parent', '')); // Add a min height it it doesn't have one yet if (instance.plugins.autoresize && instance.plugins.autoresize.autoresize_min_height < 50) { instance.plugins.autoresize.autoresize_min_height = 50; } // Trigger the resize instance.execCommand('mceAutoResize'); }); // >>> }, step: function() { // Scroll the fieldset into view Drupal.collapseScrollIntoView(this.parentNode); } }); } else { $('div.action', fieldset).hide(); var content = $('> div:not(.action)', fieldset).slideUp('fast', function() { $(this.parentNode).addClass('collapsed'); this.parentNode.animating = false; }); } };
You need to login to post a comment.
