/_/vendor/ueditor/dialogs/link/link.html

https://bitbucket.org/nemo_xiaolan/muyou · HTML · 130 lines · 126 code · 4 blank · 0 comment · 0 complexity · 90336b4c7d9045deee08f2b386d92a0b MD5 · raw file

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>插入链接</title>
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
  7. <script type="text/javascript" src="../internal.js"></script>
  8. <style type="text/css">
  9. *{color: #838383}
  10. body {
  11. font-size: 12px;
  12. width:382px;
  13. height: 100px;
  14. overflow: hidden;
  15. margin:0px;padding:0px;
  16. }
  17. span.txt{width: 60px;height:30px;line-height: 30px;display: block;float:left}
  18. .content{
  19. padding: 9px 0px 0px 15px;
  20. height:100%;
  21. }
  22. #link_href,
  23. #title{width:286px;height:21px;background: #FFF;border:1px solid #d7d7d7;padding: 0px; margin: 0px; line-height:21px}
  24. #link_href{width:208px}
  25. .content table{padding:0px;margin:0px}
  26. .content table tr{padding:0px;margin:0px; list-style: none;height: 20px; line-height: 20px;}
  27. .red{color:red;}
  28. </style>
  29. </head>
  30. <body>
  31. <div class="content">
  32. <table>
  33. <tr>
  34. <td><span class="txt">链接地址</span>
  35. <select id="protocol">
  36. <option value="http://">http://</option>
  37. <option value="https://">https://</option>
  38. </select>
  39. <input id="link_href" type="text" /><br/>
  40. <span id="msg2" class="red"></span></td>
  41. </tr>
  42. <tr>
  43. <td><span class="txt">标题</span><input id="title" type="text"/></td>
  44. </tr>
  45. <tr>
  46. <td><span>是否在新窗口打开</span><input id="target" type="checkbox"/></td>
  47. </tr>
  48. </table>
  49. </div>
  50. <script type="text/javascript">
  51. var a = editor.queryCommandValue("link"),link = {};
  52. if(a){
  53. link = a;
  54. }
  55. function G(id){
  56. return document.getElementById(id);
  57. }
  58. function jbind(obj,evt,fun){
  59. if(obj.addEventListener){ // firefox,w3c
  60. obj.addEventListener(evt,fun,false);
  61. }else{// ie
  62. obj.attachEvent("on"+evt,function(){fun.apply(obj);});
  63. }
  64. }
  65. function initIpt(){
  66. if(link.href){
  67. G("title").value = link.title ? link.title : "";
  68. var href = link.getAttribute('data_ue_src') || link.href;
  69. /^(?:http:\/\/)/ig.test(href) ? G("protocol").value="http://" : G("protocol").value="https://";
  70. G("link_href").value = href.replace(/^(?:https?:\/\/)|(?:\/)$/ig,"");
  71. if(link.target == "_blank"){
  72. G("target").checked = true;
  73. }
  74. }
  75. var ipt = G("link_href");
  76. ipt.focus();
  77. ipt.style.cssText = 'border:1px solid #ccc;background-color:#fafafa;';
  78. jbind(ipt,'focus',function(){
  79. this.style.cssText = 'border:1px solid #ccc;background-color:#fff;';
  80. });
  81. jbind(ipt,'blur',function(){
  82. this.style.cssText = 'border:1px solid #ccc;background-color:#fafafa;';
  83. });
  84. }
  85. function handleDialogOk(){
  86. var href = G('link_href').value || '';
  87. var obj = {},td,link;
  88. obj.href = href.replace(/^\s+|\s+$/g, '');
  89. if(!obj.href){
  90. G("msg2").innerHTML = "请输入链接地址!";
  91. return false;
  92. }
  93. obj.href = G("protocol").value+obj.href;
  94. if(G("target").checked){
  95. obj["target"] = "_blank";
  96. } else {
  97. obj["target"] = "_self";
  98. }
  99. if(G("title").value.replace(/^\s+|\s+$/g, '')){
  100. obj["title"] = G("title").value.replace(/^\s+|\s+$/g, '');
  101. }
  102. editor.execCommand('link', obj);
  103. dialog.close();
  104. }
  105. var keyHandle = function(evt){
  106. evt = evt || window.event;
  107. if (evt.keyCode == 13) {
  108. handleDialogOk();
  109. return false;
  110. }
  111. }
  112. initIpt();
  113. dialog.onok = handleDialogOk;
  114. G('link_href').onkeydown = keyHandle;
  115. var ipt = G('link_href');
  116. var isIE = !!window.ActiveXObject;
  117. if (isIE) {
  118. setTimeout(function (){
  119. var r = ipt.createTextRange();
  120. r.collapse(false);
  121. r.select();
  122. });
  123. }
  124. </script>
  125. </body>
  126. </html>