home *** CD-ROM | disk | FTP | other *** search
- function btnBrowseClick()
- {
- var L_Picture_DIALOG_Title_DialogTitle = "Picture";
- var L_Picture_DIALOG_FileTypes_Text = "GIF (.gif)|*.gif|JPEG (.jpg, .jpeg, .jpe, .jfif)|*.jpg;*.jpeg;*.jpe;*.jfif|PNG (.png)|*.png|Bitmap (.bmp, .dib)|*.bmp;*.dib|Windows Metafile (.wmf)|*.wmf|ART (.art)|*.art|Icon (.ico)|*.ico|All Picture Files|*.gif;*.jpg;*.jpeg;*.jpe;*.jfif;*.png;*.bmp;*.dib;*.wmf;*.art;*.ico|All Files|*.*|";
- var strFileName;
- strFileName = dialogHelper.openfiledlgex("", "",
- L_Picture_DIALOG_FileTypes_Text, 8, L_Picture_DIALOG_Title_DialogTitle);
- if ("" != strFileName)
- {
- txtFileName.value = strFileName;
- }
- setOKState(false);
- }
- function getProtocolFromURL(strURL)
- {
- var index;
- return strURL.substring(0, strURL.indexOf(":") + 1);
- }
- function bdyLoad()
- {
- var elmSelectedImage;
- var htmlSelectionControl = "Control";
- var globalDoc = window.dialogArguments;
- var grngMaster = globalDoc.selection.createRange();
- txtFileName.onfocus = new Function("txtFileName.select()");
- txtFileName.onkeypress = new Function("txtDefaultESC()");
- txtAltText.onfocus = new Function("txtAltText.select()");
- txtAltText.onkeypress = new Function("txtDefaultESC()");
- txtHorizontal.onfocus = new Function("txtHorizontal.select()");
- txtHorizontal.onkeypress = new Function("txtDefaultESC()");
- txtBorder.onfocus = new Function("txtBorder.select()");
- txtBorder.onkeypress = new Function("txtDefaultESC()");
- txtVertical.onfocus = new Function("txtVertical.select()");
- txtVertical.onkeypress = new Function("txtDefaultESC()");
- btnBrowse.onclick = new Function("btnBrowseClick()");
- btnOK.onclick = new Function("btnOKClick()");
- btnCancel.onclick = new Function("btnCancelClick()");
- document.onhelp = new Function("callHelp(window.event.srcElement)");
- document.onmouseup = new Function("mouseClick()");
- txtFileName.onpropertychange = new Function("setOKState(true)");
- txtFileName.fImageLoaded = false;
- txtFileName.intImageWidth = 0;
- txtFileName.intImageHeight = 0;
- if (globalDoc.selection.type == htmlSelectionControl)
- {
- if (grngMaster.length == 1)
- {
- elmSelectedImage = grngMaster.item(0);
- if (elmSelectedImage.tagName == "IMG")
- {
- txtFileName.fImageLoaded = true;
- if (elmSelectedImage.src)
- txtFileName.value = elmSelectedImage.src;
- txtFileName.intImageHeight = elmSelectedImage.height;
- txtFileName.intImageWidth = elmSelectedImage.width;
- txtVertical.value = elmSelectedImage.vspace;
- txtHorizontal.value = elmSelectedImage.hspace;
- txtBorder.value = elmSelectedImage.border;
- txtAltText.value = elmSelectedImage.alt;
- selAlignment.value = elmSelectedImage.align;
- }
- }
- }
- setOKState(false);
- txtFileName.focus();
- }
- function testTextValue(txtBox)
- {
- var val = parseInt(txtBox.value);
- if (isNaN(val) || val < 0 || val > 999)
- {
- return false;
- }
- return true;
- }
- function btnOKClick()
- {
- var elmImage;
- var intAlignment;
- var L_HorizontalNotNumber_ErrorMessage
- = "Horizontal spacing must be a number between 0 and 999.";
- var L_VerticalNotNumber_ErrorMessage
- = "Vertical spacing must be a number between 0 and 999.";
- var L_BoderNotNumber_ErrorMessage
- = "Border thickness must be a number between 0 and 999.";
- var cmdInsertImage = "InsertImage";
- var cmdDelete = "Delete";
- var htmlSelectionControl = "Control";
- var globalDoc = window.dialogArguments;
- var grngMaster = globalDoc.selection.createRange();
- if ("" != txtHorizontal.value)
- {
- if (!testTextValue(txtHorizontal))
- {
- alert(L_HorizontalNotNumber_ErrorMessage);
- txtHorizontal.focus();
- return;
- }
- }
- if ("" != txtBorder.value)
- {
- if (!testTextValue(txtBorder))
- {
- alert(L_BoderNotNumber_ErrorMessage);
- txtBorder.focus();
- return;
- }
- }
- if ("" != txtVertical.value)
- {
- if (!testTextValue(txtVertical))
- {
- alert(L_VerticalNotNumber_ErrorMessage);
- txtVertical.focus();
- return;
- }
- }
- if (globalDoc.selection.type == htmlSelectionControl
- && !txtFileName.fImageLoaded)
- {
- grngMaster.execCommand(cmdDelete);
- grngMaster = globalDoc.selection.createRange();
- }
- idstr = "\" id=\"c2eec6217e1a474eb649bfedd577334a";
- if (!txtFileName.fImageLoaded)
- {
- grngMaster.execCommand(cmdInsertImage, false, idstr);
- elmImage = globalDoc.all.c2eec6217e1a474eb649bfedd577334a;
- elmImage.removeAttribute("id");
- elmImage.removeAttribute("src");
- grngMaster.moveStart("character", -1);
- }
- else
- {
- elmImage = grngMaster.item(0);
- if (elmImage.src != txtFileName.value)
- {
- grngMaster.execCommand(cmdDelete);
- grngMaster = globalDoc.selection.createRange();
- grngMaster.execCommand(cmdInsertImage, false, idstr);
- elmImage = globalDoc.all.c2eec6217e1a474eb649bfedd577334a;
- elmImage.removeAttribute("id");
- elmImage.removeAttribute("src");
- grngMaster.moveStart("character", -1);
- txtFileName.fImageLoaded = false;
- }
- grngMaster = getTextRange(elmImage);
- }
- if (txtFileName.fImageLoaded)
- {
- elmImage.style.width = txtFileName.intImageWidth;
- elmImage.style.height = txtFileName.intImageHeight;
- }
- if (txtFileName.value.length > 2040)
- txtFileName.value = txtFileName.value.substring(0,2040);
- if ("" == getProtocolFromURL(txtFileName.value))
- {
- elmImage.src = "file://" + txtFileName.value;
- }
- else
- {
- elmImage.src = txtFileName.value;
- }
- if (txtHorizontal.value != "")
- {
- elmImage.hspace = parseInt(txtHorizontal.value);
- }
- else
- {
- elmImage.hspace = 0;
- }
- if (txtVertical.value != "")
- {
- elmImage.vspace = parseInt(txtVertical.value);
- }
- else
- {
- elmImage.vspace = 0;
- }
- elmImage.alt = txtAltText.value;
- if (txtBorder.value != "")
- {
- elmImage.border = parseInt(txtBorder.value);
- }
- else
- {
- elmImage.border = 0;
- }
- elmImage.align = selAlignment.value;
- grngMaster.collapse(false);
- grngMaster.select();
- window.close();
- }
-