/_/vendor/ueditor/dialogs/link/link.html
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
25 #link_href{width:208px}
26 .content table{padding:0px;margin:0px}
27 .content table tr{padding:0px;margin:0px; list-style: none;height: 20px; line-height: 20px;}
28
29 .red{color:red;}
30 </style>
31</head>
32<body>
33<div class="content">
34 <table>
35 <tr>
36 <td><span class="txt">链接地址:</span>
37 <select id="protocol">
38 <option value="http://">http://</option>
39 <option value="https://">https://</option>
40 </select>
41 <input id="link_href" type="text" /><br/>
42 <span id="msg2" class="red"></span></td>
43 </tr>
44 <tr>
45 <td><span class="txt">标题:</span><input id="title" type="text"/></td>
46 </tr>
47 <tr>
48 <td><span>是否在新窗口打开:</span><input id="target" type="checkbox"/></td>
49 </tr>
50 </table>
51
52</div>
53<script type="text/javascript">
54 var a = editor.queryCommandValue("link"),link = {};
55 if(a){
56 link = a;
57 }
58 function G(id){
59 return document.getElementById(id);
60 }
61 function jbind(obj,evt,fun){
62 if(obj.addEventListener){ // firefox,w3c
63 obj.addEventListener(evt,fun,false);
64 }else{// ie
65 obj.attachEvent("on"+evt,function(){fun.apply(obj);});
66 }
67 }
68 function initIpt(){
69 if(link.href){
70 G("title").value = link.title ? link.title : "";
71 var href = link.getAttribute('data_ue_src') || link.href;
72 /^(?:http:\/\/)/ig.test(href) ? G("protocol").value="http://" : G("protocol").value="https://";
73 G("link_href").value = href.replace(/^(?:https?:\/\/)|(?:\/)$/ig,"");
74 if(link.target == "_blank"){
75 G("target").checked = true;
76 }
77 }
78 var ipt = G("link_href");
79 ipt.focus();
80 ipt.style.cssText = 'border:1px solid #ccc;background-color:#fafafa;';
81 jbind(ipt,'focus',function(){
82 this.style.cssText = 'border:1px solid #ccc;background-color:#fff;';
83 });
84 jbind(ipt,'blur',function(){
85 this.style.cssText = 'border:1px solid #ccc;background-color:#fafafa;';
86 });
87 }
88
89 function handleDialogOk(){
90 var href = G('link_href').value || '';
91 var obj = {},td,link;
92 obj.href = href.replace(/^\s+|\s+$/g, '');
93 if(!obj.href){
94 G("msg2").innerHTML = "请输入链接地址!";
95 return false;
96 }
97 obj.href = G("protocol").value+obj.href;
98 if(G("target").checked){
99 obj["target"] = "_blank";
100 } else {
101 obj["target"] = "_self";
102 }
103 if(G("title").value.replace(/^\s+|\s+$/g, '')){
104 obj["title"] = G("title").value.replace(/^\s+|\s+$/g, '');
105 }
106 editor.execCommand('link', obj);
107 dialog.close();
108 }
109 var keyHandle = function(evt){
110 evt = evt || window.event;
111 if (evt.keyCode == 13) {
112 handleDialogOk();
113 return false;
114 }
115 }
116 initIpt();
117 dialog.onok = handleDialogOk;
118 G('link_href').onkeydown = keyHandle;
119 var ipt = G('link_href');
120 var isIE = !!window.ActiveXObject;
121 if (isIE) {
122 setTimeout(function (){
123 var r = ipt.createTextRange();
124 r.collapse(false);
125 r.select();
126 });
127 }
128</script>
129</body>
130</html>