source: trunk/modules/InsertImage/insert_image.html @ 733

Last change on this file since 733 was 733, checked in by htanaka, 13 years ago

fix #949 InsertImage? dialog can preview stripped url image.

  • Property svn:eol-style set to native
  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 5.5 KB
Line 
1<html>
2
3<head>
4  <title>Insert Image</title>
5
6<script type="text/javascript" src="../../popups/popup.js"></script>
7<link rel="stylesheet" type="text/css" href="../../popups/popup.css" />
8
9<script type="text/javascript">
10
11window.resizeTo(400, 100);
12
13Xinha = window.opener.Xinha;
14function i18n(str) {
15  return (Xinha._lc(str, 'Xinha'));
16}
17
18function resolveRelativeUrl(base, url){
19        if(url.match(/^([^:]+\:)?\//)){
20                return url;
21        }
22        else{
23                var b = base.split("/");
24                if(b[b.length - 1] == ""){
25                        b.pop();
26                }
27                var p = url.split("/");
28                if(p[0] == "."){
29                        p.shift();
30                }
31                while(p[0] == ".."){
32                        b.pop();
33                        p.shift();
34                }
35                return b.join("/") + "/" + p.join("/");
36        }
37}
38
39function Init() {
40  __dlg_translate('Xinha');
41  __dlg_init();
42  // Make sure the translated string appears in the drop down. (for gecko)
43  document.getElementById("f_align").selectedIndex = 1;
44  document.getElementById("f_align").selectedIndex = 5;
45  var param = window.dialogArguments;
46  if (param["f_base"]) {
47      document.getElementById("f_base").value = param["f_base"];
48  }
49  document.getElementById("f_url").value    = param["f_url"] ? param["f_url"] : "";
50  document.getElementById("f_alt").value    = param["f_alt"] ? param["f_alt"] : "";
51  document.getElementById("f_border").value = (typeof param["f_border"]!="undefined") ? param["f_border"] : "";
52  document.getElementById("f_align").value  = param["f_align"] ? param["f_align"] : "";
53  document.getElementById("f_vert").value   = (typeof param["f_vert"]!="undefined") ? param["f_vert"] : "";
54  document.getElementById("f_horiz").value  = (typeof param["f_horiz"]!="undefined") ? param["f_horiz"] : "";
55  if (param["f_url"]) {
56      window.ipreview.location.replace(resolveRelativeUrl(param.f_base, param.f_url));
57  }
58  document.getElementById("f_url").focus();
59}
60
61function onOK() {
62  var required = {
63    "f_url": i18n("You must enter the URL")
64  };
65  for (var i in required) {
66    var el = document.getElementById(i);
67    if (!el.value) {
68      alert(required[i]);
69      el.focus();
70      return false;
71    }
72  }
73  // pass data back to the calling window
74  var fields = ["f_url", "f_alt", "f_align", "f_border",
75                "f_horiz", "f_vert"];
76  var param = new Object();
77  for (var i in fields) {
78    var id = fields[i];
79    var el = document.getElementById(id);
80    param[id] = el.value;
81  }
82  __dlg_close(param);
83  return false;
84}
85
86function onCancel() {
87  __dlg_close(null);
88  return false;
89}
90
91function onPreview() {
92  var f_url = document.getElementById("f_url");
93  var url = f_url.value;
94  var base = document.getElementById("f_base").value;
95  if (!url) {
96    alert(i18n("You must enter the URL"));
97    f_url.focus();
98    return false;
99  }
100  window.ipreview.location.replace(resolveRelativeUrl(base, url));
101  return false;
102}
103</script>
104
105</head>
106
107<body class="dialog" onload="Init()">
108
109<div class="title">Insert Image</div>
110<!--- new stuff --->
111<form action="" method="get">
112<input type="hidden" name="base" id="f_base"/>
113<table border="0" width="100%" style="padding: 0px; margin: 0px">
114  <tbody>
115
116  <tr>
117    <td style="width: 7em; text-align: right">Image URL:</td>
118    <td><input type="text" name="url" id="f_url" style="width:75%"
119      title="Enter the image URL here" />
120      <button name="preview" onclick="return onPreview();"
121      title="Preview the image in a new window">Preview</button>
122    </td>
123  </tr>
124  <tr>
125    <td style="width: 7em; text-align: right">Alternate text:</td>
126    <td><input type="text" name="alt" id="f_alt" style="width:100%"
127      title="For browsers that don't support images" /></td>
128  </tr>
129
130  </tbody>
131</table>
132
133<p />
134
135<fieldset style="float: left; margin-left: 5px;">
136<legend>Layout</legend>
137
138<div class="space"></div>
139
140<div class="fl">Alignment:</div>
141<select size="1" name="align" id="f_align"
142  title="Positioning of this image">
143  <option value=""                             >Not set</option>
144  <option value="left"                         >Left</option>
145  <option value="right"                        >Right</option>
146  <option value="texttop"                      >Texttop</option>
147  <option value="absmiddle"                    >Absmiddle</option>
148  <option value="baseline" selected="1"        >Baseline</option>
149  <option value="absbottom"                    >Absbottom</option>
150  <option value="bottom"                       >Bottom</option>
151  <option value="middle"                       >Middle</option>
152  <option value="top"                          >Top</option>
153</select>
154
155<p />
156
157<div class="fl">Border thickness:</div>
158<input type="text" name="border" id="f_border" size="5"
159title="Leave empty for no border" />
160
161<div class="space"></div>
162
163</fieldset>
164
165<fieldset style="float:right; margin-right: 5px;">
166<legend>Spacing</legend>
167
168<div class="space"></div>
169
170<div class="fr">Horizontal:</div>
171<input type="text" name="horiz" id="f_horiz" size="5"
172title="Horizontal padding" />
173
174<p />
175
176<div class="fr">Vertical:</div>
177<input type="text" name="vert" id="f_vert" size="5"
178title="Vertical padding" />
179
180<div class="space"></div>
181
182</fieldset>
183<br clear="all" />
184<table width="100%" style="margin-bottom: 0.2em">
185 <tr>
186  <td valign="bottom">
187    <div class="fr">Image Preview:</div>
188    <iframe name="ipreview" id="ipreview" frameborder="0" style="border : 1px solid gray;"
189        height="200" width="300" src="../../popups/blank.html"></iframe>
190  </td>
191  <td valign="bottom" style="text-align: right">
192    <button type="button" name="ok" onclick="return onOK();">OK</button><br>
193    <button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
194  </td>
195 </tr>
196</table>
197</form>
198</body>
199</html>
Note: See TracBrowser for help on using the repository browser.