Skip to content

Commit

Permalink
less hacky fix for mozilla; lengthen timeout for IE hack; destroy too…
Browse files Browse the repository at this point in the history
…lbar with window
  • Loading branch information
quicklyfrozen committed Jun 27, 2012
1 parent 1ab8641 commit 0dbe0d5
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions jquery.richtext.js
Expand Up @@ -21,7 +21,7 @@ $.widget("ui.richtext", {
"bold,italic,underline,strikeThrough", "bold,italic,underline,strikeThrough",
"viewSource" "viewSource"
], ],
enter: function() { }, enter: function() { }
}, },


_create: function() { _create: function() {
Expand Down Expand Up @@ -63,6 +63,8 @@ $.widget("ui.richtext", {
destroy: function() { destroy: function() {
$.Widget.prototype.destroy.apply(this, arguments); // default destroy $.Widget.prototype.destroy.apply(this, arguments); // default destroy
// now do other stuff particular to this widget // now do other stuff particular to this widget
this._toolbars.detach();
this._toolbars = null;
this._editor.dispose(); this._editor.dispose();
this._editor = null; this._editor = null;
this.element.unwrap().show(); this.element.unwrap().show();
Expand Down Expand Up @@ -240,7 +242,7 @@ var Editor = function(element, options, uiFn) {
// FIXME IE hack... document.body for iframe is still null // FIXME IE hack... document.body for iframe is still null
setTimeout(function() { setTimeout(function() {
that.updateHtmlElement(); that.updateHtmlElement();
}, 50); }, 250);
}; };


$.extend(Editor.prototype, { $.extend(Editor.prototype, {
Expand Down Expand Up @@ -359,14 +361,15 @@ var IFrameEditor = {
//this._editor.open(); //this._editor.open();
//this._editor.write(string); //this._editor.write(string);
//this._editor.close(); //this._editor.close();


// FIXME Mozilla hack... can't enter design mode until dom is ready. var contentWindow = $(".ui-richtext-wrapper iframe")[0].contentWindow;
setTimeout(function() { contentWindow.onload = function() {
var contentWindow = $(".ui-richtext-wrapper iframe")[0].contentWindow;
contentWindow.document.designMode = "on"; contentWindow.document.designMode = "on";
contentWindow.document.execCommand("useCSS", false, true); if (!$.browser.msie) {
}, 100); contentWindow.document.execCommand("useCSS", false, true);

}
}

if (this.options.editorStyles) { if (this.options.editorStyles) {
$.each(this.options.editorStyles, function(i,e) { $.each(this.options.editorStyles, function(i,e) {
$('head', _doc).append( $('head', _doc).append(
Expand Down Expand Up @@ -492,7 +495,7 @@ $.extend(true, $.ui.richtext, {
BaseTool: { BaseTool: {
button: null, // {[type: checkbox|radio|button,] options: {button options}} button: null, // {[type: checkbox|radio|button,] options: {button options}}
// TODO : add 'select' special type where options is an hash of value:text of <OPTION> tags // TODO : add 'select' special type where options is an hash of value:text of <OPTION> tags
command: $.noop, command: $.noop
//update: $.noop // optional method, ONLY implment the function if tools needs updates on editor changes //update: $.noop // optional method, ONLY implment the function if tools needs updates on editor changes
// signature = function(ui) where ui.currentNode is the node at caret position and // signature = function(ui) where ui.currentNode is the node at caret position and
// ui.caretPosition is the caret position // ui.caretPosition is the caret position
Expand Down Expand Up @@ -600,7 +603,7 @@ $.ui.richtext.registerTools({
ui.toolbars.show(); ui.toolbars.show();
} }
} }
}, }
}) })


})(jQuery); })(jQuery);

0 comments on commit 0dbe0d5

Please sign in to comment.