📄 ftb-freetextbox.js
字号:
this.UpdateToolbars();
return;
}
*/
// if we're already in a SPAN
if (isSpan) {
if (parent.childNodes.length == 1) {
parent.className = className;
surround = false;
this.UpdateToolbars();
return;
}
} else {
}
if (surround) {
this.SurroundHtml("<span class='" + className + "'>", "</span>");
}
};
FTB_FreeTextBox.prototype.GetHtml = function() {
if (this.mode == FTB_MODE_DESIGN)
this.CopyDesignToHtml();
return this.htmlEditor.value;
};
FTB_FreeTextBox.prototype.SetHtml = function(html) {
this.htmlEditor.value = html;
this.mode = FTB_MODE_HTML;
this.GoToDesignMode();
};
FTB_FreeTextBox.prototype.StoreHtml = function() {
if (!this.initialized) return;
if (this.mode == FTB_MODE_DESIGN)
this.CopyDesignToHtml();
return true;
};
/* START: Button Methods
-------------------------------- */
FTB_FreeTextBox.prototype.DeleteContents = function() {
if (confirm('Do you want to delete all the HTML and text presently in the editor?')) {
this.designEditor.document.body.innerHTML = '';
this.htmlEditor.value='';
this.GoToDesignMode();
}
};
FTB_FreeTextBox.prototype.Cut = function() {
if (this.mode == FTB_MODE_DESIGN) {
try {
this.ExecuteCommand('cut');
} catch (e) {
alert('Your security settings to not allow you to use this command. Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
}
} else {
//alert("TODO");
}
};
FTB_FreeTextBox.prototype.Copy = function() {
if (this.mode == FTB_MODE_DESIGN) {
try {
this.ExecuteCommand('copy');
} catch (e) {
alert('Your security settings to not allow you to use this command. Please visit http://www.mozilla.org/editor/midasdemo/securityprefs.html for more information.');
}
} else {
//alert("TODO");
}
};
FTB_FreeTextBox.prototype.Paste = function() {
if (this.mode == FTB_MODE_DESIGN) this.CapturePaste();
}
FTB_FreeTextBox.prototype.SelectAll = function() {
if (this.mode == FTB_MODE_DESIGN) {
this.SelectNodeContents(this.designEditor.document.body);
}
};
FTB_FreeTextBox.prototype.Print = function() {
if (this.mode == FTB_MODE_DESIGN) {
if (FTB_Browser.isIE) {
this.ExecuteCommand('print');
} else {
this.designEditor.print();
}
} else {
printWindow = window.open('','','');
printWindow.document.open();
printWindow.document.write("<html><body><pre>" + this.HtmlEncode(this.htmlEditor.value) + "</code></body></html>");
printWindow.document.close();
printWindow.document.body.print();
printWindow.close();
}
};
FTB_FreeTextBox.prototype.CreateLink = function() {
if (FTB_Browser.isIE) {
this.ExecuteCommand('createlink','1',null);
} else {
//need to pull
var link = this.GetNearest('a');
var url = prompt('Enter a URL:', (link) ? link.href : 'http://');
if ((url != null) && (url != ''))
this.ExecuteCommand('createlink',null,url);
}
};
FTB_FreeTextBox.prototype.IeSpellCheck = function() {
if (!FTB_Browser.isIE) {
alert('IE Spell is not supported in Mozilla');
return;
}
try {
var tspell = new ActiveXObject('ieSpell.ieSpellExtension');
tspell.CheckAllLinkedDocuments(window.document);
} catch (err){
if (window.confirm('You need ieSpell to use spell check. Would you like to install it?')){
window.open('http://www.iespell.com/download.php');
};
}
};
FTB_FreeTextBox.prototype.NetSpell = function() {
if (typeof(checkSpellingById) == 'function') {
checkSpellingById(this.id + '_designEditor');
} else {
alert('Netspell libraries not properly linked.');
}
};
FTB_FreeTextBox.prototype.InsertImage = function() {
if (FTB_Browser.isIE) {
this.ExecuteCommand('insertimage','1',null);
} else {
var img = this.GetNearest('img');
var imgSrc = prompt('Enter an image URL:', (img) ? img.src : 'http://');
if ((imgSrc != null) && (imgSrc != ''))
this.ExecuteCommand('insertimage',null,imgSrc);
}
};
FTB_FreeTextBox.prototype.SaveButton = function() {
this.StoreHtml();
dotNetName = this.id.split('_').join(':');
__doPostBack(dotNetName,'Save');
};
FTB_FreeTextBox.prototype.InsertImageFromGallery = function() {
url = this.imageGalleryUrl.replace(/\{0\}/g,this.imageGalleryPath);
url += "&ftb=" + this.id;
var gallery = window.open(url,'gallery','width=700,height=600,toolbars=0,resizable=1');
gallery.focus();
}
FTB_FreeTextBox.prototype.Preview = function() {
this.CopyDesignToHtml();
printWindow = window.open('','','toolbars=no');
printWindow.document.open();
printWindow.document.write("<html><head><link rel='stylesheet' href='" + this.designModeCss + "' type='text/css' />" + ((this.baseUrl != '') ? "<base href='" + this.baseUrl + "' />" : "") + "</head><body>" + this.htmlEditor.value + "</body></html>");
printWindow.document.close();
};
/* START: InsertTable */
FTB_FreeTextBox.prototype.InsertTable = function(cols,rows,width,widthUnit,align,cellpadding,cellspacing,border) {
this.designEditor.focus();
var sel = this.GetSelection();
var range = this.CreateRange(sel);
var doc = this.designEditor.document;
// create the table element
var table = doc.createElement("table");
// assign the given arguments
table.style.width = width + widthUnit;
table.align = align;
table.border = border;
table.cellSpacing = cellspacing;
table.cellPadding = cellpadding;
var tbody = doc.createElement("tbody");
table.appendChild(tbody);
for (var i = 0; i < rows; ++i) {
var tr = doc.createElement("tr");
tbody.appendChild(tr);
for (var j = 0; j < cols; ++j) {
var td = doc.createElement("td");
tr.appendChild(td);
if (!FTB_Browser.isIE) td.appendChild(doc.createElement("br"));
}
}
if (FTB_Browser.isIE) {
range.pasteHTML(table.outerHTML);
} else {
this.InsertNodeAtSelection(table);
}
return true;
};
FTB_FreeTextBox.prototype.InsertTableWindow = function() {
this.LaunchTableWindow(false);
};
FTB_FreeTextBox.prototype.EditTable = function() {
this.LaunchTableWindow(true);
};
FTB_FreeTextBox.prototype.LaunchTableWindow = function(editing) {
var tableWin = window.open("","tableWin","width=400,height=200");
if (tableWin) {
tableWin.focus();
} else {
alert("Please turn off your PopUp blocking software");
return;
}
tableWin.document.body.innerHTML = '';
tableWin.document.open();
tableWin.document.write(FTB_TablePopUpHtml);
tableWin.document.close();
launchParameters = new Object();
launchParameters['ftb'] = this;
launchParameters['table'] = (editing) ? this.GetNearest("table") : null;
tableWin.launchParameters = launchParameters;
tableWin.load();
};
var FTB_TablePopUpHtml = new String("\
<html><body> \
<head>\
<title>Table Editor</title>\
<style type='text/css'>\
html, body { \
background-color: #eee; \
color: #000; \
font: 11px Tahoma,Verdana,sans-serif; \
padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
margin-top: 5px; \
margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px; margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\</style>\
<script type='text/javascript'>\
function doTable() { \
ftb = window.launchParameters['ftb'];\
table = window.launchParameters['table'];\
if (table) { \
table.style.width = document.getElementById('f_width').value + document.getElementById('f_unit').options[document.getElementById('f_unit').selectedIndex].value; \
table.align = document.getElementById('f_align').options[document.getElementById('f_align').selectedIndex].value; \
table.cellPadding = (document.getElementById('f_padding').value.length > 0 && !isNaN(document.getElementById('f_padding').value)) ? parseInt(document.getElementById('f_padding').value) : ''; \
table.cellSpacing = (document.getElementById('f_spacing').value.length > 0 && !isNaN(document.getElementById('f_spacing').value)) ? parseInt(document.getElementById('f_spacing').value) : ''; \
table.border = parseInt(document.getElementById('f_border').value); \
} else {\
cols = parseInt(document.getElementById('f_cols').value); \
rows = parseInt(document.getElementById('f_rows').value); \
width = document.getElementById('f_width').value; \
widthUnit = document.getElementById('f_unit').options[document.getElementById('f_unit').selectedIndex].value; \
align = document.getElementById('f_align').value; \
cellpadding = document.getElementById('f_padding').value; \
cellspacing = document.getElementById('f_spacing').value; \
border = document.getElementById('f_border').value; \
ftb.InsertTable(cols,rows,width,widthUnit,align,cellpadding,cellspacing,border); \
} \
window.close(); \
}\
</script>\
</head>\
<body>\
<form action=''> \
<h3>Table Editor</h3> \
<table border='0' style='padding: 0px; margin: 0px'> \
<tbody> \
<tr> \
<td style='width: 4em; text-align: right'>Rows:</td> \
<td><input type='text' name='rows' id='f_rows' size='5' title='Number of rows' value='2' /></td> \
<td></td> \
<td></td> \
<td></td> \
</tr> \
<tr> \
<td style='width: 4em; text-align: right'>Cols:</td> \
<td><input type='text' name='cols' id='f_cols' size='5' title='Number of columns' value='4' /></td> \
<td style='width: 4em; text-align: right'>Width:</td> \
<td><input type='text' name='width' id='f_width' size='5' title='Width of the table' value='100' /></td> \
<td><select size='1' name='unit' id='f_unit' title='Width unit'> \
<option value='%' selected='1' >Percent</option> \
<option value='px' >Pixels</option> \
<option value='em' >Em</option> \
</select></td> \
</tr> \
</tbody> \
</table> \
<table width='100%'>\
<tr><td valign='top'>\
<fieldset>\
<legend>Layout</legend> \
<table>\
<tr><td class='f_title'>Alignment:</td><td>\
<select size='1' name='align' id='f_align' \
title='Positioning of the table'> \
<option value='' selected='1' >Not set</option> \
<option value='left' >Left</option> \
<option value='center' >Center</option> \
<option value='right' >Right</option> \
</select> \
</td></tr>\
<tr><td class='f_title'>Border thickness:</td><td>\
<input type='text' name='border' id='f_border' size='5' value='1' title='Leave empty for no border' /> \
</td></tr></table>\
</fieldset>\
</td><td valign='top'>\
<fieldset>\
<legend>Spacing</legend> \
<table>\
<tr><td class='f_title'>Cell spacing:</td><td>\
<input type='text' name='spacing' id='f_spacing' size='5' value='1' title='Space between adjacent cells' /> \
</td></tr>\
<tr><td class='f_title'>Cell padding:</td><td>\
<input type='text' name='padding' id='f_padding' size='5' value='1' title='Space between content and border in cell' /> \
</td></tr></table>\
</fieldset> \
</td></tr></table>\
<div class='footer'> \
<button type='button' name='ok' id='f_goButton' onclick='doTable();window.close();'>OK</button> \
<button type='button' name='cancel' onclick='window.close();'>Cancel</button> \
</div> \
<script language='JavaScript'> \
function load() { \
ftb = window.launchParameters['ftb'];\
table = window.launchParameters['table'];\
if (table) { \
width = window.opener.FTB_ParseUnit(table.style.width); \
document.getElementById('f_width').value = width.value; \
window.opener.FTB_SetListValue(document.getElementById('f_align'),table.align,true); \
window.opener.FTB_SetListValue(document.getElementById('f_unit'),width.unitType,true); \
document.getElementById('f_border').value = table.border; \
document.getElementById('f_padding').value = table.cellPadding; \
document.getElementById('f_spacing').value = table.cellSpacing; \
document.getElementById('f_cols').disabled = true; \
document.getElementById('f_rows').disabled = true; \
} \
} \
</script></form> \
</body> \
</html>");
/* END: InsertTable */
/* --------------------------------
END: Button Methods */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -