Skip to content

Commit

Permalink
BUGFIX Only call TinyMCE.init() once per window load (actual editor c…
Browse files Browse the repository at this point in the history
…reation happens through new tinymce.Editor()
  • Loading branch information
chillu committed Apr 18, 2012
1 parent 57ee9bf commit 14895a2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions javascript/HtmlEditorField.js
Expand Up @@ -13,8 +13,15 @@
* Caution: Incomplete and unstable API. * Caution: Incomplete and unstable API.
*/ */
ss.editorWrappers = {}; ss.editorWrappers = {};
ss.editorWrappers.initial
ss.editorWrappers.tinyMCE = (function() { ss.editorWrappers.tinyMCE = (function() {
return { return {
init: function(config) {
if(!ss.editorWrappers.tinyMCE.initialized) {
tinyMCE.init(config);
ss.editorWrappers.tinyMCE.initialized = true;
}
},
/** /**
* @return Mixed Implementation specific object * @return Mixed Implementation specific object
*/ */
Expand Down Expand Up @@ -196,7 +203,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
* Constructor: onmatch * Constructor: onmatch
*/ */
onmatch : function() { onmatch : function() {
var self = this, ed = ss.editorWrappers['default'](); var self = this, edClass = this.data('editor') || ss.editorWrappers['default'], ed = edClass();
this.setEditor(ed); this.setEditor(ed);
this.closest('form').bind('beforesave', function() { this.closest('form').bind('beforesave', function() {
// TinyMCE modifies input, so change tracking might get false // TinyMCE modifies input, so change tracking might get false
Expand Down Expand Up @@ -228,7 +235,7 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
// Using a global config (generated through HTMLEditorConfig PHP logic) // Using a global config (generated through HTMLEditorConfig PHP logic)
var config = ssTinyMceConfig, self = this, ed = this.getEditor(); var config = ssTinyMceConfig, self = this, ed = this.getEditor();


tinyMCE.init(config); ed.init(config);


// Avoid flicker (also set in CSS to apply as early as possible) // Avoid flicker (also set in CSS to apply as early as possible)
self.css('visibility', ''); self.css('visibility', '');
Expand Down

0 comments on commit 14895a2

Please sign in to comment.