Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR Fixed change detection false positives for TinyMCE in IE, use T…

…inyMCE.isDirty() rather than string comparison
  • Loading branch information...
commit bad1b88942ea32c89c85799509a3bcbe5648fa6f 1 parent bf11a32
Ingo Schommer chillu authored
Showing with 22 additions and 3 deletions.
  1. +22 −3 admin/javascript/LeftAndMain.EditForm.js
25 admin/javascript/LeftAndMain.EditForm.js
View
@@ -196,9 +196,15 @@
onmatch : function() {
var self = this;
this.closest('form').bind('beforesave', function() {
- tinyMCE.triggerSave();
- // TinyMCE assigns value attr directly, which doesn't trigger change event
- self.trigger('change');
+ if(typeof tinyMCE == 'undefined') return;
+
+ // TinyMCE modifies input, so change tracking might get false
+ // positives when comparing string values - don't save if the editor doesn't think its dirty.
+ if(self.isChanged()) {
+ tinyMCE.triggerSave();
+ // TinyMCE assigns value attr directly, which doesn't trigger change event
+ self.trigger('change');
+ }
});
// Only works after TinyMCE.init() has been invoked, see $(window).bind() call below for details.
@@ -223,14 +229,26 @@
});
ed.render();
+ // Handle editor de-registration by hooking into state changes.
+ // TODO Move to onunmatch for less coupling (once we figure out how to work with detached DOM nodes in TinyMCE)
+ $('.cms-container').bind('beforestatechange', function() {
+ self.css('visibility', 'hidden');
+ var ed = tinyMCE.get(self.attr('id'));
+ if(ed) ed.remove();
+ });
+
this._super();
},
isChanged: function() {
+ if(typeof tinyMCE == 'undefined') return;
+
return tinyMCE.getInstanceById(this.attr('id')).isDirty();
},
resetChanged: function() {
+ if(typeof tinyMCE == 'undefined') return;
+
var inst = tinyMCE.getInstanceById(this.attr('id'));
if (inst) inst.startContent = tinymce.trim(inst.getContent({format : 'raw', no_events : 1}));
},
@@ -243,6 +261,7 @@
this._super();
}
});
+
});
}(jQuery));
Please sign in to comment.
Something went wrong with that request. Please try again.