');
range.select();
}
}
}
function EditorOnStartInsertSmiley(id)
{
if (!EditorValidateMode(id)) {
return;
}
if (eval(EDITOR_IMAGE_CHOOSER_PREFIX + id).IsShowing()) {
eval(EDITOR_IMAGE_CHOOSER_PREFIX + id).Hide();
}
else {
EditorHideAllDropDowns(id);
var editor = editorMap[id];
editor.selectionRange = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();
eval(EDITOR_IMAGE_CHOOSER_PREFIX + id).Show(eval(EDITOR_SMILEY_BUTTON_PREFIX + id).offsetLeft+2, eval(EDITOR_TOOLBAR_PREFIX + id).offsetTop+30);
}
}
function EditorOnEndInsertSmiley(image, id)
{
if (!EditorValidateMode(id)) {
return;
}
var imgTag = '

';
var editor = editorMap[id];
var bodyRange = eval(EDITOR_COMPOSITION_PREFIX + id).document.body.createTextRange();
if (bodyRange.inRange(editor.selectionRange)) {
editor.selectionRange.pasteHTML(imgTag);
eval(EDITOR_COMPOSITION_PREFIX + id).focus();
}
else {
eval(EDITOR_COMPOSITION_PREFIX + id).document.body.innerHTML += imgTag;
editor.selectionRange.collapse(false);
editor.selectionRange.select();
}
}
function EditorOnEndInsertLine(color, id)
{
if (!EditorValidateMode(id)) {
return;
}
var imgTag = '
';
var editor = editorMap[id];
eval(EDITOR_COMPOSITION_PREFIX + id).focus();
var range = eval(EDITOR_COMPOSITION_PREFIX + id).document.selection.createRange();
range.pasteHTML(imgTag);
}
function EditorOnFont(id, select)
{
EditorFormat(id, "fontname", select);
}
function EditorOnSize(id, select)
{
EditorFormat(id, "fontsize", select);
}
function EditorOnFontDropDown(id)
{
if (!EditorValidateMode(id)) {
return;
}
EditorToggleDropDown(id, EDITOR_FONT_PREFIX);
}
function EditorOnSizeDropDown(id)
{
if (!EditorValidateMode(id)) {
return;
}
EditorToggleDropDown(id, EDITOR_SIZE_PREFIX);
}
function EditorOnForegroundTextColor(id)
{
if (!EditorValidateMode(id)) {
return;
}
EditorToggleDropDown(id, EDITOR_FORE_PREFIX);
}
function EditorOnBackgroundTextColor(id)
{
if (!EditorValidateMode(id)) {
return;
}
EditorToggleDropDown(id, EDITOR_BACK_PREFIX);
}
function EditorOnInsertLine(id)
{
if (!EditorValidateMode(id)) {
return;
}
EditorToggleDropDown(id, EDITOR_LINE_PREFIX);
}
function EditorOnAlignment(id)
{
if (!EditorValidateMode(id)) {
return;
}
EditorToggleDropDown(id, EDITOR_ALIGN_PREFIX);
}
function EditorOnList(id)
{
if (!EditorValidateMode(id)) {
return;
}
EditorToggleDropDown(id, EDITOR_LIST_PREFIX);
}
function EditorOnViewHTMLSource(id, textMode)
{
var editor = editorMap[id];
editor.ViewHTMLSource(textMode);
}
function EditorOnClick(id)
{
EditorHideAllDropDowns(id);
}
function EditorValidateMode(id)
{
var editor = editorMap[id];
if (!editor.textMode) {
return true;
}
alert("Please uncheck the \"View HTML Source\" checkbox to use the toolbars.");
eval(EDITOR_COMPOSITION_PREFIX + id).focus();
return false;
}
function EditorFormat(id, what, opt)
{
if (!EditorValidateMode(id)) {
return;
}
if (opt == "removeFormat") {
what = opt;
opt = null;
}
EditorHideAllDropDowns(id);
eval(EDITOR_COMPOSITION_PREFIX + id).focus();
if (opt == null) {
eval(EDITOR_COMPOSITION_PREFIX + id).document.execCommand(what);
}
else
{
eval(EDITOR_COMPOSITION_PREFIX + id).document.execCommand(what,"",opt);
}
}
function EditorCleanHTML(id)
{
var fonts = eval(EDITOR_COMPOSITION_PREFIX + id).document.body.all.tags("FONT");
for (var i = fonts.length - 1; i >= 0; i--) {
var font = fonts[i];
if (font.style.backgroundColor == "#ffffff") {
font.outerHTML = font.innerHTML;
}
}
}
function EditorGetElement(tagName, start)
{
while (start && start.tagName != tagName) {
start = start.parentElement;
}
return start;
}
function EditorSetBackgroundColor(color)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.backgroundColor = color;
this.backgroundColor = color;
}
function EditorGetBackgroundColor()
{
return this.backgroundColor;
}
function EditorRemoveBackgroundColor(color)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.backgroundColor = "";
this.backgroundColor = "";
}
function EditorSetBackgroundImage(url)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.backgroundImage = 'url(' + url + ')';
this.backgroundImage = url;
}
function EditorGetBackgroundImage()
{
return this.backgroundImage;
}
function EditorRemoveBackgroundImage(url)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.backgroundImage = "none";
this.backgroundImage = "";
}
function EditorSetForegroundColor(color)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.color = color;
this.foregroundColor = color;
}
function EditorGetForegroundColor()
{
return this.foregroundColor;
}
function EditorRemoveForegroundColor(color)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.color = "";
this.foregroundColor = "";
}
function EditorSetFontFamily(fontFamily)
{
if (fontFamily == "") {
fontFamily = EDITOR_DEFAULT_FONT_FAMILY;
}
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.fontFamily = fontFamily;
this.fontFamily = fontFamily;
}
function EditorGetFontFamily()
{
return this.fontFamily;
}
function EditorRemoveFontFamily(font)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.fontFamily = EDITOR_DEFAULT_FONT_FAMILY;
this.fontFamily = EDITOR_DEFAULT_FONT_FAMILY;
}
function EditorSetFontSize(fontSize)
{
if (fontSize == "") {
fontSize = EDITOR_DEFAULT_FONT_SIZE;
}
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.fontSize = fontSize;
this.fontSize = fontSize;
}
function EditorGetFontSize()
{
return this.fontSize;
}
function EditorRemoveFontSize(font)
{
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.style.fontSize = EDITOR_DEFAULT_FONT_SIZE;
this.fontSize = EDITOR_DEFAULT_FONT_SIZE;
}
function EditorSetStationery(on)
{
this.stationery = on;
}
function EditorGetStationery()
{
return this.stationery;
}
function EditorViewHTMLSource(textMode)
{
this.textMode = textMode;
if (this.textMode) {
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerText = eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerHTML;
}
else {
eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerHTML = eval(EDITOR_COMPOSITION_PREFIX + this.id).document.body.innerText;
}
eval(EDITOR_COMPOSITION_PREFIX + this.id).focus();
}
function EditorUnload()
{
if (this.stationeryWindow != null) {
this.stationeryWindow.close();
}
}
function EditorShowDropDown(id, prefix)
{
editorActive = id;
EditorHideAllDropDowns(id);
EditorPrepareDropDownContents(id, prefix);
eval(prefix + id).document.body.style.border = "#737373 solid 1px";
d.all[prefix + id].style.display = "inline";
}
function EditorHideDropDown(id, prefix)
{
d.all[prefix + id].style.display = "none";
}
function EditorToggleDropDown(id, prefix)
{
if (d.all[prefix + id].style.display == "none") {
EditorShowDropDown(id, prefix);
}
else {
EditorHideDropDown(id, prefix);
}
}
function EditorHideAllDropDowns(id)
{
var editor = editorMap[id];
for (var i in editor.dropDownMap) {
EditorHideDropDown(id, i);
}
eval(EDITOR_IMAGE_CHOOSER_PREFIX + id).Hide();
}
function EditorPrepareDropDownContents(id, prefix)
{
var editor = editorMap[id];
var dropDown = editor.dropDownMap[prefix];
if (dropDown.external) {
if (d.all[prefix + id].src == "") {
d.all[prefix + id].src = dropDown.content;
}
}
else {
if (eval(prefix + id).document.body.innerHTML == "") {
eval(prefix + id).document.body.innerHTML = dropDown.content;
}
}
}
function EditorInitDropDowns(id)
{
var editor = editorMap[id];
editor.dropDownMap = new Object();
editor.dropDownMap[EDITOR_FONT_PREFIX] = {
external: false,
content: (
"
"
)
};
editor.dropDownMap[EDITOR_SIZE_PREFIX] = {
external: false,
content: (
"
"
)
};
editor.dropDownMap[EDITOR_ALIGN_PREFIX] = {
external: false,
content: (
"
"
+
"
"
+
" | Flush Left |
"
+
" | Centered |
"
+
" | Flush Right |
"
+
"
"
+
"
"
)
};
editor.dropDownMap[EDITOR_LIST_PREFIX] = {
external: false,
content: (
"
"
+
"
"
+
" | Numbered List |
"
+
" | Bulleted List |
"
+
"
"
+
"
"
)
};
editor.dropDownMap[EDITOR_FORE_PREFIX] = {
external: true,
content: "tcolor.html"
};
editor.dropDownMap[EDITOR_BACK_PREFIX] = {
external: true,
content: "hcolor.html"
};
editor.dropDownMap[EDITOR_LINE_PREFIX] = {
external: true,
content: "line.html"
};
}
© 2002-2009 ~ Dhriti ~