?? onlineeditor.ascx
字號:
setUnselectable(menu);
};
this.initMenuContainer = function(cmd, width, height, overflow) {
var menu = document.createElement('div');
menu.id = editorid + '_popup_' + cmd + '_menu';
menu.className = 'popupmenu_popup';
menu.style.display = 'none';
menu.style.cursor = 'default';
menu.style.padding = '3px';
menu.style.width = width;
menu.style.height = height;
menu.style.overflow = overflow;
return menu;
}
this.buildFontnamePopup = function(obj, menu) {
fol = fontoptions.length;
for(var n = 0; n < fol; n++) {
var option = document.createElement('div');
option.innerHTML = '<font face="' + fontoptions[n] + '">' + fontoptions[n] + '</font>';
option.className = 'editor_ofont';
option.style.textAlign = 'left';
option.cmd = obj.cmd;
option.editorid = editorid;
option.onmouseover = option.onmouseout = option.onmouseup = option.onmousedown = EVENT.menuoption_onmouseevent;
option.onclick = EVENT.formatting_option_onclick;
menu.appendChild(option);
}
}
this.buildFontsizePopup = function(obj, menu) {
sol = sizeoptions.length;
for(var n = 0; n < sol; n++) {
var option = document.createElement('div');
option.innerHTML = '<font size="' + sizeoptions[n] + '">' + sizeoptions[n] + '</font>';
option.className = 'editor_osize';
option.style.textAlign = 'center';
option.cmd = obj.cmd;
option.editorid = editorid;
option.onmouseover = option.onmouseout = option.onmouseup = option.onmousedown = EVENT.menuoption_onmouseevent;
option.onclick = EVENT.formatting_option_onclick;
menu.appendChild(option);
}
}
this.buildForecolorPopup = function(obj, menu) {
var colorout = $(editorid + '_color_out');
colorout.editorid = editorid;
colorout.onclick = EVENT.colorout_onclick;
var table = document.createElement('table');
table.cellPadding = 0;
table.cellSpacing = 0;
table.border = 0;
var i = 0;
for(var hex in coloroptions) {
if(i % 8 == 0) {
var tr = table.insertRow(-1);
}
i++;
var div = document.createElement('div');
div.style.backgroundColor = coloroptions[hex];
var option = tr.insertCell(-1);
option.style.textAlign = 'center';
option.className = 'editor_ocolor';
option.appendChild(div);
option.cmd = obj.cmd;
option.editorid = editorid;
option.colorname = coloroptions[hex];
option.onmouseover = option.onmouseout = option.onmouseup = option.onmousedown = EVENT.menuoption_onmouseevent;
option.onclick = EVENT.coloroption_onclick;
}
menu.appendChild(table);
}
this.menu_context = function(obj, state) {
if(obj.state) {
this.setControlStyle(obj, 'button', 'down');
} else if(state=='mouseout') {
this.setControlStyle(obj, 'button', 'normal');
} else if(state=='mousedown') {
this.setControlStyle(obj, 'popup', 'down');
} else if(state=='mouseup' || state=='mouseover') {
this.setControlStyle(obj, 'button', 'hover');
}
};
this.button_context = function(obj, state, controltype) {
if(undefined(controltype)) {
controltype = 'button';
}
if(obj.state) {
if(state=='mouseover' || state=='mousedown' || state=='mouseup') {
this.setControlStyle(obj, controltype, 'down');
} else if(state=='mouseout') {
this.setControlStyle(obj, 'button', 'selected');
}
}else{
if(state=='mouseout') {
this.setControlStyle(obj, controltype, 'normal');
} else if(state=='mousedown') {
this.setControlStyle(obj, controltype, 'down');
} else if(state=='mouseup' || state=='mouseover') {
this.setControlStyle(obj, controltype, 'hover');
}
}
};
this.setControlStyle = function(obj, controltype, mode) {
if(obj.mode != mode) {
obj.mode = mode;
istyle = 'pi_' + controltype + '_' + obj.mode;
if(typeof istyles != 'undefined' && typeof istyles[istyle] != 'undefined') {
obj.style.background = istyles[istyle][0];
obj.style.color = istyles[istyle][1];
if(controltype != 'menu') {
obj.style.padding = istyles[istyle][2];
}
obj.style.border = istyles[istyle][3];
var tds = findtags(obj, 'td');
for(var i = 0; i < tds.length; i++) {
switch(tds[i].className) {
case 'editor_ofeedback':
tds[i].style.borderRight = (mode == 'normal' ? istyles['pi_menu_normal'][3] : istyles[istyle][3]);
break;
case 'editor_opickbutton':
tds[i].style.borderColor = (mode == 'normal' ? istyles['pi_menu_normal'][0] : istyles[istyle][0]);
break;
case 'editor_apickbutton':
if(obj.state) {
tds[i].style.paddingLeft = istyles['pi_button_normal'][2];
tds[i].style.borderLeft = istyles['pi_button_normal'][3];
} else {
tds[i].style.paddingLeft = istyles[istyle][2];
tds[i].style.borderLeft = istyles[istyle][3];
}
}
}
}
}
};
this.format = function(e, cmd, arg) {
e = doane(e);
if(cmd != 'redo') {
history.add_snapshot(this.getEditorContents());
}
if(cmd.substr(0, 6) == 'resize') {
this.resizeEditor(parseInt(cmd.substr(9), 10) * (parseInt(cmd.substr(7, 1), 10) == '1' ? 1 : -1));
return;
}
this.checkFocus();
if(cmd.substr(0, 4) == 'wrap') {
var ret = this.wrapTags(cmd.substr(6), (cmd.substr(4, 1) == '1' ? true : false));
} else if(cmd.substr(0, 6) == 'custom') {
var ret = this.customTags(cmd.substr(8), cmd.substr(6, 1));
} else if(this[cmd]) {
var ret = this[cmd](e);
} else {
try {
var ret = this.applyFormat(cmd, false, (undefined(arg) ? true : arg));
} catch(e) {
var ret = false;
}
}
if(cmd != 'undo') {
history.add_snapshot(this.getEditorContents());
}
this.setContext(cmd);
this.checkFocus();
return ret;
};
this.insertimage = function(e, img) {
if(undefined(img)) {
img = this.showPrompt(lang['enter_image_url'], 'http://');
}
if(img = this.verifyPrompt(img)) {
return this.applyFormat('insertimage', false, img);
} else {
return false;
}
};
this.wrapTags = function(tagname, useoption, selection) {
if(tagname=='CODE' || tagname=='HTML' || tagname=='PHP') {
this.applyFormat('removeformat');
}
if(undefined(selection)) {
selection = this.getSel();
if(selection === false) {
selection = '';
} else {
selection = new String(selection);
}
}
if(useoption === true) {
var option = this.showPrompt(construct_phrase(lang['enter_tag_option'], ('[' + tagname + ']')), '');
if(option = this.verifyPrompt(option)) {
var opentag = '[' + tagname + '=' + option + ']';
} else {
return false;
}
} else if(useoption !== false) {
var opentag = '[' + tagname + '=' + useoption + ']';
} else {
var opentag = '[' + tagname + ']';
}
var closetag = '[/' + tagname + ']';
var text = opentag + selection + closetag;
this.insertText(text, mb_strlen(opentag), mb_strlen(closetag));
return false;
};
this.get_selection = function(){
if(wysiwyg) {
if(is_moz || is_opera) {
selection = this.editwin.getSelection();
this.checkFocus();
range = selection ? selection.getRangeAt(0) : this.editdoc.createRange();
return this.read_nodes(range.cloneContents(), false);
} else {
var range = this.editdoc.selection.createRange();
if(range.htmlText && range.text) {
return range.htmlText;
} else {
var do_not_steal_this_code_html = '';
for(var i = 0; i < range.length; i++) {
do_not_steal_this_code_html += range.item(i).outerHTML;
}
return do_not_steal_this_code_html;
}
}
} else {
if(typeof(this.editdoc.selectionStart) != 'undefined') {
return this.editdoc.value.substr(this.editdoc.selectionStart, this.editdoc.selectionEnd - this.editdoc.selectionStart);
} else if(document.selection && document.selection.createRange) {
return document.selection.createRange().text;
} else if(window.getSelection) {
return window.getSelection() + '';
} else {
return false;
}
}
};
this.customTags = function(tagindex, params) {
var tagname = custombbcodes[tagindex][0];
var closetag = custombbcodes[tagindex][0]
var tagvalue = custombbcodes[tagindex][0];
var selection;
if (params>0){
if(undefined(selection)) {
selection = this.get_selection();
if(selection === false) {
selection = '';
} else {
selection = new String(selection);
}
}
var dialogtxt = "";
var defaultval = "";
var tempTagname = "";
if (selection == ""){
if (undefined(custombbcodes[tagindex][3][0])){
title = "請輸入?yún)?shù) 1 :";
}
else{
title = custombbcodes[tagindex][3][0];
}
if (undefined(custombbcodes[tagindex][4][0])){
defval = "";
}
else{
defval = custombbcodes[tagindex][4][0];
}
selection=this.showPrompt(title,defval);
if (selection=="null"){
return;
}
}
for (i=2;i<=params;i++){
if (undefined(custombbcodes[tagindex][3][i-1])){
title = "請輸入?yún)?shù) " + (i-1) + " :";
}
else{
title = custombbcodes[tagindex][3][i-1];
}
if (undefined(custombbcodes[tagindex][4][i-1])){
defval = "";
}
else{
defval = custombbcodes[tagindex][4][i-1];
}
tempTagname = this.showPrompt(title,defval)
if (tempTagname=="null"){
return;
}
if (i==2){
tagname = tagname + "=" + tempTagname;
}
else{
tagname = tagname + "," + tempTagname;
}
}
}
this.applyFormat('removeformat');
if(tagvalue.indexOf(']') == -1) {
tagvalue = '[' + tagname + ']' + selection + '[/' + closetag + ']';
}
params == 1 ?
this.insertText(tagvalue, mb_strlen('[' + tagname + ']'), mb_strlen('[/' + closetag + ']')) : this.insertText(tagvalue, tagvalue.indexOf(']') + 1, mb_strlen('[/' + closetag + ']'));
};
this.showPrompt = function(dialogtxt, defaultval) {
return PHP.trim(new String(prompt(dialogtxt, defaultval)));
};
this.verifyPrompt = function(str) {
if(str=='http://' || str=='null' || str=='undefined' || str=='false' || str=='' || str==null || str==false) {
return false;
} else {
return str;
}
};
this.resizeEditor = function(change) {
var newheight = parseInt(this.editbox.style.height, 10) + change;
if(newheight >= 100) {
this.editbox.style.height = newheight + 'px';
if(change % 99 != 0) {
document.cookie = 'editor_height=' + escape(newheight) + '; path=/';
}
}
};
this.destroyPopup = function(popupname) {
ePopups[popupname].parentNode.removeChild(ePopups[popupname]);
}
this.destroy = function() {
for(var i in eButtons) {
this.setControlStyle(eButtons[i], 'button', 'normal');
}
for(var menu in ePopups) {
this.destroyPopup(menu);
}
if(this.fontoptions) {
for(var i in this.fontoptions) {
if(i != '') {
this.fontoptions[i].parentNode.removeChild(this.fontoptions[i]);
}
}
this.fontoptions[''].style.display = '';
}
if(this.sizeoptions) {
for(var i in this.sizeoptions) {
if(i != '') {
this.sizeoptions[i].parentNode.removeChild(this.sizeoptions[i]);
}
}
this.sizeoptions[''].style.display = '';
}
};
this.insertSmiley = function(e, smilietext, smiliepath, smilieid) {
this.checkFocus();
if(wysiwyg && this.parsesmilies && !fetchCheckbox("smileyoff")) {
if(is_moz) {
this.applyFormat('InsertImage', false, smiliepath);
var smilies = findtags(this.editdoc.body, 'img');
for(var i = 0; i < smilies.length; i++)
if(smilies[i].src == smiliepath && smilies[i].getAttribute('smilieid') < 1) {
smilies[i].setAttribute('smilieid', smilieid);
smilies[i].setAttribute('border', "0");
}
} else {
this.insertText('<img src="' + smiliepath + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false);
}
} else {
smilietext += ' ';
return this.insertText(smilietext, smilietext.length, 0);
}
};
this.setEditorContents = function(initialtext) {
if(wysiwyg) {
if(findobj(editorid + '_iframe')) {
this.editbox = findobj(editorid + '_iframe');
} else {
var iframe = document.createElement('iframe')
iframe.id = editorid + '_iframe';
iframe.tabIndex = 1;
iframe.frameBorder = 0;
iframe.style.margin="0px 0px 0px 0px";
this.editbox = textobj.parentNode.appendChild(iframe);
}
if(!is_ie) {
this.editbox.style.border = '0px';
}
if (!is_ie){
this.editbox.style.width = textobj.style.width;
if (!is_opera){
this.editbox.style.height = textobj.style.height.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -