home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC/CD Gamer UK 45
/
PCGAMER45.bin
/
netware
/
msie4pp
/
ie4_s3.cab
/
IE4_3.CAB
/
MSHTMENU.DLL
/
2110
/
INSIMAGE.DLG
< prev
next >
Wrap
Text File
|
1997-04-04
|
22KB
|
647 lines
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML 3.2//EN">
<HTML id=dlgImage STYLE="font-family: 'ms sans serif'; font-size: '8pt';
width: '41.9em'; height: '21.2em'">
<HEAD>
<TITLE>
Image
</TITLE>
<SCRIPT LANGUAGE=JavaScript>
//+-------------------------------------------------------------------------
//
// This section contains code to be moved into a GLOBAL MODULE outside
// of this particular dialog.
//
//--------------------------------------------------------------------------
//----------------------------------------------------------------------
//
// Synopsis: Turns on the document's expando property. When this
// property is on, it is possible to create new expando
// properties or assign to existing ones.
//
// Arguments: none
//
// Returns: Nothing
//
//----------------------------------------------------------------------
function expandoOn()
{
document.expando = true;
} // expandoOn
//----------------------------------------------------------------------
//
// Synopsis: Turns off the document's expando property. When this
// property is off, it is possible to read the value of
// existing expando properties, but not possible to create
// new ones or modify existing ones.
//
// EXPANDO SHOULD BE OFF EXCEPT WHEN CREATING/MODIFYING
// EXPANDO PROPERTIES. This will save hours debugging
// accidentally created expando properties.
//
// Arguments: none
//
// Returns: Nothing.
//
//----------------------------------------------------------------------
function expandoOff()
{
document.expando = false;
} // expandoOff
//+---------------------------------------------------------------------
//
// Synopsis: Given a string, returns the number the string represents.
// This is needed because current localization tools can
// only find strings.
//
// Arguments: string The string we're changing into a number.
//
// Returns: a number
//
//----------------------------------------------------------------------
function number(string)
{
return parseFloat(string);
} // number
</SCRIPT>
<SCRIPT LANGUAGE=JavaScript>
//+--------------------------------------------------------------------------
//
// This section contains variables that need to be LOCALIZED
//
//---------------------------------------------------------------------------
// var L_InsertImage_DIALOG_Width_Text = "41.9em";
// var L_InsertImage_DIALOG_Height_Text = "21.2em";
var L_HorizontalNotNumber_Text = "Horizontal spacing must be a number.";
var L_VerticalNotNumber_Text = "Vertical spacing must be a number.";
var L_BoderNotNumber_Text = "Border thickness must be a number.";
var L_NoHelp_Text = "No help topic available.";
</SCRIPT>
<SCRIPT LANGUAGE=JavaScript>
//+-------------------------------------------------------------------------
//
// This section contains code LOCAL to this particular dilaog.
//
//--------------------------------------------------------------------------
expandoOff();
// Set dialog dimensions
// window.width = L_InsertImage_DIALOG_Width_Text;
// window.height = L_InsertImage_DIALOG_Height_Text;
// Constants
var cmdInsertImage = "InsertImage";
var cmdDelete = "Cut";
var htmlSelectionNone = "None";
var htmlSelectionText = "Text";
var htmlSelectionControl = "Control";
var htmlSelectionTable = "Table";
var htmlNotSet = "";
var htmlControlAlignLeft = "left";
var htmlControlAlignTop = "top";
var htmlControlAlignRight = "right";
var htmlControlAlignTextTop = "textTop";
var htmlControlAlignAbsMiddle = "absMiddle";
var htmlControlAlignBaseLine = "baseline";
var htmlControlAlignAbsBottom = "absBottom";
var htmlControlAlignBottom = "bottom";
var htmlControlAlignMiddle = "middle";
//
// The constants below correspond to the index of the correspoding options is selAlignment
//
var ALIGN_NOT_SET = 0;
var ALIGN_LEFT = 1;
var ALIGN_RIGHT = 2;
var ALIGN_TEXT_TOP = 3;
var ALIGN_ABS_MIDDLE = 4;
var ALIGN_BASE_LINE = 5;
var ALIGN_ABS_BOTTOM = 6;
var ALIGN_BOTTOM = 7;
var ALIGN_MIDDLE = 8;
var ALIGN_TOP = 9;
// Global variables
var globalDoc; // The document we're working on.
var grngMaster; // The range we're working on.
var gboolImageLoaded; // Whether an image has been loaded into the preview window
var gboolBrowseOpen = false; // Whether the browse dialog is already open.
var gintImageWidth; // The width of the selected image
var gintImageHeight; // The height of the selected image
//+-----------------------------------------------------------------------
//
// Synopsis: Opens the open file common dialog. If the user selects a
// file, put the file name into txtFileName.
//
// Arguments: none
//
// Returns: nothing
//
//------------------------------------------------------------------------
function btnBrowseClick()
{
var strFileName;
if (!gboolBrowseOpen)
{
var strFileTypes = "GIF and JPEG (*.gif, *.jpg)|*.gif;*.jpg";
strFileTypes = strFileTypes + "|Bitmap (*.bmp)|*.bmp|Windows Metafile (*.wmf)|*.wmf";
strFileTypes = strFileTypes + "|XBM (*.xbm)|*.xbm|ART (*.art)|*.art|All files (*.*)|*.*|";
gboolBrowseOpen = true;
strFileName = window.dialogArgs.openfiledlg("","",strFileTypes,"Image");
gboolBrowseOpen = false;
if ("" != strFileName)
{
txtFileName.value = strFileName;
}
}
} // btnBrowseClick
//+-------------------------------------------------------------------------------------
//
// Synopsis: First, set up the dialog with the default options. Then if an image is
// selected, fill the dialog with the settings for that image.
//
// Agruments: none
//
// Returns: nothing
//
//--------------------------------------------------------------------------------------
function bdyLoad()
{
var elmSelectedImage; // the image that's selected when the dialog os called.
// (If any image is selected.)
//
// Set the document and master range variables
//
globalDoc = window.dialogArgs.document;
grngMaster = globalDoc.selection.createRange();
//
// If the currently selected object is an image, get its attributes and
// fill the dialog accordingly
//
if (globalDoc.selection.type == htmlSelectionControl) // a control range is selected
{
if (grngMaster.length == 1) // There's only one control selected
{
elmSelectedImage = grngMaster.item(0);
if (elmSelectedImage.tagName == "IMG") // and it's an image
{
gboolImageLoaded = true;
//
// set the source
//
txtFileName.value = elmSelectedImage.src;
//
// Get the height and width
//
gintImageHeight = elmSelectedImage.height;
gintImageWidth = elmSelectedImage.width;
//
// Set the vertical and horizontal spacing.
//
txtVertical.value = elmSelectedImage.vSpace;
txtHorizontal.value = elmSelectedImage.hSpace;
//
// Get the border size
//
txtBorder.value = elmSelectedImage.border;
//
// Get the alt text
//
txtAltText.value = elmSelectedImage.alt;
//
// set the alignment
//
with (elmSelectedImage)
{
if (align == htmlNotSet)
{
selAlignment.selectedIndex = ALIGN_NOT_SET;
}
else if (align == htmlControlAlignLeft)
{
selAlignment.selectedIndex = ALIGN_LEFT;
}
else if (align == htmlControlAlignRight)
{
selAlignment.selectedIndex = ALIGN_RIGHT;
}
else if (align == htmlControlAlignTextTop)
{
selAlignment.selectedIndex = ALIGN_TEXT_TOP;
}
else if (align == htmlControlAlignAbsMiddle)
{
selAlignment.selectedIndex = ALIGN_ABS_MIDDLE;
}
else if (align == htmlControlAlignBaseLine)
{
selAlignment.selectedIndex = ALIGN_BASE_LINE;
}
else if (align == htmlControlAlignAbsBottom)
{
selAlignment.selectedIndex = ALIGN_ABS_BOTTOM;
}
else if (align == htmlControlAlignBottom)
{
selAlignment.selectedIndex = ALIGN_BOTTOM;
}
else if (align == htmlControlAlignMiddle)
{
selAlignment.selectedIndex = ALIGN_MIDDLE;
}
else if (align == htmlControlAlignTop)
{
selAlignment.selectedIndex = ALIGN_TOP;
}
}
}
}
}
} // bdyLoad
//+----------------------------------------------------------------------------------------------
//
// Synopsis: Okay, this function does quite a bit. First, if there is no text in the
// file name input, we do nothing or delete the currently selected image.
// Then we insert an image, select it and set its properties according to the
// user's selections in the dialog box.
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------------------------------
function btnOKClick()
{
var elmImage; // The element that is the image we're inserting.
var intAlignment; // The selectedIndex of selAlignment
//
// Make sure the border spacing textboxes are numbers or blank
//
if ("" != txtHorizontal.value)
{
if (isNaN(parseInt(txtHorizontal.value)))
{
alert(L_HorizontalNotNumber_Text);
txtHorizontal.focus();
return;
}
}
if ("" != txtBorder.value)
{
if (isNaN(parseInt(txtBorder.value)))
{
alert(L_BoderNotNumber_Text);
txtBorder.focus();
return;
}
}
if ("" != txtVertical.value)
{
if (isNaN(parseInt(txtVertical.value)))
{
alert(L_VerticalNotNumber_Text);
txtVertical.focus();
return;
}
}
if (txtFileName.value == "")
{
//
// No file name has been entered, so we do nothing, or delete the selected image.
//
if (gboolImageLoaded)
{
grngMaster.execCommand(cmdDelete);
return;
}
else
{
window.close();
return;
}
}
//
// If the current selection is a control range, delete it.
//
if (globalDoc.selection.type == htmlSelectionControl)
{
grngMaster.execCommand(cmdDelete);
grngMaster = globalDoc.selection.createRange();
}
grngMaster.execCommand(cmdInsertImage);
//
// Inserting the image collapses the range, so we have to expand it to include the newly inserted
// image.
//
grngMaster.start--;
elmImage = grngMaster.parentElement();
elmImage.src = txtFileName.value;
if (txtHorizontal.value != "")
{
elmImage.hSpace = txtHorizontal.value;
}
else
{
elmImage.hSpace = 0;
}
if (txtVertical.value != "")
{
elmImage.vSpace = txtVertical.value;
}
else
{
elmImage.vSpace = 0;
}
//
// Set the alt text
//
elmImage.alt = txtAltText.value;
//
// Set the border size
//
elmImage.border = txtBorder.value;
//
// If the image was selected when the dialog was started,
// Set the width and height to previous settings
//
if (gboolImageLoaded)
{
elmImage.style.width = gintImageWidth;
elmImage.style.height = gintImageHeight;
}
//
// Set the alignment;
//
intAlignment = selAlignment.selectedIndex;
if (intAlignment == ALIGN_NOT_SET)
{
elmImage.align = htmlNotSet;
}
else if (intAlignment == ALIGN_LEFT)
{
elmImage.align = htmlControlAlignLeft;
}
else if (intAlignment == ALIGN_RIGHT)
{
elmImage.align = htmlControlAlignRight;
}
else if (intAlignment == ALIGN_TEXT_TOP)
{
elmImage.align = htmlControlAlignTextTop;
}
else if (intAlignment == ALIGN_ABS_MIDDLE)
{
elmImage.align = htmlControlAlignAbsMiddle;
}
else if (intAlignment == ALIGN_BASE_LINE)
{
elmImage.align = htmlControlAlignBaseLine;
}
else if (intAlignment == ALIGN_ABS_BOTTOM)
{
elmImage.align = htmlControlAlignAbsBottom;
}
else if (intAlignment == ALIGN_BOTTOM)
{
elmImage.align = htmlControlAlignBottom;
}
else if (intAlignment == ALIGN_MIDDLE)
{
elmImage.align = htmlControlAlignMiddle;
}
else if (intAlignment == ALIGN_TOP)
{
elmImage.align = htmlControlAlignTop;
}
//
// Put insertion point after newly inserted image.
//
grngMaster.collapse(false); // Collapse to end.
grngMaster.select();
window.close();
} // btnOKClick
//+----------------------------------------------------------------------
//
// Synopsis: Closes the dialog doing nothing
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------
function btnCancelClick()
{
window.close();
} // btnCancelClick
</SCRIPT>
<SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onhelp()">
//+-------------------------------------------------------------------------
//
// Synopsis: Opens the help file with the appropriate helpid
//
// Arguments: none
//
// Returns: nothing
//
//--------------------------------------------------------------------------
// BUGBUG Once we get help for the editing dialogs, this function
// will have to change.
alert(L_NoHelp_Text);
</SCRIPT>
<SCRIPT LANGUAGE=JavaScript FOR=document EVENT="onkeypress()">
//+---------------------------------------------------------------------
//
// Synopsis: Looks for the ENTER and ESC keypresses and runs the
// appropriate action.
//
// Arguments: none
//
// Returns: nothing
//
//-----------------------------------------------------------------------
var htmlKeyReturn = 13;
var htmlKeyEscape = 27;
if ((event.keyCode) == htmlKeyReturn) // Enter
{
btnOKClick();
btnOK.focus();
}
if ((event.keyCode) == htmlKeyEscape) // Esc
{
btnCancelClick();
}
</SCRIPT>
</HEAD>
<BODY onload="bdyLoad()" style="font-family: 'ms sans serif'; font-size: '8pt'; background: buttonface;" >
<DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '1em'; TOP: '1.3em'; WIDTH: '9em'; HEIGHT: '1em'">
<LABEL FOR=txtFileName tabIndex=-1>
<U>I</U>mage Source:
</LABEL>
</DIV>
<INPUT type=text style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '7.7em'; TOP: '1em'; WIDTH: '25em'; HEIGHT: '2.1em'"
ID=txtFileName tabIndex=10 ACCESSKEY=i>
<DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '1em'; TOP: '3.8em'; WIDTH: '10em'; HEIGHT: '1em'">
<LABEL FOR=txtAltText tabIndex=-1>
Alternate <u>T</u>ext:
</LABEL>
</DIV>
<INPUT type=text ID=txtAltText tabIndex=15 ACCESSKEY=t
style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '7.7em'; TOP: '3.5em'; WIDTH: '25em'; HEIGHT: '2.1em'">
<BUTTON style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '33.5em'; TOP: '1em'; WIDTH: '6.8em'; HEIGHT: '2.1em'"
ID=btnBrowse onclick="btnBrowseClick()" ACCESSKEY=r tabIndex=12>
B<U>r</U>owse...
</BUTTON>
<table cellPadding=7 cellspacing borderColorDark=buttonhighlight borderColorLight=buttonshadow noshade="yes" border=1
style="position: absolute;font-family: 'ms sans serif'; font-size: '8pt';LEFT: '1em'; TOP: '7em'; WIDTH: '39em'; HEIGHT: '7.5em'">
<tr>
<td valign=top style="font-family: 'ms sans serif'; font-size: '8pt';WIDTH='35em'; HEIGHT:'5em'">
<DIV style="color: buttonface;">a</DIV>
</td>
</tr>
</table>
<DIV style="position: absolute;LEFT: '2em'; TOP: '9em'; WIDTH: '4.5em'; HEIGHT: '2em'; font-family: 'ms sans serif'; font-size: '8pt';">
<LABEL FOR=selAlignment tabIndex=-1>
<U>A</U>lignment:
</LABEL>
</DIV>
<SELECT size=1 ID=selAlignment tabIndex=20 ACCESSKEY=a
style="position: absolute;font-family: 'ms sans serif'; font-size: '8pt';LEFT: '11.5em'; TOP: '8.5em'; WIDTH: '7em'; HEIGHT: '2.1em'">
<OPTION>Not set</OPTION>
<OPTION>Left</OPTION>
<OPTION>Right</OPTION>
<OPTION>Texttop</OPTION>
<OPTION>Absmiddle</OPTION>
<OPTION SELECTED>Baseline</OPTION>
<OPTION>Absbottom</OPTION>
<OPTION>Bottom</OPTION>
<OPTION>Middle</OPTION>
<OPTION>Top</OPTION>
</SELECT>
<DIV style="position: absolute;LEFT: '23em'; TOP: '8.8em'; WIDTH: '9em'; HEIGHT: '1.5em'; font-family: 'ms sans serif'; font-size: '8pt';">
<LABEL FOR=txtHorizontal tabIndex=-1>
<U>H</U>orizontal Spacing:
</LABEL>
</DIV>
<INPUT style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '33em'; TOP: '8.5em'; WIDTH: '4em'; HEIGHT: '2.1em'"
type=text size=3 value="" ID=txtHorizontal tabIndex=25 ACCESSKEY=h>
<DIV style="position: absolute;LEFT: '2em'; TOP: '11.3em'; WIDTH: '10em'; HEIGHT: '2em'; font-family: 'ms sans serif'; font-size: '8pt';">
<LABEL tabIndex=-1 FOR=txtBorder>
<u>B</u>order Thickness:
</LABEL>
</DIV>
<INPUT style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute; LEFT: '11.5em'; TOP: '11em'; WIDTH: '5em'; HEIGHT: '2.1em'"
type=text size=3 value="" ID=txtBorder tabIndex=25 ACCESSKEY=b>
<DIV style="position: absolute; LEFT: '23em'; TOP: '11.3em'; WIDTH: '10em'; HEIGHT:'1.5em'; font-family: 'ms sans serif'; font-size: '8pt';">
<LABEL FOR=txtVertical tabIndex=-1>
<U>V</U>ertical Spacing:
</LABEL>
</DIV>
<INPUT style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '33em'; TOP: '11em'; WIDTH: '4em'; HEIGHT: '2.1em'"
type=text size=3 value="" ID=txtVertical tabIndex=30 ACCESSKEY=v>
<DIV style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;background: buttonface; LEFT: '1.5em'; TOP: '6.5em'; WIDTH: '3em'; HEIGHT: '1em'">
<LABEL tabIndex=-1>
Layout
</LABEL>
</DIV>
<BUTTON style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '25.9em'; TOP: '15.8em'; WIDTH: '6.8em'; HEIGHT: '2.1em'"
ID=btnOK onclick="btnOKClick()" tabIndex=40>
OK
</BUTTON>
<BUTTON style="font-family: 'ms sans serif'; font-size: '8pt'; position: absolute;LEFT: '33.5em'; TOP: '15.8em'; WIDTH: '6.8em'; HEIGHT: '2.1em'"
ID=btnCancel onclick="btnCancelClick()" tabIndex=45>
Cancel
</BUTTON>
</BODY>
</HTML>