Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.DesignPanel = function(element) {
Sys.Extended.UI.HtmlEditor.DesignPanel.initializeBase(this, [element]);
this._doc = null;
this._updated_now = false;
this._updateTimer = null;
this._popup = null;
this._contextElement = null;
this._a_prize = false;
this.__stack = null;
this._StyleForTyping = null;
this.isWord = false;
this.isPlainText = false;
this.dfltBlockElement = "P";
this._FontNotSet = true;
this._design_timer1 = null;
this._events$delegate = Function.createDelegate(this, Sys.Extended.UI.HtmlEditor.DesignPanelEventHandler);
this._blur$delegate = Function.createDelegate(this, this._blur);
this._focus$delegate = Function.createDelegate(this, this._focus_event);
}
Sys.Extended.UI.HtmlEditor.DesignPanel.prototype = {
initialize: function() {
Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this, "initialize");
},
dispose: function() {
Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this, "dispose");
},
_activate: function(value) {
Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this, "_activate");
this._wasFocused = false;
this._initIframe(value);
this._onDocumentLoaded();
},
_deactivate: function() {
this._deactivateCommon();
if(Sys.Extended.UI.HtmlEditor.isIE) {
this._doc.open();
this._doc.write("");
this._doc.close();
this.get_element().src = "javascript:false;";
}
this._doc = null;
Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this, "_deactivate");
},
_deactivateCommon: function() {
this._editPanel.__blured = false;
var aList = this._doc.body.getElementsByTagName("IMG");
for(var i = 0; i < aList.length; i++) {
if(aList[i].getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute) && aList[i].getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute).length > 0) {
try {
if(Sys.Extended.UI.HtmlEditor.isIE)
$removeHandler(aList[i], "dragstart", Sys.Extended.UI.HtmlEditor.stopDrag);
else
$removeHandler(aList[i], "draggesture", Sys.Extended.UI.HtmlEditor.stopDrag);
} catch(e) { }
}
}
Sys.Extended.UI.HtmlEditor._removeEvents(this._doc, ["keydown", "keypress", "mousedown", "mouseup", "dblclick"], this._events$delegate);
Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow, ["blur"], this._blur$delegate);
Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow, ["focus"], this._focus$delegate);
},
_initIframe: function(value) {
if(!Sys.Extended.UI.HtmlEditor.isIE) {
this._savedValue = value;
this._absAndFixedParents = this._getAbsAndFixedParents();
}
var str = Sys.Extended.UI.HtmlEditor.Trim(this._prepareContent(value));
this._doc = this.get_element().contentWindow.document;
if(!Sys.Extended.UI.HtmlEditor.isIE)
this._doc.designMode = "on";
this._doc.open();
this._doc.write("" + str + "");
this._doc.close();
this._doc.id = "EditorDocument";
if(Sys.Extended.UI.HtmlEditor.isIE) {
this._doc.body.contentEditable = true;
this._tryForward = true;
}
},
_blur: function(event) {
this._editPanel.__blured = true;
if(!Sys.Extended.UI.HtmlEditor.isIE && this._design_timer1 != null) {
clearTimeout(this._design_timer1);
this._design_timer1 = null;
}
if(!this.isPopup)
this._editPanel._validate(event, null);
return true;
},
_focus_event: function() {
this._editPanel.__blured = false;
if(Sys.Extended.UI.HtmlEditor.isIE) {
this._really_focused();
} else {
var panel = this;
Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel = this._editPanel;
if(this._design_timer1 == null)
this._design_timer1 = setTimeout(function() { panel._really_focused(); panel._design_timer1 = null; }, 0);
}
return true;
},
_getAbsAndFixedParents: function() {
var el = this.get_element(),
str = "";
while(el != null && el.tagName && el.tagName.toLowerCase() != "body") {
str += el.tagName;
if(el.style.position == "absolute" || el.style.position == "fixed")
str += ": " + el.style.position;
str += "\n";
el = el.parentNode;
}
return str;
},
_onDocumentLoaded: function() {
var editor = this;
if(!Sys.Extended.UI.HtmlEditor.isIE) {
var absAndFixedParents = this._getAbsAndFixedParents();
if(absAndFixedParents != this._absAndFixedParents) {
this._initIframe(this._savedValue);
setTimeout(function() {
editor._onDocumentLoaded()
}, 10);
return;
}
}
try {
if(!Sys.Extended.UI.HtmlEditor.isIE) {
this._doc.queryCommandValue("forecolor");
if(Sys.Extended.UI.HtmlEditor.isSafari || Sys.Extended.UI.HtmlEditor.isOpera)
if(!Sys.Extended.UI.HtmlEditor.isReallyVisible(this.get_element())) {
setTimeout(function() {
editor._onDocumentLoaded()
}, 10);
return;
}
}
var temp = editor._doc.body.innerHTML;
} catch(e) {
setTimeout(function() {
editor._onDocumentLoaded()
}, 10); // waiting for loading
return;
}
this._afterBodyIsFormed();
setTimeout(function() {
editor._activateFinished();
if(Sys.Extended.UI.HtmlEditor.isIE && !editor._editPanel.get_autofocus())
editor._getSelection().empty();
}, 0);
},
_afterBodyIsFormed: function() {
var editor = this;
Sys.Extended.UI.HtmlEditor._addEvents(this._doc, ["keydown", "keypress", "mousedown", "mouseup", "dblclick"], this._events$delegate);
Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow, ["blur"], this._blur$delegate);
Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow, ["focus"], this._focus$delegate);
Sys.Extended.UI.HtmlEditor.inspectForShadows(editor._doc.body);
var body = this._doc.body;
if(body.childNodes.length == 1 && body.firstChild.tagName && body.firstChild.tagName.toUpperCase() == "DIV" &&
body.firstChild.style.cssText.length > 0 && body.firstChild.style.direction.length > 0 &&
Sys.Extended.UI.HtmlEditor.getStyle(body.firstChild, "position") != "absolute") {
body.style.cssText = body.firstChild.style.cssText;
var temp = body.firstChild;
while(temp.firstChild)
body.insertBefore(temp.firstChild, temp);
body.removeChild(temp);
}
editor._clearP();
},
_getContent: function() {
if(this._popup != null)
if(typeof this._popup._forceImClose == "function") {
var func = this._popup._forceImClose;
func(this._popup._iframe.contentWindow);
}
this._clearP();
var temp;
if(Sys.Extended.UI.HtmlEditor.isIE) {
Sys.Extended.UI.HtmlEditor.spanJoiner(this._doc.body, this._doc);
temp = Sys.Extended.UI.HtmlEditor.getHTML(this._doc.body, false, true);
temp = temp.replace(/(]*?>)([\s ]*?)(<\/td[^>]*?>)/ig, "$1 $3")
.replace(/( | ]*?>)\s*( )\s*(<\/td[^>]*?>)/ig, "$1 $3")
.replace(/(]*?>)\s*( )\s*(<\/p[^>]*?>)/ig, "$1 $3");
temp = ((this._doc.body.style.cssText.length > 0) ? " " : "") + temp + ((this._doc.body.style.cssText.length > 0) ? " " : "");
if(this._editPanel.get_noScript())
temp = temp.replace(/(
|