📄 ftb-freetextbox.js
字号:
var imgSrc = '';
if (img) {
var imgSrc = link.getAttribute('temp_src');
if (!imgSrc) imgSrc = img.getAttribute('src');
}
if (imgSrc != null) {
if (!img) {
var tempUrl = 'http://tempuri.org/tempuri.html';
this.ExecuteCommand('insertimage',null,tempUrl);
var imgs = this.designEditor.document.getElementsByTagName('img');
for (var i=0;i<imgs.length;i++) {
if (imgs[i].src == tempUrl) {
img = imgs[i];
break;
}
}
}
img.src = imgSrc;
img.setAttribute('temp_src',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>");
var FTB_ImagePopUpHtml = new String("\
<html><body> \
<head>\
<title>图片编辑</title>\
<style type='text/css'>\
html, body { \
background-color: #ECE9D8; \
color: #000000; \
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 updateImage() {\
ftb = window.launchParameters['ftb'];\
img = ftb.GetNearest('img');\
src = document.getElementById('image_src');\
if (src.value == '') {\
alert('您必须输入一个图片链接地址');\
return false;\
}\
if (!img) {\
var tempUrl = 'http://tempuri.org/tempuri.html';\
ftb.ExecuteCommand('insertimage',null,tempUrl);\
var imgs = ftb.designEditor.document.getElementsByTagName('img');\
for (var i=0;i<imgs.length;i++) {\
if (imgs[i].src == tempUrl) {\
img = imgs[i];\
break;\
}\
}\
}\
updateImageProperties(img);\
}\
function updateImageProperties(img) {\
if (img) {\
src = document.getElementById('image_src');\
alt = document.getElementById('image_alt');\
align = document.getElementById('image_align');\
border = document.getElementById('image_border');\
hspace = document.getElementById('image_hspace');\
vspace = document.getElementById('image_vspace');\
width = document.getElementById('image_width');\
height = document.getElementById('image_height');\
img.src = src.value;\
img.setAttribute('temp_src',src.value);\
img.alt = alt.value;\
img.align = align.value;\
img.border = border.value;\
img.hspace = hspace.value;\
img.vspace = vspace.value;\
if(width.value != '')\
img.width = width.value;\
if(height.value != '')\
img.height = height.value;\
}\
}\
function updatePreview() {\
src = document.getElementById('image_src');\
alt = document.getElementById('image_alt');\
align = document.getElementById('image_align');\
border = document.getElementById('image_border');\
hspace = document.getElementById('image_hspace');\
vspace = document.getElementById('image_vspace');\
preview = document.getElementById('preview');\
width = document.getElementById('image_width');\
height = document.getElementById('image_height');\
\
if (width.value == ''|| height.value == '') preview.src = new Image();\
preview.src = src.value;\
preview.alt = alt.value;\
preview.align = align.value;\
preview.border = border.value;\
preview.hspace = hspace.value;\
preview.vspace = vspace.value;\
if (width.value != '') preview.width = width.value;\
if (height.value != '') preview.height = height.value;\
}\
</script>\
</head>\
<body>\
<form action='' onsubmit='updateImage();window.close();'> \
<h3>图片编辑</h3> \
<table><tr><td>\
<table>\
<tr><td class='f_title'>图片地址:</td>\
<td><input type='text' id='image_src' style='width:200px;' onblur='updatePreview();' /></td></tr>\
<tr><td class='f_title'>提示文本:</td>\
<td><input type='text' id='image_alt' style='width:200px;' onblur='updatePreview();' /></td></tr>\
</table>\
</td><td rowspan='3' valign='top'>\
<fieldset><legend>预览</legend>\
<div style='width:180px;height:180px;overflow:scroll;background-color:#fff;'>\
<p><img id='preview' />Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum accumsan, ipsum ut dapibus dapibus, nunc arcu congue velit, sit amet pretium est felis ut libero. Suspendisse hendrerit vestibulum pede.</p>\
</div>\
</fieldset>\
</td></tr><tr><td>\
<fieldset><legend>版面(Layout)</legend><table>\
<tr><td class='f_title'>对齐方式:</td>\
<td><select id='image_align' style='width:70px;' onchange='updatePreview();'>\
<option value='' selected='1'>Not set</option> \
<option value='left' >Left</option> \
<option value='center' >Center</option> \
<option value='right' >Right</option> \
<option value='texttop' >TextTop</option> \
<option value='AbsMiddle' >AbsMiddle</option> \
<option value='Baseline' >Baseline</option> \
<option value='AbsBottom' >AbsBottom</option> \
<option value='Middle' >Middle</option> \
<option value='Top' >Top</option> \
</select> \
</td></tr>\
<tr><td class='f_title'>边框宽度:</td>\
<td><input type='text' id='image_border' style='width:70px;' onblur='updatePreview();' /></td></tr>\
</table>\
</fieldset>\
</td></tr><tr><td>\
<table cellspacing='0' cellpadding='0'><tr><td style='padding-right:5px;'>\
<fieldset><legend>间隔</legend><table>\
<tr><td class='f_title'>水平:</td>\
<td><input type='text' id='image_hspace' style='width:30px;' onblur='updatePreview();' /></td></tr>\
<tr><td class='f_title'>垂直:</td>\
<td><input type='text' id='image_vspace' style='width:30px;' onblur='updatePreview();' /></td></tr>\
</table>\
</fieldset>\
</td><td>\
<fieldset><legend>尺寸</legend><table>\
<tr><td class='f_title'>宽度:</td>\
<td><input type='text' id='image_width' style='width:40px;' onblur='updatePreview();' /></td></tr>\
<tr><td class='f_title'>高度:</td>\
<td><input type='text' id='image_height' style='width:40px;' onblur='updatePreview();' /></td></tr>\
</table>\
</fieldset>\
</td></tr></table>\
</td></tr></table>\
<div class='footer'>\
<button type='button' name='updateImageButton' id='updateImageButton' onclick='updateImage();window.close();'>确定</button>\
<button type='button' name='cancel' id='cancelButton' onclick='window.close();'>取消</button>\
</div>\
<script type='text/javascript'>\
function load() {\
ftb = window.launchParameters['ftb'];\
img = ftb.GetNearest('img');\
src = document.getElementById('image_src');\
alt = document.getElementById('image_alt');\
align = document.getElementById('image_align');\
border = document.getElementById('image_border');\
hspace = document.getElementById('image_hspace');\
vspace = document.getElementById('image_vspace');\
width = document.getElementById('image_width');\
height = document.getElementById('image_height');\
if (img) {\
var imgUrl = img.getAttribute('temp_src');\
src.value = (imgUrl) ? imgUrl : img.src;\
alt.value = img.alt;\
window.opener.FTB_SetListValue(align,img.align,true);\
border.value = img.border;\
hspace.value = img.hspace;\
vspace.value = img.vspace;\
width.value = img.width;\
height.value = img.height;\
updatePreview();\
}\
}\
</script>\
</form> \
</body> \
</html>");
/* END: InsertTable */
/* --------------------------------
END: Button Methods */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -