⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edit_html_linkall

📁 cms是开源的框架
💻
📖 第 1 页 / 共 2 页
字号:
<?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/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 type="text/javascript" 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];

                            document.forms["NEU"].elements["neulink"].value = foundLink.getAttribute("HREF", 2);
                            document.forms["NEU"].elements["linkanchor"].value = foundLink.getAttribute("NAME", 2);
                            if (linkEditorStyleInputs) {
                                document.forms["NEU"].elements["linkstyle"].value = foundLink.style.getAttribute("CSSTEXT", 2);
                                document.forms["NEU"].elements["linkstyleclass"].value = foundLink.getAttribute("CLASSNAME", 2);
                            }

                            document.forms["NEU"].elements["targetname"].value = "";
                            if((foundLink.target == "_self") || (foundLink.target == "") || (foundLink.target == null)) {
                                document.forms["NEU"].elements["linktarget"].selectedIndex = 0;
                            } else if(foundLink.target == "_blank") {
                                document.forms["NEU"].elements["linktarget"].selectedIndex = 1;
                            } else if(foundLink.target == "_top") {
                                document.forms["NEU"].elements["linktarget"].selectedIndex = 2;
                            } else {
                                document.forms["NEU"].elements["linktarget"].selectedIndex = 3;
                                document.forms["NEU"].elements["targetname"].value = foundLink.target;
                            }
                            setNameTarget(false);
                            break;
                        }
                    }

                    if (foundLink == null) {
                        // No previous "A" element found, set selection text in input area
                        foundRange = range;
                    }
                }

                if ((foundRange == null) || (foundRange.htmlText == "") || (foundRange.htmlText == null)) {
                    // No valid selection, display message and close window
                    alert("]]><LABEL value="editor.message.noselection" /><![CDATA[");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -