home *** CD-ROM | disk | FTP | other *** search
- //Find Text dialog box
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Checks the status of the appropriate checkboxes and
- // sets the flags for the findText method.
- //
- // Arguments: none
- //
- // returns: a number representing the flags for the findText
- // method. (See OM spec for more info.)
- //
- //----------------------------------------------------------------------
-
- function findFlags()
- {
- var htmlMatchWord = 2;
- var htmlMatchCase = 4;
- var htmlMatchDiacritic = 536870912; // 0x20000000 FR_MATCHDIAC
- var htmlMatchKashida = 1073741824; // 0x40000000 FR_MATCHKASHIDA
- var htmlMatchAlefHamza = 2147483648; // 0x80000000 FR_MATCHALEFHAMZA
-
- //
- // Note: the CS options work "backwards" and should be
- // assumed to be true.
- //
- return (htmlMatchWord * document.all.chkWholeWord.checked)
- | (htmlMatchCase * document.all.chkMatchCase.checked)
- | htmlMatchDiacritic | htmlMatchKashida | htmlMatchAlefHamza;
- } // findFlags
-
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Sets the focus to the find button. Also determines
- // whether something is selected in the document.
- //
- // Arguments: none
- //
- // Returns: nothing
- //
- //-----------------------------------------------------------------------
-
- function loadBdy()
- {
- // win.screenLeft == x-coordinate of the document window (not the frame)
- // doc.body.clientoffsetWidth > doc.body.clientWidth
- // doc.body.clientLeft > doc.body.offsetLeft
- // document.body.offsetWidth == window.dialogWidth
- // document.body.clientLeft == 0
- // document.body.offsetLeft == 0
- // Currently there is no way to get the total dialog width (only document width).
- // Positioning of the dialog is done in dhuihand.cpp after the dialog is shown.
-
- //
- // Bind events to controls. This is done here to load the dialog
- // quicker.
- //
- btnFindPrev.onclick = new
- Function("btnFindClick(false)");
- btnFindPrev.ondblclick = new
- Function("btnFindClick(false)");
- btnFindNext.onclick = new
- Function("btnFindClick(true)");
- btnFindNext.ondblclick = new
- Function("btnFindClick(true)");
- btnCancel.onclick = new Function("btnCancelClick2()");
-
- document.onmouseup = new Function("mouseClick()");
-
- txtFindText.onpropertychange = new Function("setFindState(true)");
- txtFindText.onfocus = new Function("txtFindText.select()");
- txtFindText.onkeypress = new Function("txtDefaultESC()");
-
- g_fFindStartPoint = true;
-
- if ("" != window.dialogArguments.findText)
- {
- txtFindText.value = window.dialogArguments.findText;
- }
- txtFindText.focus();
- txtFindText.select();
- } // loadBdy
-
- //+---------------------------------------------------------------------
- //
- // Synopsis: Sets the find text so it can be used next time.
- //
- // Arguments: none
- //
- // Returns: nothing
- //
- //-----------------------------------------------------------------------
-
- function unloadBdy()
- {
- window.onerror = SuppressError;
- window.dialogArguments.findText = txtFindText.value;
- window.onerror = HandleError;
- } // unloadBdy
-
- function findStartPoint(fForward)
- {
- if (g_fFindStartPoint)
- {
- g_fFindStartPoint = false;
-
- var win = window.dialogArguments.unsecuredWindowOfDocument;
- var doc = window.dialogArguments.document;
-
- //
- // Are we in a frameset?
- //
- if (!g_fError && win.frames.length)
- {
- var win2;
-
- g_fFrameset = true;
- g_arrFrames[0] = 0;
- g_arrFrames[1] = -1;
-
- //
- // Search through the frameset for a selection
- //
- win2 = CrawlPath();
-
- // the find dialog gets it's own error handler
- // until while we're not sure if the iframe
- // is hosting trident. (It could host Word,
- // explorer, etc.)
- window.onerror = FindHandleError;
- doc2 = win2.document;
- window.onerror = HandleError;
-
- while (doc2.selection.type == "None")
- {
- if (MoveDoc(fForward))
- {
- win2 = CrawlPath();
- doc2 = win2.document;
- }
- else // no selection. reset search
- {
- g_arrFrames[0] = fForward ? 0 : win.frames.length - 1;
- g_arrFrames[1] = -1;
- break;
- }
- }
- doc = GetFirstDoc();
- g_docLastFound = doc;
- }
-
- //
- // If a control is selected, select it as a text range.
- // Dont set the text range to the control if we are doing this
- // on wrap. That will scope the wrap to within the control.
- //
- if (!g_fWrapped && doc.selection.type == "Control")
- {
- var r = doc.selection.createRange();
- r = getTextRange(r(0));
- r.select();
- }
- }
- } // findStartPoint
-
-