edit_html_linkall
来自「内容管理」· 代码 · 共 353 行 · 第 1/2 页
TXT
353 行
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
MSHTML edit dialog for links that allows the insertion of anchors (a name="") and targets in the link.
Based on previous versions of the OpenCms link dialog.
Author : Alexander Kandzior (a.kandzior@alkacon.com)
File : $Source: /usr/local/cvs/opencms/etc/ocsetup/vfs/system/workplace/templates/Attic/edit_html_linkall,v $
Date : $Date: 2003/04/01 12:57:40 $
Version: $Revision: 1.8 $
-->
<WORKPLACE>
<TEMPLATE>
<![CDATA[
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=]]><METHOD name="getEncoding"/><![CDATA[">
<script language=JavaScript>
<!--
var linkEditor = null;
var linkEditorAll = null;
var linkEditorRange = null;
var linkEditorSelection = null;
var linkEditorStyleInputs = false;
var linkEditorPrefix = null;
var foundRange = null;
var foundLink = null;
/**
* Extends Javascript String to have a trim() function.
*/
String.prototype.trim = function() {
// skip leading and trailing whitespace
return this.replace(/^\s*(\b.*\b|)\s*$/, "$1");
}
/**
* Paste the calculated link to the calling editor.
*/
function pasteLink() {
var linkurl = document.NEU.neulink.value;
var linktarget = document.NEU.linktarget.options[document.NEU.linktarget.selectedIndex].value;
if ("named" == linktarget) {
linktarget = document.NEU.targetname.value;
if ((linktarget == null) || (linktarget.trim() == "")) {
linktarget="_self";
}
}
var linkanchor = document.NEU.linkanchor.value;
if (linkEditorStyleInputs) {
var linkstyle = document.NEU.linkstyle.value;
var linkstyleclass = document.NEU.linkstyleclass.value;
}
if (foundLink != null) {
foundLink.removeNode();
}
if ((linkurl.length > 0) || (linkanchor.length > 0)) {
foundRange.execCommand("CreateLink", false, "/");
var el = foundRange.parentElement();
while ((el.tagName != "BODY") && (el.tagName != "A")) {
if (el.tagName == "IMG") {
// Set border to 0 for images, this is what you want in 99% of all cases
el.border = 0;
}
el = el.parentElement;
}
if (linkurl.length > 0) {
el.setAttribute("HREF", linkurl, 0);
} else {
el.removeAttribute("HREF", false);
}
if ((linktarget.length > 0) && (linkurl.length > 0)) {
el.target = linktarget;
} else {
el.removeAttribute("TARGET", false);
}
if (linkanchor.length > 0) {
el.name = linkanchor;
} else {
el.removeAttribute("NAME", false);
}
if (linkEditorStyleInputs) {
if(linkstyle.length > 0) {
el.style.cssText = linkstyle;
}
if(linkstyleclass.length > 0) {
el.className = linkstyleclass;
}
}
}
window.close();
}
/**
* Set the current selection in the calling editor and fill the fields of the editor form.
* You must set the following variables in the javascript of the opening window:
*
* linkEditor
* linkEditorAll
* linkEditorRange
* linkEditorSelection
* linkEditorStyleInputs
* linkEditorPrefix
*/
function init() {
// Get the editor element, a complete range of the editor and the editor selection
linkEditor = window.opener.linkEditor;
linkEditorAll = window.opener.linkEditorAll;
linkEditorRange = window.opener.linkEditorRange;
linkEditorSelection = window.opener.linkEditorSelection;
if (window.opener.linkEditorStyleInputs != null) {
linkEditorStyleInputs = window.opener.linkEditorStyleInputs;
}
if (window.opener.linkEditorPrefix != null) {
linkEditorPrefix = window.opener.linkEditorPrefix;
}
// Get all links in editor (ie. tags like <A HREF>)
var allLinks = linkEditorAll.tags("A");
// Create a range on the current selection
var range = linkEditorSelection.createRange();
if (typeof(range.text) != 'undefined') {
// If this is undefined, the selection is a MS IE "ControlSelection",
// which can not be used for adding a link
for(i = 0; i < allLinks.length; i++) {
foundRange = null;
// Create range on whole text
var mainrange = linkEditorRange;
// Move range to the current A-element
mainrange.moveToElementText(allLinks[i]);
// Compare the selection with the current range, and expand if neccessary
if (mainrange.inRange(range)) {
foundRange = mainrange;
} else if (range.inRange(mainrange) || range.isEqual(mainrange)) {
foundRange = range;
} else {
var s2e = range.compareEndPoints("StartToEnd", mainrange);
var s2s = range.compareEndPoints("StartToStart", mainrange);
var e2s = range.compareEndPoints("EndToStart", mainrange);
var e2e = range.compareEndPoints("EndToEnd", mainrange);
if ((s2s == -1) && (e2s >= 0)) {
foundRange = range;
foundRange.setEndPoint("EndToEnd", mainrange);
} else if ((s2e == -1) && (e2e >= 0)) {
foundRange = range;
foundRange.setEndPoint("StartToStart", mainrange);
}
}
// Finally fill the input fields of the form
if (foundRange != null) {
// Use expanded selection to fill input areas
foundRange.select();
foundLink = allLinks[i];
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?