📄 script_gecko.js.php
字号:
function SPAW_image_popup_click(editor, sender) { var wnd = window.open('<?php echo $spaw_dir?>dialogs/img_library.php?lang=' + document.getElementById('SPAW_'+editor+'_lang').value + '&theme=' + document.getElementById('SPAW_'+editor+'_theme').value + '&editor=' + editor + '&callback=SPAW_image_popup_click_callback', "img_library", 'status=no,modal=yes,width=420,height=420'); } function SPAW_image_popup_click_callback(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); var a = SPAW_getA(editor); var imgSrc = sender.returnValue; if(imgSrc != null) { if (a) { // edit hyperlink a.href="#"; a.setAttribute("onclick","window.open('<?php echo $spaw_img_popup_url?>?img_url="+imgSrc+"','Image','width=500,height=300,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100');return false;"); } else { var a; a = document.createElement('A'); a.href="#"; a.setAttribute("onclick","window.open('<?php echo $spaw_img_popup_url?>?img_url="+imgSrc+"','Image','width=500,height=300,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100');return false;"); if (ed.contentWindow.getSelection().rangeCount>0 && ed.contentWindow.getSelection().getRangeAt(0).startOffset != ed.contentWindow.getSelection().getRangeAt(0).endOffset) { a.appendChild(ed.contentWindow.getSelection().getRangeAt(0).cloneContents()); } else { a.innerHTML = (a.href && a.attributes["href"].nodeValue!='')?a.attributes["href"].nodeValue:a.name; } insertNodeAtSelection(ed.contentWindow, a); } } ed.contentWindow.focus(); } function SPAW_hr_click(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); ed.contentDocument.execCommand('inserthorizontalrule', false, null); ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_copy_click(editor, sender) { // not implemented in gecko } function SPAW_paste_click(editor, sender) { // not implemented in gecko } function SPAW_cut_click(editor, sender) { // not implemented in gecko } function SPAW_delete_click(editor, sender) { // not implemented in gecko } function SPAW_indent_click(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); ed.contentDocument.execCommand('indent', false, null); ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_unindent_click(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); ed.contentDocument.execCommand('outdent', false, null); ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_undo_click(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); ed.contentDocument.execCommand('undo','',null); ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_redo_click(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); ed.contentDocument.execCommand('redo', false, null); ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_getParentTag(editor) { var ed = document.getElementById(editor+'_rEdit'); var selection = ed.contentWindow.getSelection(); var selectedRange; var aControl; if (selection && selection.rangeCount > 0) { selectedRange = selection.getRangeAt(0); aControl = selectedRange.startContainer; if (aControl.nodeType != 1) aControl = aControl.parentNode; } return aControl; } // trim functions function SPAW_ltrim(txt) { } function SPAW_rtrim(txt) { } function SPAW_trim(txt) { } // is selected text a full tags inner html? function SPAW_isFoolTag(editor, el) { } function SPAW_style_change(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); var classname = sender.options[sender.selectedIndex].value; if (ed.contentWindow.getSelection().rangeCount>0) { var currentRange = ed.contentWindow.getSelection().getRangeAt(0); var parent = currentRange.commonAncestorContainer; if (parent.nodeType != 1) parent = currentRange.commonAncestorContainer.parentNode; if (parent && parent.tagName.toLowerCase() != "body" && parent.tagName.toLowerCase() != "html") { // set class on parent parent.className = classname; } else { // create new container var newSpan = ed.contentDocument.createElement("SPAN"); newSpan.className = classname; newSpan.appendChild(currentRange.cloneContents()); insertNodeAtSelection(ed.contentWindow, newSpan); } } ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_font_change(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); var fontname = sender.options[sender.selectedIndex].value; if (fontname == null || fontname == '') { ed.contentDocument.execCommand('RemoveFormat', false, null); } else { ed.contentDocument.execCommand('fontname', false, fontname); } sender.selectedIndex = 0; ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_fontsize_change(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); var fontsize = sender.options[sender.selectedIndex].value; ed.contentDocument.execCommand('fontsize', false, fontsize); sender.selectedIndex = 0; ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_paragraph_change(editor, sender) { var ed = document.getElementById(editor+'_rEdit'); var format = sender.options[sender.selectedIndex].value; ed.contentDocument.execCommand('formatBlock', false, format); sender.selectedIndex = 0; ed.contentWindow.focus(); SPAW_update_toolbar(editor, true); } function SPAW_table_create_click(editor, sender) { var wnd = window.open('<?php echo $spaw_dir?>dialogs/table.php?lang=' + document.getElementById('SPAW_'+editor+'_lang').value + '&theme=' + document.getElementById('SPAW_'+editor+'_theme').value + '&editor=' + editor + '&callback=SPAW_table_create_click_callback', "table_prop", 'status=no,modal=yes,width=420,height=420'); } function SPAW_table_create_click_callback(editor, sender) { var nt = sender.returnValue; var ed = document.getElementById(editor+'_rEdit'); if (nt) { var newtable = document.createElement('TABLE'); try { if (nt.width) newtable.width = nt.width; if (nt.height) newtable.height = nt.height; if (nt.border) newtable.border = nt.border; if (nt.cellPadding) newtable.cellPadding = nt.cellPadding; if (nt.cellSpacing) newtable.cellSpacing = nt.cellSpacing; if (nt.bgColor) newtable.bgColor = nt.bgColor; if (nt.background) newtable.style.backgroundImage = "url("+nt.background+");"; if (nt.className) newtable.className = nt.className; // create rows for (var i=0;i<parseInt(nt.rows);i++) { var newrow = document.createElement('TR'); for (var j=0; j<parseInt(nt.cols); j++) { var newcell = document.createElement('TD'); newcell.innerHTML = " "; // otherwise it doesn't show cell borders newrow.appendChild(newcell); } newtable.appendChild(newrow); } insertNodeAtSelection(ed.contentWindow, newtable); SPAW_toggle_borders(editor, ed.contentDocument.body, null); SPAW_update_toolbar(editor, true); } catch (excp) { alert('error'); } } } function SPAW_table_prop_click(editor, sender) { var tTable = SPAW_getTable(editor); if (tTable) { var tProps = {}; tProps.width = (tTable.style.width)?tTable.style.width:tTable.width; tProps.height = (tTable.style.height)?tTable.style.height:tTable.height; tProps.border = tTable.border; tProps.cellPadding = tTable.cellPadding; tProps.cellSpacing = tTable.cellSpacing; tProps.bgColor = tTable.bgColor; tProps.className = tTable.className; if (tTable.style.backgroundImage != undefined) tProps.background = tTable.style.backgroundImage.substr(4,tTable.style.backgroundImage.length-5); var wnd = window.open('<?php echo $spaw_dir?>dialogs/table.php?lang=' + document.getElementById('SPAW_'+editor+'_lang').value + '&theme=' + document.getElementById('SPAW_'+editor+'_theme').value + '&editor=' + editor + '&callback=SPAW_table_prop_click_callback', "table_prop", 'status=no,modal=yes,width=420,height=420'); wnd.dialogArguments = tProps; } } function SPAW_table_prop_click_callback(editor, sender) { var ntProps = sender.returnValue; var ed = document.getElementById(editor+'_rEdit'); var tTable = SPAW_getTable(editor) if (tTable && ntProps) { // set new settings if (ntProps.width) tTable.width = ntProps.width; else tTable.removeAttribute('width',0); if (ntProps.height) tTable.height = ntProps.height else tTable.removeAttribute('height',0); if (ntProps.border) tTable.border = ntProps.border; else tTable.removeAttribute('border',0); if (ntProps.cellPadding) tTable.cellPadding = ntProps.cellPadding; else tTable.removeAttribute('cellpadding',0); if (ntProps.cellSpacing) tTable.cellSpacing = ntProps.cellSpacing; else tTable.removeAttribute('cellspacing',0); if (ntProps.bgColor) tTable.bgColor = ntProps.bgColor; else tTable.removeAttribute('bgcolor',0); if (ntProps.background) tTable.style.backgroundImage = "url("+ntProps.background+")"; else tTable.style.backgroundImage = ""; if (ntProps.className) tTable.className = ntProps.className; else tTable.removeAttribute('className',0); SPAW_toggle_borders(editor, tTable, null); } SPAW_update_toolbar(editor, true); } // edits table cell properties function SPAW_table_cell_prop_click(editor, sender) { var cd = SPAW_getTD(editor); if (cd) { var cProps = {}; cProps.width = (cd.style.width)?cd.style.width:cd.width; cProps.height = (cd.style.height)?cd.style.height:cd.height; cProps.bgColor = cd.bgColor; if (cd.style.backgroundImage != undefined) cProps.background = cd.style.backgroundImage.substr(4,cd.style.backgroundImage.length-5); cProps.align = cd.align; cProps.vAlign = cd.vAlign; cProps.className = cd.className; cProps.noWrap = cd.noWrap; cProps.styleOptions = new Array(); if (document.getElementById('SPAW_'+editor+'_tb_style') != null) { cProps.styleOptions = document.getElementById('SPAW_'+editor+'_tb_style').options; } var wnd = window.open('<?php echo $spaw_dir?>dialogs/td.php?lang=' + document.getElementById('SPAW_'+editor+'_lang').value + '&theme=' + document.getElementById('SPAW_'+editor+'_theme').value + '&editor=' + editor + '&callback=SPAW_table_cell_prop_click_callback', "table_prop", 'status=no,modal=yes,width=420,height=420'); wnd.dialogArguments = cProps; } } function SPAW_table_cell_prop_click_callback(editor, sender) { var ncProps = sender.returnValue; var ed = document.getElementById(editor+'_rEdit'); var cd = SPAW_getTD(editor) if (cd && ncProps) { if (ncProps.align) cd.align = ncProps.align; else cd.removeAttribute('align',0); if (ncProps.vAlign) cd.vAlign = ncProps.vAlign; else cd.removeAttribute('valign',0); if (ncProps.width) cd.width = ncProps.width; else cd.removeAttribute('width',0); if (ncProps.height) cd.height = ncProps.height; else cd.removeAttribute('height',0); if (ncProps.bgColor) cd.bgColor = ncProps.bgColor; else cd.removeAttribute('bgcolor',0); if (ncProps.background) cd.style.backgroundImage = "url(" + ncProps.background + ")"; else cd.style.backgroundImage = ""; if (ncProps.className) cd.className = ncProps.className; else cd.removeAttribute('className',0); if (ncProps.noWrap) cd.noWrap = ncProps.noWrap; else cd.removeAttribute('nowrap',0); } SPAW_update_toolbar(editor, true); } // returns current table cell function SPAW_getTD(editor) { var ed = document.getElementById(editor+'_rEdit'); var selection = ed.contentWindow.getSelection(); var selectedRange; var aControl; if (selection.rangeCount > 0) { selectedRange = selection.getRangeAt(0); aControl = selectedRange.startContainer; if (aControl.nodeType != 1) aControl = aControl.parentNode; while ((aControl.tagName.toLowerCase() != 'td') && (aControl.tagName.toLowerCase() != 'th') && (aControl.tagName.toLowerCase() != 'table') && (aControl.tagName.toLowerCase() != 'body')) { aControl = aControl.parentNode; } } if (aControl.tagName.toLowerCase() == 'td' || aControl.tagName.toLowerCase() == 'th') return(aControl); else return(null); } // returns current table row function SPAW_getTR(editor) { var ed = document.getElementById(editor+'_rEdit'); var selection = ed.contentWindow.getSelection(); var selectedRange; var aControl; if (selection.rangeCount > 0) { selectedRange = selection.getRangeAt(0); aControl = selectedRange.startContainer; if (aControl.nodeType != 1) aControl = aControl.parentNode; while ((aControl.tagName.toLowerCase() != 'tr') && (aControl.tagName.toLowerCase() != 'table') && (aControl.tagName.toLowerCase() != 'body')) { aControl = aControl.parentNode; } } if (aControl.tagName.toLowerCase() == 'tr') return(aControl); else return(null); } // returns current table function SPAW_getTable(editor) { var ed = document.getElementById(editor+'_rEdit'); var selection = ed.contentWindow.getSelection(); var selectedRange; var aControl = null; if (selection && selection.rangeCount > 0) { selectedRange = selection.getRangeAt(0); aControl = selectedRange.startContainer; if (aControl.nodeType != 1) aControl = aControl.parentNode; while ((aControl.tagName.toLowerCase() != 'table') && (aControl.tagName.toLowerCase() != 'body')) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -