| 1 |
lars |
1 |
<!-- based on insimage.dlg -->
|
|
|
2 |
|
|
|
3 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
|
|
|
4 |
<HTML id=dlgImage STYLE="width: 432px; height: 194px; ">
|
|
|
5 |
<HEAD>
|
|
|
6 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
|
7 |
<meta http-equiv="MSThemeCompatible" content="Yes">
|
|
|
8 |
<TITLE>Insert Image</TITLE>
|
|
|
9 |
<style>
|
|
|
10 |
html, body, button, div, input, select, fieldset { font-family: MS Shell Dlg; font-size: 8pt; position: absolute; };
|
|
|
11 |
</style>
|
|
|
12 |
<SCRIPT defer>
|
|
|
13 |
|
|
|
14 |
function _CloseOnEsc() {
|
|
|
15 |
if (event.keyCode == 27) { window.close(); return; }
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
function _getTextRange(elm) {
|
|
|
19 |
var r = elm.parentTextEdit.createTextRange();
|
|
|
20 |
r.moveToElementText(elm);
|
|
|
21 |
return r;
|
|
|
22 |
}
|
|
|
23 |
|
|
|
24 |
window.onerror = HandleError
|
|
|
25 |
|
|
|
26 |
function HandleError(message, url, line) {
|
|
|
27 |
var str = "An error has occurred in this dialog." + "\n\n"
|
|
|
28 |
+ "Error: " + line + "\n" + message;
|
|
|
29 |
alert(str);
|
|
|
30 |
window.close();
|
|
|
31 |
return true;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
function Init() {
|
|
|
35 |
var elmSelectedImage;
|
|
|
36 |
var htmlSelectionControl = "Control";
|
|
|
37 |
var globalDoc = window.dialogArguments;
|
|
|
38 |
var grngMaster = globalDoc.selection.createRange();
|
|
|
39 |
|
|
|
40 |
// event handlers
|
|
|
41 |
document.body.onkeypress = _CloseOnEsc;
|
|
|
42 |
btnOK.onclick = new Function("btnOKClick()");
|
|
|
43 |
|
|
|
44 |
txtFileName.fImageLoaded = false;
|
|
|
45 |
txtFileName.intImageWidth = 0;
|
|
|
46 |
txtFileName.intImageHeight = 0;
|
|
|
47 |
|
|
|
48 |
if (globalDoc.selection.type == htmlSelectionControl) {
|
|
|
49 |
if (grngMaster.length == 1) {
|
|
|
50 |
elmSelectedImage = grngMaster.item(0);
|
|
|
51 |
if (elmSelectedImage.tagName == "IMG") {
|
|
|
52 |
txtFileName.fImageLoaded = true;
|
|
|
53 |
if (elmSelectedImage.src) {
|
|
|
54 |
txtFileName.value = elmSelectedImage.src.replace(/^[^*]*(\*\*\*)/, "$1"); // fix placeholder src values that editor converted to abs paths
|
|
|
55 |
txtFileName.intImageHeight = elmSelectedImage.height;
|
|
|
56 |
txtFileName.intImageWidth = elmSelectedImage.width;
|
|
|
57 |
txtVertical.value = elmSelectedImage.vspace;
|
|
|
58 |
txtHorizontal.value = elmSelectedImage.hspace;
|
|
|
59 |
txtBorder.value = elmSelectedImage.border;
|
|
|
60 |
txtAltText.value = elmSelectedImage.alt;
|
|
|
61 |
selAlignment.value = elmSelectedImage.align;
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
txtFileName.value = txtFileName.value || "http://";
|
|
|
67 |
txtFileName.focus();
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
function _isValidNumber(txtBox) {
|
|
|
71 |
var val = parseInt(txtBox);
|
|
|
72 |
if (isNaN(val) || val < 0 || val > 999) { return false; }
|
|
|
73 |
return true;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
function btnOKClick() {
|
|
|
77 |
var elmImage;
|
|
|
78 |
var intAlignment;
|
|
|
79 |
var htmlSelectionControl = "Control";
|
|
|
80 |
var globalDoc = window.dialogArguments;
|
|
|
81 |
var grngMaster = globalDoc.selection.createRange();
|
|
|
82 |
|
|
|
83 |
// error checking
|
|
|
84 |
|
|
|
85 |
if (!txtFileName.value || txtFileName.value == "http://") {
|
|
|
86 |
alert("Image URL must be specified.");
|
|
|
87 |
txtFileName.focus();
|
|
|
88 |
return;
|
|
|
89 |
}
|
|
|
90 |
if (txtHorizontal.value && !_isValidNumber(txtHorizontal.value)) {
|
|
|
91 |
alert("Horizontal spacing must be a number between 0 and 999.");
|
|
|
92 |
txtHorizontal.focus();
|
|
|
93 |
return;
|
|
|
94 |
}
|
|
|
95 |
if (txtBorder.value && !_isValidNumber(txtBorder.value)) {
|
|
|
96 |
alert("Border thickness must be a number between 0 and 999.");
|
|
|
97 |
txtBorder.focus();
|
|
|
98 |
return;
|
|
|
99 |
}
|
|
|
100 |
if (txtVertical.value && !_isValidNumber(txtVertical.value)) {
|
|
|
101 |
alert("Vertical spacing must be a number between 0 and 999.");
|
|
|
102 |
txtVertical.focus();
|
|
|
103 |
return;
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
// delete selected content and replace with image
|
|
|
107 |
if (globalDoc.selection.type == htmlSelectionControl && !txtFileName.fImageLoaded) {
|
|
|
108 |
grngMaster.execCommand('Delete');
|
|
|
109 |
grngMaster = globalDoc.selection.createRange();
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
idstr = "\" id=\"556e697175657e537472696e67"; // new image creation ID
|
|
|
113 |
if (!txtFileName.fImageLoaded) {
|
|
|
114 |
grngMaster.execCommand("InsertImage", false, idstr);
|
|
|
115 |
elmImage = globalDoc.all['556e697175657e537472696e67'];
|
|
|
116 |
elmImage.removeAttribute("id");
|
|
|
117 |
elmImage.removeAttribute("src");
|
|
|
118 |
grngMaster.moveStart("character", -1);
|
|
|
119 |
} else {
|
|
|
120 |
elmImage = grngMaster.item(0);
|
|
|
121 |
if (elmImage.src != txtFileName.value) {
|
|
|
122 |
grngMaster.execCommand('Delete');
|
|
|
123 |
grngMaster = globalDoc.selection.createRange();
|
|
|
124 |
grngMaster.execCommand("InsertImage", false, idstr);
|
|
|
125 |
elmImage = globalDoc.all['556e697175657e537472696e67'];
|
|
|
126 |
elmImage.removeAttribute("id");
|
|
|
127 |
elmImage.removeAttribute("src");
|
|
|
128 |
grngMaster.moveStart("character", -1);
|
|
|
129 |
txtFileName.fImageLoaded = false;
|
|
|
130 |
}
|
|
|
131 |
grngMaster = _getTextRange(elmImage);
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
if (txtFileName.fImageLoaded) {
|
|
|
135 |
elmImage.style.width = txtFileName.intImageWidth;
|
|
|
136 |
elmImage.style.height = txtFileName.intImageHeight;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
if (txtFileName.value.length > 2040) {
|
|
|
140 |
txtFileName.value = txtFileName.value.substring(0,2040);
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
elmImage.src = txtFileName.value;
|
|
|
144 |
|
|
|
145 |
if (txtHorizontal.value != "") { elmImage.hspace = parseInt(txtHorizontal.value); }
|
|
|
146 |
else { elmImage.hspace = 0; }
|
|
|
147 |
|
|
|
148 |
if (txtVertical.value != "") { elmImage.vspace = parseInt(txtVertical.value); }
|
|
|
149 |
else { elmImage.vspace = 0; }
|
|
|
150 |
|
|
|
151 |
elmImage.alt = txtAltText.value;
|
|
|
152 |
|
|
|
153 |
if (txtBorder.value != "") { elmImage.border = parseInt(txtBorder.value); }
|
|
|
154 |
else { elmImage.border = 0; }
|
|
|
155 |
|
|
|
156 |
elmImage.align = selAlignment.value;
|
|
|
157 |
grngMaster.collapse(false);
|
|
|
158 |
grngMaster.select();
|
|
|
159 |
window.close();
|
|
|
160 |
}
|
|
|
161 |
</SCRIPT>
|
|
|
162 |
</HEAD>
|
|
|
163 |
<BODY id=bdy onload="Init()" style="background: threedface; color: windowtext;" scroll=no>
|
|
|
164 |
|
|
|
165 |
<DIV id=divFileName style="left: 0.98em; top: 1.2168em; width: 7em; height: 1.2168em; ">Image URL:</DIV>
|
|
|
166 |
<INPUT ID=txtFileName type=text style="left: 8.54em; top: 1.0647em; width: 21.5em;height: 2.1294em; " tabIndex=10 onfocus="select()">
|
|
|
167 |
|
|
|
168 |
<DIV id=divAltText style="left: 0.98em; top: 4.1067em; width: 6.58em; height: 1.2168em; ">Alternate Text:</DIV>
|
|
|
169 |
<INPUT type=text ID=txtAltText tabIndex=15 style="left: 8.54em; top: 3.8025em; width: 21.5em; height: 2.1294em; " onfocus="select()">
|
|
|
170 |
|
|
|
171 |
<FIELDSET id=fldLayout style="left: .9em; top: 7.1em; width: 17.08em; height: 7.6em;">
|
|
|
172 |
<LEGEND id=lgdLayout>Layout</LEGEND>
|
|
|
173 |
</FIELDSET>
|
|
|
174 |
|
|
|
175 |
<FIELDSET id=fldSpacing style="left: 18.9em; top: 7.1em; width: 11em; height: 7.6em;">
|
|
|
176 |
<LEGEND id=lgdSpacing>Spacing</LEGEND>
|
|
|
177 |
</FIELDSET>
|
|
|
178 |
|
|
|
179 |
<DIV id=divAlign style="left: 1.82em; top: 9.126em; width: 4.76em; height: 1.2168em; ">Alignment:</DIV>
|
|
|
180 |
<SELECT size=1 ID=selAlignment tabIndex=20 style="left: 10.36em; top: 8.8218em; width: 6.72em; height: 1.2168em; ">
|
|
|
181 |
<OPTION id=optNotSet value=""> Not set </OPTION>
|
|
|
182 |
<OPTION id=optLeft value=left> Left </OPTION>
|
|
|
183 |
<OPTION id=optRight value=right> Right </OPTION>
|
|
|
184 |
<OPTION id=optTexttop value=textTop> Texttop </OPTION>
|
|
|
185 |
<OPTION id=optAbsMiddle value=absMiddle> Absmiddle </OPTION>
|
|
|
186 |
<OPTION id=optBaseline value=baseline SELECTED> Baseline </OPTION>
|
|
|
187 |
<OPTION id=optAbsBottom value=absBottom> Absbottom </OPTION>
|
|
|
188 |
<OPTION id=optBottom value=bottom> Bottom </OPTION>
|
|
|
189 |
<OPTION id=optMiddle value=middle> Middle </OPTION>
|
|
|
190 |
<OPTION id=optTop value=top> Top </OPTION>
|
|
|
191 |
</SELECT>
|
|
|
192 |
|
|
|
193 |
<DIV id=divHoriz style="left: 19.88em; top: 9.126em; width: 4.76em; height: 1.2168em; ">Horizontal:</DIV>
|
|
|
194 |
<INPUT ID=txtHorizontal style="left: 24.92em; top: 8.8218em; width: 4.2em; height: 2.1294em; ime-mode: disabled;" type=text size=3 maxlength=3 value="" tabIndex=25 onfocus="select()">
|
|
|
195 |
|
|
|
196 |
<DIV id=divBorder style="left: 1.82em; top: 12.0159em; width: 8.12em; height: 1.2168em; ">Border Thickness:</DIV>
|
|
|
197 |
<INPUT ID=txtBorder style="left: 10.36em; top: 11.5596em; width: 6.72em; height: 2.1294em; ime-mode: disabled;" type=text size=3 maxlength=3 value="" tabIndex=21 onfocus="select()">
|
|
|
198 |
|
|
|
199 |
<DIV id=divVert style="left: 19.88em; top: 12.0159em; width: 3.64em; height: 1.2168em; ">Vertical:</DIV>
|
|
|
200 |
<INPUT ID=txtVertical style="left: 24.92em; top: 11.5596em; width: 4.2em; height: 2.1294em; ime-mode: disabled;" type=text size=3 maxlength=3 value="" tabIndex=30 onfocus="select()">
|
|
|
201 |
|
|
|
202 |
<BUTTON ID=btnOK style="left: 31.36em; top: 1.0647em; width: 7em; height: 2.2em; " type=submit tabIndex=40>OK</BUTTON>
|
|
|
203 |
<BUTTON ID=btnCancel style="left: 31.36em; top: 3.6504em; width: 7em; height: 2.2em; " type=reset tabIndex=45 onClick="window.close();">Cancel</BUTTON>
|
|
|
204 |
|
|
|
205 |
</BODY>
|
|
|
206 |
</HTML>
|