context: HTMLArea.prototype.generate = function () {	var editor = this; // we'll need "this" in some nested functions	// get the textarea	var textarea = this._textArea;	if (typeof textarea == "string") {		// it's not element but ID		this._textArea = textarea = document.getElementById(textarea);	}	this._ta_size = {		w: textarea.offsetWidth,		h: textarea.offsetHeight	};	// hide the textarea	textarea.style.display = "none";	// create the editor framework	var htmlarea = document.createElement("div");	htmlarea.id = "htmlarea";	htmlarea.className = "htmlarea";	this._htmlArea = htmlarea;	// insert the editor before the textarea.	textarea.parentNode.insertBefore(htmlarea, textarea);	// retrieve the HTML on submit	eval ('var otherOnSubmit_' + this._uniqueID + '= (textarea.form.onsubmit) ? textarea.form.onsubmit :  (function() {"return true;"});');	eval ('textarea.form.onsubmit = function() { editor._formSubmit(); return otherOnSubmit_' + this._uniqueID + '(); };');	// add a handler for the "back/forward" case -- on body.unload we save	// the HTML content into the original textarea.	eval ('var otherOnUnload_' + this._uniqueID + '= (window.onunload) ? window.onunload :  new Function;');	eval ('window.onunload = function() { editor._textArea.value = editor.getHTML(); otherOnUnload_' + this._uniqueID + '(); };');		// appends the toolbar	this._htmlArea.appendChild(this._toolbar);	// appends the status bar	this._htmlArea.appendChild(this._statusBar);	if (HTMLArea.is_gecko || editor.config.bodyType.toLowerCase() == 'iframe') {		// create the IFRAME		var iframe = document.createElement("iframe");		htmlarea.appendChild(iframe);		this._iframe = iframe;		// resize the iframe after the window is loaded		HTMLArea._addEvent(window, "load", function (event) {			editor._resizeIframe(HTMLArea.is_ie ? window.event : event);		});	} else if (HTMLArea.is_ie && editor.config.bodyType.toLowerCase() == 'div') {		var contentDiv = document.createElement("div");		this._htmlArea.appendChild(contentDiv);		this._doc = contentDiv;	}	// IMPORTANT: we have to allow Mozilla a short time to recognize the	// new frame. Otherwise we get a stupid exception.	function initIframe() {		var doc = editor._iframe.contentWindow.document;		if (!doc) {			if (HTMLArea.is_gecko) {				setTimeout(function () { editor._initIframe(); }, 10);				return false;			} else {				alert("ERROR: IFRAME can't be initialized.");			}		}		if (HTMLArea.is_gecko) {			// enable editable mode for Mozilla			doc.designMode = "on";		}		editor._doc = doc;		doc.open();		var html = "<html>\n";		html += "<head>\n";		if (editor.config.styleSheet) { html += "<link rel=\"stylesheet\" href=\"" + editor.config.styleSheet + "\" type=\"text/css\">"; }		html += "<style> body { " + editor.config.bodyStyle + " } </style>\n";		html += "</head>\n";		html += "<body>\n";		html += unescape(editor._textArea.value);		html += "</body>\n";		html += "</html>";		doc.write(html);		doc.close();		editor._docContent = doc.body;		if (HTMLArea.is_ie) {			// enable editable mode for IE.  For some reason this doesn't 			// work if done in the same place as for Gecko (above).			doc.body.contentEditable = true;		}		editor.focusEditor();		// intercept some events; for updating the toolbar & keyboard handlers		HTMLArea._addEvents			(doc, ["keydown", "keypress", "mousedown", "mouseup", "drag"],			 function (event) {				 return editor._editorEvent(HTMLArea.is_ie ? editor._iframe.contentWindow.event : event);			 });		editor.updateToolbar();		editor.focusEditor();		editor._initialised = true;	};	function initDiv() {		editor._doc.style.width  = "100%";		editor._doc.style.height = "100%";		editor._doc.innerHTML = unescape(editor._textArea.value);		if (HTMLArea.is_ie) { editor._doc.contentEditable = true; }		// intercept some events; for updating the toolbar & keyboard handlers		HTMLArea._addEvents			(editor._doc, ["keydown", "keypress", "mousedown", "mouseup", "drag"],			 function (event) {				 return editor._editorEvent(event);			 });		editor._docContent = contentDiv;		editor._doc = editor._docContent.document;		editor.updateToolbar();		editor.focusEditor();		editor._initialised = true;	};	if (HTMLArea.is_gecko || editor.config.bodyType.toLowerCase() == 'iframe') {		setTimeout(initIframe, HTMLArea.is_gecko ? 10 : 0);	} else if (HTMLArea.is_ie && editor.config.bodyType.toLowerCase() == 'div') {		setTimeout(initDiv, 0);	}};
meta: 5635	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/5635/e27038dc8513fce46de7575660ecbffbdf5bf1e7/core.js/buggy/fudge/wysiwyg/core/core.js