!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is Editor Image Properties Overlay.
15 *
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1998-1999
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 * Pete Collins
23 * Brian King
24 * Ben Goodger
25 * Neil Rashbrook <neil@parkwaycc.co.uk> (Separated from EdImageProps.js)
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
38 *
39 * ***** END LICENSE BLOCK ***** */
40
41 /*
42 Note: We encourage non-empty alt text for images inserted into a page.
43 When there's no alt text, we always write 'alt=""' as the attribute, since "alt" is a required attribute.
44 We allow users to not have alt text by checking a "Don't use alterate text" radio button,
45 and we don't accept spaces as valid alt text. A space used to be required to avoid the error message
46 if user didn't enter alt text, but is unnecessary now that we no longer annoy the user
47 with the error dialog if alt="" is present on an img element.
48 We trim all spaces at the beginning and end of user's alt text
49 */
50
51 var gInsertNewImage = true;
52 var gInsertNewIMap = true;
53 var gDoAltTextError = false;
54 var gConstrainOn = false;
55 // Note used in current version, but these are set correctly
56 // and could be used to reset width and height used for constrain ratio
57 var gConstrainWidth = 0;
58 var gConstrainHeight = 0;
59 var imageElement;
60 var gImageMap = 0;
61 var gCanRemoveImageMap = false;
62 var gRemoveImageMap = false;
63 var gImageMapDisabled = false;
64 var gActualWidth = "";
65 var gActualHeight = "";
66 var gOriginalSrc = "";
67 var gHaveDocumentUrl = false;
68 var gTimerID;
69 var gValidateTab;
70
71 // These must correspond to values in EditorDialog.css for each theme
72 // (unfortunately, setting "style" attribute here doesn't work!)
73 var gPreviewImageWidth = 80;
74 var gPreviewImageHeight = 50;
75
76 // dialog initialization code
77
ImageStartup
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
78 function ImageStartup()
79 {
80 gDialog.tabBox = document.getElementById( "TabBox" );
81 gDialog.tabLocation = document.getElementById( "imageLocationTab" );
82 gDialog.tabDimensions = document.getElementById( "imageDimensionsTab" );
83 gDialog.tabBorder = document.getElementById( "imageBorderTab" );
84 gDialog.srcInput = document.getElementById( "srcInput" );
85 gDialog.titleInput = document.getElementById( "titleInput" );
86 gDialog.altTextInput = document.getElementById( "altTextInput" );
87 gDialog.altTextRadioGroup = document.getElementById( "altTextRadioGroup" );
88 gDialog.altTextRadio = document.getElementById( "altTextRadio" );
89 gDialog.noAltTextRadio = document.getElementById( "noAltTextRadio" );
90 gDialog.customSizeRadio = document.getElementById( "customSizeRadio" );
91 gDialog.actualSizeRadio = document.getElementById( "actualSizeRadio" );
92 gDialog.constrainCheckbox = document.getElementById( "constrainCheckbox" );
93 gDialog.widthInput = document.getElementById( "widthInput" );
94 gDialog.heightInput = document.getElementById( "heightInput" );
95 gDialog.widthUnitsMenulist = document.getElementById( "widthUnitsMenulist" );
96 gDialog.heightUnitsMenulist = document.getElementById( "heightUnitsMenulist" );
97 gDialog.imagelrInput = document.getElementById( "imageleftrightInput" );
98 gDialog.imagetbInput = document.getElementById( "imagetopbottomInput" );
99 gDialog.border = document.getElementById( "border" );
100 gDialog.alignTypeSelect = document.getElementById( "alignTypeSelect" );
101 gDialog.ImageHolder = document.getElementById( "preview-image-holder" );
102 gDialog.PreviewWidth = document.getElementById( "PreviewWidth" );
103 gDialog.PreviewHeight = document.getElementById( "PreviewHeight" );
104 gDialog.PreviewSize = document.getElementById( "PreviewSize" );
105 gDialog.PreviewImage = null;
106 gDialog.OkButton = document.documentElement.getButton("accept");
107 }
108
109 // Set dialog widgets with attribute data
110 // We get them from globalElement copy so this can be used
111 // by AdvancedEdit(), which is shared by all property dialogs
InitImage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
112 function InitImage()
113 {
114 // Set the controls to the image's attributes
115 gDialog.srcInput.value = globalElement.getAttribute("src");
116
117 // Set "Relativize" checkbox according to current URL state
118 SetRelativeCheckbox();
119
120 // Force loading of image from its source and show preview image
121 LoadPreviewImage();
122
123 if (globalElement.hasAttribute("title"))
124 gDialog.titleInput.value = globalElement.getAttribute("title");
125
126 var hasAltText = globalElement.hasAttribute("alt");
127 var altText;
128 if (hasAltText)
129 {
130 altText = globalElement.getAttribute("alt");
131 gDialog.altTextInput.value = altText;
132 }
133
134 // Initialize altText widgets during dialog startup
135 // or if user enterred altText in Advanced Edit dialog
136 // (this preserves "Don't use alt text" radio button state)
137 if (!gDialog.altTextRadioGroup.selectedItem || altText)
138 {
139 if (gInsertNewImage || !hasAltText || (hasAltText && gDialog.altTextInput.value))
140 {
141 SetAltTextDisabled(false);
142 gDialog.altTextRadioGroup.selectedItem = gDialog.altTextRadio;
143 }
144 else
145 {
146 SetAltTextDisabled(true);
147 gDialog.altTextRadioGroup.selectedItem = gDialog.noAltTextRadio;
148 }
149 }
150
151 // setup the height and width widgets
152 var width = InitPixelOrPercentMenulist(globalElement,
153 gInsertNewImage ? null : imageElement,
154 "width", "widthUnitsMenulist", gPixel);
155 var height = InitPixelOrPercentMenulist(globalElement,
156 gInsertNewImage ? null : imageElement,
157 "height", "heightUnitsMenulist", gPixel);
158
159 // Set actual radio button if both set values are the same as actual
160 SetSizeWidgets(width, height);
161
162 gDialog.widthInput.value = gConstrainWidth = width ? width : (gActualWidth ? gActualWidth : "");
163 gDialog.heightInput.value = gConstrainHeight = height ? height : (gActualHeight ? gActualHeight : "");
164
165 // set spacing editfields
166 gDialog.imagelrInput.value = globalElement.getAttribute("hspace");
167 gDialog.imagetbInput.value = globalElement.getAttribute("vspace");
168
169 // dialog.border.value = globalElement.getAttribute("border");
170 var bv = GetHTMLOrCSSStyleValue(globalElement, "border", "border-top-width");
171 if (/px/.test(bv))
172 {
173 // Strip out the px
174 bv = RegExp.leftContext;
175 }
176 else if (bv == "thin")
177 {
178 bv = "1";
179 }
180 else if (bv == "medium")
181 {
182 bv = "3";
183 }
184 else if (bv == "thick")
185 {
186 bv = "5";
187 }
188 gDialog.border.value = bv;
189
190 // Get alignment setting
191 var align = globalElement.getAttribute("align");
192 if (align)
193 align = align.toLowerCase();
194
195 var imgClass;
196 var textID;
197
198 switch ( align )
199 {
200 case "top":
201 case "middle":
202 case "right":
203 case "left":
204 gDialog.alignTypeSelect.value = align;
205 break;
206 default: // Default or "bottom"
207 gDialog.alignTypeSelect.value = "bottom";
208 }
209
210 // Get image map for image
211 gImageMap = GetImageMap();
212
213 doOverallEnabling();
214 doDimensionEnabling();
215 }
216
SetSizeWidgets
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
217 function SetSizeWidgets(width, height)
218 {
219 if (!(width || height) || (gActualWidth && gActualHeight && width == gActualWidth && height == gActualHeight))
220 gDialog.actualSizeRadio.radioGroup.selectedItem = gDialog.actualSizeRadio;
221
222 if (!gDialog.actualSizeRadio.selected)
223 {
224 gDialog.actualSizeRadio.radioGroup.selectedItem = gDialog.customSizeRadio;
225
226 // Decide if user's sizes are in the same ratio as actual sizes
227 if (gActualWidth && gActualHeight)
228 {
229 if (gActualWidth > gActualHeight)
230 gDialog.constrainCheckbox.checked = (Math.round(gActualHeight * width / gActualWidth) == height);
231 else
232 gDialog.constrainCheckbox.checked = (Math.round(gActualWidth * height / gActualHeight) == width);
233 }
234 }
235 }
236
237 // Disable alt text input when "Don't use alt" radio is checked
SetAltTextDisabled
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
238 function SetAltTextDisabled(disable)
239 {
240 gDialog.altTextInput.disabled = disable;
241 }
242
GetImageMap
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
243 function GetImageMap()
244 {
245 var usemap = globalElement.getAttribute("usemap");
246 if (usemap)
247 {
248 gCanRemoveImageMap = true;
249 var mapname = usemap.substring(1, usemap.length);
250 var mapCollection;
251 try {
252 mapCollection = GetCurrentEditor().document.getElementsByName(mapname);
253 } catch (e) {}
254 if (mapCollection && mapCollection[0] != null)
255 {
256 gInsertNewIMap = false;
257 return mapCollection[0];
258 }
259 }
260 else
261 {
262 gCanRemoveImageMap = false;
263 }
264
265 gInsertNewIMap = true;
266 return null;
267 }
268
chooseFile
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
269 function chooseFile()
270 {
271 if (gTimerID)
272 clearTimeout(gTimerID);
273 // Get a local file, converted into URL format
274 var fileName = GetLocalFileURL("img");
275 if (fileName)
276 {
277 // Always try to relativize local file URLs
278 if (gHaveDocumentUrl)
279 fileName = MakeRelativeUrl(fileName);
280
281 gDialog.srcInput.value = fileName;
282
283 SetRelativeCheckbox();
284 doOverallEnabling();
285 }
286 LoadPreviewImage();
287
288 // Put focus into the input field
289 SetTextboxFocus(gDialog.srcInput);
290 }
291
PreviewImageLoaded
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
292 function PreviewImageLoaded()
293 {
294 if (gDialog.PreviewImage)
295 {
296 // Image loading has completed -- we can get actual width
297 gActualWidth = gDialog.PreviewImage.naturalWidth;
298 gActualHeight = gDialog.PreviewImage.naturalHeight;
299
300 if (gActualWidth && gActualHeight)
301 {
302 // Use actual size or scale to fit preview if either dimension is too large
303 var width = gActualWidth;
304 var height = gActualHeight;
305 if (gActualWidth > gPreviewImageWidth)
306 {
307 width = gPreviewImageWidth;
308 height = gActualHeight * (gPreviewImageWidth / gActualWidth);
309 }
310 if (height > gPreviewImageHeight)
311 {
312 height = gPreviewImageHeight;
313 width = gActualWidth * (gPreviewImageHeight / gActualHeight);
314 }
315 gDialog.PreviewImage.width = width;
316 gDialog.PreviewImage.height = height;
317
318 gDialog.PreviewWidth.setAttribute("value", gActualWidth);
319 gDialog.PreviewHeight.setAttribute("value", gActualHeight);
320
321 gDialog.PreviewSize.collapsed = false;
322 gDialog.ImageHolder.collapsed = false;
323
324 SetSizeWidgets(gDialog.widthInput.value, gDialog.heightInput.value);
325 }
326
327 if (gDialog.actualSizeRadio.selected)
328 SetActualSize();
329 }
330 }
331
LoadPreviewImage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
332 function LoadPreviewImage()
333 {
334 gDialog.PreviewSize.collapsed = true;
335 // XXXbz workaround for bug 265416 / bug 266284
336 gDialog.ImageHolder.collapsed = true;
337
338 var imageSrc = TrimString(gDialog.srcInput.value);
339 if (!imageSrc)
340 return;
341
342 try {
343 // Remove the image URL from image cache so it loads fresh
344 // (if we don't do this, loads after the first will always use image cache
345 // and we won't see image edit changes or be able to get actual width and height)
346
347 var IOService = GetIOService();
348 if (IOService)
349 {
350 // We must have an absolute URL to preview it or remove it from the cache
351 imageSrc = MakeAbsoluteUrl(imageSrc);
352
353 if (GetScheme(imageSrc))
354 {
355 var uri = IOService.newURI(imageSrc, null, null);
356 if (uri)
357 {
358 var imgCacheService = Components.classes["@mozilla.org/image/cache;1"].getService();
359 var imgCache = imgCacheService.QueryInterface(Components.interfaces.imgICache);
360
361 // This returns error if image wasn't in the cache; ignore that
362 imgCache.removeEntry(uri);
363 }
364 }
365 }
366 } catch(e) {}
367
368 if (gDialog.PreviewImage)
369 removeEventListener("load", PreviewImageLoaded, true);
370
371 if (gDialog.ImageHolder.firstChild)
372 gDialog.ImageHolder.removeChild(gDialog.ImageHolder.firstChild);
373
374 gDialog.PreviewImage = document.createElementNS("http://www.w3.org/1999/xhtml", "html:img");
375 if (gDialog.PreviewImage)
376 {
377 // set the src before appending to the document -- see bug 198435 for why
378 // this is needed.
379 // XXXbz that bug is long-since fixed. Is this still needed?
380 gDialog.PreviewImage.addEventListener("load", PreviewImageLoaded, true);
381 gDialog.PreviewImage.src = imageSrc;
382 gDialog.ImageHolder.appendChild(gDialog.PreviewImage);
383 }
384 }
385
SetActualSize
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
386 function SetActualSize()
387 {
388 gDialog.widthInput.value = gActualWidth ? gActualWidth : "";
389 gDialog.widthUnitsMenulist.selectedIndex = 0;
390 gDialog.heightInput.value = gActualHeight ? gActualHeight : "";
391 gDialog.heightUnitsMenulist.selectedIndex = 0;
392 doDimensionEnabling();
393 }
394
ChangeImageSrc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
395 function ChangeImageSrc()
396 {
397 if (gTimerID)
398 clearTimeout(gTimerID);
399
400 gTimerID = setTimeout("LoadPreviewImage()", 800);
401
402 SetRelativeCheckbox();
403 doOverallEnabling();
404 }
405
doDimensionEnabling
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
406 function doDimensionEnabling()
407 {
408 // Enabled only if "Custom" is selected
409 var enable = (gDialog.customSizeRadio.selected);
410
411 // BUG 74145: After input field is disabled,
412 // setting it enabled causes blinking caret to appear
413 // even though focus isn't set to it.
414 SetElementEnabledById( "heightInput", enable );
415 SetElementEnabledById( "heightLabel", enable );
416 SetElementEnabledById( "heightUnitsMenulist", enable );
417
418 SetElementEnabledById( "widthInput", enable );
419 SetElementEnabledById( "widthLabel", enable);
420 SetElementEnabledById( "widthUnitsMenulist", enable );
421
422 var constrainEnable = enable
423 && ( gDialog.widthUnitsMenulist.selectedIndex == 0 )
424 && ( gDialog.heightUnitsMenulist.selectedIndex == 0 );
425
426 SetElementEnabledById( "constrainCheckbox", constrainEnable );
427 }
428
doOverallEnabling
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
429 function doOverallEnabling()
430 {
431 var enabled = TrimString(gDialog.srcInput.value) != "";
432
433 SetElementEnabled(gDialog.OkButton, enabled);
434 SetElementEnabledById("AdvancedEditButton1", enabled);
435 SetElementEnabledById("imagemapLabel", enabled);
436
437 //TODO: Restore when Image Map editor is finished
438 //SetElementEnabledById("editImageMap", enabled);
439 SetElementEnabledById("removeImageMap", gCanRemoveImageMap);
440 }
441
ToggleConstrain
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
442 function ToggleConstrain()
443 {
444 // If just turned on, save the current width and height as basis for constrain ratio
445 // Thus clicking on/off lets user say "Use these values as aspect ration"
446 if (gDialog.constrainCheckbox.checked && !gDialog.constrainCheckbox.disabled
447 && (gDialog.widthUnitsMenulist.selectedIndex == 0)
448 && (gDialog.heightUnitsMenulist.selectedIndex == 0))
449 {
450 gConstrainWidth = Number(TrimString(gDialog.widthInput.value));
451 gConstrainHeight = Number(TrimString(gDialog.heightInput.value));
452 }
453 }
454
constrainProportions
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
455 function constrainProportions( srcID, destID )
456 {
457 var srcElement = document.getElementById(srcID);
458 if (!srcElement)
459 return;
460
461 var destElement = document.getElementById(destID);
462 if (!destElement)
463 return;
464
465 // always force an integer (whether we are constraining or not)
466 forceInteger(srcID);
467
468 if (!gActualWidth || !gActualHeight ||
469 !(gDialog.constrainCheckbox.checked && !gDialog.constrainCheckbox.disabled))
470 return;
471
472 // double-check that neither width nor height is in percent mode; bail if so!
473 if ( (gDialog.widthUnitsMenulist.selectedIndex != 0)
474 || (gDialog.heightUnitsMenulist.selectedIndex != 0) )
475 return;
476
477 // This always uses the actual width and height ratios
478 // which is kind of funky if you change one number without the constrain
479 // and then turn constrain on and change a number
480 // I prefer the old strategy (below) but I can see some merit to this solution
481 if (srcID == "widthInput")
482 destElement.value = Math.round( srcElement.value * gActualHeight / gActualWidth );
483 else
484 destElement.value = Math.round( srcElement.value * gActualWidth / gActualHeight );
485
486 /*
487 // With this strategy, the width and height ratio
488 // can be reset to whatever the user entered.
489 if (srcID == "widthInput")
490 destElement.value = Math.round( srcElement.value * gConstrainHeight / gConstrainWidth );
491 else
492 destElement.value = Math.round( srcElement.value * gConstrainWidth / gConstrainHeight );
493 */
494 }
495
editImageMap
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
496 function editImageMap()
497 {
498 // Create an imagemap for image map editor
499 if (gInsertNewIMap)
500 {
501 try {
502 gImageMap = GetCurrentEditor().createElementWithDefaults("map");
503 } catch (e) {}
504 }
505
506 // Note: We no longer pass in a copy of the global ImageMap. ImageMap editor should create a copy and manage onOk and onCancel behavior
507 window.openDialog("chrome://editor/content/EdImageMap.xul", "_blank", "chrome,close,titlebar,modal", globalElement, gImageMap);
508 }
509
removeImageMap
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
510 function removeImageMap()
511 {
512 gRemoveImageMap = true;
513 gCanRemoveImageMap = false;
514 SetElementEnabledById("removeImageMap", false);
515 }
516
SwitchToValidatePanel
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
517 function SwitchToValidatePanel()
518 {
519 if (gDialog.tabBox && gValidateTab && gDialog.tabBox.selectedTab != gValidateTab)
520 gDialog.tabBox.selectedTab = gValidateTab;
521 }
522
523 // Get data from widgets, validate, and set for the global element
524 // accessible to AdvancedEdit() [in EdDialogCommon.js]
ValidateImage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
525 function ValidateImage()
526 {
527 var editor = GetCurrentEditor();
528 if (!editor)
529 return false;
530
531 gValidateTab = gDialog.tabLocation;
532 if (!gDialog.srcInput.value)
533 {
534 AlertWithTitle(null, GetString("MissingImageError"));
535 SwitchToValidatePanel();
536 gDialog.srcInput.focus();
537 return false;
538 }
539
540 // We must convert to "file:///" or "http://" format else image doesn't load!
541 var src = TrimString(gDialog.srcInput.value);
542 var checkbox = document.getElementById("MakeRelativeCheckbox");
543 try
544 {
545 if (checkbox && !checkbox.checked)
546 {
547 var URIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
548 .getService(Components.interfaces.nsIURIFixup);
549 src = URIFixup.createFixupURI(src, Components.interfaces.nsIURIFixup.FIXUP_FLAG_NONE).spec;
550 }
551 } catch (e) { }
552
553 globalElement.setAttribute("src", src);
554
555 var title = TrimString(gDialog.titleInput.value);
556 if (title)
557 globalElement.setAttribute("title", title);
558 else
559 globalElement.removeAttribute("title");
560
561 // Force user to enter Alt text only if "Alternate text" radio is checked
562 // Don't allow just spaces in alt text
563 var alt = "";
564 var useAlt = gDialog.altTextRadioGroup.selectedItem == gDialog.altTextRadio;
565 if (useAlt)
566 alt = TrimString(gDialog.altTextInput.value);
567
568 if (gDoAltTextError && useAlt && !alt)
569 {
570 AlertWithTitle(null, GetString("NoAltText"));
571 SwitchToValidatePanel();
572 gDialog.altTextInput.focus();
573 return false;
574 }
575 globalElement.setAttribute("alt", alt);
576
577 var width = "";
578 var height = "";
579
580 gValidateTab = gDialog.tabDimensions;
581 if (!gDialog.actualSizeRadio.selected)
582 {
583 // Get user values for width and height
584 width = ValidateNumber(gDialog.widthInput, gDialog.widthUnitsMenulist, 1, gMaxPixels,
585 globalElement, "width", false, true);
586 if (gValidationError)
587 return false;
588
589 height = ValidateNumber(gDialog.heightInput, gDialog.heightUnitsMenulist, 1, gMaxPixels,
590 globalElement, "height", false, true);
591 if (gValidationError)
592 return false;
593 }
594
595 // We always set the width and height attributes, even if same as actual.
596 // This speeds up layout of pages since sizes are known before image is loaded
597 if (!width)
598 width = gActualWidth;
599 if (!height)
600 height = gActualHeight;
601
602 // Remove existing width and height only if source changed
603 // and we couldn't obtain actual dimensions
604 var srcChanged = (src != gOriginalSrc);
605 if (width)
606 editor.setAttributeOrEquivalent(globalElement, "width", width, true);
607 else if (srcChanged)
608 editor.removeAttributeOrEquivalent(globalElement, "width", true);
609
610 if (height)
611 editor.setAttributeOrEquivalent(globalElement, "height", height, true);
612 else if (srcChanged)
613 editor.removeAttributeOrEquivalent(globalElement, "height", true);
614
615 // spacing attributes
616 gValidateTab = gDialog.tabBorder;
617 ValidateNumber(gDialog.imagelrInput, null, 0, gMaxPixels,
618 globalElement, "hspace", false, true, true);
619 if (gValidationError)
620 return false;
621
622 ValidateNumber(gDialog.imagetbInput, null, 0, gMaxPixels,
623 globalElement, "vspace", false, true);
624 if (gValidationError)
625 return false;
626
627 // note this is deprecated and should be converted to stylesheets
628 ValidateNumber(gDialog.border, null, 0, gMaxPixels,
629 globalElement, "border", false, true);
630 if (gValidationError)
631 return false;
632
633 // Default or setting "bottom" means don't set the attribute
634 // Note that the attributes "left" and "right" are opposite
635 // of what we use in the UI, which describes where the TEXT wraps,
636 // not the image location (which is what the HTML describes)
637 switch ( gDialog.alignTypeSelect.value )
638 {
639 case "top":
640 case "middle":
641 case "right":
642 case "left":
643 editor.setAttributeOrEquivalent( globalElement, "align",
644 gDialog.alignTypeSelect.value , true);
645 break;
646 default:
647 try {
648 editor.removeAttributeOrEquivalent(globalElement, "align", true);
649 } catch (e) {}
650 }
651
652 return true;
653 }