📄 ftb-pro.js
字号:
FTB_FreeTextBox.prototype.InsertDiv = function() {
var div = window.document.createElement("div");
div.style.width = "200px";
div.style.height = "200px";
div.style.border = "dotted 1px gray";
this.InsertElement(div);
}
FTB_FreeTextBox.prototype.EditStyle = function() {
// custom implimentation of GetParentElement() and GetSelection() and GetRange()
el = this.GetParentElement();
this.EditElementStyle(el);
}
var els,styleWins;
FTB_FreeTextBox.prototype.EditElementStyle = function(el) {
var styleWin = window.open("","propWin","width=530,height=420,status=0,toolbars=0");
if (styleWin) {
styleWin.focus();
} else {
alert(messages[6][this.language]);
return;
}
//return;
styleWins = styleWin;
ftb = this;
els = el;
setTimeout("EditElementStyle1()","500")
//edit by tht
//alert();
}
function EditElementStyle1()
{
html = FTB_StyleEditorHtml;
styleWins.document.body.innerHTML = '';
styleWins.document.open();
styleWins.document.write( html );
styleWins.document.close();
launchParameters = new Object();
launchParameters['ftb'] = this;
launchParameters['element'] = els;
styleWins.launchParameters = launchParameters;
styleWins.load();
}
/* START: Table Functions
These functions are derived from HTMLAREA who
gave permission for them to be used in FreeTextBox
- Thanks HTMLAREA!!
----------------------------------------------- */
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);
}
var tableWin,editi,ftb;
FTB_FreeTextBox.prototype.LaunchTableWindow = function(editing) {
tableWin = window.open("","tableWin","width=400,height=200");
if (tableWin) {
tableWin.focus();
} else {
alert(messages[6][this.language]);
return;
}
ftb = this;
editi = editing
setTimeout("test()",500);
}
function test()
{
tableWin.document.body.innerHTML = '';
tableWin.document.open();
tableWin.document.write(FTB_TablePopUpHtml);
tableWin.document.close();
launchParameters = new Object();
launchParameters['ftb'] = ftb;
//alert(tableWin);
launchParameters['table'] = (editi) ? ftb.GetNearest("table") : null;
tableWin.launchParameters = launchParameters;
tableWin.load();
}
FTB_FreeTextBox.prototype.InsertTableColumnBefore = function() {
this.InsertTableColumn(false);
}
FTB_FreeTextBox.prototype.InsertTableColumnAfter = function() {
this.InsertTableColumn(true);
}
FTB_FreeTextBox.prototype.InsertTableColumn = function(after) {
var td = this.GetNearest("td");
if (!td) {
return;
}
var rows = td.parentNode.parentNode.rows;
var index = td.cellIndex;
for (var i = rows.length; --i >= 0;) {
var tr = rows[i];
var otd = this.designEditor.document.createElement("td");
otd.innerHTML = (FTB_Browser.isIE) ? "" : "<br />";
//if last column and insert column after is select append child
if (index==tr.cells.length-1 && after) {
tr.appendChild(otd);
} else {
var ref = tr.cells[index + ((after) ? 1 : 0)]; // 0
tr.insertBefore(otd, ref);
}
}
}
FTB_FreeTextBox.prototype.InsertTableRowBefore = function() {
this.InsertTableRow(false);
}
FTB_FreeTextBox.prototype.InsertTableRowAfter = function() {
this.InsertTableRow(true);
}
FTB_FreeTextBox.prototype.InsertTableRow = function(after) {
var tr = this.GetNearest("tr");
if (!tr) return;
var otr = tr.cloneNode(true);
this.ClearRow(otr);
tr.parentNode.insertBefore(otr, ((after) ? tr.nextSibling : tr));
}
FTB_FreeTextBox.prototype.DeleteTableColumn = function() {
var td = this.GetNearest("td");
if (!td) {
return;
}
var index = td.cellIndex;
if (td.parentNode.cells.length == 1) {
return;
}
// set the caret first to a position that doesn't disappear
this.SelectNextNode(td);
var rows = td.parentNode.parentNode.rows;
for (var i = rows.length; --i >= 0;) {
var tr = rows[i];
tr.removeChild(tr.cells[index]);
}
}
FTB_FreeTextBox.prototype.DeleteTableRow = function() {
var tr = this.GetNearest("tr");
if (!tr) {
return;
}
var par = tr.parentNode;
if (par.rows.length == 1) {
return;
}
// set the caret first to a position that doesn't disappear.
this.SelectNextNode(tr);
par.removeChild(tr);
}
// helper table
FTB_FreeTextBox.prototype.ClearRow = function(tr) {
var tds = tr.getElementsByTagName("td");
for (var i = tds.length; --i >= 0;) {
var td = tds[i];
td.rowSpan = 1;
td.innerHTML = (FTB_Browser.isIE) ? "" : "<br />";
}
}
FTB_FreeTextBox.prototype.SplitRow = function(td) {
var n = parseInt("" + td.rowSpan);
var nc = parseInt("" + td.colSpan);
td.rowSpan = 1;
tr = td.parentNode;
var itr = tr.rowIndex;
var trs = tr.parentNode.rows;
var index = td.cellIndex;
while (--n > 0) {
tr = trs[++itr];
var otd = editor._doc.createElement("td");
otd.colSpan = td.colSpan;
otd.innerHTML = mozbr;
tr.insertBefore(otd, tr.cells[index]);
}
}
FTB_FreeTextBox.prototype.SplitCol = function(td) {
var nc = parseInt("" + td.colSpan);
td.colSpan = 1;
tr = td.parentNode;
var ref = td.nextSibling;
while (--nc > 0) {
var otd = editor._doc.createElement("td");
otd.rowSpan = td.rowSpan;
otd.innerHTML = mozbr;
tr.insertBefore(otd, ref);
}
}
FTB_FreeTextBox.prototype.SplitCell = function(td) {
var nc = parseInt("" + td.colSpan);
splitCol(td);
var items = td.parentNode.cells;
var index = td.cellIndex;
while (nc-- > 0) {
this.SplitRow(items[index++]);
}
}
/* FORM Functions
-------------------------------------- */
FTB_FreeTextBox.prototype.IsInForm = function() {
return (this.GetNearest("form")) ? true : false ;
}
FTB_FreeTextBox.prototype.InsertForm = function() {
var form = window.document.createElement("form");
this.InsertElement(form);
}
FTB_FreeTextBox.prototype.InsertCheckBox = function() {
this.InsertInputElement("","checkbox");
}
FTB_FreeTextBox.prototype.InsertTextBox = function() {
this.InsertInputElement("","text");
}
FTB_FreeTextBox.prototype.InsertRadioButton = function() {
this.InsertInputElement("","radio");
}
FTB_FreeTextBox.prototype.InsertButton = function() {
this.InsertInputElement("","button");
}
FTB_FreeTextBox.prototype.InsertDropDownList = function() {
var select = window.document.createElement("select");
this.InsertElement(select);
}
FTB_FreeTextBox.prototype.InsertTextArea = function() {
var textarea = window.document.createElement("textarea");
this.InsertElement(textarea);
}
FTB_FreeTextBox.prototype.InsertInputElement = function(id,type) {
var input = window.document.createElement("input");
input.id = id;
input.type = type;
this.InsertElement(input);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -