insertframe.html
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript" src="../internal.js"></script>
<style type="text/css">
.warp {width: 362px;height: 225px;padding: 20px 0 0 20px;position: relative;}
/*#url { margin-bottom: 2px; }*/
.format span{display: inline-block; text-align: center; zoom:1;width: 45px;}
input {
border-radius: 5px;
outline: none;
border: 1px solid #ccc;
margin-right: 8px;
}
table td{display: flex;
height: 30px;
line-height: 30px;
padding-bottom: 20px;}
table tr:last-child td{
padding-bottom: 10px;
}
#align {width: 79px;height: 29px;line-height: 29px;margin-top: 2px;border-radius: 5px; border: 1px solid #ccc;}
.scroll {
display: flex;
}
.scroll input {margin-top:9px;margin-right: 32px;}
.scroll td {padding-bottom:10px;}
</style>
</head>
<body>
<div class="warp">
<table width="300" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" class="format">
<span><var id="lang_input_address"></var></span>
<input style="width:294px;height:30px;" id="url" type="text" value=""/>
</td>
</tr>
<tr>
<td colspan="2" class="format"><span><var id="lang_input_width"></var></span><input style="width:294px;height:30px;" type="text" id="width"/> px</td>
</tr>
<tr>
<td colspan="2" class="format"><span><var id="lang_input_height"></var></span><input style="width:294px;height:30px;" type="text" id="height"/> px</td>
</tr>
<tr class="scroll">
<td><span><var id="lang_input_isScroll"></var></span><input type="checkbox" id="scroll"/> </td>
<td><span><var id="lang_input_frameborder"></var></span><input type="checkbox" id="frameborder"/> </td>
</tr>
<tr >
<td colspan="2"><span><var id="lang_input_alignMode"></var></span>
<select id="align">
<option value=""></option>
<option value="left"></option>
<option value="right"></option>
</select>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
var iframe = editor._iframe;
if(iframe){
$G("url").value = iframe.getAttribute("src")||"";
$G("width").value = iframe.getAttribute("width")||iframe.style.width.replace("px","")||"";
$G("height").value = iframe.getAttribute("height") || iframe.style.height.replace("px","") ||"";
$G("scroll").checked = (iframe.getAttribute("scrolling") == "yes") ? true : false;
$G("frameborder").checked = (iframe.getAttribute("frameborder") == "1") ? true : false;
$G("align").value = iframe.align ? iframe.align : "";
}
function setIframe(){
var url = $G("url").value.replace(/^\s*|\s*$/ig,""),
width = $G("width").value,
height = $G("height").value,
scroll = $G("scroll"),
frameborder = $G("frameborder"),
float = $G("align").value,
newIframe = editor.document.createElement("iframe"),
div;
if(!url){
alert(lang.enterAddress);
return false;
}
newIframe.setAttribute("src",/http:\/\/|https:\/\//ig.test(url) ? url : "http://"+url);
/^[1-9]+[.]?\d*$/g.test( width ) ? newIframe.setAttribute("width",width) : "";
/^[1-9]+[.]?\d*$/g.test( height ) ? newIframe.setAttribute("height",height) : "";
scroll.checked ? newIframe.setAttribute("scrolling","yes") : newIframe.setAttribute("scrolling","no");
frameborder.checked ? newIframe.setAttribute("frameborder","1",0) : newIframe.setAttribute("frameborder","0",0);
float ? newIframe.setAttribute("align",float) : newIframe.setAttribute("align","");
if(iframe){
iframe.parentNode.insertBefore(newIframe,iframe);
domUtils.remove(iframe);
}else{
div = editor.document.createElement("div");
div.appendChild(newIframe);
editor.execCommand("inserthtml",div.innerHTML);
}
editor._iframe = null;
dialog.close();
}
dialog.onok = setIframe;
$G("url").onkeydown = function(evt){
evt = evt || event;
if(evt.keyCode == 13){
setIframe();
}
};
$focus($G( "url" ));
</script>
</body>
</html>